8 struct termios _orig_tty
, _tty
;
11 WINDOW
*stdscr
, *curscr
;
15 char termcap
[1024]; /* termcap buffer */
16 char tc
[200]; /* area to hold string capabilities */
17 char *ttytype
; /* terminal type from env */
18 static char *arp
; /* pointer for use in tgetstr */
19 char *cp
; /* character pointer */
21 char *cl
; /* clear screen capability */
22 char *cm
; /* cursor motion capability */
23 char *so
; /* start standout capability */
24 char *se
; /* end standout capability */
25 char *mr
; /* start of reverse */
26 char *me
; /* revert to normal */
27 char *mb
; /* start of blink */
28 char *md
; /* start of bold */
29 char *us
; /* start of underscore */
30 char *ue
; /* end of underscore */
31 char *vi
; /* cursor invisible */
32 char *ve
; /* cursor normal */
33 char *vs
; /* cursor good visible */
34 char *as
; /* alternative charset start */
35 char *ae
; /* alternative charset end */
36 char *bl
; /* ring the bell */
37 char *vb
; /* visual bell */
39 /* fatal - report error and die. Never returns */
43 (void) fprintf(stderr
, "curses: %s\n", s
);
47 /* Outc - call putchar, necessary because putchar is a macro. */
54 /* Move cursor to r,c */
58 tputs(tgoto(cm
, c
, r
), 1, outc
);
61 /* Clear the screen */
67 /* This are terminal independent characters which can be used in curses */
69 unsigned int ACS_ULCORNER
;
70 unsigned int ACS_LLCORNER
;
71 unsigned int ACS_URCORNER
;
72 unsigned int ACS_LRCORNER
;
73 unsigned int ACS_RTEE
;
74 unsigned int ACS_LTEE
;
75 unsigned int ACS_BTEE
;
76 unsigned int ACS_TTEE
;
77 unsigned int ACS_HLINE
;
78 unsigned int ACS_VLINE
;
79 unsigned int ACS_PLUS
;
82 unsigned int ACS_DIAMOND
;
83 unsigned int ACS_CKBOARD
;
84 unsigned int ACS_DEGREE
;
85 unsigned int ACS_PLMINUS
;
86 unsigned int ACS_BULLET
;
87 unsigned int ACS_LARROW
;
88 unsigned int ACS_RARROW
;
89 unsigned int ACS_DARROW
;
90 unsigned int ACS_UARROW
;
91 unsigned int ACS_BOARD
;
92 unsigned int ACS_LANTERN
;
93 unsigned int ACS_BLOCK
;
95 /* These defines describe the full set of grafic block characters which
96 * can be defined via termcap.
105 #define EMPTYSQUARE 6
127 unsigned int _cursgraftable
[27] =
129 '>', '<', 'v', '^', '#', ':', ' ', '#', '+', '\'', '#', '+', '+',
130 '+', '+', '+', '-', ' ', '-', ' ', '_', '+', '+', '+', '+', '|'
132 char _cursident
[28] = "+,.-0ahI`fgjklmnopqrstuvwx~";
140 struct winsize wsize
;
143 if (tgetent(termcap
, type
) != 1) return ERR
;
146 if (ioctl(0, TIOCGWINSZ
, &wsize
) == 0) {
147 LINES
= wsize
.ws_row
!= 0 ? wsize
.ws_row
: tgetnum("li");
148 COLS
= wsize
.ws_col
!= 0 ? wsize
.ws_col
: tgetnum("co");
151 LINES
= tgetnum("li");
152 COLS
= tgetnum("co");
157 cl
= tgetstr("cl", &arp
);
158 so
= tgetstr("so", &arp
);
159 se
= tgetstr("se", &arp
);
160 cm
= tgetstr("cm", &arp
);
161 mr
= tgetstr("mr", &arp
);
162 me
= tgetstr("me", &arp
);
163 mb
= tgetstr("mb", &arp
);
164 md
= tgetstr("md", &arp
);
165 us
= tgetstr("us", &arp
);
166 ue
= tgetstr("ue", &arp
);
167 vi
= tgetstr("vi", &arp
);
168 ve
= tgetstr("ve", &arp
);
169 vs
= tgetstr("vs", &arp
);
170 as
= tgetstr("as", &arp
);
171 ae
= tgetstr("ae", &arp
);
172 ac
= (unsigned char *) tgetstr("ac", &arp
);
173 bl
= tgetstr("bl", &arp
);
174 vb
= tgetstr("vb", &arp
);
179 while (*ac
!= _cursident
[i
]) i
++;
180 _cursgraftable
[i
] = *++ac
| A_ALTCHARSET
;
185 ACS_ULCORNER
= _cursgraftable
[UPLEFT
];
186 ACS_LLCORNER
= _cursgraftable
[DOWNLEFT
];
187 ACS_URCORNER
= _cursgraftable
[UPRIGHT
];
188 ACS_LRCORNER
= _cursgraftable
[DOWNRIGHT
];
189 ACS_RTEE
= _cursgraftable
[TEERIGHT
];
190 ACS_LTEE
= _cursgraftable
[TEELEFT
];
191 ACS_BTEE
= _cursgraftable
[TEEHEAD
];
192 ACS_TTEE
= _cursgraftable
[TEENORMAL
];
193 ACS_HLINE
= _cursgraftable
[MIDLINE
];
194 ACS_VLINE
= _cursgraftable
[VERTLINE
];
195 ACS_PLUS
= _cursgraftable
[CROSS
];
196 ACS_S1
= _cursgraftable
[UPLINE
];
197 ACS_S9
= _cursgraftable
[DOWNLINE
];
198 ACS_DIAMOND
= _cursgraftable
[DIAMOND
];
199 ACS_CKBOARD
= _cursgraftable
[GREYSQUARE
];
200 ACS_DEGREE
= _cursgraftable
[DEGREE
];
201 ACS_PLMINUS
= _cursgraftable
[PLUSMINUS
];
202 ACS_BULLET
= 'o'; /* where the hell is a bullet defined in
204 ACS_LARROW
= _cursgraftable
[LEFTARROW
];
205 ACS_RARROW
= _cursgraftable
[RIGHTARROW
];
206 ACS_DARROW
= _cursgraftable
[DOWNARROW
];
207 ACS_UARROW
= _cursgraftable
[UPARROW
];
208 ACS_BOARD
= _cursgraftable
[EMPTYSQUARE
];
209 ACS_LANTERN
= _cursgraftable
[LATERN
];
210 ACS_BLOCK
= _cursgraftable
[FULLSQUARE
];
217 tcgetattr(0, &_orig_tty
);
219 _cursvar
.echoit
= (_tty
.c_lflag
& ECHO
) != 0;
220 _cursvar
.rawmode
= (_tty
.c_lflag
& (ICANON
|ISIG
)) == 0;
221 _cursvar
.cbrkmode
= (_tty
.c_lflag
& (ICANON
|ISIG
)) == ISIG
;
222 NONL
= (_tty
.c_iflag
& ICRNL
) != 0;