home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / demo3.zoo / demo / misc / mgrmode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-24  |  3.8 KB  |  163 lines

  1. /*                        Copyright (c) 1988 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: mgrmode.c,v 4.2 88/06/22 14:37:52 bianchi Exp $
  9.     $Source: /tmp/mgrsrc/demo/misc/RCS/mgrmode.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/demo/misc/RCS/mgrmode.c,v $$Revision: 4.2 $";
  12.  
  13. /* set or clear an MGR window mode */
  14.  
  15. #include <signal.h>
  16. #include "term.h"
  17.  
  18.  
  19. #define    SET    0
  20. #define    CLEAR    1
  21.  
  22. #define    EQ(a,b)    (!strcmp(a,b))
  23.  
  24. static char    *allmodes[] = {
  25.     "ABS",
  26.     /*    ACTIVATE is not really a mode; it is actually an action.
  27.         We won't deactivate a window when CLEARALL is specified.
  28.     */
  29.     "AUTOEXPOSE",
  30.     "BACKGROUND",
  31.     "DUPKEY",
  32.     "NOBUCKEY",
  33.     "NOINPUT",
  34.     "NOWRAP",
  35.     "OVERSTRIKE",
  36.     "SNARFHARD",
  37.     "SNARFLINES",
  38.     "SNARFTABS",
  39.     "STACK",
  40.     "STANDOUT",
  41.     "WOB",
  42.     0
  43. };
  44. static char    *pgm;
  45.  
  46.  
  47. main(argc,argv)
  48. int    argc;
  49. char    **argv;
  50. {
  51.     int    setclear = SET;
  52.  
  53.     pgm = *argv;
  54.     ckmgrterm( pgm );
  55.  
  56.     if( argc < 2 ) {
  57.         fprintf( stderr,
  58.             "Usage:  %s [ SETMODE | CLEARMODE ] mgr-modes ...\n",
  59.             pgm );
  60.         fputs( "\
  61. Set or clear MGR window modes.\n\
  62. SETMODE        (Default) Set the mode\n\
  63. CLEARMODE    Clear the mode\n\
  64. CLEARALL    Clear all modes, except ACTIVATE\n\
  65. Modes include:\n\
  66. M_ABS        Turn on Absolute Coordinate mode.\n\
  67. M_ACTIVATE    Activate window (not really a mode).\n\
  68. M_AUTOEXPOSE    Expose window when written to.\n\
  69. M_BACKGROUND    Do not block window update when window is obscured.\n\
  70. M_DUPKEY    Duplicate the Escape character when from keyboard.\n\
  71. M_NOBUCKEY    Turn off mgr interpreting Left and Right (Buckey) keys;\n\
  72.         Pass them on to the application.\n\
  73. M_NOINPUT    Keyboard input is held until cleared or another window\n\
  74.         becomes active.\n\
  75. M_NOWRAP    Do not wrap around when text reaches right edge of window.\n\
  76. M_OVERSTRIKE    Turn on overstriking of text.\n\
  77. M_SNARFHARD    Snarf (cut) even if there are errors.\n\
  78. M_SNARFLINES    Only cut entire lines.\n\
  79. M_SNARFTABS    Change spaces to tabs within the snarf buffer.\n\
  80. M_STACK        Turn on event stacking.\n\
  81. M_STANDOUT    Write characters in standout mode (foreground and background\n\
  82.         colors reversed).\n\
  83. M_WOB        White On Black, entire window's sense of white and black is\n\
  84.         reversed.\n\
  85. `M_' may be omitted.  Lower case letters are permitted.  M_ABS == ABS == abs.\n\
  86. ",
  87.             stderr );
  88.         exit( 255 );
  89.     }
  90.     m_setup( M_FLUSH );
  91.     argv++;
  92.     argc--;
  93.     for(  ;  *argv;  argv++, argc-- ) {
  94.         register char    *mode = *argv;
  95.  
  96.         /* Uppercase modes are optional.  abs == ABS
  97.         */
  98.         do {
  99.             if( *mode >= 'a'  &&  *mode <= 'z' )
  100.                 *mode -= 'a' - 'A';
  101.         } while( *(mode++) );
  102.  
  103.         mode = *argv;
  104.  
  105.         if( EQ( mode, "SETMODE" ) ) {
  106.             setclear = SET;
  107.             continue;
  108.         }
  109.         if( EQ( mode, "CLEARMODE" ) ) {
  110.             setclear = CLEAR;
  111.             continue;
  112.         }
  113.         if( EQ( mode, "CLEARALL" ) ) {
  114.             char    **cpp;
  115.             for( cpp = allmodes;  *cpp;  cpp++ )
  116.                 action( CLEAR, *cpp, *cpp );
  117.             continue;
  118.         }
  119.  
  120.         /* M_ in front of mode is optional.  M_ABS == ABS
  121.         */
  122.         if( mode[0] == 'M'  &&  mode[1] == '_' )
  123.             mode += 2;
  124.         action( setclear, mode, *argv );
  125.     }
  126. }
  127.  
  128.  
  129. #define    CASE(arg)    if( EQ("arg", mode) ) {\
  130.                 switch( setclear ) {\
  131.                 case SET:\
  132.                     m_setmode( M_/**/arg );\
  133.                     return;\
  134.                 case CLEAR:\
  135.                     m_clearmode( M_/**/arg );\
  136.                     return;\
  137.                 }\
  138.             }
  139.  
  140. static
  141. action( setclear, mode, originalmode )
  142. int    setclear;
  143. char    *mode;
  144. {
  145.     CASE(ABS);
  146.     CASE(ACTIVATE);
  147.     CASE(AUTOEXPOSE);
  148.     CASE(BACKGROUND);
  149.     CASE(DUPKEY);
  150.     CASE(NOBUCKEY);
  151.     CASE(NOINPUT);
  152.     CASE(NOWRAP);
  153.     CASE(OVERSTRIKE);
  154.     CASE(SNARFHARD);
  155.     CASE(SNARFLINES);
  156.     CASE(SNARFTABS);
  157.     CASE(STACK);
  158.     CASE(STANDOUT);
  159.     CASE(WOB);
  160.     fprintf( stderr, "%s:  unrecognized mode: `%s'\n",
  161.         pgm, originalmode );
  162. }
  163.