home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / xdme1821.lha / XDME / mikro.c < prev    next >
C/C++ Source or Header  |  1993-03-25  |  9KB  |  422 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     mikro.c
  5.  
  6.     DESCRIPTION
  7.     hier ist alles, was zu klein war fuer einen vernuenftigen Oberbegriff
  8.  
  9.     NOTES
  10.  
  11.     BUGS
  12.  
  13.     TODO
  14.  
  15.     EXAMPLES
  16.  
  17.     SEE ALSO
  18.  
  19.     INDEX
  20.  
  21.     HISTORY
  22.  
  23. ******************************************************************************/
  24.  
  25. /**************************************
  26.         Includes
  27. **************************************/
  28. #include "defs.h"
  29.  
  30. /**************************************
  31.         Globale Variable
  32. **************************************/
  33.  
  34.  
  35. /**************************************
  36.       Interne Defines & Strukturen
  37. **************************************/
  38.  
  39.  
  40. /**************************************
  41.         Interne Variable
  42. **************************************/
  43.  
  44.  
  45. /**************************************
  46.        Interne Prototypes
  47. **************************************/
  48. Prototype void      do_viewmode (void);
  49. Prototype void      do_eval     (void);
  50. Prototype void      do_unfail   (void);
  51. Prototype void      do_quiet    (void);
  52. Prototype void      do_untitle  (void);
  53. Prototype void      do_force    (void);
  54. Prototype void      do_abort    (void);
  55. Prototype void      do_unabort  (void);
  56. Prototype void      do_insertwrite(void);
  57. Prototype void      do_break     (void);
  58. Prototype void      do_continue  (void);
  59. Prototype void      clearcont    (void);
  60. Prototype void      clearbreak   (void);
  61. Prototype void      clearbreaks  (void);
  62.  
  63. Prototype void      do_simpletabs  (void);
  64. Prototype void      do_activefront (void);
  65. Prototype void      do_sourcebreak (void);
  66. Prototype void      do_windowcyc     (void);
  67.  
  68. void
  69. do_viewmode(void)
  70. {
  71.     Ep->viewmode = test_arg(av[1], Ep->viewmode);
  72.  
  73.     if (Ep->viewmode)
  74.     {
  75.     title ("Viewmode ON");
  76.     } else
  77.     {
  78.     title ("Viewmode OFF");
  79.     } /* if */
  80. } /* do_viewmode */
  81.  
  82.  
  83.  
  84. /*
  85. *! >ABORT
  86. *! >UNABORT
  87. *!  they toggle a flag which controlles macro-executing
  88. *!  ABORT sets the break-flag which causes e.g. immediately macro-abortion at keys
  89. *!  or terminates line-execution
  90. *!  UNABORT allows to reset this flag in a AREXX-script,
  91. *!  is the last line produced an error, you may clear the error-flag
  92. *!  if UNABORT is the first (or only) command of a line
  93. *!
  94. */
  95.  
  96. void
  97. do_abort ( void )
  98. {
  99.     globalflags.Abortcommand = 1;
  100. } /* do_abort */
  101.  
  102. void
  103. do_unabort ( void )
  104. {
  105.     globalflags.Abortcommand = 0;
  106. } /* do_unabort */
  107.  
  108. BOOL
  109. is_aborted ( void )
  110. {
  111.     return(globalflags.Abortcommand);
  112. } /* is_aborted */
  113.  
  114.  
  115.  
  116. /* PATCH_NULL - missing in 180 */
  117.  
  118. void do_break (void)
  119. {
  120.     LoopBreak++;
  121. } /* do_break */
  122.  
  123.  
  124.  
  125. void do_continue (void)
  126. {
  127.     LoopCont++;
  128. } /* do_continue */
  129.  
  130. #ifdef NOT_DEF
  131. void clearcont (void)  { LoopCont = 0;  } /* clearcont */
  132. void clearbreak (void) { LoopBreak = 0; } /* clearbreak */
  133. #endif
  134.  
  135.  
  136. void clearbreaks (void)
  137. {
  138.     LoopCont = 0;
  139.     LoopBreak = 0;
  140.     globalflags.Abortcommand = 0;
  141. } /* clearbreaks */
  142.  
  143. /* PATCH_NULL - missing in 180 */
  144.  
  145.  
  146.  
  147. /*
  148. *! >EVAL com
  149. *!
  150. *!  to split longer commandsequences to fit their length down to MAXIA
  151. *!  so MAXIA may stay "small" and anybody can avoid "expression too complex"
  152. *!
  153. */
  154.  
  155. void
  156. do_eval(void)
  157. {
  158.     char* buffer = (char*)malloc(LINE_LENGTH); /* allocate a buffer */
  159.     if (buffer)
  160.     {
  161.     strcpy(buffer, av[1]);                 /* copy the command into that buffer */
  162.     do_command(buffer);                    /* execute the buffer */
  163.     free(buffer);                          /* and then free it again */
  164.     } else
  165.     {
  166.     nomemory();
  167.     globalflags.Abortcommand = 1;
  168.     } /* if */
  169. } /* do_eval */
  170.  
  171.  
  172.  
  173. /*
  174. *!  >UNFAIL com
  175. *!
  176. *! That's really like EVAL, but it ignore's failures
  177. *! Very useful if U try to call an Command but U don't
  178. *! know if it is one, or if you don't want a failure to break your macro
  179. *!
  180. */
  181.  
  182. void
  183. do_unfail(void)
  184. {
  185.     do_eval();
  186.     globalflags.Abortcommand = 0;
  187.     // do_clearallbreaks();                /* simply cancel all breaks after evaluation */
  188. } /* do_unfail */
  189.  
  190.  
  191.  
  192. /*
  193. *!  >QUIET com
  194. *!
  195. *! That's like EVAL, but during execution no window
  196. *! should be refreshed
  197. *! as _No_Screen_Update is increased during operation
  198. *!
  199. */
  200.  
  201. void
  202. do_quiet()
  203. {
  204.     int inter = Nsu;            /* extern Nsu controlles screen updates */
  205.     Nsu = 1;                /* buffer that value and change it for evaluation, then restore it */
  206.     do_eval();
  207.     Nsu = inter;
  208. } /* do_quiet */
  209.  
  210.  
  211.  
  212. /*
  213. *!  >UNTITLE com
  214. *!
  215. *!  That's also like EVAL, except for the feature, that
  216. *!  No Title is shown during the macrocall
  217. *!
  218. */
  219.  
  220. void
  221. do_untitle()
  222. {
  223.     char inter = globalflags.Showtitle;   /* extern showtitle controlles changes in window-titling */
  224.     globalflags.Showtitle = 0;          /* buffer that value and change it for evaluation, then restore it */
  225.     do_eval();
  226.     globalflags.Showtitle = inter;
  227. } /* do_untitle */
  228.  
  229.  
  230.  
  231. /*
  232. *!  >FORCE [T|S|F|R|D] command
  233. *!
  234. *!  Thats a command that means conjunction
  235. *!  of EVAL, QUIET, UNFAIL and UNTITLE
  236. *!
  237. *!    T == unTitle
  238. *!    S == quiet (no Screen updating)
  239. *!    F == unFail
  240. *!    R == no Requestors
  241. *!    D == enable debugging mode
  242. *!     <no flags> -> simple eval
  243. *!
  244. */
  245.  
  246. void do_force (void)
  247. {
  248.     char inter_screen  = Nsu;        /* extern Nsu controlles screen updates */
  249.     char inter_title   = globalflags.Showtitle;     /* extern showtitle controlles changes in window-titling */
  250.     char inter_request = globalflags.NoRequest;     /* Disable flag for requestors */
  251.     char inter_debug   = globalflags.debug;        /* Debugging mode */
  252.     int failures       = 0;
  253.  
  254.     char* typer = av[1];
  255.     char* av1 = av[1];
  256.     char* av2 = av[2];
  257.  
  258.     av[1] = av[2];
  259.     av[2] = NULL;
  260.  
  261.     if (typer)
  262.     {                 /* check for any set flags */
  263.     while (*typer)
  264.     {
  265.         switch ((*typer)|32)
  266.         {
  267.         case 't':
  268.         globalflags.Showtitle = 0;
  269.         break;
  270.         case 's':
  271.         Nsu = 1;
  272.         break;
  273.         case 'f':
  274.         failures = 1;
  275.         break;
  276. /* PATCH_NULL - missing in 180 */
  277.         case 'r':
  278.         globalflags.NoRequest = 1;
  279.         break;
  280.         case 'd':
  281.         globalflags.debug = 1;
  282.         break;
  283. /* PATCH_NULL - missing in 180 */
  284.         default:
  285.         error ("%s:\nInvalid flags '%s'", av[0], typer);
  286.         goto df_quit;
  287.         } /* switch */
  288.         typer++;
  289.     } /* while */
  290.     } /* if */
  291.  
  292.     do_eval();                          /* do the evaluation */
  293.  
  294.     if (failures)
  295.     {              /* (...) cancel all breaks */
  296.     extern char MacroBreak;  /* PATCH_NULL [08 Mar 1993] : added */
  297.     if (MacroBreak != 1)     /* PATCH_NULL [08 Mar 1993] : added */
  298.         globalflags.Abortcommand = 0;
  299.     /* do_unbreak();  */
  300.     } /* if */
  301.  
  302. df_quit:
  303.     Nsu  = inter_screen;        /* (if necessary) restore old values */
  304.     globalflags.Showtitle = inter_title;
  305.     globalflags.NoRequest = inter_request;
  306.     globalflags.debug      = inter_debug;
  307.  
  308.     av[2] = av2;
  309.     av[1] = av1;
  310.     return;
  311. } /* do_force */
  312.  
  313.  
  314.  
  315.  
  316. /*
  317. *! >INSERT text
  318. *! >OVERWRITE text
  319. *!
  320. *!  insert or overwrite text in the current line without respect
  321. *!  to the specialflag INSERTMODE
  322. *!
  323. *!  note that it is possible to define that ^-combinations
  324. *!  can be interpreted like commands or like ctrl-keystrokes
  325. *!  when they are INSERTed (not in overwrite mode)
  326. *!  that patch is switched with the specialvar TEXTCOM
  327. *!
  328. */
  329.  
  330. void
  331. do_insertwrite()
  332. {
  333.     char insertbackup = Ep->config.insertmode;
  334.  
  335.     Ep->config.insertmode = av[0][0] == 'i';
  336.  
  337.     text_write(av[1]);
  338.  
  339.     Ep->config.insertmode = insertbackup;
  340. } /* do_insertwrite */
  341.  
  342.  
  343.  
  344. /*
  345. **  The following commands should be placed into prefs.c
  346. **
  347. *!
  348. *!  ActivateToFront
  349. *!  Windowcycling
  350. *!
  351. *!    These two flags refer to SELECT:
  352. *!
  353. *!    ActivateToFront invokes a "WindowToFront()" every
  354. *!            time, windows are switched
  355. *!    Windowcycling    enables the possibility to switch
  356. *!            to the other end of Textlist, if
  357. *!            one end is reacjed with SELECT next/prev
  358. *!
  359. *!
  360. *!  SourceBreaks
  361. *!    That flag refers to SOURCE
  362. *!    if an abortcommand or a break occurs on
  363. *!    sourcing level, the operation is aborted
  364. *!
  365. *!  SimpleTabs
  366. *!    That flag is an add to SAVETABS and SAVE[old|as]
  367. *!    if Savetabs is set, SimpleTabs decides to optimize
  368. *!    TAB-Optimisation until the first non-blank only
  369. *!
  370. */
  371.  
  372. void do_activefront (void)
  373. {
  374.     globalflags.ActivateToFront = test_arg (av[1], globalflags.ActivateToFront);
  375.  
  376.     if (globalflags.ActivateToFront)
  377.     title ("Activated Windows are moved to front now");
  378.     else
  379.     title ("Activated Windows are NOT moved front now");
  380. } /* do_activefront */
  381.  
  382.  
  383. void do_windowcyc (void)
  384. {
  385.     globalflags.Windowcycling = test_arg (av[1], globalflags.Windowcycling);
  386.  
  387.     if (globalflags.Windowcycling)
  388.     title ("Windowcycling is now ON");
  389.     else
  390.     title ("Windowcycling is now OFF");
  391. } /* do_windowcyc */
  392.  
  393.  
  394. void do_sourcebreak (void)
  395. {
  396.     globalflags.SourceBreaks = test_arg (av[1], globalflags.SourceBreaks);
  397.  
  398.     if (globalflags.SourceBreaks)
  399.     title ("Source - Breaks are Enabled");
  400.     else
  401.     title ("Source - Breaks are Ignored");
  402. } /* do_sourcebreak */
  403.  
  404.  
  405. void do_simpletabs (void)
  406. {
  407.     globalflags.SimpleTabs = test_arg (av[1], globalflags.SimpleTabs);
  408.  
  409.     if (globalflags.SimpleTabs && globalflags.Savetabs)
  410.     title ("Tabsaving up to forstnb");
  411.     else if (globalflags.Savetabs)
  412.     title ("Tabsaving full");
  413.     else
  414.     title ("Tabsaving off");
  415. } /* do_simpletabs */
  416.  
  417.  
  418.  
  419. /******************************************************************************
  420. *****  ENDE mikro.c
  421. ******************************************************************************/
  422.