home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume2 / window / part2 / wm.h < prev   
Encoding:
C/C++ Source or Header  |  1986-11-30  |  6.1 KB  |  193 lines

  1. /*
  2.  *************
  3.  * DISTRIBUTION NOTICE  July 30 1985
  4.  * A Revised Edition of WM, by Matt Lennon and Tom Truscott,
  5.  *        Research Triangle Institute, (919) 541-7005.
  6.  * Based on the original by Robert Jacob (decvax!nrl-css!jacob),
  7.  *        Naval Research Laboratory, (202) 767-3365.
  8.  * No claims or warranties of any sort are made for this distribution.
  9.  * General permission is granted to copy, but not for profit,
  10.  * any of this distribution, provided that this notice
  11.  * is always included in the copies.
  12.  *************
  13.  */
  14. /*
  15.  * definitions for wm
  16.  */
  17.  
  18. #include "curses.h"
  19. #include <sys/types.h>
  20. #include <ctype.h>
  21.  
  22. #define    CURSEASSIST        /* give curses a hand, sigh. */
  23. #define    SET_WINDOW        /* assist all-wonderful scrolling rectangles */
  24. #define    GAGMEKEYPAD        /* gross hack for arrow keys */
  25. /*#define    SNEAKYTERMCAP        /* /tmp termcap kludge */
  26.  
  27. /* define TERMINFO if we are using a terminfo version of curses */
  28. #ifdef A_STANDOUT
  29. #define    TERMINFO
  30. #endif
  31.  
  32. #ifdef TERMINFO
  33. /* define FASTTERMINFO if your terminfo has a clever doupdate */
  34. /*#define    FASTTERMINFO    /**/
  35. /* define BUGGYTERMINFO if your terminfo has 'certain bugs' */
  36. #define    BUGGYTERMINFO    /**/
  37. #endif
  38.  
  39. /*
  40.  * Definitions for curses
  41.  */
  42. #define    wcury(w)    ((w)->_cury)    /* current (y,x) in window w */
  43. #define    wcurx(w)    ((w)->_curx)
  44. #define    wbegy(w)    ((w)->_begy)    /* window offset from origin */
  45. #define    wbegx(w)    ((w)->_begx)
  46. #define    wlines(w)    ((w)->_maxy)    /* # lines/cols in window w */
  47. #define    wcols(w)    ((w)->_maxx)
  48. #define    cursrow()    wcury(curscr)    /* current (y,x) on screen */
  49. #define    curscol()    wcurx(curscr)
  50.  
  51. /* stuff dependent on the version of curses */
  52. #ifdef TERMINFO
  53. #undef GAGMEKEYPAD
  54. #ifdef FASTTERMINFO
  55. #undef CURSEASSIST
  56. #endif
  57. #undef wlines
  58. #undef wcols
  59. #define    wlines(w)    ((w)->_maxy+1)    /* # lines/cols in window w */
  60. #define    wcols(w)    ((w)->_maxx+1)
  61. #include <term.h>
  62. /* undefine one of the more annoying definitions in term.h */
  63. #ifdef lines
  64. #undef lines
  65. #endif
  66. extern WINDOW *newscr;
  67. #define    Untouchwin(wp)    untouchwin(wp),untouchwin(newscr)
  68. #ifdef CURSEASSIST
  69. /* curseassist cheats big */
  70. #define    Cmove(y,x)    wmove(curscr,y,x),wmove(newscr,y,x)
  71. #define    Cinsertln()    winsertln(curscr),winsertln(newscr)
  72. #define    Cdeleteln()    wdeleteln(curscr),wdeleteln(newscr)
  73. #endif
  74. #else
  75. extern int *_putchar();
  76. #define    putp            _puts
  77. #define    enter_ca_mode        TI
  78. #define    cursor_address        CM
  79. #define    flash_screen        VB
  80. #define    enter_standout_mode    SO
  81. #define    exit_standout_mode    SE
  82. #define    move_standout_mode    MS
  83. #define    insert_line        AL
  84. #define    delete_line        DL
  85. #define    change_scroll_region    CS
  86. #define    scroll_reverse        SR
  87. #define    save_cursor        SC
  88. #define    restore_cursor        RC
  89. #define    insert_character    IC
  90. #define    insert_null_glitch    IN
  91. #define    enter_insert_mode    IM
  92. #define    exit_insert_mode    EI
  93. #define    delete_character    DC
  94. #define    scroll_forward        NL
  95. #define    cursor_down        DO
  96. #define    cursor_up        UP
  97. #define    Untouchwin(wp)    untouchwin(wp)
  98. #ifdef CURSEASSIST
  99. /* curseassist cheats big */
  100. #define    Cmove(y,x)    wmove(curscr,y,x)
  101. #define    Cinsertln()    winsertln(curscr)
  102. #define    Cdeleteln()    wdeleteln(curscr)
  103. #endif
  104. #endif
  105.  
  106. /* key pad atrocities follow */
  107. extern char tty_text[], keycap[];
  108. extern int tty_textlen, tty_backcnt;
  109. #ifndef KEY_BACKSPACE
  110. #define    KEY_BACKSPACE    0401
  111. #define    KEY_UP        0402
  112. #define    KEY_DOWN    0403
  113. #define    KEY_LEFT    0404
  114. #define    KEY_RIGHT    0405
  115. #define    KEY_HOME    0406
  116. #endif
  117. #ifndef GAGMEKEYPAD
  118. #define    tty_getch    tty_realgetch
  119. #endif
  120.  
  121. /*
  122.  * The number of active windows is limited by the number of
  123.  * open files a process (i.e., main) may have,
  124.  * the number of processes a user or the whole system can have,
  125.  * and (on an 11 but not a VAX) the memory for the per-window curses buffers.
  126.  * Also, window names are limited to 0..9, i.e. at most 10 windows.
  127.  */
  128. #define    MAXWINDOWS    10    /* windows #0..#9 */
  129.  
  130. #define    ESC        '\033'    /* char for virtual terminal functions */
  131. #define    CANCEL1        '\033'    /* char to cancel wm command */
  132. #define    CANCEL2        '\177'    /* char to cancel wm command */
  133.  
  134. #define    MINWINDOW    1    /* change this to 0 to permit window #0 */
  135. #define    iswindow(w) ((w)>=MINWINDOW && (w)<MAXWINDOWS && (win[w].flags&INUSE))
  136. #define    ctoi(c)        ((c)-'0')    /* convert ascii digit to int */
  137. #define    itoc(i)        ((i)+'0')    /* convert int to ascii digit */
  138.  
  139. /*
  140.  * Global data with miscellaneous information about each window
  141.  */
  142. struct win_struct
  143. {
  144.     int flags;            /* window status bits */
  145. #define    INUSE    001    /* window is in use */
  146. #define    XFLEX    002    /* # of columns is COLS (depends on terminal type) */
  147. #define    YFLEX    004    /* # of rows    is ROWS ( ""     ""    ""     "" ) */
  148. #define    FAST    010    /* window can scroll 'quickly' (not redrawn) */
  149. #define    BROWSE    020    /* window is in 'browse' mode */
  150. #define    BLOCKED    040    /* window updates are being delayed */
  151.     int next;            /* next window in list */
  152.     char covers[MAXWINDOWS];    /* TRUE for windows we're on top of */
  153.     WINDOW *wptr;        /* ptr to small curses win to be displayed */
  154.     WINDOW *boxbot, *boxtop;    /* ptrs to curses wins for box, or NULL */
  155.     WINDOW *boxright, *boxleft;    /* ptrs to curses wins for box, or NULL */
  156.     char pend[4];        /* characters in partial escape sequence */
  157.     int pid;            /* pid of this window's shell */
  158.     int pty;            /* fildes of pty to/from this win's shell */
  159. };
  160.  
  161. /*
  162.  * Handy macros
  163.  */
  164. #define    MAX(a,b)    ((a)>=(b)? (a): (b))
  165. #define    MIN(a,b)    ((a)<=(b)? (a): (b))
  166.  
  167. /*
  168.  * External variables.
  169.  */
  170. extern struct win_struct win[];    /* array of windows */
  171. extern int botw, topw, lastw;    /* bottom, top, last window */
  172. extern int prefix;        /* WM command prefix character */
  173. extern char savefile[];        /* name of save/restore file */
  174. extern char shellname[];    /* name of shell */
  175. extern char shellpgm[];        /* pathname of shell */
  176. extern int configflag;        /* true if window config. has changed */
  177. extern time_t msgbirth;        /* time last message was displayed */
  178. #ifndef TERMINFO
  179. extern char *change_scroll_region, *save_cursor, *restore_cursor;
  180. extern char *set_window;
  181. #endif
  182. extern int has_scroll_window, has_scroll_region, has_insdel_line;
  183.  
  184. /*
  185.  * Functions returning a non-int value
  186.  */
  187. FILE *fopen();
  188. char *sprintf(), *strcpy(), *strcat(), *rindex(), *getenv();
  189. char *mkprint(), *termcap(), *WPrompt(), *plural();
  190. double *Malloc();    /* if only malloc were declared this way */
  191.  
  192. #define    alloc(n,type)    ((type*)Malloc((unsigned)((n)*sizeof(type))))
  193.