home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a063 / 7.img / INCLUDE / SCREENIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-08  |  51.1 KB  |  1,214 lines

  1. /*
  2. ** Sybase Data Workbench Version 2.0
  3. ** Confidential property of Sybase, Inc.
  4. ** (c) Copyright Sybase, Inc. 1985-1988
  5. ** All rights reserved
  6. */
  7.  
  8. /*      screenio.h:     41.2    10/7/88 */
  9.  
  10. /*
  11. **
  12. **      SCREENIO.H      - Header for the Screen I/O Subsystem
  13. **
  14. */
  15.  
  16. #define SCREENIO        1       /* Used to tell if screenio.h has       *
  17.                                  * been included by source code.        */
  18.  
  19. /* !!! */
  20. #if ((MSDOS || OS2) && _PCAPT_PRIVATE_)
  21. /*
  22. ** Special defines for the IBMPC console.
  23. */
  24. #include <scracc.h>
  25.  
  26. extern char *ColorMap;
  27.  
  28. /*
  29. ** Basic structure into which keyboard or mouse event is read.
  30. */
  31. typedef struct event
  32. {
  33.         unsigned char   inphystype;     /* phys type of event that occurred*/
  34.         short           inmoux;      /* physical x of mouse location picked */
  35.         short           inmouy;      /* physical y of mouse location picked */
  36.         char            inkey;          /* key just entered */
  37.  
  38.        /* 
  39.        ** inkey modifier  - possible states: CNTRL, ALT, SHIFT & META.
  40.        */
  41.         unsigned short            inaccent;
  42.        
  43.        char            PAD;
  44.     
  45. } EVENT;
  46. #endif  /* If MSDOS or OS/2 and _PCAPT_PRIVATE_ */
  47.  
  48. #if defined(SDBL_40)
  49. /*
  50. ** Moved REGION here from SYBFRONT.H =======================================
  51. */
  52. typedef    struct    region
  53. {
  54.     short        rgx;        /* Starting (upper left) coordinates */
  55.     short        rgy;
  56.     short        rgwidth;    /* Width (horizontal extent) */
  57.     short        rgheight;    /* Height (vertical extent) */
  58. } REGION;
  59.  
  60. #endif /* SDBL_40 */
  61. /*
  62. ** Typedefs
  63. */
  64.  
  65. typedef unsigned char    DBBOOL;    /* Less likely to collide than "BOOL". */
  66.  
  67. /*
  68. **    Pointers to functions returning ...
  69. */
  70.  
  71. typedef    int        (*INTFUNCPTR)();
  72. typedef    DBBOOL    (*BOOLFUNCPTR)();
  73.  
  74. typedef BYTE        *POINTER;
  75.  
  76. typedef int        SYBINT;
  77.  
  78. /*
  79. ** ===========================================================================
  80. */
  81.  
  82. /*
  83. **      General type definitions for screen I/O 
  84. */
  85.  
  86. typedef unsigned char   BITFLD;         /* Byte Field - 8 bits */
  87. typedef unsigned short  SBITFLD;        /* Short Field - 16 bits */
  88. typedef SBITFLD         FLAGS;          /* Flags (bitmask) */
  89. typedef SBITFLD         FONT;           /* Font/Size (bitmask) */
  90. typedef unsigned char   SYBCOLOR;          /* Color/Grey-scale */          
  91. typedef SBITFLD         VIDEO;          /* Video Attribute */
  92. # define CHOICEVAL      short           /* Values which id an option or menu */
  93.  
  94.  
  95. /*
  96. **      Standard Screen I/O Command Tokens
  97. */
  98.                         
  99. #define TKSPBAR         (CHOICEVAL)0    /* Selectport bar identifier */
  100. #define TKBEGSIO        (CHOICEVAL)1    /* begin standard screen I/O tokens */
  101. #define TKBEGEDIT       (CHOICEVAL)1    /* begin editing tokens */
  102. #define TKCURSUP        (CHOICEVAL)1    /* cursor up */
  103. #define TKCURSDN        (CHOICEVAL)2    /* cursor down */
  104. #define TKCURSLT        (CHOICEVAL)3    /* cursor left */
  105. #define TKCURSRT        (CHOICEVAL)4    /* cursor right */
  106. #define TKTAB           (CHOICEVAL)5    /* tab key */
  107. #define TKBACKSP        (CHOICEVAL)6    /* backspace */
  108. #define TKCR            (CHOICEVAL)7    /* carriage return */
  109. #define TKNWORD         (CHOICEVAL)8    /* move to next word */
  110. #define TKPWORD         (CHOICEVAL)9    /* move to previous word */
  111. #define TKNEXT          (CHOICEVAL)10   /* move to next object */
  112. #define TKPREV          (CHOICEVAL)11   /* move to previous object */
  113. #define TKBEGLINE       (CHOICEVAL)12   /* move to beginning of line */
  114. #define TKENDLINE       (CHOICEVAL)13   /* move to end of line */
  115. #define TKBEGENTRY      (CHOICEVAL)14   /* move to beginning of ENTRY */
  116. #define TKENDENTRY      (CHOICEVAL)15   /* move to end of ENTRY */
  117. #define TKENFORWARD     (CHOICEVAL)16   /* scroll ENTRY forward */
  118. #define TKENBACK        (CHOICEVAL)17   /* scroll ENTRY back */
  119. #define TKDELLINE       (CHOICEVAL)18   /* delete current line */
  120. #define TKDELCHAR       (CHOICEVAL)19   /* delete current character */
  121. #define TKDELWORD       (CHOICEVAL)20   /* delete current word */
  122. #define TKDELENTRY      (CHOICEVAL)21   /* delete entire entry */
  123. #define TKENDEDIT       TKDELENTRY      /* last editing token */
  124.  
  125.                                         /* standard selport tokens */
  126. #define TKHELP          (CHOICEVAL)22   /* help */
  127. #define TKBEGSP         TKHELP          /* beginning of selport tokens */
  128. #define TKEXIT          (CHOICEVAL)23   /* exit */
  129. #define TKUP            (CHOICEVAL)24   /* scroll up */
  130. #define TKDOWN          (CHOICEVAL)25   /* scroll down */
  131. #define TKLEFT          (CHOICEVAL)26   /* pan left */
  132. #define TKRIGHT         (CHOICEVAL)27   /* pan right */
  133. #define TKPLUS          (CHOICEVAL)28   /* plus, the scroll accelerator */
  134. #define TKTOOLS         (CHOICEVAL)29   /* the tools select option */
  135. #define TKCOMMAND       (CHOICEVAL)30   /* command introducer */     
  136. #define TKENDSP         TKCOMMAND       /* end of selport standard tokens */
  137.  
  138. #define TKMETA          (CHOICEVAL)31   /* begins a function key string */
  139. #define TKINTERRUPT     (CHOICEVAL)32   /* interrupt key*/
  140. #define TKVALUES        (CHOICEVAL)33   /* show values list */
  141. #define TKREDRAW        (CHOICEVAL)34   /* redraw the screen */
  142. #define TKPRSCREEN      (CHOICEVAL)35   /* print the screen */
  143. #define TKVPDUMP        (CHOICEVAL)36   /* dump viewport to file */
  144. #define TKRECORD        (CHOICEVAL)37   /* record input events */
  145. #define TKPLAYBACK      (CHOICEVAL)38   /* play back stored input events */
  146. #define TKPORT          (CHOICEVAL)39   /* change port - toggle txt/selport */
  147. #define TKCHGWIN        (CHOICEVAL)40   /* change window */
  148. #define TKFUNCKEY       (CHOICEVAL)41   /* function key */
  149.  
  150.                                         /* tokens for keystroke files */
  151. #define TKKEYSTACK      (CHOICEVAL)42   /* key stack follows */
  152. #define TKTEXT          (CHOICEVAL)43   /* user text follows */
  153. #define TKCLICK         (CHOICEVAL)44   /* user click follows */
  154. #define TKMOVE          (CHOICEVAL)45   /* user locator move follows */
  155. #define TKINCLUDE       (CHOICEVAL)46   /* include keystroke file */
  156.  
  157. #define TKENDSIO        TKMOVE          /* current end of screen I/O tokens */
  158. #define TKMAXSIO        (CHOICEVAL)60   /* maximum screen I/O token */
  159.  
  160. #define TKKEY_CNTRL        (CHOICEVAL)995    /* Control key accent.            */
  161. #define TKKEY_ALT        (CHOICEVAL)996    /* Alternate key accent.            */
  162. #define TKKEY_SHIFT        (CHOICEVAL)997    /* Shift key accent.            */
  163. #define TKKEY_META        (CHOICEVAL)998    /* Meta or composite key accent.    */
  164.  
  165.  
  166.  
  167. /*
  168. **      Define Logical Key Numbers for Fast Key Binding
  169. */
  170.  
  171. #define LKEYS           30              /* number of logical keys */
  172.  
  173. #define LK1             1
  174. #define LK2             2
  175. #define LK3             3
  176. #define LK4             4
  177. #define LK5             5
  178. #define LK6             6
  179. #define LK7             7
  180. #define LK8             8
  181. #define LK9             9
  182. #define LK10            10      
  183. #define LK11            11      
  184. #define LK12            12      
  185. #define LK13            13      
  186. #define LK14            14      
  187. #define LK15            15      
  188. #define LK16            16      
  189. #define LK17            17      
  190. #define LK18            18      
  191. #define LK19            19      
  192. #define LK20            20
  193. #define LK21            21
  194. #define LK22            22
  195. #define LK23            23
  196. #define LK24            24
  197. #define LK25            25
  198. #define LK26            26
  199. #define LK27            27
  200. #define LK28            28
  201. #define LK29            29
  202. #define LK30            30
  203.  
  204.  
  205. /*
  206. **      Maximum number of VISIBLE windows.
  207. */
  208.  
  209. #define WNMAXVISWIN     25
  210.  
  211. /*
  212. **      Definitions for Fonts and Font Sizes
  213. */
  214.  
  215.                                         /* Parms for fontsize function */
  216. #define FTHEIGHT        0               /* caller is asking for char height */
  217. #define FTWIDTH         1               /* caller wants char width */   
  218.  
  219.                                         /* Logical Fonts */
  220. #define FTROMAN         0x001           /* Standard serif face; default */
  221. #define FTBROMAN        0x002           /* Roman bold */
  222. #define FTITALIC        0x004           /* Italics */
  223. #define FTBITALIC       0x008           /* Italics Bold */
  224. #define FTHELVET        0x010           /* Helvetica - some non-serif face */
  225. #define FTBHELVET       0x020           /* Helvetica Bold */
  226. #define FTSPECIAL       0x040           /* Some special face- for selports */
  227. #define FTBSPECIAL      0x080           /* Special Bold - */   
  228.  
  229.                                         /* Logical Font Sizes */
  230. #define FTSMALL         0x100           /* smallest size */
  231. #define FTMEDIUM        0x200           /* medium, the default size */
  232. #define FTLARGE         0x400           /* Large */
  233. #define FTVLARGE        0x800           /* Very Large */
  234. #define FTUNDEFINED     0x1000          /* Unspecified */
  235.  
  236. #define FTSELPORT       FTSPECIAL | FTMEDIUM    /* selport logical font */
  237. #define FTSELTITLE      FTSELPORT               /* selport title font */
  238. #define FTMENU          FTSPECIAL | FTMEDIUM    /* menuline font */
  239. #define FTTEXTPORT      FTBHELVET  | FTMEDIUM   /* default texport font */
  240.  
  241.  
  242.  
  243. /*
  244. **      Definitions for Logical Colors/Gray Tones 
  245. */
  246.  
  247. #define CLNORMAL        (SYBCOLOR)0        /* Normal, do nothing special */
  248. #define CLWHITE         (SYBCOLOR)1        /* White */
  249. #define CLVLTGRAY       (SYBCOLOR)2        /* Very light gray */
  250. #define CLLTGRAY        (SYBCOLOR)3        /* Light gray */
  251. #define CLMIDGRAY       (SYBCOLOR)4        /* Mid gray */
  252. #define CLDKGRAY        (SYBCOLOR)5        /* Dark gray */
  253. #define CLBLACK         (SYBCOLOR)6        /* Black */
  254.  
  255. #define CLRED           (SYBCOLOR)7        
  256. #define CLORANGE        (SYBCOLOR)8    
  257. #define CLYELLOW        (SYBCOLOR)9     
  258. #define CLGREEN         (SYBCOLOR)10
  259. #define CLBLUE          (SYBCOLOR)11
  260. #define CLINDIGO        (SYBCOLOR)12 
  261. #define CLVIOLET        (SYBCOLOR)13   
  262. #define CLUNDEFINED     (SYBCOLOR)14       /* Unspecified color */
  263.  
  264. #define CLSELPORT       CLVLTGRAY       /* selectport background color */
  265. #define CLCOUNT         9               /* count of colors */
  266. #define CLGRAYCNT       4               /* count of special grays */
  267.  
  268.  
  269.  
  270. /*
  271. **      Definitions for Logical Video Attributes 
  272. */
  273.  
  274. #define VONORMAL        (VIDEO)0x000    /* Normal */
  275. #define VOREVERSE       (VIDEO)0x001    /* Reverse video */
  276. #define VOUNDER         (VIDEO)0x002    /* Underscore */
  277. #define VOBLINK         (VIDEO)0x004    /* Blinking */
  278. #define VODIM           (VIDEO)0x008    /* Dim; Half Intensity */
  279. #define VOBOLD          (VIDEO)0x010    /* Bold; Bright Intensity */
  280. #define VOINVIS         (VIDEO)0x020    /* Invisible (do not display) */
  281. #define VOALTSET        (VIDEO)0x040    /* Alternate character set */
  282. #define VOHILITE        (VIDEO)0x080    /* Highlight mode */
  283. #define VOINACTIVE      (VIDEO)0x100    /* Inactive ("off") mode */
  284. #define VOUNDEFINED     (VIDEO)0x200    /* Unspecified video mode */
  285. #define VOSELPORT       (VIDEO)0x400    /* Video modes for selectports */
  286.  
  287. #define VOOFFCHAR       ':'             /* Char for inactive, if terminal */
  288.                                         /*   cannot do an "off" mode      */
  289.  
  290. /*
  291. ** Offsets into ColorMap for desired effect.
  292. */
  293. #define CONORMAL        0x00
  294. #define COREVERSE       0x01
  295. #define COUNDER         0x02
  296. #define COBLINK         0x03
  297. #define CODIM           0x04
  298. #define COBOLD          0x05
  299. #define COINVIS         0x06
  300. #define COHILITE        0x07
  301. #define COINACTIVE      0x08
  302. #define COSELPORT       0x09
  303.  
  304. #define COFRAME         (COSELPORT + 1) /* Window border color          */
  305. #define COTITLE         (COFRAME + 1)   /* Window title color           */
  306.  
  307. #define COSPORTH        (COTITLE + 1)   /* Selport on color             */
  308. #define COSPORTL        (COSPORTH + 1)  /* Selport off color            */
  309. #define COSPORTS        (COSPORTL + 1)  /* Selport highlight color      */
  310.  
  311. #define COSCROLLH       (COSPORTS + 1)  /* Scroll icon no color         */
  312. #define COSCROLLL       (COSCROLLH + 1) /* Scroll icon off color        */
  313. #define COSCROLLS       (COSCROLLL + 1) /* Scroll icon highlight color  */
  314.  
  315. #define COTOOLH         (COSCROLLS + 1) /* Tools icon on color          */
  316. #define COTOOLL         (COTOOLH + 1)   /* Tools icon off color         */
  317. #define COTOOLS         (COTOOLL + 1)   /* Tools icon highlight color   */
  318.  
  319. #define COHELPH         (COTOOLS + 1)   /* Help icon on color           */
  320. #define COHELPL         (COHELPH + 1)   /* Help icon off color          */
  321. #define COHELPS         (COHELPL + 1)   /* Help icon highlight color    */
  322.  
  323. #define COEXITH         (COHELPS + 1)   /* Exit icon on color           */
  324. #define COEXITL         (COEXITH + 1)   /* Exit icon off color          */
  325. #define COEXITS         (COEXITL + 1)   /* Exit icon highlight color    */
  326.  
  327. #define COTEXTH         (COEXITS + 1)   /* Textport on color            */
  328. #define COTEXTL         (COTEXTH + 1)   /* Textport off color           */
  329. #define COTEXTS         (COTEXTL + 1)   /* Textport highlight color     */
  330.  
  331. #define COCOMMANDH      (COTEXTS + 1)   /* Command icon on color        */
  332. #define COCOMMANDL      (COCOMMANDH + 1)/* Command icon off color       */
  333. #define COCOMMANDS      (COCOMMANDL + 1)/* Command icon hightlight color*/
  334.  
  335. #define COSPOPTH        (COCOMMANDS + 1)/* Selport option on color      */
  336. #define COSPOPTL        (COSPOPTH + 1)  /* Selport option off color     */
  337. #define COSPOPTS        (COSPOPTL + 1)  /* Selport option highlight color*/
  338.  
  339. #define COBUSYH         (COSPOPTS + 1)  /* Busy icon on color           */
  340. #define COBUSYL         (COBUSYH + 1)   /* Busy icon off color          */
  341. #define COBUSYS         (COBUSYL + 1)   /* Busy icon highlight color    */
  342.  
  343. #define COPRNH          (COBUSYS + 1)   /* Printer icon on color        */
  344. #define COPRNL          (COPRNH + 1)    /* Printer icon off color       */
  345. #define COPRNS          (COPRNL + 1)    /* Printer icon highlight color */
  346.  
  347. #define COMNUTXTH       (COPRNS +1)     /* Menu text on color           */
  348. #define COMNUTXTL       (COMNUTXTH + 1) /* Menu text off color          */
  349. #define COMNUTXTS       (COMNUTXTL + 1) /* Menu text highlight color    */
  350.  
  351. /*
  352. **      Definitions for Logical Line Styles and Widths 
  353. */
  354.  
  355.                                         /* Styles */
  356. #define LNDEFAULT       0x000           /* default line style */        
  357. #define LNDOTTED        0x001           /* Dotted line */
  358. #define LNDASHED        0x002           /* Dashed line */
  359. #define LNDOTDASH       0x004           /* Dot-Dash line */
  360.  
  361.                                         /* Widths */
  362. #define LNNARROW        0x008           /* Narrow width */
  363. #define LNMEDIUM        0x010           /* Medium width */
  364. #define LNTHICK         0x020           /* Thick width */
  365. #define LNDOUBLE        0x040           /* Double line */
  366.  
  367.  
  368. /*
  369. **      Definitions for window areas and display types.
  370. */
  371.  
  372. #define WNSPREPAIR      (short)0        /* Damage repair of selport */
  373. #define WNTXTPORT       (short)1        /* Normal printable ascii chars */
  374. #define WNBOUNDARY      (short)2        /* Window boundary line */
  375. #define WNTPSPLINE      (short)3        /* Special line drawing chars */
  376.  
  377.  
  378.  
  379. /*
  380. **      INPSTACK - choicevalues which have been input on the currently
  381. **                 active window
  382. */
  383.  
  384. #define INSTACKMAX      10
  385.  
  386.  
  387. typedef struct inpstack
  388. {
  389.         CHOICEVAL       isvalues[INSTACKMAX];
  390.                                         /* array of input choice values */
  391.         short           iscount;        /* count of array elements */
  392.         char           *iscomment;      /* description of functionality - */
  393.                                         /*   used for Logical Key binding */
  394. } INPSTACK;
  395.  
  396.  
  397. /*
  398. **      INPEVENT - input event; screenio internal data structure
  399. **
  400. */
  401.  
  402.                                 /* generic types of physical input events */
  403. #define INKEY           0x001   /* keyboard entry */
  404. #define INCLICK         0x002   /* locator click */
  405. #define INMOVE          0x004   /* locator motion */
  406. #define INFLUSHMOVE     0x008   /* flush to the last move */
  407.  
  408.  
  409.                                 /* logical types of input events for     */
  410.                                 /*     OPTION.optype and INPEVENT.intype */
  411.  
  412. #define INMENU          (unsigned char)1        /* menu line picked */
  413. #define INCXTOK         (unsigned char)2        /* token set up in Cntxt */
  414. #define INLOCPIC        (unsigned char)3        /* txtport location picked */
  415. #define INENTRY         (unsigned char)4        /* an entry was last input */
  416. #define INERROR         (unsigned char)5        /* input event error */
  417. #define INNOEVENT       (unsigned char)6        /* no significant inp event */
  418.  
  419.  
  420.                                 /* Bits for inflags */
  421. #define INCMDMODE       (BITFLD)0x001           /* currently in cmd mode */
  422. #define INRECORDMODE    (BITFLD)0x002           /* currently recording */
  423. #define INPLAYMODE      (BITFLD)0x004           /* currently playing back */
  424. #define INWAITMODE      (BITFLD)0x008           /* wait on playback */
  425. #define ININTERRUPT     (BITFLD)0x010           /* an interrupt occurred */
  426.  
  427. /*      Handler return codes */
  428.  
  429. #define HNDL_RETURN     1                       /* Return control to client */
  430. #define HNDL_CONTINUE   2                       /* Continue thru inpevent code*/
  431.  
  432. typedef struct inpevent
  433. {
  434.         BITFLD          inflags;        /* bits as defined above */
  435.         BITFLD          inmask;         /* types of physical events wanted */
  436.         unsigned char   inphystype;     /* phys type of event that occurred*/
  437.         unsigned char   intype;         /* logical type of event that occurred*/
  438.         short           inphysx;        /* physical x of a location picked */
  439.         short           inphysy;        /* physical y of a location picked */
  440.         short           inoldx;         /* last phys x (-1 initially) */
  441.         short           inoldy;         /* last phys y (-1 initially) */
  442.         char            inkey;          /* key just entered */
  443.  
  444.        /* 
  445.        ** inkey modifier  - possible states: CNTRL, ALT, SHIFT & META.
  446.        */
  447.        unsigned short    inaccent;
  448.  
  449.         CHOICEVAL       intoken;        /* current screen I/O token */
  450.         INPSTACK        *incurstack;    /* currently input values */
  451.         INPSTACK        *inkeystack;    /* fast key stack values */
  452.         struct window   *inwin;         /* window on which input occurred */
  453.         struct selport  *inselport;     /* use this selport for input */
  454.         struct menu     *inmenu;        /* menu to execute */
  455.         REGION          *inregion;      /* region to drag, size */
  456.         struct scr_entry    *inentry;   /* text entry pointer */
  457.         BOOLFUNCPTR     inhandler;      /* pointer to input handler function */
  458. } INPEVENT;
  459.  
  460. /*   
  461. **      OPTION - data returned from getoption
  462. */
  463.  
  464. typedef struct option
  465. {
  466.         unsigned char   optype;         /* logical type of event that occurred*/
  467.         short           oplogx;         /* logical x on current win txtport */
  468.         short           oplogy;         /* logical y on current win txtport */
  469.         struct window  *opwin;          /* window on which option was entered */
  470.         INPSTACK       *opstack;        /* inputs which occurred on opwin */
  471. } OPTION;
  472.  
  473.  
  474. /*
  475. **      ENTRY - text entry structure
  476. */
  477.                                         
  478.                                         /* Values for enedtype      */
  479. #define ENTEXT  (unsigned char)1        /* text, chars and numbers */
  480. #define ENALPHA (unsigned char)2        /* letters only */
  481. #define ENDIGIT (unsigned char)3        /* 0 - 9  only  */
  482.  
  483.                                         /* Bits for enflags */
  484. #define ENEDIT          (FLAGS)0x001    /* Can entry buffer be edited?  */
  485. #define ENRETURN        (FLAGS)0x002    /* Auto return when max len entered? */
  486. #define ENSAVESTAT      (FLAGS)0x004    /* Should scroll status be preserved? */
  487. #define ENLITE          (FLAGS)0x008    /* Is region currently hilited?  */
  488. #define ENTRAP          (FLAGS)0x010    /* Trap cursor motion toks in entry? */
  489. #define ENCHANGED       (FLAGS)0x020    /* Has entry changed (touched)? */
  490.                                         /*      set only by entry mgr */
  491. #define ENERROR         (FLAGS)0x040    /* Is an error message currently up? */
  492.                                         /*      set only by entry mgr */
  493. #define ENCR            (FLAGS)0x080    /* Always return TKNEXT at CR */
  494. #define ENNOECHO        (FLAGS)0x100    /* No echo of chars or cursorposition */
  495. #define ENNOSCROLL      (FLAGS)0x200    /* Do not show scrolling characters */
  496.                                         /*      set only by entry mgr */
  497. #define ENTAB           (FLAGS)0x400    /* Consider TAB same as TKNEXT */
  498. #define ENAUTOTAB       (FLAGS)0x800    /* Consider full field same as TKNEXT */
  499.  
  500.  
  501. #define ENBACK          "<"             /* entry scroll back character */
  502. #define ENFORWARD       ">"             /* entry scroll forward character */
  503.  
  504. #define ENAPPEND        (DBINT)-9       /* offset value set for appends */
  505.  
  506.  
  507. /*
  508. **      ENFMTNODE - node stores format info as entry is scrolled
  509. **                  region by region
  510. */
  511.  
  512. typedef struct enfmtnode
  513. {
  514.         DBINT   enstartbuf;     /* index into buffer of first char in region */
  515.         struct  enfmtnode
  516.                 *enfmtprev;     /* previous node */
  517. } ENFMTNODE;
  518.  
  519. /*
  520. ** ENFMTLINES - offsets to start/end of formatted lines
  521. */
  522. typedef struct enfmtlines
  523. {
  524.         DBINT   enfirst;        /* offset of first source char on line */
  525.         DBINT   enlast;         /* offset of last source char on line
  526.                                 ** or (first + width - 1),
  527.                                 ** whichever is less
  528.                                 */
  529.  
  530. } ENFMTLINES;
  531.  
  532. /*
  533. **      ENSTATDATA - "status" data; data which may optionally be
  534. **                    preserved by client between calls to getentry.
  535. */
  536.  
  537. typedef struct enstatdata
  538. {
  539.         char    *enstring;      /* formatted text for a region put here */
  540.         struct  enfmtlines
  541.                 *enlines;       /* ptr to array of formatted line indices */
  542.         struct  enfmtlines
  543.                 *enprevlines;   /* offsets save before reformatting */
  544.         short   enlnlast;       /* index of enlines holding last significant */
  545.                                 /*    character in the region                */
  546.         DBINT   eneditbuf;      /* index into buffer of last char */
  547.                                 /*   edited. Cursor placed here.  */
  548.         ENFMTNODE
  549.                 *enfmtcur;      /* pointer to current region's format node */
  550.         struct  scrmap
  551.                 *enmap;         /* pointer to output map: only for bitmaps */
  552. } ENSTATDATA;
  553.  
  554.  
  555. /*
  556. **      ENMGRDATA - entry data private to entry manager 
  557. */
  558.  
  559. typedef struct enmgrdata
  560. {
  561.         short   enlocx;         /* current x-coord of cursor */
  562.         short   enlocy;         /* current y-coord of cursor */
  563.         short   enxforward;     /* x-coord of scroll entry forward char */
  564.         short   enyforward;     /* y-coord of scroll entry forward char */
  565.         short   enxback;        /* x-coord of scroll entry back char */
  566.         short   enyback;        /* y-coord of scroll entry back char */
  567.         short   enxpad;         /* beginning x-coord of any padding chars */
  568.         short   enypad;         /* beginning y-coord of any padding chars */
  569.         short   encount;        /* count of chars in last insert/append/del */
  570.         char    enadddel;       /* a = add chars; d = delete chars */
  571.         DBBOOL    enokchamode;    /* after change locator position,    */
  572.                                 /* ok to change insert/append mode   */
  573.         struct  window 
  574.                 *enwin;         /* window entry is on */
  575.         struct  window 
  576.                 *enmsgwin;      /* a window for error messages */
  577. } ENMGRDATA;
  578.  
  579.  
  580. typedef struct scr_entry
  581. {
  582.         FLAGS           enflags;        /* bits as defined above */
  583.         unsigned char   enedtype;       /* types above */
  584.         REGION          enregion;       /* entry input & display region */
  585.         char            *enbuffer;      /* pointer to buffer to hold entry */
  586.         DBINT           encurlen;       /* current length of the buffer */
  587.         DBINT           enmaxlen;       /* max entry length */           
  588.         DBINT           enminlen;       /* min entry length */
  589.         char            enpadchar;      /* pad char for prompt line, or null */
  590.         REGION          *enmsgreg;      /* ptr to region for messages       */
  591.                                         /*   If NULL, one is made as needed */
  592.         ENSTATDATA      *enstatus;      /* if NULL, buffer is formatted and   */
  593.                                         /*   output from beginning; if client */
  594.                                         /*   wishes to preserve scroll status */
  595.                                         /*   of entry, s/he should keep this  */
  596.                                         /*   pointer; else free it via  a call*/
  597.                                         /*   to the function 'enstfree' */
  598.         struct option   *enoption;      /* option info entered */
  599.         ENMGRDATA       *enmgr;         /* private data for entry manager */
  600. } ENTRY;
  601.  
  602.  
  603. /*
  604. **      CNTLKEY  - maps a control key to an input stack for
  605. **                 fastkey binding
  606. **                 Index in control key array is equal to the
  607. **                 key's decimal value, except for DEL key
  608. **                 which is the last entry in the array.
  609. **                 Allocated in ldfastkeys.
  610. */
  611.  
  612.  
  613. #define CKEYLABEL       4               /* length of control key label string */
  614. #define FKEYLABEL       10              /* length of funct key label */
  615. #define FKEYLEN         12              /* length of transmitted fkey string */
  616. #define OFFEIGHT        95              /* offset into Ckey array for DEL key
  617.                                         ** and eight bit characters (127-159)*/
  618.  
  619.  
  620. typedef struct cntlkey
  621. {
  622.         char            cklabel[CKEYLABEL + 1]; /* label on the key e.g. ^N */
  623.         CHOICEVAL       cktoken;                /* bound to screenio token */
  624.         struct inpstack *ckstack;               /* bound to application stack*/
  625. } CNTLKEY;
  626.  
  627.  
  628.  
  629.  
  630. /*
  631. **      FUNCTKEY -  holds the transmitted strings for function keys
  632. **                  and special keys (printscreen, scroll, etc)
  633. **                  and serves to bind these to inputs.
  634. **                  Allocated and loaded in ldfastkeys.
  635. */
  636.  
  637. typedef struct functkey
  638. {
  639.         char            fkstring[FKEYLEN + 1];  /* transmitted string */
  640.         char            fklabel[FKEYLABEL + 1]; /* label on the key */
  641.         short           fktermkey;              /* key number in termdef */
  642.         CHOICEVAL       fktoken;                /* bound to this sio token */
  643.         struct inpstack *fkstack;               /* bound to this stack */
  644. } FUNCTKEY;
  645.  
  646.  
  647. /*
  648. **      SCRMAP  - Map of what is on the screen: for character terminals.
  649. **                Allocated in scralloc, called from physinit.
  650. **                Freed in scrfree, called from physend.
  651. **                Updated by the output routines:      
  652. **                      outtext, outline, outcorner, outground.
  653. **                Also used for optimization of ENTRYs on bitmaps
  654. */
  655.  
  656.  
  657. typedef struct scrmap
  658. {
  659.         char    *scchars;               /* ptr to array lines * cols big */
  660.         VIDEO   *scvideo;               /* array of video attrib for each char*/
  661.         SYBCOLOR   *scolor;                /* color of each char - unused now */
  662. } SCRMAP;
  663.  
  664. /*      Maximum number of seloptions or menulines in a single menu */
  665.  
  666. #define MAXMENULINES    15
  667. #define MAXOPTIONS      10
  668.  
  669.  
  670. /*
  671. **      MLPARMS - Menu Line Parameters.
  672. **                This structure is assigned by clients to 
  673. **                specify a menu.  Also see MUPARMS, below.
  674. */
  675.  
  676. typedef struct mlparms
  677. {
  678.         char   *mlptext;                /* Text to display */           
  679.         CHOICEVAL
  680.                 mlpchoiceval;           /* value to indicate line chosen */
  681.         struct  muparms *mlpmuslide;    /* Pointer to menu to execute if */
  682.                                         /*  this line brings up a "slide */
  683.                                         /*  off" menu.                   */
  684.         DBBOOL  mlpinitactive;          /* Initial state active ? */
  685.         int     mlpid;                  /* Internal id used by menu editor */
  686.         POINTER mlpproclist;            /* Pointer to runtime processing list */
  687. } MLPARMS;  
  688.  
  689. /*
  690. **      MUPARMS - Menu Parameters.
  691. **                This structure is assigned by a client
  692. **                in order to specify a menu.
  693. */
  694.                                         /* Bit fields for mupflags */
  695. #define MUREQ     0x001                 /* Is a menu choice required? */
  696. #define MUSTICKY  0x002                 /* Is user's choice sticky? (Last  */
  697.                                         /*    choice becomes next default) */
  698. typedef struct muparms
  699. {
  700.         char   *muptitle;               /* Menu title (ignored if selbar menu)*/
  701.         short   mupxnorm;               /* Normalized coords of upper left   */
  702.         short   mupynorm;               /*   corner of menu (ignored if is a */
  703.                                         /*   selectbar menu).                */
  704.         BITFLD mupflags;                /* Bits as defined above */
  705.         MLPARMS *muplines;              /* Pointer to array of mlparms */
  706.         short   mupcntlines;            /* Count of lines */
  707.         CHOICEVAL
  708.                 mupdefault;             /* choice value of default line */
  709. } MUPARMS;
  710.  
  711. /*
  712. **      SELPARMS - Selectport Parameters.
  713. **                 Assigned by client to specify a selectport.
  714. */
  715.  
  716. typedef struct selparms
  717. {
  718.         char    *spptitle;              /* Selectport title */
  719.         DBBOOL  sppscroll;              /* Is there a scroll icon? */
  720.         MLPARMS *spphelp;               /* Help option parameters */
  721.         MLPARMS *sppexit;               /* Exit parms */
  722.         MLPARMS *spptools;              /* Tools parms */
  723.         MLPARMS *sppbar;                /* Menu bar parms - ptr to array of */
  724.         short    sppbarcnt;             /* Count of sppbar elements */
  725. } SELPARMS;
  726.  
  727.         
  728. /*
  729. **      MENULINE - Describes a line on a menu.
  730. **                 Screen I/O internal data structure
  731. **                 created from client's MLPARMS.
  732. */
  733.  
  734. typedef struct menuline
  735. {
  736.         char    *mltext;                /* Complete text to show */
  737.         CHOICEVAL
  738.                 mlchoiceval;            /* value to indicate chosen */
  739.         struct  menu
  740.                 *mlmuslide;             /* slide off menu to execute */
  741.         BITFLD  mlstatus;               /* see selopt status bits */
  742.         DBBOOL  mlinitactive;
  743.         POINTER mlproclist;
  744.         SYBCOLOR   mlcolor;                /* Color */
  745. } MENULINE;
  746.  
  747. /*
  748. **      MENU - Describes a menu.  Screen I/O internal
  749. **             data structure created from client's MUPARMS.
  750. */
  751.  
  752. typedef struct menu
  753. {
  754.         char    *mutitle;               /* title (ignored if selbar menu) */
  755.         BITFLD  muflags;                /* as defined in MUPARMS */
  756.         MENULINE
  757.                 *mulines[MAXMENULINES]; /* array of pointers to menulines */
  758.         short   mucntlines;             /* count of lines */
  759.         short   mudefault;              /* index of default line */
  760.         short   mulastline;             /* last highlighted line */
  761.         CHOICEVAL
  762.                 muchoice;               /* choiceval of chosen menuline */
  763.         REGION  muregion;               /* physical region of menu */
  764.         short   mutpwidth;              /* logical width of menu textport */
  765.         short   mutpheight;             /* logical height of menu textport */
  766.         struct  window
  767.                 *muwin;                 /* window created for the menu */
  768. } MENU; 
  769.  
  770.  
  771. /*
  772. **      SELOPTION - Selectport Option.
  773. **                  Screen I/O internal data structure
  774. **                  created from client's SPOPTPARMS.
  775. */
  776.  
  777.  
  778.                                         /* Bits for sostatus */
  779. #define SO_ON           0x001           /* Turn option on(normal; active) */
  780. #define SO_OFF          0x002           /* Turn option off (dehilite; */  
  781.                                         /*    inactive)               */
  782. #define SO_LITE         0x004           /* Highlite the option */
  783. #define SO_CHANGED      0x008           /* Has this option changed since */
  784.                                         /*    last sprefresh?            */
  785.  
  786. typedef struct  seloption
  787. {
  788.         CHOICEVAL sovalue;              /* value to indicate picked */
  789.         char    *sotext;                /* text for select bar options */
  790.         MENU    *somenu;                /* menu to execute if opt picked */
  791.         BITFLD  sostatus;               /* status bits as defined above */
  792.         REGION  soregion;               /* physical region of the option */
  793.         POINTER sophysmap;              /* pointer to object holding physical */
  794.                                         /*   image of the option e.g. on Sun */
  795.                                         /*   it's a ptr to pixrect, elsewhere */
  796.                                         /*   it's a ptr to a char array      */ 
  797.         DBBOOL  soinitactive;
  798.         POINTER soproclist;
  799.         SYBCOLOR   socolor;                /* Current color/status of this opt. */
  800. } SELOPTION;
  801.  
  802.  
  803. /*
  804. **      SELPORT - Selectport Structure.  Screen I/O internal
  805. **                data structure created from clients SELPARMS
  806. */
  807.  
  808. typedef struct  selport
  809. {
  810.         struct window   *spwin;         /* window selport is in */
  811.         char            *sptitle;       /* Selectport title */
  812.         POINTER         spmaptitle;     /* pointer to physical map of title */
  813.         SYBCOLOR           spcolortitle;   /* color of title. */   
  814.         REGION          spregtitle;     /* region occupied by title */
  815.         SELOPTION       *spup;          /* pointer to up icon opt */
  816.         SELOPTION       *spdown;        /* down icon option */
  817.         SELOPTION       *spleft;        /* pan left icon */   
  818.         SELOPTION       *spright;       /* pan right icon */
  819.         SELOPTION       *spplus;        /* plus (scroll accelerator) icon */
  820.         SELOPTION       *sphelp;        /* help icon */
  821.         SELOPTION       *spexit;        /* exit icon */
  822.         SELOPTION       *sptools;       /* special selbar option "Tools" */
  823.         SELOPTION       *spcommand;     /* the command icon */
  824.         SELOPTION       
  825.                 *spbar[MAXOPTIONS];     /* array of options on bar */
  826.         short           spbarcnt;       /* count of bar opts */
  827.         SELOPTION       *splastopt;     /* option last picked */
  828.         REGION          spregion;       /* physical region of entire selport */
  829.         struct damage   *spdamage;      /* pointer to head of damage list */
  830.         
  831.  
  832.  
  833.  
  834. } SELPORT;
  835.  
  836.  
  837. /*
  838. **      VIEWPORT - Visible portion of textport.  
  839. */
  840.  
  841. typedef struct  viewport
  842. {
  843.         REGION          vppregion;      /* Viewport region expressed in */
  844.                                         /* physical (screen) coordinates */
  845.         REGION          vplregion;      /* Viewport region expressed in */
  846.                                         /* logical (textport) coordinates */ 
  847.         short           vplastx;        /* Last logical x-coord at chgwin */
  848.                                         /*      or chgport                */
  849.         short           vplasty;        /* Last logical y-coord           */
  850. } VIEWPORT;     
  851.  
  852. /*
  853. **      TEXTLINE - Textport Line Buffer.
  854. */
  855.  
  856. /*
  857. ** Special line drawing characters which may be inserted into the textport.
  858. */ 
  859.  
  860. #define SPTPHLINE               '\001'
  861. #define SPTPVLINE               '\002'
  862. #define SPTPULCORNER            '\003'
  863. #define SPTPURCORNER            '\004'
  864. #define SPTPLLCORNER            '\005'
  865. #define SPTPLRCORNER            '\006'
  866. #define SPTPBOTTEE              '\007'
  867. #define SPTPTOPTEE              '\010'
  868. #define SPTPRIGHTTEE            '\011'
  869. #define SPTPLEFTTEE             '\012'
  870. #define SPTPCROSS               '\013'
  871.  
  872. typedef struct  textline
  873. {
  874.         char            *tlline;        /* Pointer to characters on line */
  875.         VIDEO           *tlvideo;       /* Array of video attribute bit masks */
  876.                                         /* for each character on the line */
  877.         FONT            *tlfont;        /* Array of font/size bit masks */
  878.                                         /* for each character on the line */
  879.         SYBCOLOR           *tlcolor;       /* Array of character colors */
  880.                                         /* for each character on the line */
  881.         short           tlheight;       /* Height (physical dimension) of */
  882.                                         /* tallest character on the line */
  883.                                         /* (Used to determine line height */
  884.                                         /* when multiple sized chars lie on */
  885.                                         /* the same line) */
  886.         char            tltemp;         /* Used to temporarily hold a char */
  887.                                         /* while a '\0' has been inserted */
  888.                                         /* in its place (used by display */
  889.                                         /* routines to make any subset of */
  890.                                         /* a line into a string) */
  891.         DBBOOL          tlfcvchg;       /* TRUE if font, color, or video */
  892.                                         /* changed from default for this line */
  893.         DBBOOL          tlspcchg;       /* TRUE if any special line */
  894.                                         /* character is on this line */
  895. } TEXTLINE;
  896.  
  897. /*
  898. **      Textport Change list Defines
  899. */
  900.  
  901. #define WNTPCHGEOL      (short)-1       /* Change from (x,y) to end-of-line */
  902. #define WNTPCHGEOP      (short)-2       /* Change from (x,y) to end-of-port */
  903.  
  904. #define TPCHGMOVE       0               /* Move the viewport */
  905. #define TPCHGWRITE      1               /* TP change type = tp write */ 
  906. #define TPCHGCLEAR      2               /* Clear the textport */
  907.  
  908. /*
  909. **      TCHANGE - Textport Changes (used to optimize refresh)
  910. */
  911.  
  912. typedef struct  tchange
  913. {
  914.         int             tctype;         /* Type of change (see above) */
  915.         short           tcx;            /* Starting location of change (in */
  916.         short           tcy;            /* logical coordinates) */
  917.         FONT            tcfont;         /* Font of change (if type = write) */
  918.         SYBCOLOR           tccolor;        /* Color of change (if type = write) */
  919.         VIDEO           tcvideo;        /* Video of change (if type = write) */
  920.         short           tccount;        /* Number of characters in the change */
  921.         struct tchange  *tcnext;        /* Link to next element of list */
  922. } TCHANGE;
  923.  
  924. /*
  925. **      TPNDCHG - Textport Pending Change.
  926. */
  927.  
  928. typedef struct  tpndchg
  929. {
  930.         
  931.         int             octype;         /* Type of change (see above) */
  932.         short           ocx;            /* Starting location of the change */
  933.         short           ocy;
  934.         FONT            ocfont;         /* font of the change */
  935.         SYBCOLOR           occolor;        /* color of the change */
  936.         VIDEO           ocvideo;        /* video of the change */
  937.         char            *octext;        /* Text of the change */
  938.         struct tpndchg *ocnext;         /* Link to next element of list */
  939. } TPNDCHG;
  940.  
  941. /*
  942. **      DAMAGE - Damage List Node.
  943. */
  944.  
  945. typedef struct  damage
  946. {
  947.         REGION          dmregion;       /* Region describing damage in */
  948.                                         /* physical coordinates */
  949.         struct damage   *dmprev;        /* Link to previous list item */
  950.         struct damage   *dmnext;        /* Link to next list item */
  951. } DAMAGE;
  952.  
  953. /*
  954. **      TEXTPORT - Textport Structure. ### Not Fully Defined ###
  955. */ 
  956.  
  957. typedef struct  textport 
  958. {
  959.         REGION          tplregion;      /* Textport region (logical coords) */
  960.         REGION          tppregion;      /* Textport region (phys. coords) */
  961.         VIEWPORT        *tpviewport;    /* Viewport */
  962.         TEXTLINE        **tplines;      /* Textport data lines */
  963.         char            *tplinblk;      /* Pointer to line list storage */
  964.         VIDEO           *tpvidblk;      /* Pointer to video storage block */
  965.         SYBCOLOR           *tpcolblk;      /* Pointer to color storage block */
  966.         FONT            *tpfntblk;      /* Pointer to font storage block */
  967.         FONT            tpdfont;        /* Default font/size for textport */
  968.         FONT            tpfont;         /* Current font/size for textport */
  969.         SYBCOLOR           tpdcolor;       /* Default color for the textport */
  970.         SYBCOLOR           tpcolor;        /* Current color for textport chars */
  971.         VIDEO           tpdvideo;       /* Default video attribute */
  972.         VIDEO           tpvideo;        /* Current video for textport chars */
  973.         SYBCOLOR           tpbckgnd;       /* Current textport background color */
  974.         TCHANGE         *tpchg;         /* Textport change list */
  975.         TCHANGE         *tpchgend;      /* End of change list */
  976.         TPNDCHG         *tppndchg;      /* Pending change list */
  977.         TPNDCHG         *tppndend;      /* End of pending change list */
  978.         short           tpcurx;         /* coordinates of last (most */
  979.                                         /* recent) textport change */
  980.         short           tpcury;
  981.         DAMAGE          *tpdamage;      /* List of regions in viewport */
  982.                                         /* damaged due to overlay by other */
  983.                                         /* windows (physical coordinates) */
  984. } TEXTPORT;
  985.  
  986. /*
  987. **      Window Flags
  988. */
  989.  
  990. /*      Window placement definitions for wnwinx, wnwiny functions */
  991.  
  992. #define WNUPLEFT        1
  993. #define WNUPRIGHT       2
  994. #define WNLOWLEFT       3
  995. #define WNLOWRIGHT      4
  996. #define WNCENTER        5
  997.  
  998. /*              Wnmgrflags - Private Window System Flags */
  999.  
  1000. #define WNACTIVE        (FLAGS)0x001    /* Window is ACTIVE (current) */
  1001. #define WNTPREFRESH     (FLAGS)0x002    /* Refresh entire textport */
  1002.                                         /* (regardless of changes) */
  1003. #define WNNEWWIN        (FLAGS)0x004    /* Window is new (never refreshed) */
  1004. #define WNSPREFRESH     (FLAGS)0x008    /* Refresh entire selectport */
  1005. #define WNSPCHANGED     (FLAGS)0x010    /* Part of selectport changed */
  1006.                                         /*    If WNSPREFRESH or WNSPCHANGED */
  1007.                                         /*    wnrefresh must call sprefresh */
  1008. #define WNOPEN          (FLAGS)0x020    /* Window is currently open */
  1009. #define WNIAMWINDOW     (FLAGS)0x040    /* Shows that struct is a window */
  1010. #define WNSAFEREFRESH    (FLAGS)0x80    /* Assume no update regions overlap */
  1011.  
  1012.  
  1013. /*              Wnflags - General Window Flags set by client */
  1014.  
  1015. #define WNBOX           (FLAGS)0x001    /* Box the window */
  1016. #define WNUSRWIN        (FLAGS)0x002    /* Normal "user" window */
  1017. #define WNMENUWIN       (FLAGS)0x004    /* Menu window */
  1018. #define WNPREVINPUT     (FLAGS)0x008    /* Keep input status of previously  */
  1019.                                         /*      visible windows             */  
  1020. #define WNNOINPUT       (FLAGS)0x010    /* Do not accept input on this win  */
  1021.                                         /*      (default is input accepted) */
  1022. #define WNPREVSELPORT   (FLAGS)0x020    /* If no selport, accept input on   */
  1023.                                         /*      most recent parent's selport*/
  1024. #define WNSPLAST        (FLAGS)0x080    /* Last place saved was in selport */
  1025. #define WNVPLAST        (FLAGS)0x100    /* Last place save was in viewport */
  1026. #define WNNOTEXTPORT    (FLAGS)0x200    /* This window is viewport-less. */
  1027. #define WNSUBWINDOW     (FLAGS)0x400    /* Window placement important, window
  1028.                                                 guarantees it will behave. */
  1029.  
  1030.  
  1031. /*
  1032. **      OVWINDOW - Overlapping Window List Node.
  1033. */
  1034.  
  1035. typedef struct  ovwindow
  1036. {
  1037.         struct  window  *owwin;         /* Pointer to the overlapping window */
  1038.         struct  ovwindow *ownext;       /* Link to next element of list */
  1039. } OVWINDOW;
  1040.  
  1041. /*
  1042. **      WINDOW - Window Structure.
  1043. */
  1044.  
  1045. typedef struct  window
  1046. {
  1047.         REGION          wnregion;       /* Region occupied by the visible */
  1048.                                         /* portion of the window expressed */
  1049.                                         /* in physical coordinates. */
  1050.         SELPORT         *wnselport;     /* Pointer to the window's selectport */
  1051.         TEXTPORT        *wntxtport;     /* Pointer to the window's textport */
  1052.         struct  window  *wnparent;      /* Pointer to the parent */
  1053.         struct  window  *wnchild;       /* Pointer to the child window */
  1054.         struct  window  *wnprevactive;  /* Pointer to prev active window */
  1055.         OVWINDOW        *wnovlapwin;    /* List of overlapping window ptrs */
  1056.         FLAGS           wnmgrflags;     /* Flags private to window system */
  1057.         FLAGS           wnflags;        /* Flags set by window system client */
  1058.                                         /* as defined above */
  1059.         DAMAGE          *wndamage;      /* pointer to boundary damage */
  1060.         DAMAGE          *wnclip;        /* list of visible regions */
  1061.         DBBOOL            wninpstatus[WNMAXVISWIN];
  1062.                                         /* Input status of previously      */
  1063.                                         /*      opened & refreshed windows */
  1064. } WINDOW;
  1065.  
  1066. /*
  1067. **      CONTEXT - Screen I/O Environment
  1068. */
  1069. typedef struct  context
  1070. {
  1071.         WINDOW          *cxrootwin;     /* Pointer to the "root" window */
  1072.         WINDOW          *cxactwin;      /* Pointer to the active window */
  1073.         WINDOW          *cxlastwin;     /* Pointer to last active window */
  1074.         WINDOW          *cxtailwin;     /* Pointer to tail of window chain */
  1075.         INPEVENT        *cxinpevent;    /* Pointer to current input event */
  1076.         int             (*cxinterrupt)();
  1077.                                         /* Pointer to function which returns */
  1078.                                         /*   an int: the function to call    */
  1079.                                         /*   when an interrupt is received   */
  1080.                                         /*   Set by sioinit and calls to     */
  1081.                                         /*   siointerrupt.                   */
  1082.         DBBOOL           cxcmdtokens[TKENDSIO];
  1083.                                         /* Status of token in context */
  1084. } CONTEXT;
  1085.  
  1086. /*
  1087. **      Display List - Used for refresh and damage repair of screen.
  1088. */
  1089.  
  1090. typedef struct  dispnode
  1091. {
  1092.         short   dnlogx;                 /* Logical x coordinate */
  1093.         short   dnlogy;                 /* Logical y coordinate */
  1094.         short   dnphysx;                        /* Physical x coordinate */
  1095.         short   dnphysy;                        /* Physical y coordinate */
  1096.         short   dncount;                /* Number of contiguous chars in */
  1097.                                         /* this item */
  1098.         short   dntype;                 /* Display type (see types below) */
  1099.         WINDOW  *dnwindow;              /* Pointer to window containing */
  1100.                                         /* this item */
  1101.         struct dispnode *dnnext;        /* Next display element in list */
  1102. } DISPNODE;
  1103.  
  1104. /*
  1105. **      Macro Definitions.
  1106. */
  1107.  
  1108. /*
  1109. **              Selectport Accessing Macros.
  1110. */
  1111.  
  1112. #define SPWIDTH(sp)             ((sp)->spregion.rgwidth)
  1113. #define SPHEIGHT(sp)            ((sp)->spregion.rgheight)
  1114.  
  1115. /*
  1116. **              Textport Accessing Macros.
  1117. */
  1118.  
  1119. #define TPGTFONT(win, x, y)     (win->wntxtport->tplines[y-1]->tlfont[x-1])
  1120. #define TPGTCOLOR(win, x, y)    (win->wntxtport->tplines[y-1]->tlcolor[x-1])
  1121. #define TPGTVIDEO(win, x, y)    (win->wntxtport->tplines[y-1]->tlvideo[x-1])
  1122. #define TPGTCHAR(win, x, y)     (win->wntxtport->tplines[y-1]->tlline[x-1])
  1123. #define TPGTSTR(win, x, y)      (&(win->wntxtport->tplines[y-1]->tlline[x-1]))
  1124.  
  1125. /*
  1126. **              Text/Viewport size Macros
  1127. */
  1128.  
  1129. #define WNTPREGION(win)         (&(win->wntxtport->tplregion))
  1130. #define WNTPWIDTH(win)          (win->wntxtport->tplregion.rgwidth)
  1131. #define WNTPHEIGHT(win)         (win->wntxtport->tplregion.rgheight)
  1132. #define WNVPWIDTH(win)          (win->wntxtport->tpviewport->vplregion.rgwidth)
  1133. #define WNVPHEIGHT(win)         (win->wntxtport->tpviewport->vplregion.rgheight)
  1134. #define WNVPXLOC(win)           (win->wntxtport->tpviewport->vplregion.rgx)
  1135. #define WNVPYLOC(win)           (win->wntxtport->tpviewport->vplregion.rgy)
  1136. #define WNWINXLOC(win)          ((win)->wnregion.rgx)
  1137. #define WNWINYLOC(win)          ((win)->wnregion.rgy)
  1138. #define WNWINWIDTH(win)         ((win)->wnregion.rgwidth)
  1139. #define WNWINHEIGHT(win)        ((win)->wnregion.rgheight)
  1140.  
  1141. /*
  1142. ** Definitions of the keyboard (ScanCode) mapping functions.
  1143. */
  1144. #define ESC_KEY        (0x01U)
  1145.  
  1146. #define RSHIFT_KEY_MASK    (0x0001)    /* The Right Shift Key.            */
  1147. #define LSHIFT_KEY_MASK    (0x0002)    /* The Left Shift Key.            */
  1148. #define SHIFT_KEYS_MASK    (0x0003)    /* Either L or R Shift Key.        */
  1149. #define CTRL_KEY_MASK    (0x0004)    /* The Control Key.                */
  1150. #define ALT_KEY_MASK    (0x0008)    /* The Alt Key.                */
  1151. #define SCROLL_LOCK_MASK    (0x0010)    /* The Scroll Lock Key.            */
  1152. #define NUM_LOCK_MASK    (0x0020)    /* The Num Lock Key.            */
  1153. #define CAPS_LOCK_MASK    (0x0040)    /* The Caps Lock Key.            */
  1154. #define INS_TOGGLE_MASK    (0x0080)    /* The Insert Key Toggle Mask.    */
  1155.  
  1156. #define BYTE_SHIFT        (8)        /* Shift to get only the scan code.    */
  1157. #define STATUS_MASK        (0x00ff)    /* Mask through only the status bits.    */
  1158. #define VALUE_MASK        (0xff00)
  1159.  
  1160. #define ALPHANUM_SCANCODE_END    (0x39U)    /* Highest alphanum scancode value.*/
  1161.  
  1162. #define MAXCFGTABLE        256    /* 256 possible scan codes. */
  1163.  
  1164. /*
  1165. ** ScanCodes to exclude during normal key stroke processing.
  1166. */
  1167. #define SPACE_SC        (0x39U)
  1168. #define BACKSP_SC        (0x0eU)
  1169. #define O_ABRACKET_SC    (0x33U)
  1170. #define C_ABRACKET_SC    (0x34U)
  1171. #define O_CBRACKET_SC    (0x1aU)
  1172. #define C_CBRACKET_SC    (0x1bU)
  1173. #define COLON_SC        (0x27U)
  1174. #define DQUOTE_SC        (0x28U)
  1175. #define QUESTION_SC        (0x35U)
  1176. #define TILDE_SC        (0x29U)
  1177. #define TAB_SC            (0x0fU)
  1178. #define ENTER_SC        (0x1cU)
  1179. #define PAD_ENTER_SC    (0xe0U)
  1180. #define PAD_PLUS_SC        (0x4eU)
  1181. #define PAD_MINUS_SC    (0x4aU)
  1182. #define PAD_MUL_SC        (0x37U)
  1183. #define PAD_DIV_SC        (0xe0U)
  1184. #define BAR_SC            (0x2bU)
  1185. #define ESC_KEY_SC        (0x01U)    /* The ScanCode value for the ESC key.    */
  1186. #define COMMAND_KEY_SC    (0x41U)
  1187. #define HELP_KEY_SC        (0x43U)
  1188. #define EXIT_KEY_SC        (0x44U)
  1189.  
  1190. #define BEG_1ST_ALPHA_SC    (0x10U)    /* Fist line in the ALPHA section.        */
  1191. #define END_1ST_ALPHA_SC (0x19U)
  1192. #define BEG_2ND_ALPHA_SC    (0x1eU)    /* Second line in the ALPHA section.    */
  1193. #define END_2ND_ALPHA_SC    (0x26U)
  1194. #define BEG_3RD_ALPHA_SC    (0x2cU)    /* Third line in the ALPHA section.    */
  1195. #define END_3RD_ALPHA_SC    (0x32U)
  1196.  
  1197. #define BEG_NUMPAD_SC    (0x47U)
  1198. #define END_NUMPAD_SC    (0x53U)
  1199.  
  1200. #define BEG_FUNCKEY_SC    (0x3bU)
  1201. #define END_FUNCKEY_SC    (0x44U)
  1202.  
  1203. #define BEG_NUMROW_SC    (0x02U)
  1204. #define END_NUMROW_SC    (0x0dU)
  1205.  
  1206. #define EXTENDED_SC        (0xe0U)
  1207.  
  1208. #define PAD_ENTER_VAL    ((int)0x0d00)
  1209. #define PAD_DIV_VAL        ((int)0x2f00)
  1210. #define INVERT_T_VAL    ((int)0xe000)    /* Interted T encoder                */
  1211.  
  1212. #define TOK_EVENT        (0xaaU)
  1213. #define CH_EVENT        (0xbbU)
  1214.