00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef _h_el_tty
00050 #define _h_el_tty
00051
00052 #include "histedit.h"
00053 #include <termios.h>
00054 #include <unistd.h>
00055
00056
00057 #define CONTROL(A) ((A) & 037)
00058
00059
00060
00061
00062 #if defined(VWERSE) && !defined(VWERASE)
00063 # define VWERASE VWERSE
00064 #endif
00065
00066 #if defined(VDISCRD) && !defined(VDISCARD)
00067 # define VDISCARD VDISCRD
00068 #endif
00069
00070 #if defined(VFLUSHO) && !defined(VDISCARD)
00071 # define VDISCARD VFLUSHO
00072 #endif
00073
00074 #if defined(VSTRT) && !defined(VSTART)
00075 # define VSTART VSTRT
00076 #endif
00077
00078 #if defined(VSTAT) && !defined(VSTATUS)
00079 # define VSTATUS VSTAT
00080 #endif
00081
00082 #ifndef ONLRET
00083 # define ONLRET 0
00084 #endif
00085
00086 #ifndef TAB3
00087 # ifdef OXTABS
00088 # define TAB3 OXTABS
00089 # else
00090 # define TAB3 0
00091 # endif
00092 #endif
00093
00094 #if defined(OXTABS) && !defined(XTABS)
00095 # define XTABS OXTABS
00096 #endif
00097
00098 #ifndef ONLCR
00099 # define ONLCR 0
00100 #endif
00101
00102 #ifndef IEXTEN
00103 # define IEXTEN 0
00104 #endif
00105
00106 #ifndef ECHOCTL
00107 # define ECHOCTL 0
00108 #endif
00109
00110 #ifndef PARENB
00111 # define PARENB 0
00112 #endif
00113
00114 #ifndef EXTPROC
00115 # define EXTPROC 0
00116 #endif
00117
00118 #ifndef FLUSHO
00119 # define FLUSHO 0
00120 #endif
00121
00122
00123 #if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
00124 # define _POSIX_VDISABLE VDISABLE
00125 #endif
00126
00127
00128
00129
00130
00131 #ifdef ISC
00132 # if defined(IEXTEN) && defined(XCASE)
00133 # if IEXTEN == XCASE
00134 # undef IEXTEN
00135 # define IEXTEN 0
00136 # endif
00137 # endif
00138 # if defined(IEXTEN) && !defined(XCASE)
00139 # define XCASE IEXTEN
00140 # undef IEXTEN
00141 # define IEXTEN 0
00142 # endif
00143 #endif
00144
00145
00146
00147
00148
00149 #if defined(convex) || defined(__convex__)
00150 # if defined(IEXTEN) && IEXTEN != 0
00151 # undef IEXTEN
00152 # define IEXTEN 0
00153 # endif
00154 #endif
00155
00156
00157
00158
00159 #ifdef __SVR4
00160 # undef CSWTCH
00161 #endif
00162
00163 #ifndef _POSIX_VDISABLE
00164 # define _POSIX_VDISABLE ((unsigned char) -1)
00165 #endif
00166
00167 #if !defined(CREPRINT) && defined(CRPRNT)
00168 # define CREPRINT CRPRNT
00169 #endif
00170 #if !defined(CDISCARD) && defined(CFLUSH)
00171 # define CDISCARD CFLUSH
00172 #endif
00173
00174 #ifndef CINTR
00175 # define CINTR CONTROL('c')
00176 #endif
00177 #ifndef CQUIT
00178 # define CQUIT 034
00179 #endif
00180 #ifndef CERASE
00181 # define CERASE 0177
00182 #endif
00183 #ifndef CKILL
00184 # define CKILL CONTROL('u')
00185 #endif
00186 #ifndef CEOF
00187 # define CEOF CONTROL('d')
00188 #endif
00189 #ifndef CEOL
00190 # define CEOL _POSIX_VDISABLE
00191 #endif
00192 #ifndef CEOL2
00193 # define CEOL2 _POSIX_VDISABLE
00194 #endif
00195 #ifndef CSWTCH
00196 # define CSWTCH _POSIX_VDISABLE
00197 #endif
00198 #ifndef CDSWTCH
00199 # define CDSWTCH _POSIX_VDISABLE
00200 #endif
00201 #ifndef CERASE2
00202 # define CERASE2 _POSIX_VDISABLE
00203 #endif
00204 #ifndef CSTART
00205 # define CSTART CONTROL('q')
00206 #endif
00207 #ifndef CSTOP
00208 # define CSTOP CONTROL('s')
00209 #endif
00210 #ifndef CSUSP
00211 # define CSUSP CONTROL('z')
00212 #endif
00213 #ifndef CDSUSP
00214 # define CDSUSP CONTROL('y')
00215 #endif
00216
00217 #ifdef hpux
00218
00219 # ifndef CREPRINT
00220 # define CREPRINT _POSIX_VDISABLE
00221 # endif
00222 # ifndef CDISCARD
00223 # define CDISCARD _POSIX_VDISABLE
00224 # endif
00225 # ifndef CLNEXT
00226 # define CLNEXT _POSIX_VDISABLE
00227 # endif
00228 # ifndef CWERASE
00229 # define CWERASE _POSIX_VDISABLE
00230 # endif
00231
00232 #else
00233
00234 # ifndef CREPRINT
00235 # define CREPRINT CONTROL('r')
00236 # endif
00237 # ifndef CDISCARD
00238 # define CDISCARD CONTROL('o')
00239 # endif
00240 # ifndef CLNEXT
00241 # define CLNEXT CONTROL('v')
00242 # endif
00243 # ifndef CWERASE
00244 # define CWERASE CONTROL('w')
00245 # endif
00246
00247 #endif
00248
00249 #ifndef CSTATUS
00250 # define CSTATUS CONTROL('t')
00251 #endif
00252 #ifndef CPAGE
00253 # define CPAGE ' '
00254 #endif
00255 #ifndef CPGOFF
00256 # define CPGOFF CONTROL('m')
00257 #endif
00258 #ifndef CKILL2
00259 # define CKILL2 _POSIX_VDISABLE
00260 #endif
00261 #ifndef CBRK
00262 # ifndef masscomp
00263 # define CBRK 0377
00264 # else
00265 # define CBRK '\0'
00266 # endif
00267 #endif
00268 #ifndef CMIN
00269 # define CMIN CEOF
00270 #endif
00271 #ifndef CTIME
00272 # define CTIME CEOL
00273 #endif
00274
00275
00276
00277
00278
00279 #if defined(TERMIO) || defined(POSIX)
00280 # if defined(POSIX) && defined(NCCS)
00281 # define NUMCC NCCS
00282 # else
00283 # ifdef NCC
00284 # define NUMCC NCC
00285 # endif
00286 # endif
00287 # ifdef NUMCC
00288 # ifdef VINTR
00289 # if NUMCC <= VINTR
00290 # undef VINTR
00291 # endif
00292 # endif
00293 # ifdef VQUIT
00294 # if NUMCC <= VQUIT
00295 # undef VQUIT
00296 # endif
00297 # endif
00298 # ifdef VERASE
00299 # if NUMCC <= VERASE
00300 # undef VERASE
00301 # endif
00302 # endif
00303 # ifdef VKILL
00304 # if NUMCC <= VKILL
00305 # undef VKILL
00306 # endif
00307 # endif
00308 # ifdef VEOF
00309 # if NUMCC <= VEOF
00310 # undef VEOF
00311 # endif
00312 # endif
00313 # ifdef VEOL
00314 # if NUMCC <= VEOL
00315 # undef VEOL
00316 # endif
00317 # endif
00318 # ifdef VEOL2
00319 # if NUMCC <= VEOL2
00320 # undef VEOL2
00321 # endif
00322 # endif
00323 # ifdef VSWTCH
00324 # if NUMCC <= VSWTCH
00325 # undef VSWTCH
00326 # endif
00327 # endif
00328 # ifdef VDSWTCH
00329 # if NUMCC <= VDSWTCH
00330 # undef VDSWTCH
00331 # endif
00332 # endif
00333 # ifdef VERASE2
00334 # if NUMCC <= VERASE2
00335 # undef VERASE2
00336 # endif
00337 # endif
00338 # ifdef VSTART
00339 # if NUMCC <= VSTART
00340 # undef VSTART
00341 # endif
00342 # endif
00343 # ifdef VSTOP
00344 # if NUMCC <= VSTOP
00345 # undef VSTOP
00346 # endif
00347 # endif
00348 # ifdef VWERASE
00349 # if NUMCC <= VWERASE
00350 # undef VWERASE
00351 # endif
00352 # endif
00353 # ifdef VSUSP
00354 # if NUMCC <= VSUSP
00355 # undef VSUSP
00356 # endif
00357 # endif
00358 # ifdef VDSUSP
00359 # if NUMCC <= VDSUSP
00360 # undef VDSUSP
00361 # endif
00362 # endif
00363 # ifdef VREPRINT
00364 # if NUMCC <= VREPRINT
00365 # undef VREPRINT
00366 # endif
00367 # endif
00368 # ifdef VDISCARD
00369 # if NUMCC <= VDISCARD
00370 # undef VDISCARD
00371 # endif
00372 # endif
00373 # ifdef VLNEXT
00374 # if NUMCC <= VLNEXT
00375 # undef VLNEXT
00376 # endif
00377 # endif
00378 # ifdef VSTATUS
00379 # if NUMCC <= VSTATUS
00380 # undef VSTATUS
00381 # endif
00382 # endif
00383 # ifdef VPAGE
00384 # if NUMCC <= VPAGE
00385 # undef VPAGE
00386 # endif
00387 # endif
00388 # ifdef VPGOFF
00389 # if NUMCC <= VPGOFF
00390 # undef VPGOFF
00391 # endif
00392 # endif
00393 # ifdef VKILL2
00394 # if NUMCC <= VKILL2
00395 # undef VKILL2
00396 # endif
00397 # endif
00398 # ifdef VBRK
00399 # if NUMCC <= VBRK
00400 # undef VBRK
00401 # endif
00402 # endif
00403 # ifdef VMIN
00404 # if NUMCC <= VMIN
00405 # undef VMIN
00406 # endif
00407 # endif
00408 # ifdef VTIME
00409 # if NUMCC <= VTIME
00410 # undef VTIME
00411 # endif
00412 # endif
00413 # endif
00414 #endif
00415
00416 #define C_INTR 0
00417 #define C_QUIT 1
00418 #define C_ERASE 2
00419 #define C_KILL 3
00420 #define C_EOF 4
00421 #define C_EOL 5
00422 #define C_EOL2 6
00423 #define C_SWTCH 7
00424 #define C_DSWTCH 8
00425 #define C_ERASE2 9
00426 #define C_START 10
00427 #define C_STOP 11
00428 #define C_WERASE 12
00429 #define C_SUSP 13
00430 #define C_DSUSP 14
00431 #define C_REPRINT 15
00432 #define C_DISCARD 16
00433 #define C_LNEXT 17
00434 #define C_STATUS 18
00435 #define C_PAGE 19
00436 #define C_PGOFF 20
00437 #define C_KILL2 21
00438 #define C_BRK 22
00439 #define C_MIN 23
00440 #define C_TIME 24
00441 #define C_NCC 25
00442 #define C_SH(A) (1 << (A))
00443
00444
00445
00446
00447 #define EX_IO 0
00448 #define ED_IO 1
00449 #define TS_IO 2
00450 #define QU_IO 2
00451 #define NN_IO 3
00452
00453 #define MD_INP 0
00454 #define MD_OUT 1
00455 #define MD_CTL 2
00456 #define MD_LIN 3
00457 #define MD_CHAR 4
00458 #define MD_NN 5
00459
00460 typedef struct {
00461 const char* t_name;
00462 u_int t_setmask;
00463 u_int t_clrmask;
00464 } TTYPerm_t[NN_IO][MD_NN];
00465
00466 typedef unsigned char TTYChar_t[NN_IO][C_NCC];
00467
00468 el_protected int tty_init(EditLine_t*);
00469 el_protected void tty_end(EditLine_t*);
00470 el_protected int tty_stty(EditLine_t*, int, const char**);
00471 el_protected int tty_rawmode(EditLine_t*);
00472 el_protected int tty_cookedmode(EditLine_t*);
00473 el_protected int tty_quotemode(EditLine_t*);
00474 el_protected int tty_noquotemode(EditLine_t*);
00475 el_protected void tty_bind_char(EditLine_t*, int);
00476 el_protected int tty_can_output(void);
00477
00478 typedef struct {
00479 TTYPerm_t t_t;
00480 TTYChar_t t_c;
00481 struct termios t_ex, t_ed, t_ts;
00482 int t_tabs;
00483 int t_eight;
00484 speed_t t_speed;
00485 int t_mode;
00486 unsigned char t_vdisable;
00487 } ElTTY_t;
00488
00489
00490 #endif