incorrect max login name size
[unix-history] / usr / src / usr.bin / window / ww.h
CommitLineData
bb05dfb5 1/*
73218728 2 * @(#)ww.h 3.9 83/08/19
bb05dfb5 3 */
0edb449f 4
4711df8b 5#include <stdio.h>
0edb449f 6#include <sgtty.h>
bb05dfb5
EW
7
8#define NWW 30
0edb449f 9
c417b691 10struct ww_dim {
bb05dfb5
EW
11 int nr; /* number of rows */
12 int nc; /* number of columns */
13 int t, b; /* top, bottom */
14 int l, r; /* left, right */
15};
16
17struct ww_pos {
18 int r; /* row */
19 int c; /* column */
c417b691
EW
20};
21
0edb449f 22struct ww {
bb05dfb5
EW
23 struct ww *ww_forw; /* doubly linked list, for overlapping info */
24 struct ww *ww_back;
2b44d852 25 char ww_state; /* state of window creation */
2b44d852 26 char ww_wstate; /* state for printing charcters */
7d77e730
EW
27 char ww_modes; /* current printing modes */
28 char ww_insert :1; /* insert mode, for printing */
29 char ww_mapnl :1; /* map \n to \r\n */
30 char ww_haspty :1; /* has pty */
73218728 31 char ww_hascursor :1; /* has fake cursor */
bb05dfb5
EW
32 char ww_index; /* the index, for wwindex[] */
33 char ww_order; /* the overlapping order */
c417b691 34 struct ww_dim ww_w; /* window dimemsions */
d2e11566
EW
35 int ww_nline; /* size of the buffer */
36 int ww_scroll; /* where the window is relative to the buffer */
bb05dfb5
EW
37 struct ww_pos ww_cur; /* the cursor position, relative to ww_w */
38 char **ww_win; /* the window */
39 union ww_char **ww_buf; /* the buffer */
40 char **ww_cov; /* the covered-by array */
41 short *ww_nvis; /* how many ww_buf chars are visible per row */
42 int ww_pty; /* file descriptor of pty */
43 int ww_tty; /* . . . tty */
44 int ww_pid; /* pid of process, if WWS_HASPROC true */
0896e17e 45 char ww_ttyname[11]; /* "/dev/ttyp?" */
bb05dfb5
EW
46 /* below are things for the user */
47 char ww_hasframe :1; /* frame it */
48 char ww_center :1; /* center the label */
49 int ww_id; /* the user id */
50 char *ww_label; /* the user supplied label */
4711df8b
EW
51};
52
53struct ww_tty {
0edb449f
EW
54 struct sgttyb ww_sgttyb;
55 struct tchars ww_tchars;
56 struct ltchars ww_ltchars;
57 int ww_lmode;
58 int ww_ldisc;
59 int ww_pgrp;
0edb449f
EW
60};
61
0896e17e
EW
62union ww_char {
63 short c_w; /* as a word */
64 struct {
65 char C_c; /* the character part */
66 char C_m; /* the mode part */
67 } c_un;
68};
69#define c_c c_un.C_c
70#define c_m c_un.C_m
71
72 /* parts of ww_char */
73#define WWC_CMASK 0x00ff
74#define WWC_MMASK 0xff00
75#define WWC_MSHIFT 8
76
77 /* c_m bits */
78#define WWM_REV 0x01 /* reverse video */
79#define WWM_BLK 0x02 /* blinking */
80#define WWM_UL 0x04 /* underlined */
81#define WWM_GLS 0x10 /* window only, glass, i.e. transparent */
82#define WWM_COV 0x20 /* window only, covered */
83
84 /* ww_state values */
85#define WWS_INITIAL 0 /* just opened */
86#define WWS_HASPROC 1 /* forked, in parent */
87#define WWS_INCHILD 2 /* forked, in child */
88#define WWS_DEAD 3 /* child died */
89
bb05dfb5
EW
90 /* flags to wwopen() */
91#define WWO_PTY 0x01 /* want pty */
92#define WWO_REVERSE 0x02 /* make it all reverse video */
93#define WWO_GLASS 0x04 /* make it all glass */
0edb449f 94
0896e17e
EW
95 /* flags for wwfmap */
96#define WWF_U 0x01
97#define WWF_R 0x02
98#define WWF_D 0x04
99#define WWF_L 0x08
100#define WWF_MASK (WWF_U|WWF_R|WWF_D|WWF_L)
101#define WWF_LABEL 0x40
102#define WWF_TOP 0x80
103
104 /* special ww_index value */
105#define WWX_NOBODY NWW
106
bb05dfb5 107struct ww wwhead;
0896e17e 108struct ww *wwindex[NWW + 1]; /* last location is for wwnobody */
bb05dfb5 109struct ww wwnobody;
2b44d852 110
0896e17e
EW
111struct ww_tty wwoldtty; /* the old (saved) terminal settings */
112struct ww_tty wwnewtty; /* the new (current) terminal settings */
113struct ww_tty wwwintty; /* the terminal settings for windows */
114char *wwterm; /* the terminal name */
115char wwtermcap[1024]; /* place for the termcap */
116char wwkeys[512]; /* termcap fields for the function keys */
bb05dfb5 117
bb05dfb5 118int wwnrow, wwncol; /* the screen size */
7d77e730 119char wwavailmodes; /* actually supported modes */
73218728 120char wwcursormodes; /* the modes for the fake cursor */
5e785082 121char wwwrap; /* terminal has auto wrap around */
0896e17e 122int wwdtablesize; /* result of getdtablesize() call */
bb05dfb5 123char **wwsmap; /* the screen map */
0896e17e
EW
124char **wwfmap; /* the frame map */
125union ww_char **wwos; /* the old (current) screen */
126union ww_char **wwns; /* the new (desired) screen */
861cd1ed 127char *wwtouched; /* wwns changed flags */
0896e17e
EW
128int wwbaudmap[]; /* maps stty() baud rate code into number */
129int wwbaud; /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
130int wwcursorrow, wwcursorcol; /* where we want the cursor to be */
0edb449f 131
bb05dfb5 132 /* statistics */
861cd1ed
EW
133int wwnwrite, wwnwritec;
134int wwnupdate, wwntouched, wwnmiss;
0edb449f 135
0896e17e 136 /* quicky macros */
bb05dfb5
EW
137#define wwcurrow(w) ((w)->ww_cur.r + (w)->ww_w.t)
138#define wwcurcol(w) ((w)->ww_cur.c + (w)->ww_w.l)
139#define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
140#define wwcurtowin(w) wwsetcursor(wwcurrow(w), wwcurcol(w))
141#define wwbell() putchar(CTRL(g))
2b44d852 142
7d77e730
EW
143 /* the window virtual terminal */
144#define WWT_TERM "TERM=window"
a598c465 145#define WWT_TERMCAP "WW|window|window package:\
7d77e730 146 :cr=^M:nl=^J:bl=^G:\
a598c465
EW
147 :al=\\EL:am:le=^H:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%+ %+ :\
148 :da:db:dc=\\EN:dl=\\EM:do=\\EB:ei=\\EO:ho=\\EH:im=\\E@:mi:\
7d77e730
EW
149 :nd=\\EC:ta=^I:pt:up=\\EA:"
150#define WWT_REV "se=\\Eq:so=\\Ep:"
151#define WWT_UL "ue=\\Es:us=\\Er:"
152
0896e17e 153 /* our functions */
2b44d852
EW
154struct ww *wwopen();
155struct ww *wwfind();
156int wwchild();
bb05dfb5 157int wwsuspend();
27fd1bda 158char *unctrl();
bb05dfb5
EW
159char **wwalloc();
160
0896e17e 161 /* c library functions */
bb05dfb5
EW
162char *malloc();
163char *calloc();
164char *getenv();
165char *tgetstr();
166char *rindex();
167char *strcpy();
168char *strcat();
169
170#undef MIN
171#undef MAX
172#define MIN(x, y) ((x) > (y) ? (y) : (x))
173#define MAX(x, y) ((x) > (y) ? (x) : (y))
174
175#undef CTRL
176#define CTRL(c) ('c'&0x1f)
177#define DEL 0x7f
178#define ISCTRL(c) ((c) < ' ' || (c) >= DEL)