home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Src / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-22  |  32.3 KB  |  1,459 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     $Id: main.c 1.6 1994/09/09 12:31:30 digulla Exp digulla $
  5.  
  6.     HISTORY
  7.     28. Nov 1992    ada created
  8.     $Log: main.c $
  9.  * Revision 1.6  1994/09/09  12:31:30  digulla
  10.  * added new style Prototypes, DEFCMD and DEFHELP
  11.  *
  12.  * Revision 1.5  1994/08/30  11:07:40  digulla
  13.  * DoubleClick-Code now checks is the mouse has been moved
  14.  * Default for "Saveicons" is now 1 on WBStartup
  15.  * Use GetDiskObjectNew
  16.  * clear NumClicks if some other event happens
  17.  *
  18.  * Revision 1.4  1994/08/19  14:05:00  digulla
  19.  * added INACTIVEWINDOW support
  20.  * removed dead code in Zoom-Code
  21.  * Fixed wrong colors and modes in DoOptimizedRefresh
  22.  *
  23.  * Revision 1.3  1994/08/13  16:33:46  digulla
  24.  * made mouse coords available
  25.  * added set_window_params() in DoOptimizedRefresh
  26.  * swapped lines and columns in tomouse
  27.  *
  28.  * Revision 1.2  1994/08/09  15:55:50  digulla
  29.  * removed debug printf
  30.  *
  31.  * Revision 1.1  1994/08/09  13:53:34  digulla
  32.  * Initial revision
  33.  *
  34.  
  35. ******************************************************************************/
  36.  
  37. /**************************************
  38.         Includes
  39. **************************************/
  40. #include "defs.h"
  41. #include <dos/dostags.h>
  42. #include <clib/layers_protos.h>
  43. #include <pragmas/layers_pragmas.h>
  44. #include <proto/reqtools.h>
  45. #include <proto/asl.h>
  46. #define MYDEBUG     1
  47. #include "debug.h"
  48. //#define DEBUG
  49. //#define DETACH
  50.  
  51.  
  52. /**************************************
  53.         Globale Variable
  54. **************************************/
  55. Prototype struct MsgPort  * Sharedport;
  56. Prototype char            MShowTitle;
  57. Prototype char            noadj;
  58. Prototype struct __XDMEArgs XDMEArgs;
  59.  
  60. struct MsgPort * Sharedport;        /* Port for all Windows */
  61. char         MShowTitle;        /* Should DME refresh the title ? */
  62. char         noadj;         /* for blocking software adj. of prop gad
  63.                        when intuition (user) already did it */
  64.  
  65. extern struct Library        * LayersBase;
  66.  
  67. extern long __stack = 20000;
  68.  
  69. WORD      Mx, My;         /* Mouse-Coords */
  70.  
  71.  
  72. /**************************************
  73.            Typedefs
  74. **************************************/
  75. typedef struct WBStartup    WBS;
  76. typedef struct DiskObject   DISKOBJ;
  77.  
  78.  
  79. /**************************************
  80.         Interne Variable
  81. **************************************/
  82. static WORD     oMx, oMy;        /* starting coords */
  83. static ULONG     newxdme;        /* force new xdme */
  84.  
  85. static const char default_startupfile[] = ".edrc";
  86. static const char default_projectfile[] = "XDME_Project_File";
  87.  
  88. static const char tmplate[] = "Files/M,"
  89.                   "Startup=-S/K,"
  90.                   "New=-N/S,"
  91.                   "Iconify=-I/S,"
  92.                   "Autoload=-A/S,"
  93.                   "PubScreen=-PS/K,"
  94.                   "ProjectFile=-PF/K";
  95.  
  96. struct __XDMEArgs XDMEArgs =
  97. {
  98.     NULL,        /* Files */
  99.     NULL,        /* Startup-Filename */
  100.     FALSE,        /* NEW */
  101.     FALSE,        /* Iconify */
  102.     FALSE,        /* Autoload */
  103.     NULL,        /* PublicScreen */
  104.     NULL,        /* ProjectFile */
  105.     /* ... */
  106. };
  107.  
  108.  
  109. static const struct Config startup_config =
  110. {
  111.     -1,     /* wwcol */
  112.  
  113.     0, 0,    /* winx, winy           */
  114.     640, 200,    /* winwidth, winheight */
  115.  
  116.     0, 11,    /* iwinx, iwiny */
  117.  
  118.     0, 0,    /* aslleft/top       */
  119.     400, 200,    /* aslwidth/height */
  120.  
  121.     4,        /* tabstop */
  122.     75,     /* margin  */
  123.  
  124.     1,        /* fgpen */
  125.     0,        /* bgpen */
  126.     2,        /* hgpen */
  127.     1,        /* bbpen */
  128.     1,        /* tfpen */
  129.     0,        /* tbpen */
  130.  
  131.     1,        /* insertmode        */
  132.     0,        /* ignorecase        */
  133.     0,        /* wordwrap        */
  134.     0,        /* autosplit        */
  135.     1,        /* autoindent        */
  136.     1,        /* autounblock        */
  137.     0,        /* doback        */
  138.     0,        /* nicepaging        */
  139.     0,        /* iconactive        */
  140.     0,        /* blockendsfloat   */
  141. };
  142.  
  143.  
  144. /**************************************
  145.        Interne Prototypes
  146. **************************************/
  147. extern void __regargs __chkabort (void);
  148.  
  149.  
  150. #ifdef UNUSED
  151. Prototype void PrintCWD (void);
  152.  
  153. void PrintCWD (void)
  154. {
  155.     static char puffer[256];
  156.     PROC * proc = (PROC *)FindTask (NULL);
  157.  
  158.     NameFromLock (proc->pr_CurrentDir, puffer, sizeof(puffer));
  159.  
  160.     kprintf ("CWD: `%s'\n", puffer);
  161. }
  162. #endif
  163.  
  164.  
  165. extern int wbmain (WBS * wbs); /* !!! No Prototype !!! */
  166.  
  167. int wbmain (WBS * wbs)
  168. {
  169.     return (main (0, (char **)wbs));
  170. } /* wbmain */
  171.  
  172.  
  173. /* disable ^C checking */
  174. void __regargs __chkabort (void) { /* empty */ }
  175.  
  176.  
  177. Prototype int main (int mac, char ** mav);
  178.  
  179. int main (int mac, char ** mav)
  180. {
  181.     ULONG  nf;            /* # files on command line       */
  182.     BOOL   iawm        = 0; /* overide mouse buttons       */
  183.     BOOL   dontwait    = 0; /* don't wait for a message    */
  184.     BOOL   LeftArea    = 0; /* has mouse after buttonpress moved a certain
  185.                    distance */
  186.     WORD   i;            /* temp. counter           */
  187.     WORD   Code;        /* IDCMP->Code           */
  188.     ULONG  Qualifier;        /* IDCMP->Qualifier        */
  189.     PROC * proc        = (PROC *)FindTask(NULL);   /* our Task    */
  190.     BPTR   origlock;        /* Start-Lock           */
  191.     ULONG  wait_ret;        /* HD Result of Wait       */
  192.     ULONG  Mask        = 0; /* Mask for Wait()             */
  193.     BOOL   gad_active  = 0; /* Is any gadget active ?       */
  194.     UWORD  gad_id;        /* Which one ?           */
  195.     WORD   mqual;        /* Qualifiers for mmove       */
  196.     BOOL   mmove       = 0; /* Mousemove           */
  197.     int    show_cursor;     /* shall I redraw the cursor ? */
  198.  
  199. /*#if MYDEBUG
  200.     D(bug("------------- Hallo, hier ist XDME ----------------\n"));
  201. #endif // */
  202.  
  203. //puts (__FILE__);
  204.  
  205.     if (!pDBase) {
  206.     if (mac)
  207.         puts ("Not enough memory!");
  208.     return 20;
  209.     } /* if */
  210.  
  211.  
  212. #ifdef DETACH
  213.     /* Detach from CLI */
  214.     fclose (stdin);
  215.     fclose (stdout);        /*  debugging output needs kprintf ! */
  216.     fclose (stderr);        /*  close stderr & console ref. */
  217. #endif
  218.  
  219.     /* cd to dir of shell */
  220.     origlock = CurrentDir (DupLock (proc->pr_CurrentDir));
  221.  
  222.     /* Init lists */
  223.     // NewList ((LIST *)&DBase);
  224.     // NewList ((LIST *)&PBase);
  225.     // init_macros ();
  226.     // init_variables ();
  227.     // path_init ();
  228.     // init_kb ();
  229.  
  230.     /* IntuitionBase = (struct IntuitionBase *)OpenLibrary ("intuition.library", 37L);
  231.     GfxBase      = (struct GfxBase       *)OpenLibrary ("graphics.library",  37L);
  232.     if (!IntuitionBase || !GfxBase)
  233.     exiterr ("cannot open intuition or graphics library");
  234.  
  235.     AslBase = OpenLibrary ("asl.library", 37L); */
  236.     ReqToolsBase = (struct ReqToolsBase *)OpenLibrary ("reqtools.library", 37);
  237.  
  238.     PageJump = 80;        /* 80% of page for Propgad & pageup/down */
  239.  
  240.     String = NULL;        /*    initialize scanf variable   */
  241.  
  242.     unblock ();             /* No block */
  243.  
  244.     /* making a default-ed-config */
  245.     movmem (&startup_config, &default_config, CONFIG_SIZE);
  246.  
  247.     /* setting default flags */
  248.     SETF_SAVEICONS(Ep,0);
  249.     SETF_ACTIVATETOFRONT(Ep,1);
  250.     SETF_WINDOWCYCLING(Ep,1);
  251.     SETF_SHOWTITLE(Ep,1);
  252.  
  253.     if (mac == 0)
  254.     {          /*  WORKBENCH STARTUP   */
  255.     SETF_SAVEICONS(Ep,1);           /*  allow icon save     */
  256.     Wbs = (WBS *)mav;
  257.  
  258.     /* if (!(IconBase = OpenLibrary ("icon.library", 0)) )
  259.         exiterr ("unable to open icon library"); */
  260.     }
  261.  
  262.     /* Init AREXX */
  263.     mountrequest (0);
  264.     openrexx ();     /*   do this after the last possible call to exiterr() */
  265.     mountrequest (1);
  266.  
  267.     /* Init Keyboard */
  268.     // new_menustrip ("default",1);
  269.     // new_keytable  ("default",1);
  270.  
  271.     {
  272.     struct MsgPort * mp;
  273.  
  274.     Forbid ();
  275.     mp = FindPort ("XDME.1");
  276.     Permit ();
  277.  
  278.     newxdme = (!strcmp (RexxPortName, "XDME.1") || !mp);
  279.     }
  280.  
  281.     nf = 0;
  282.     /* Here we have to set the names BEFORE the parsing since none of the
  283.        Arg-Parsers does set them (we make copies later) */
  284.     XDMEArgs.projectfilename = default_projectfile; /* no strdup() here ! */
  285.     XDMEArgs.startupfile     = default_startupfile; /* no strdup() here ! */
  286.  
  287.     /* WB-Startup or CLI ? */
  288.     if (Wbs)
  289.     {
  290.     /* Work on TOOLTypes */
  291.     if (Wbs->sm_ArgList[0].wa_Lock)
  292.     {
  293.         DISKOBJ     * dobj;    /* For WB-Startup */
  294.         struct WBArg * wbarg;
  295.         BPTR       current;
  296.  
  297.         for (i=0; i<Wbs->sm_NumArgs; i++)
  298.         {
  299.         wbarg = &Wbs->sm_ArgList[i];
  300.  
  301.         UnLock (CurrentDir (current = DupLock (wbarg->wa_Lock)));
  302.  
  303.         if (dobj = GetDiskObjectNew (wbarg->wa_Name))
  304.         {
  305.             /* Only process names for ToolTypes, not for the the
  306.                program itself ! */
  307.  
  308.             ops (dobj->do_ToolTypes);
  309.  
  310.             if (i)
  311.             {
  312.             if (loadfile (wbarg->wa_Lock, wbarg->wa_Name))
  313.                 nf ++;
  314.             else
  315.             {
  316.                 FreeDiskObject (dobj);
  317.                 break;
  318.             }
  319.             }
  320.  
  321.             FreeDiskObject (dobj);
  322.         }
  323.         }
  324.  
  325.         /* CD to new base-dir */
  326.         UnLock (CurrentDir (DupLock (Wbs->sm_ArgList[0].wa_Lock)));
  327.     }
  328.     } else
  329.     {
  330.     XDMEArgs.newxdme = newxdme;
  331.  
  332.     /* Parse CLI-args */
  333.     if ((XDMEArgs.ra = ReadArgs (tmplate, (LONG *)&XDMEArgs, NULL))
  334.         && XDMEArgs.files)
  335.     {
  336. #ifdef DEBUG
  337.         UWORD count = 0;
  338. #endif
  339.         char ** nameptr;
  340.  
  341.         for (nameptr=XDMEArgs.files; *nameptr; nameptr ++)
  342.         {
  343. #ifdef DEBUG
  344.         D(bug("Loading %ld %s ...\n", count ++, *nameptr));
  345. #endif
  346.  
  347.         if (loadfile (origlock, *nameptr))
  348.             nf ++;
  349.         else
  350.             break;
  351.         }
  352.     }
  353.     }
  354.  
  355. #ifdef DEBUG
  356.     D(bug("Parsed ARGS\n"));
  357. #endif
  358.  
  359.     if (XDMEArgs.startupfile)
  360.     XDMEArgs.startupfile = strdup (XDMEArgs.startupfile);
  361.     else
  362.     {
  363. #ifdef DEBUG
  364.     D(bug("ERROR: XDMEArgs.startupfile == NULL <<<------------\n"));
  365. #endif
  366.     XDMEArgs.startupfile = strdup (default_startupfile);
  367.     }
  368.  
  369. #ifdef DEBUG
  370.     D(bug("Startup-file : \"%s\"\n", XDMEArgs.startupfile));
  371. #endif
  372.  
  373.     if (XDMEArgs.projectfilename)
  374.     XDMEArgs.projectfilename = strdup (XDMEArgs.projectfilename);
  375.     else
  376.     {
  377. #ifdef DEBUG
  378.     D(bug("ERROR: XDMEArgs.projectfilename == NULL <<<------------\n"));
  379. #endif
  380.     XDMEArgs.projectfilename = strdup (default_projectfile);
  381.     }
  382.  
  383. #ifdef DEBUG
  384.     D(bug("Projectfile : \"%s\"\n", XDMEArgs.projectfilename));
  385. #endif
  386.  
  387.     if (XDMEArgs.publicscreenname)
  388.     XDMEArgs.publicscreenname = strdup (XDMEArgs.publicscreenname);
  389.  
  390. #ifdef DEBUG
  391.     D(bug("Screen : \"%s\"\n", XDMEArgs.publicscreenname ?
  392.         XDMEArgs.publicscreenname : "WBench"));
  393. #endif
  394.  
  395.     /* Free args */
  396.     if (XDMEArgs.ra)
  397.     FreeArgs (XDMEArgs.ra);
  398.  
  399.     if (!nf)
  400.     {  /* no files to edit: Open simple empty window */
  401.     if (XDMEArgs.newxdme || newxdme)
  402.     {
  403.         do_newwindow ();
  404.         if (!Ep)
  405.         goto quit_dme;
  406.  
  407.         if (XDMEArgs.iconify)
  408.         do_iconify ();
  409.     } else
  410.     {
  411.         if (XDMEArgs.iconify)
  412.         {
  413.         do_rexx ("XDME.1", "newwindow iconify");
  414.         } else
  415.         {
  416.         do_rexx ("XDME.1", "newwindow");
  417.         }
  418.     }
  419.     } /* No files */
  420.  
  421.     if (!XDMEArgs.newxdme) /* All done, quit */
  422.     goto quit_dme;
  423.  
  424.     /* Read main .edrc file */
  425.     mountrequest (0);
  426.     av[0] = "source";
  427.     av[1] = (UBYTE *)"s:.edrc";
  428.     do_source (TRUE);   /* Display error */
  429.  
  430.     /* Read other file (if possible) */
  431.     if (NameFromLock (origlock, tmp_buffer, sizeof(tmp_buffer)))
  432.     {
  433.     AddPart (tmp_buffer, XDMEArgs.startupfile, sizeof(tmp_buffer));
  434.     av[1] = tmp_buffer;
  435.     do_source (FALSE); /* Not */
  436.     }
  437.     mountrequest (1);
  438.  
  439.     /* Initialize certain fields in structure */
  440.     {
  441.     ED * ep;
  442.     ED * eb = GetHead ((LIST *)&DBase);
  443.     UWORD ix, iy;
  444.  
  445.     for (ep = eb; ep = GetSucc(&ep->node); )
  446.     {
  447.         ix = ep->beginconfig.iwinx;
  448.         iy = ep->beginconfig.iwiny;
  449.  
  450.         movmem (&eb->beginconfig, &ep->beginconfig, CONFIG_SIZE);
  451.  
  452.         ep->beginconfig.iwinx = ix;
  453.         ep->beginconfig.iwiny = iy;
  454.  
  455.         if (eb->font)
  456.         {
  457.         ep->font = eb->font;
  458.         eb->font->tf_Accessors ++;
  459.         } /* if font */
  460.     } /* for ed */
  461.     }
  462.  
  463.     /* Get Wait()-Mask */
  464.     Mask    |= 1 << Sharedport->mp_SigBit;
  465.     wait_ret = 0;
  466.  
  467.  
  468.  
  469. loop:
  470.     if (!GETF_ICONMODE(Ep))  /* Display cursor ? */
  471.     text_cursor (1);
  472.  
  473.     for ( ; !GETF_QUITFLAG(Ep); )
  474.     {
  475.  
  476.     if (!GETF_ICONMODE(Ep))
  477.         window_title ();
  478.  
  479.     if (dontwait)
  480.     {
  481.         dontwait --;
  482.     } else if (!wait_ret)
  483.     {
  484.         /* Wait for Window, AREXX or ^C */
  485.         wait_ret = Wait (Mask | RexxMask | SIGBREAKF_CTRL_C
  486.         /* ---- we do OR external sigbits into the wait mask */
  487. #undef    DEFSIGHANDLER
  488. #define DEFSIGHANDLER(bits,func)    | (bits)
  489. #include "gen_sighandlers.h"
  490. #undef    DEFSIGHANDLER
  491. #define DEFSIGHANDLER(bits,func) /* nothing */
  492.         );
  493.     }
  494.  
  495.     show_cursor = 0;    /* don't update cursor */
  496.  
  497.     /*
  498.      *  NOTE: due to operation of breakcheck(), the userport signal
  499.      *  may not be set even if there are messages pending.
  500.      */
  501.  
  502. #undef    DEFSIGHANDLER
  503. #define DEFSIGHANDLER(bits,func) \
  504.     if (wait_ret & (bits))   \
  505.     {             \
  506.        text_cursor (0);      \
  507.        show_cursor ++;     \
  508.        func          \
  509.        wait_ret &= ~(bits);  \
  510.     }
  511. #include "gen_sighandlers.h"
  512. #undef    DEFSIGHANDLER
  513. #define DEFSIGHANDLER(bits,func) /* nothing */
  514.  
  515.     if (wait_ret & RexxMask)          /* HD RexxMessage */
  516.     {
  517.         text_cursor (0);
  518.  
  519.         extern_rexx_command ();       /* process HD rexxcommand */
  520.  
  521.         wait_ret &= ~RexxMask;
  522.         show_cursor ++;
  523.     }
  524.     /* else */if (wait_ret & SIGBREAKF_CTRL_C)
  525.     {
  526.         SETF_QUITALL(Ep,1);
  527.         SETF_QUITFLAG(Ep,1);
  528.  
  529.         wait_ret &= ~SIGBREAKF_CTRL_C;
  530.  
  531.         goto boom;
  532.     }
  533.     /* else */if (wait_ret & Mask)              /* HD IntuiMessage */
  534.     {
  535.         IMESS * im;
  536.  
  537.         wait_ret &= ~Mask;
  538.  
  539.         while (im = (IMESS *)GetMsg(Ep->win->UserPort))
  540.         {
  541.         SETF_ABORTCOMMAND(Ep,0);
  542.         SETF_MSGCHECK(Ep,1);
  543.  
  544.         Code         = im->Code;
  545.         Qualifier    = im->Qualifier;
  546.  
  547.         clearbreaks ();
  548.  
  549.         if (im->IDCMPWindow != Ep->win)
  550.         {
  551.             SETF_OVERIDE(Ep,0);
  552.  
  553.             if (GETF_COMLINEMODE(Ep))
  554.             escapecomlinemode ();
  555.  
  556.             text_sync ();
  557.  
  558.             MShowTitle = 0;
  559.  
  560.             if (!GETF_ICONMODE(Ep))
  561.             window_title ();
  562.  
  563.             if (text_switch (im->IDCMPWindow) == 0)
  564.             {
  565.             ReplyMsg ((MSG *)im);
  566.             continue;
  567.             }
  568.         }
  569.  
  570.         Mx = im->MouseX;
  571.         My = im->MouseY;
  572.  
  573.         switch(im->Class)
  574.         {
  575.             case IDCMP_NEWSIZE: {
  576.             struct Window * win = Ep->win;
  577.             WORD        wid;
  578.             WORD        hei;
  579.  
  580.             /* Only works if uniconified */
  581.             if (!GETF_ICONMODE(Ep))
  582.             {
  583.                 /* clear damage list */
  584.                 BeginRefresh (Ep->win);
  585.                 EndRefresh (Ep->win, TRUE);
  586.  
  587.                 /* Leave Comlinemode if neccessary */
  588.                 if (GETF_COMLINEMODE(Ep))
  589.                 escapecomlinemode ();
  590.  
  591.                 /* Set new window-parameters */
  592.                 set_window_params ();
  593.  
  594.                 /* Erase if neccessary */
  595.                 wid = win->Width - win->BorderRight - 1;
  596.                 hei = win->Height - win->BorderBottom - 1;
  597.  
  598.                 SetAPen (win->RPort, TEXT_BPEN(Ep));
  599.                 SetWrMsk (win->RPort, BLOCK_MASK(Ep));
  600.  
  601.                 if (wid > Xpixs)
  602.                 {
  603.                 RectFill (win->RPort, Xpixs+1, Ybase,
  604.                     wid, hei);
  605.                 }
  606.  
  607.                 if (hei > Ypixs)
  608.                 {
  609.                 RectFill (win->RPort, Xbase, Ypixs+1,
  610.                     Xpixs, hei);
  611.                 }
  612.  
  613.                 SetWrMsk (win->RPort, ALL_MASK);
  614.  
  615.                 /* Update Text */
  616.                 text_adjust (TRUE);
  617.                 show_cursor ++;
  618.             }
  619.             break; } /* NEWSIZE */
  620.  
  621.             case IDCMP_REFRESHWINDOW:
  622.             if (!GETF_ICONMODE(Ep))
  623.                 OptimizedRefresh (Ep);
  624.  
  625.             break; /* REFRESHWINDOW */
  626.  
  627.             case IDCMP_MOUSEBUTTONS: {
  628.             static WORD   lastCode = 0;
  629.             static ULONG  lastSeconds;
  630.             static ULONG  lastMicros;
  631.             ULONG          Seconds;
  632.             ULONG          Micros;
  633.             WORD          movement;
  634.  
  635.             /* get time of message */
  636.             Seconds = im->Seconds;
  637.             Micros = im->Micros;
  638.  
  639.             /* Avoid Crashing if Window is closed during keyctl() */
  640.             ReplyMsg ((struct Message *)im);
  641.             im = NULL;
  642.  
  643.             switch(Code)
  644.             {
  645.                 case MENUDOWN:
  646.                 if (GETF_ICONMODE(Ep))
  647.                     break;
  648.  
  649.                 case MIDDLEDOWN:
  650.                 case SELECTDOWN:
  651.                 /* if we only activated the window with a
  652.                    buttonpress, ignore it */
  653.                 if (iawm)
  654.                 {
  655.                     iawm = FALSE;
  656.                     break;
  657.                 }
  658.  
  659.                 /* If User moved the mouse "too much", this
  660.                    cannot be called "dblclick" ;-) */
  661.                 {    /* PATCH_NULL 22-08-94 added */
  662.                     WORD mx = Mx - oMx;
  663.                     WORD my = My - oMy;
  664.  
  665.                     mx = mx >= 0 ? mx: -mx;
  666.                     my = my >= 0 ? my: -my;
  667.                     movement = mx > my? mx :my;
  668.                 }    /* PATCH_NULL 22-08-94 added */
  669.  
  670.                 /* if there was no click yet or
  671.                    the button changed or this is no
  672.                    double-click anymore, then clear
  673.                    the number of clicks and use the new code */
  674.                 if (!NumClicks          ||
  675.                     lastCode != Code    ||
  676.                     movement > 4    || /* PATCH_NULL 22-08-94 added */
  677.                     !DoubleClick (lastSeconds, lastMicros,
  678.                         Seconds, Micros))
  679.                 {
  680.                     lastCode    = Code;   /* new code */
  681.                     NumClicks    = 0;      /* button changed */
  682.                 }
  683.  
  684.                 /* remember the time of this click */
  685.                 lastSeconds = Seconds;
  686.                 lastMicros  = Micros;
  687.                 /* increase the number of clicks */
  688.                 NumClicks ++;
  689.  
  690.                 ReportMouse (TRUE, Ep->win);
  691.                 ModifyIDCMP (Ep->win, Ep->win->IDCMPFlags |
  692.                     IDCMP_INTUITICKS);
  693.  
  694.                 oMx = Mx;
  695.                 oMy = My;
  696.                 LeftArea = FALSE;
  697.                 break;
  698.  
  699.                 case SELECTUP:
  700.                 case MENUUP:
  701.                 case MIDDLEUP:
  702.                 ReportMouse (FALSE, Ep->win);
  703.                 ModifyIDCMP (Ep->win, Ep->win->IDCMPFlags &
  704.                     ~IDCMP_INTUITICKS);
  705.                 break;
  706.  
  707.             }
  708.  
  709.             if (Code == MENUDOWN && GETF_ICONMODE(Ep))
  710.             {
  711.                 uniconify ();
  712.                 show_cursor ++;
  713.             } else if (!iawm)
  714.             {
  715.                 text_cursor (0);
  716.                 show_cursor ++;
  717. #if 1 /* PATCH_NULL 03-07-94 */
  718.     /* /* WARNING - THESE VALUES MIGHT INTERFERE WITH OTHER KEYS */
  719.                 /* COMMENT:                              */
  720.                 /* Wir sollten noch eine Ueberpruefung der Mausposition einbauen und */
  721.                 /* (unter Beruecksichtigung eines Schwellwertes) bei Mausbewegungen  */
  722.                 /* NumClicks auf 0 resetten, das sollte jedoch jemand machen, der     */
  723.                 /* sich in main auskennt, nicht ich ;-)                 */
  724.                 /* dasselbe ist zu den Qualifiern zu sagen, wenn die sich aendern,     */
  725.                 /* waere es vielleicht geschickter, NumClicks wieder auf 0 zurueck-  */
  726.                 /* zusetzten                             */
  727.                 /* noch besser ware es natuerlich, dieses Verhalten ueber FLAGS zu     */
  728.                 /* regeln, damit alle Seiten zufrieden sind 8-)             */
  729.                 /* oder soll diese Funktionalitaet nach keyctl verlagert werden? ;-) */
  730.                 /* (just my $0.02)                                                   */
  731.                 if ((NumClicks > 1) && (NumClicks < 5))
  732.                 {
  733.                 switch (Code)
  734.                 {
  735.                 case SELECTDOWN: Code = (2 - NumClicks) + 0x67; break;
  736.                 case MIDDLEDOWN: Code = (2 - NumClicks) + 0x64; break;
  737.                 case MENUDOWN:     Code = (2 - NumClicks) + 0x61; break;
  738.     /* /* WARNING - THESE VALUES MIGHT INTERFERE WITH OTHER KEYS */
  739.                 default: ;
  740.                 } /* switch */
  741.                 }
  742.                 else if ((NumClicks > 1) && !(Code & 0x80))
  743.                 NumClicks = 0;
  744. #endif /* PATCH_NULL 03-07-94 */
  745.  
  746.                 keyctl (NULL, Code, Qualifier);
  747.             } else
  748.                 iawm = FALSE;
  749.             break; } /* IDCMP_MOUSEBUTTONS */
  750.  
  751.             case IDCMP_RAWKEY: {
  752.             IMESS    copy;
  753.             ULONG    prevkeys;            /* PATCH_NULL 27-06-94 */
  754.  
  755.             /* Keybuttons stop Click-sequences */
  756.             NumClicks = 0;                /* PATCH_NULL 22-08-94 */
  757.             /* Should we add that "NoMoreIntuiticks" here, too? */
  758.  
  759.             /* Prevent crashing in do_iconify()->
  760.                closesharedwindow */
  761.  
  762.             copy = *im;
  763.             prevkeys = *(ULONG*)im->IAddress;   /* PATCH_NULL 27-06-94 */
  764.             copy.IAddress = &prevkeys;        /* PATCH_NULL 27-06-94 */
  765.  
  766.             ReplyMsg ((struct Message *)im);
  767.             im = NULL;
  768.  
  769.             text_cursor (0);
  770.             show_cursor ++;
  771.             keyctl (©, Code, Qualifier);
  772.             break; } /* IDCMP_RAWKEY */
  773.  
  774.             case IDCMP_MENUPICK: {
  775.             /* PATCH_NULL [02 Apr 1993] : menucontrol like keycontrol >>> */
  776.             IMESS copy;
  777.  
  778.             /* Menues stop Click-sequences */
  779.             NumClicks = 0;                /* PATCH_NULL 22-08-94 */
  780.             /* Should we add that "NoMoreIntuiticks" here, too? */
  781.  
  782.             /* Prevent crashing in do_iconify()-> closesharedwindow */
  783.             copy = *im;
  784.             ReplyMsg ((struct Message *)im);
  785.             im = NULL;
  786.  
  787.             text_cursor (0);
  788.             show_cursor ++;
  789.             menu_cmd (©);
  790.             /* PATCH_NULL [02 Apr 1993] : menucontrol like keycontrol <<< */
  791.             break; } /* IDCMP_MENUPICK */
  792.  
  793.             case IDCMP_CLOSEWINDOW:
  794.             if (GETF_COMLINEMODE(Ep))
  795.                 escapecomlinemode ();
  796.  
  797.             text_sync ();
  798.             SETF_QUITFLAG(Ep,TRUE);
  799.             show_cursor = 0;
  800.             break; /* IDCMP_CLOSEWINDOW */
  801.  
  802.             case IDCMP_ACTIVEWINDOW:
  803.             if (!GETF_ICONMODE(Ep))
  804.                 iawm = TRUE;
  805.             break; /* IDCMP_ACTIVEWINDOW */
  806.  
  807.             case IDCMP_INACTIVEWINDOW:        /* PATCH_NULL 15-08-94 ADDED */
  808.             SetWindowTitles (Ep->win, Ep->wtitle, (UBYTE *)-1);
  809.  
  810.             /* Another Window starts w/ 0 Clicks */
  811.             NumClicks = 0;                    /* PATCH_NULL 22-08-94 added */
  812.  
  813.             /* "NoMoreIntuiticks" */
  814.             /* I think that it the better way to make sure no other
  815.                window catches any input ... and it is called less
  816.                frequently  */
  817.             if (Ep->win->IDCMPFlags & IDCMP_INTUITICKS) {   /* PATCH_NULL 22-08-94 added */
  818.                 ReportMouse (FALSE, Ep->win);               /* PATCH_NULL 22-08-94 added */
  819.                 ModifyIDCMP (Ep->win, Ep->win->IDCMPFlags & /* PATCH_NULL 22-08-94 added */
  820.                             ~IDCMP_INTUITICKS); /* PATCH_NULL 22-08-94 added */
  821.             } /* if */                    /* PATCH_NULL 22-08-94 added */
  822.             break; /* IDCMP_INACTIVEWINDOW */    /* PATCH_NULL 15-08-94 ADDED */
  823.  
  824.             case IDCMP_MOUSEMOVE:
  825.             if (gad_active)
  826.             {
  827.                 int newtop = new_top ();
  828.  
  829.                 if (newtop != Ep->topline)
  830.                 {
  831.                 noadj = 1;  /* don't touch the damn prop-gadget ! */
  832.                 text_sync ();
  833.  
  834.                 newtop -= Ep->topline;
  835.  
  836.                 text_cursor (0); /* Cursor off */
  837.                 show_cursor ++;
  838.  
  839.                 Ep->line    += newtop;
  840.                 Ep->topline += newtop;
  841.  
  842.                 text_load ();
  843.  
  844.                 scroll_display (0, newtop, 0, Ep->topline,
  845.                     MAXLINELEN, Ep->topline + Lines);
  846.                 }
  847.             }
  848.             else
  849.             {
  850.                 /* Lost ButtonUP ? */
  851.                 if (!(Qualifier & ( IEQUALIFIER_MIDBUTTON |
  852.                         IEQUALIFIER_RBUTTON |
  853.                         IEQUALIFIER_LEFTBUTTON )) )
  854.                 {
  855.                 ReportMouse (FALSE, Ep->win);
  856.                 ModifyIDCMP (Ep->win, Ep->win->IDCMPFlags &
  857.                     ~IDCMP_INTUITICKS);
  858.                 break;
  859.                 }
  860.  
  861.                 /* Process these after all messages have been
  862.                    processed */
  863.                 if (!LeftArea)
  864.                 {
  865.                 if (((Mx > oMx) ? Mx-oMx>4 : oMx-Mx>4) ||
  866.                     ((My > oMy) ? My-oMy>4 : oMy-My>4) )
  867.                     LeftArea = TRUE;
  868.                 }
  869.  
  870.                 if (LeftArea)
  871.                 {
  872.                 mmove = 1;
  873.                 mqual = Qualifier;
  874.                 }
  875.             }
  876.             break; /* IDCMP_MOUSEMOVE */
  877.  
  878.             case IDCMP_GADGETDOWN:
  879.             if (GETF_COMLINEMODE(Ep))
  880.                 escapecomlinemode ();
  881.  
  882.             gad_id = ((struct Gadget *)im->IAddress)->GadgetID;
  883.  
  884.             if (!gad_id)
  885.             {
  886.                 noadj = 1;      /* block software prop refresh */
  887.             } else
  888.             {
  889.                 text_cursor (0);
  890.                 show_cursor ++;
  891.  
  892.                 if (gad_id == 1)
  893.                 do_scrollup ();
  894.                 else
  895.                 do_scrolldown ();
  896.             }
  897.  
  898.             /* up&down */
  899.             if (gad_id == 1 || gad_id == 2)
  900.                 ModifyIDCMP (Ep->win, Ep->win->IDCMPFlags |
  901.                     IDCMP_INTUITICKS);
  902.             else if (gad_id == 0)  /* scroller */
  903.                 text_adjust (FALSE);
  904.  
  905.             gad_active = TRUE;
  906.             break;
  907.  
  908.             case IDCMP_GADGETUP: {
  909.             gad_id = ((struct Gadget *)im->IAddress)->GadgetID;
  910.  
  911.             switch (gad_id)
  912.             {
  913.             case 0: { /* scroller */
  914.                 int newtop = new_top ();
  915.  
  916.                 if (newtop != Ep->topline)
  917.                 { /* Make sure we don't miss a jump */
  918.                 noadj = 1;  /* don't touch the damn prop-gadget ! */
  919.  
  920.                 text_sync ();
  921.  
  922.                 newtop -= Ep->topline;
  923.  
  924.                 text_cursor (0); /* Cursor off */
  925.                 show_cursor ++;
  926.  
  927.                 Ep->line    += newtop;
  928.                 Ep->topline += newtop;
  929.  
  930.                 text_load ();
  931.  
  932.                 // Reinstalled old way ...
  933.                 scroll_display (0, newtop, 0, Ep->topline,
  934.                     MAXLINELEN, Ep->topline + Lines);
  935.                 //ScrollAndUpdate (0, newtop);
  936.                 }
  937.                 break; }
  938.  
  939.             case 4: /* zoom */
  940.                 if (!GETF_ICONMODE(Ep))
  941.                 {
  942.                 ReplyMsg ((struct Message *)im);
  943.                 im = NULL;
  944.  
  945.                 iconify ();
  946.                 }
  947.  
  948.                 break;
  949.  
  950.             default:
  951.                 ModifyIDCMP (Ep->win, Ep->win->IDCMPFlags &
  952.                     ~IDCMP_INTUITICKS);
  953.             }
  954.  
  955.             gad_active = FALSE;
  956.  
  957.             noadj = 0;        /* reallow software prop refresh */
  958.             break; }
  959.  
  960.             case IDCMP_INTUITICKS:
  961.             if (gad_active && gad_id)
  962.             {
  963.                 text_cursor (0);
  964.                 show_cursor ++;
  965.  
  966.                 if (gad_id == 1)
  967.                 do_scrollup ();
  968.                 else
  969.                 do_scrolldown ();
  970.             } else if (LeftArea)
  971.             {
  972.                 mmove = 1;
  973.                 mqual = Qualifier;
  974.             }
  975.             break; /* IDCMP_INTUITICKS */
  976.         } /* switch (class) */
  977.  
  978.         if (im)
  979.             ReplyMsg ((MSG *)im);
  980.  
  981.         if (GETF_QUITFLAG(Ep))
  982.         {
  983.             dontwait = 2;
  984.             goto boom;
  985.         } /* if (Quitflag) */
  986.         } /* While IntuiMessage */
  987.  
  988.     } /* if (Wait & Mask) */
  989.  
  990.     /* no more iawm */
  991.     iawm = FALSE;
  992.  
  993.     if (mmove && !GETF_ICONMODE(Ep))
  994.     {
  995.         mmove = 0;
  996.  
  997.         text_cursor (0);
  998.         show_cursor ++;
  999.         keyctl (NULL, QMOVE, mqual);
  1000.     } /* if (mmove) */
  1001.  
  1002.     if (show_cursor && !GETF_ICONMODE(Ep))
  1003.         text_cursor (1);
  1004.  
  1005.     } /* for ( ; !Quitflag; ) */
  1006.  
  1007. boom:
  1008.     text_sync ();
  1009.  
  1010.     /* Close window(s) */
  1011.     {
  1012.     WIN          * win;
  1013.     struct Gadget * gadget;
  1014.     int        result;
  1015.  
  1016.     do
  1017.     {
  1018.         if (GETF_MODIFIED(Ep))
  1019.         {
  1020.         uniconify ();
  1021.         text_cursor (1);
  1022.  
  1023. DEFMESSAGE( __xdme_warning, "XDME Warning" )
  1024.         result = getyn (__xdme_warning,
  1025.             "The file `%s' has been modified.\n"
  1026.             "Do you want to quit anyway (and loose all\n"
  1027.             "your work) ?",
  1028.             "Quit|Save & Quit|Cancel", Ep->name);
  1029.  
  1030.         switch (result)
  1031.         {
  1032.             case 0:
  1033.             SETF_QUITFLAG(Ep,0);
  1034.             goto loop;
  1035.             break;
  1036.  
  1037.             case 2:
  1038.             if (!do_save ())
  1039.             {
  1040.                 SETF_QUITFLAG(Ep,0);
  1041.                 goto loop;
  1042.             }
  1043.             break;
  1044.         }
  1045.         }
  1046.  
  1047.         win    = Ep->win;
  1048.         gadget = Ep->propgad;
  1049.  
  1050.         rem_prop (Ep);
  1051.         text_uninit ();
  1052.         closesharedwindow (win);
  1053.  
  1054.         if (gadget)
  1055.         free_prop ((struct PropGadget *)gadget);
  1056.     } while (GETF_QUITALL(Ep) && Ep);
  1057.     }
  1058.  
  1059.     /* If we have another window left */
  1060.     if (Ep)
  1061.     {
  1062.     SETF_QUITFLAG(Ep,0);
  1063.  
  1064.     if (!GETF_ICONMODE(Ep))
  1065.         set_window_params ();
  1066.  
  1067.     text_load ();
  1068.  
  1069.     MShowTitle = 0;
  1070.     goto loop;
  1071.     }
  1072.  
  1073. quit_dme:
  1074.  
  1075.     /* Close AREXX */
  1076.     closerexx ();
  1077.  
  1078.     /* Close Port after ARexx */
  1079.     if (Sharedport)
  1080.     {
  1081.     DeletePort (Sharedport);
  1082.     Sharedport = NULL;
  1083.     }
  1084.  
  1085.     /* Free Lock */
  1086.     UnLock (CurrentDir (origlock));
  1087.  
  1088.     /* Free memory */
  1089.     // dealloc_hash (currenthash());        /* PATCH_NULL [25 Jan 1993] : added currenthash */
  1090.     check_stack (NULL);
  1091.  
  1092.     if (XDMEArgs.startupfile)
  1093.     free (XDMEArgs.startupfile);
  1094.  
  1095.     if (XDMEArgs.projectfilename)
  1096.     free (XDMEArgs.projectfilename);
  1097.  
  1098.     if (XDMEArgs.publicscreenname)
  1099.     free (XDMEArgs.publicscreenname);
  1100.  
  1101. #ifdef DEBUG_MEM_H
  1102.     _debug_FreeAllMem ();
  1103. #endif /* DEBUG_MEM_H */
  1104.  
  1105.     clear_record ();
  1106.     //exit_menustrips ();
  1107.     //exit_keytables ();
  1108.  
  1109.     AmTerminating = 1;
  1110.  
  1111.     /* All OK. */
  1112.     exiterr (NULL);
  1113. } /* main */
  1114.  
  1115.  
  1116. Prototype void OptimizedRefresh (ED *);
  1117.  
  1118. void OptimizedRefresh (ED * ep)
  1119. {
  1120.     BOOL old;
  1121.  
  1122.     noadj = 1;    /* don't touch the damn prop-gadget ! */
  1123.  
  1124.     BeginRefresh (ep->win);
  1125.     LockLayer (NULL, ep->win->WLayer);
  1126.     /* text_redisplay ();   Must not be used because it calls RefreshGList() */
  1127.  
  1128.     set_window_params (); /* query current window parameters */
  1129.  
  1130.     /* leave Comlinemode */
  1131.     if (old = GETF_COMLINEMODE(Ep))
  1132.     escapecomlinemode ();
  1133.  
  1134.     /* clear background */
  1135.     SetAPen (ep->win->RPort, TEXT_BPEN(ep));
  1136.     SetWrMsk (ep->win->RPort, ALL_MASK);
  1137.     RectFill (ep->win->RPort, Xbase,Ybase, Xpixs, Ypixs);
  1138.  
  1139.     redraw_block (TRUE, ep->topline, ep->topcolumn,
  1140.         ep->topline + Lines - 1, ep->topcolumn + Columns - 1);
  1141.  
  1142.     if (old)
  1143.     do_recall ();
  1144.  
  1145.     text_cursor (1);
  1146.  
  1147.     UnlockLayer (ep->win->WLayer);
  1148.     EndRefresh (ep->win, TRUE);
  1149.  
  1150.     noadj = 0;
  1151. } /* OptimizedRefresh */
  1152.  
  1153.  
  1154. /*DEFHELP #cmd movement TOMOUSE - moves cursor to mouse position */
  1155.  
  1156. DEFUSERCMD("tomouse", 0, CF_VWM, void, do_tomouse, (void),)
  1157. {
  1158.     WORD cx, cy;
  1159.     WORD minx, miny, maxx, maxy;
  1160.  
  1161.     if (Columns < 2 || Lines < 2)
  1162.     return;
  1163.  
  1164.     cx = (Mx-Xbase);
  1165.     if (cx >= 0)
  1166.     {
  1167.     if (cx < Xpixs)
  1168.         cx /= Xsize;
  1169.     else
  1170.         cx = Columns;
  1171.     } else
  1172.     cx = -1;
  1173.  
  1174.     cy = (My-Ybase);
  1175.     if (cy >= 0)
  1176.     {
  1177.     if (cy < Ypixs)
  1178.         cy /= Ysize;
  1179.     else
  1180.         cy = Lines;
  1181.     } else
  1182.     cy = -1;
  1183.  
  1184.     minx = 0;            /* Scroll when MOUSE left window */
  1185.     miny = 0;
  1186.     maxx = Columns;
  1187.     maxy = Lines;
  1188.  
  1189.     if (cx < minx)
  1190.     { /* to the left */
  1191.     do_scroll (SCROLL_LEFT);
  1192.  
  1193.     if (cy < miny)
  1194.     { /* Also up */
  1195.         do_scrollup ();
  1196.     } else if (cy >= maxy)
  1197.     { /* also down */
  1198.         do_scrolldown ();
  1199.     }
  1200.     } else if (cx >= maxx)
  1201.     { /* dito to the right */
  1202.     do_scroll (SCROLL_RIGHT);
  1203.  
  1204.     if (cy < miny)
  1205.     {
  1206.         do_scrollup ();
  1207.     } else if (cy >= maxy)
  1208.     {
  1209.         do_scrolldown ();
  1210.     }
  1211.     } else
  1212.     { /* x is ok, check y */
  1213.     if (cy < miny)
  1214.     { /* up */
  1215.         do_scrollup ();
  1216.     } else if (cy >= maxy)
  1217.     { /* down */
  1218.         do_scrolldown ();
  1219.     } else
  1220.         text_position (cx, cy); /* Just reposition cursor */
  1221.     }
  1222. } /* do_tomouse */
  1223.  
  1224.  
  1225. Prototype void exiterr (char * str);
  1226.  
  1227. void exiterr (char * str)
  1228. {
  1229.     if (str)
  1230.     {
  1231.     if (Output ())
  1232.     {
  1233.         Write (Output (), str, strlen (str));
  1234.         Write (Output (), "\n", 1);
  1235.     } else
  1236.     {
  1237.         if (IntuitionBase)
  1238.         error (str);
  1239.     }
  1240.     }
  1241.  
  1242.     /* if (IconBase)
  1243.     {
  1244.     CloseLibrary (IconBase);
  1245.     IconBase = NULL;
  1246.     } */
  1247.  
  1248.     if (ReqToolsBase)
  1249.     {
  1250.     if (RFReq)
  1251.     {
  1252.         rtFreeRequest (RFReq);
  1253.  
  1254.         RFReq = NULL;
  1255.     }
  1256.  
  1257.     CloseLibrary ((struct Library *)ReqToolsBase);
  1258.     ReqToolsBase = NULL;
  1259.     }
  1260.  
  1261.     if (AslBase)
  1262.     {
  1263.     if (FReq)
  1264.     {
  1265.         FreeAslRequest (FReq);
  1266.  
  1267.         FReq = NULL;
  1268.     }
  1269.  
  1270.     /*      CloseLibrary (AslBase);
  1271.     AslBase = NULL; */
  1272.     }
  1273.  
  1274.     /* if (GfxBase)
  1275.     {
  1276.     CloseLibrary ((struct Library *)GfxBase);
  1277.     GfxBase = NULL;
  1278.     }
  1279.  
  1280.     if (IntuitionBase)
  1281.     {
  1282.     CloseLibrary ((struct Library *)IntuitionBase);
  1283.     IntuitionBase = NULL;
  1284.     } */
  1285.  
  1286.     if (str)
  1287.     exit (1);
  1288.  
  1289.     exit (0);
  1290. } /* exiterr */
  1291.  
  1292.  
  1293. /*
  1294.  *  Check break by scanning pending messages in the Inputstream for a ^C.
  1295.  *  Msgchk forces a check, else the check is only made if the signal is
  1296.  *  set in the Inputstream (the signal is reset).
  1297.  */
  1298.  
  1299. Prototype int breakcheck (void);
  1300.  
  1301. int breakcheck (void)
  1302. {
  1303.     IMESS    * im;
  1304.     WIN     * win  = Ep->win;
  1305.     struct List * list = &win->UserPort->mp_MsgList;
  1306.  
  1307.     ULONG sigs = SetSignal(0,SIGBREAKF_CTRL_C);                     /* PATCH_NULL [14 Feb 1993] : that mode slows looping not markably down ; PATCH_NULL 20-07-94 clearing ctl-c */
  1308.  
  1309.     if ((sigs & SIGBREAKF_CTRL_C) != 0) {                           /* PATCH_NULL [14 Feb 1993] : These lines are   */
  1310.     SETF_ABORTCOMMAND(Ep,1); /* PATCH_NULL 20-07-94 added */
  1311.     return(1);                                                  /* PATCH_NULL [14 Feb 1993] : intended to allow */
  1312.     }
  1313.     else if (GETF_MSGCHECK(Ep) || (sigs & (1<<win->UserPort->mp_SigBit)))    /* PATCH_NULL [14 Feb 1993] : external breaking */
  1314.     {
  1315.     SETF_MSGCHECK(Ep,0);
  1316.     SetSignal (0,1<<win->UserPort->mp_SigBit);
  1317.  
  1318.     im = (IMESS *)list->lh_Head;
  1319.     Forbid();
  1320.  
  1321.     for ( ; im != (IMESS *)&list->lh_Tail;
  1322.         im = (IMESS *)im->ExecMessage.mn_Node.ln_Succ)
  1323.         {
  1324.         if (im->Class == RAWKEY && (im->Qualifier & 0xFB) == 0x08 &&
  1325.         im->Code == CtlC)
  1326.         {
  1327.  
  1328.         Permit ();
  1329. //          SetSignal (SIGBREAKF_CTRL_C,SIGBREAKF_CTRL_C); /* PATCH_NULL 20-07-94 commented out */
  1330.         SETF_ABORTCOMMAND(Ep,1); /* PATCH_NULL 20-07-94 added */
  1331.         return (1);
  1332.         }
  1333.     } /* for IMESS */
  1334.  
  1335.     Permit ();
  1336.     }
  1337.  
  1338.     return (0);
  1339. } /* breakcheck */
  1340.  
  1341.  
  1342. Prototype void breakreset (void);
  1343.  
  1344. void breakreset (void)
  1345. {
  1346.     SetSignal(0, SIGBREAKF_CTRL_C);
  1347. }
  1348.  
  1349.  
  1350. /* Parse WB-ToolTypes */
  1351.  
  1352. Prototype void ops (char ** toolarray);
  1353.  
  1354. void ops (char ** toolarray)
  1355. {
  1356.     char * tooltype;
  1357.  
  1358.     if (tooltype = FindToolType (toolarray, "ICONIFY"))
  1359.     XDMEArgs.iconify = MatchToolValue (tooltype, "YES");
  1360.     else
  1361.     XDMEArgs.iconify = FALSE;
  1362.  
  1363.     if (tooltype = FindToolType (toolarray, "NEW"))
  1364.     XDMEArgs.newxdme = MatchToolValue (tooltype, "YES") | newxdme;
  1365.     else
  1366.     XDMEArgs.newxdme = newxdme;
  1367.  
  1368.     if (tooltype = FindToolType (toolarray, "AUTOLOAD"))
  1369.     XDMEArgs.autoload = MatchToolValue (tooltype, "YES");
  1370.     else
  1371.     XDMEArgs.autoload = FALSE;
  1372.  
  1373.     if (tooltype = FindToolType (toolarray, "PUBSCREEN"))
  1374.     XDMEArgs.publicscreenname = tooltype;    /* no strdup() here ! */
  1375.  
  1376.     if (tooltype = FindToolType (toolarray, "PROJECTFILE"))
  1377.     XDMEArgs.projectfilename = tooltype;   /* no strdup() here ! */
  1378.  
  1379.     if (tooltype = FindToolType (toolarray, "STARTUP"))
  1380.     XDMEArgs.startupfile = tooltype;   /* no strdup() here ! */
  1381.  
  1382. #ifdef DEBUG
  1383.     D(bug("sfile: %s\nnew %ld\niconify %ld\nauto %ld\n"
  1384.         "PSName: `%s'\npf: `%s'\n", XDMEArgs.startupfile,
  1385.         XDMEArgs.newxdme, XDMEArgs.iconify, XDMEArgs.autoload,
  1386.         XDMEArgs.publicscreenname ? XDMEArgs.publicscreenname : "(nul)",
  1387.         XDMEArgs.projectfilename ? XDMEArgs.projectfilename : "(nul)"));
  1388. #endif
  1389. } /* ops */
  1390.  
  1391.  
  1392. Prototype BOOL loadfile (BPTR lock, char * name);
  1393.  
  1394. BOOL loadfile (BPTR lock, char * name)
  1395. {
  1396.     char buf[512];
  1397.  
  1398.     /* Load project ? */
  1399.     if (!stricmp (name, XDMEArgs.projectfilename))
  1400.     {
  1401.     if (XDMEArgs.newxdme)
  1402.     {
  1403.         return ((BOOL) load_project ());
  1404.     } else
  1405.     {
  1406.         strcpy (buf, "cd `");
  1407.  
  1408.         if (NameFromLock (lock, buf + 4, sizeof (buf) - 4))
  1409.         {
  1410.         strcat (buf, "' projectload");
  1411.  
  1412.         do_rexx ("XDME.1", buf);
  1413.         }
  1414.     }
  1415.     } else
  1416.     {
  1417.     if (XDMEArgs.newxdme)
  1418.     {
  1419.         /* Normal file. Open new window */
  1420.         do_newwindow ();
  1421.         if (!Ep)
  1422.         return (FALSE);
  1423.  
  1424.         /* Load file for editing */
  1425.         av[0] = (UBYTE *)"newfile";
  1426.         av[1] = (UBYTE *)name;
  1427.  
  1428.         UnLock (Ep->dirlock);
  1429.         Ep->dirlock = DupLock (lock);
  1430.  
  1431.         do_edit ();
  1432.  
  1433.         /* Show title */
  1434.         SETF_MFORCETITLE(Ep,1);
  1435.         window_title ();
  1436.  
  1437.         if (XDMEArgs.iconify)
  1438.         do_iconify ();
  1439.     } else
  1440.     { /* Use AREXX */
  1441.         strcpy (buf, "newwindow cd `");
  1442.  
  1443.         if (NameFromLock (lock, buf + 14, sizeof (buf) - 14))
  1444.         {
  1445.         sprintf (buf + strlen (buf), "' newfile `%s'%s",
  1446.             name, (XDMEArgs.iconify ? " iconify" : ""));
  1447.         do_rexx ("XDME.1", buf);
  1448.         }
  1449.     }
  1450.     } /* No PROJECTFILE */
  1451.  
  1452.     return (TRUE);
  1453. } /* loadfile */
  1454.  
  1455.  
  1456. /******************************************************************************
  1457. *****  ENDE main.c
  1458. ******************************************************************************/
  1459.