/****************************************/
/*                                      */
/* 3.1.3.3.A.    CLIed.c                */
/*                                      */
/* Program: A new CLI Ed                */
/* ==================================== */
/*                                      */
/* Author:  Date:      Comments:        */
/* ------  ----------  ----------       */
/* Wgb     10/20//1987 just the window  */
/* JLD     01/09/1989  for testing      */
/*                                      */
/****************************************/


#include <exec/types.h>
#include <intuition/intuition.h>

struct IntuitionBase *IntuitionBase;
struct Window        *FirstWindow;
struct IntuiMessage  *message;


struct NewWindow ConsoleWindow =
   {
   0, 0,                   /* LeftEdge, TopEdge   */
   640, 101,               /* Width, Height       */
   2, 3,                   /* DetailPen, BlockPen */
   CLOSEWINDOW,            /* IDCMP Flags         */
   WINDOWDEPTH |           /* Flags               */
   WINDOWSIZING |
   WINDOWDRAG |
   WINDOWCLOSE |
   ACTIVATE |
   SMART_REFRESH,
   NULL,                   /* First Gadget        */
   NULL,                   /* CheckMark           */
   (UBYTE *)"Wgb Prod. presents  BECKERshell",
   NULL,                   /* Screen              */
   NULL,                   /* BitMap              */
   640, 50,                /* Min Width, Height   */
   640, 200,               /* Max Width, Height   */
   WBENCHSCREEN,           /* Type                */
   };


main()
   {
   ULONG MessageClass;
   USHORT code;
   
   struct Message *GetMsg();
   
   Open_All();
   
   FOREVER
      {
      if (message = (struct IntuiMessage *)
          GetMsg(FirstWindow->UserPort))
         {
         MessageClass = message->Class;
         code = message->Code;
         ReplyMsg(message);
         switch (MessageClass)
            {
            case CLOSEWINDOW : Close_All();
                               exit(TRUE);
                               break;
            }
         }
      }
   }


/***************************************
 *                                     *
 * Function: Open everything           *
 * =================================== *
 *                                     *
 * Author:  Date:      Comments:       *
 * ------  ----------  ----------      *
 * Wgb     10/20/1987                  *
 *                                     *
 * No parameters                       *
 *                                     *
 ***************************************/


Open_All()

   {
   struct Library *OpenLibrary();
   struct Window  *OpenWindow();
   
   if (!(IntuitionBase = (struct IntuitionBase *)
       OpenLibrary("intuition.library", 0L)))
      {
      printf("Intuition library not found!\n");
      Close_All();
      exit(FALSE);
      }
   
   if (!(FirstWindow = (struct Window *)
       OpenWindow(&ConsoleWindow)))
      {
      printf("Window can't be opened!\n");
      Close_All();
      exit(FALSE);
      }
   }


/***************************************
 *                                     *
 * Function: Close everything          *
 * =================================== *
 *                                     *
 * Author:  Date:      Comments:       *
 * ------  ----------  ----------      *
 * Wgb     10/20/1987                  *
 *                                     *
 * No parameters                       *
 *                                     *
 ***************************************/


Close_All()

   {
   if (FirstWindow)
      CloseWindow(FirstWindow);
   
   if (IntuitionBase)
      CloseLibrary(IntuitionBase);
   }

