tty.h

Go to the documentation of this file.
00001 // @(#)root/editline:$Id: tty.h 32454 2010-03-04 11:06:09Z axel $
00002 // Author: Mary-Louise Gill, 2009
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 /*      $NetBSD: tty.fH,v 1.8 2000/09/04 22:06:33 lukem Exp $   */
00013 
00014 /*-
00015  * Copyright (c) 1992, 1993
00016  *      The Regents of the University of California.  All rights reserved.
00017  *
00018  * This code is derived from software contributed to Berkeley by
00019  * Christos Zoulas of Cornell University.
00020  *
00021  * Redistribution and use in source and binary forms, with or without
00022  * modification, are permitted provided that the following conditions
00023  * are met:
00024  * 1. Redistributions of source code must retain the above copyright
00025  *    notice, this list of conditions and the following disclaimer.
00026  * 2. Redistributions in binary form must reproduce the above copyright
00027  *    notice, this list of conditions and the following disclaimer in the
00028  *    documentation and/or other materials provided with the distribution.
00029  * 3. Neither the name of the University nor the names of its contributors
00030  *    may be used to endorse or promote products derived from this software
00031  *    without specific prior written permission.
00032  *
00033  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00034  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00035  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00036  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00037  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00038  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00039  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00040  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00041  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00042  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00043  * SUCH DAMAGE.
00044  */
00045 
00046 /*
00047  * el.tty.fH: Local terminal header
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 /* Define our own since everyone gets it wrong! */
00057 #define CONTROL(A) ((A) & 037)
00058 
00059 /*
00060  * Aix compatible names
00061  */
00062 #if defined(VWERSE) && !defined(VWERASE)
00063 # define VWERASE VWERSE
00064 #endif  /* VWERSE && !VWERASE */
00065 
00066 #if defined(VDISCRD) && !defined(VDISCARD)
00067 # define VDISCARD VDISCRD
00068 #endif  /* VDISCRD && !VDISCARD */
00069 
00070 #if defined(VFLUSHO) && !defined(VDISCARD)
00071 # define VDISCARD VFLUSHO
00072 #endif   /* VFLUSHO && VDISCARD */
00073 
00074 #if defined(VSTRT) && !defined(VSTART)
00075 # define VSTART VSTRT
00076 #endif  /* VSTRT && ! VSTART */
00077 
00078 #if defined(VSTAT) && !defined(VSTATUS)
00079 # define VSTATUS VSTAT
00080 #endif  /* VSTAT && ! VSTATUS */
00081 
00082 #ifndef ONLRET
00083 # define ONLRET 0
00084 #endif  /* ONLRET */
00085 
00086 #ifndef TAB3
00087 # ifdef OXTABS
00088 #  define TAB3 OXTABS
00089 # else
00090 #  define TAB3 0
00091 # endif  /* OXTABS */
00092 #endif  /* !TAB3 */
00093 
00094 #if defined(OXTABS) && !defined(XTABS)
00095 # define XTABS OXTABS
00096 #endif  /* OXTABS && !XTABS */
00097 
00098 #ifndef ONLCR
00099 # define ONLCR 0
00100 #endif  /* ONLCR */
00101 
00102 #ifndef IEXTEN
00103 # define IEXTEN 0
00104 #endif  /* IEXTEN */
00105 
00106 #ifndef ECHOCTL
00107 # define ECHOCTL 0
00108 #endif  /* ECHOCTL */
00109 
00110 #ifndef PARENB
00111 # define PARENB 0
00112 #endif  /* PARENB */
00113 
00114 #ifndef EXTPROC
00115 # define EXTPROC 0
00116 #endif  /* EXTPROC */
00117 
00118 #ifndef FLUSHO
00119 # define FLUSHO 0
00120 #endif  /* FLUSHO */
00121 
00122 
00123 #if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
00124 # define _POSIX_VDISABLE VDISABLE
00125 #endif  /* VDISABLE && ! _POSIX_VDISABLE */
00126 
00127 /*
00128  * Work around ISC's definition of IEXTEN which is
00129  * XCASE!
00130  */
00131 #ifdef ISC
00132 # if defined(IEXTEN) && defined(XCASE)
00133 #  if IEXTEN == XCASE
00134 #   undef IEXTEN
00135 #   define IEXTEN 0
00136 #  endif  /* IEXTEN == XCASE */
00137 # endif  /* IEXTEN && XCASE */
00138 # if defined(IEXTEN) && !defined(XCASE)
00139 #  define XCASE IEXTEN
00140 #  undef IEXTEN
00141 #  define IEXTEN 0
00142 # endif  /* IEXTEN && !XCASE */
00143 #endif  /* ISC */
00144 
00145 /*
00146  * Work around convex weirdness where turning off IEXTEN makes us
00147  * lose all postprocessing!
00148  */
00149 #if defined(convex) || defined(__convex__)
00150 # if defined(IEXTEN) && IEXTEN != 0
00151 #  undef IEXTEN
00152 #  define IEXTEN 0
00153 # endif /* IEXTEN != 0 */
00154 #endif /* convex || __convex__ */
00155 
00156 /*
00157  * So that we don't lose job control.
00158  */
00159 #ifdef __SVR4
00160 # undef CSWTCH
00161 #endif
00162 
00163 #ifndef _POSIX_VDISABLE
00164 # define _POSIX_VDISABLE ((unsigned char) -1)
00165 #endif /* _POSIX_VDISABLE */
00166 
00167 #if !defined(CREPRINT) && defined(CRPRNT)
00168 # define CREPRINT CRPRNT
00169 #endif /* !CREPRINT && CRPRNT */
00170 #if !defined(CDISCARD) && defined(CFLUSH)
00171 # define CDISCARD CFLUSH
00172 #endif /* !CDISCARD && CFLUSH */
00173 
00174 #ifndef CINTR
00175 # define CINTR CONTROL('c')
00176 #endif /* CINTR */
00177 #ifndef CQUIT
00178 # define CQUIT 034              /* ^\ */
00179 #endif /* CQUIT */
00180 #ifndef CERASE
00181 # define CERASE 0177            /* ^? */
00182 #endif /* CERASE */
00183 #ifndef CKILL
00184 # define CKILL CONTROL('u')
00185 #endif /* CKILL */
00186 #ifndef CEOF
00187 # define CEOF CONTROL('d')
00188 #endif /* CEOF */
00189 #ifndef CEOL
00190 # define CEOL _POSIX_VDISABLE
00191 #endif /* CEOL */
00192 #ifndef CEOL2
00193 # define CEOL2 _POSIX_VDISABLE
00194 #endif /* CEOL2 */
00195 #ifndef CSWTCH
00196 # define CSWTCH _POSIX_VDISABLE
00197 #endif /* CSWTCH */
00198 #ifndef CDSWTCH
00199 # define CDSWTCH _POSIX_VDISABLE
00200 #endif /* CDSWTCH */
00201 #ifndef CERASE2
00202 # define CERASE2 _POSIX_VDISABLE
00203 #endif /* CERASE2 */
00204 #ifndef CSTART
00205 # define CSTART CONTROL('q')
00206 #endif /* CSTART */
00207 #ifndef CSTOP
00208 # define CSTOP CONTROL('s')
00209 #endif /* CSTOP */
00210 #ifndef CSUSP
00211 # define CSUSP CONTROL('z')
00212 #endif /* CSUSP */
00213 #ifndef CDSUSP
00214 # define CDSUSP CONTROL('y')
00215 #endif /* CDSUSP */
00216 
00217 #ifdef hpux
00218 
00219 # ifndef CREPRINT
00220 #  define CREPRINT _POSIX_VDISABLE
00221 # endif /* CREPRINT */
00222 # ifndef CDISCARD
00223 #  define CDISCARD _POSIX_VDISABLE
00224 # endif /* CDISCARD */
00225 # ifndef CLNEXT
00226 #  define CLNEXT _POSIX_VDISABLE
00227 # endif /* CLNEXT */
00228 # ifndef CWERASE
00229 #  define CWERASE _POSIX_VDISABLE
00230 # endif /* CWERASE */
00231 
00232 #else /* !hpux */
00233 
00234 # ifndef CREPRINT
00235 #  define CREPRINT CONTROL('r')
00236 # endif /* CREPRINT */
00237 # ifndef CDISCARD
00238 #  define CDISCARD CONTROL('o')
00239 # endif /* CDISCARD */
00240 # ifndef CLNEXT
00241 #  define CLNEXT CONTROL('v')
00242 # endif /* CLNEXT */
00243 # ifndef CWERASE
00244 #  define CWERASE CONTROL('w')
00245 # endif /* CWERASE */
00246 
00247 #endif /* hpux */
00248 
00249 #ifndef CSTATUS
00250 # define CSTATUS CONTROL('t')
00251 #endif /* CSTATUS */
00252 #ifndef CPAGE
00253 # define CPAGE ' '
00254 #endif /* CPAGE */
00255 #ifndef CPGOFF
00256 # define CPGOFF CONTROL('m')
00257 #endif /* CPGOFF */
00258 #ifndef CKILL2
00259 # define CKILL2 _POSIX_VDISABLE
00260 #endif /* CKILL2 */
00261 #ifndef CBRK
00262 # ifndef masscomp
00263 #  define CBRK 0377
00264 # else
00265 #  define CBRK '\0'
00266 # endif /* masscomp */
00267 #endif /* CBRK */
00268 #ifndef CMIN
00269 # define CMIN CEOF
00270 #endif /* CMIN */
00271 #ifndef CTIME
00272 # define CTIME CEOL
00273 #endif /* CTIME */
00274 
00275 /*
00276  * Fix for sun inconsistency. On termio VSUSP and the rest of the
00277  * ttychars > NCC are defined. So we undefine them.
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 /* NCC */
00286 # endif /* POSIX && NCCS */
00287 # ifdef NUMCC
00288 #  ifdef VINTR
00289 #   if NUMCC <= VINTR
00290 #    undef VINTR
00291 #   endif /* NUMCC <= VINTR */
00292 #  endif /* VINTR */
00293 #  ifdef VQUIT
00294 #   if NUMCC <= VQUIT
00295 #    undef VQUIT
00296 #   endif /* NUMCC <= VQUIT */
00297 #  endif /* VQUIT */
00298 #  ifdef VERASE
00299 #   if NUMCC <= VERASE
00300 #    undef VERASE
00301 #   endif /* NUMCC <= VERASE */
00302 #  endif /* VERASE */
00303 #  ifdef VKILL
00304 #   if NUMCC <= VKILL
00305 #    undef VKILL
00306 #   endif /* NUMCC <= VKILL */
00307 #  endif /* VKILL */
00308 #  ifdef VEOF
00309 #   if NUMCC <= VEOF
00310 #    undef VEOF
00311 #   endif /* NUMCC <= VEOF */
00312 #  endif /* VEOF */
00313 #  ifdef VEOL
00314 #   if NUMCC <= VEOL
00315 #    undef VEOL
00316 #   endif /* NUMCC <= VEOL */
00317 #  endif /* VEOL */
00318 #  ifdef VEOL2
00319 #   if NUMCC <= VEOL2
00320 #    undef VEOL2
00321 #   endif /* NUMCC <= VEOL2 */
00322 #  endif /* VEOL2 */
00323 #  ifdef VSWTCH
00324 #   if NUMCC <= VSWTCH
00325 #    undef VSWTCH
00326 #   endif /* NUMCC <= VSWTCH */
00327 #  endif /* VSWTCH */
00328 #  ifdef VDSWTCH
00329 #   if NUMCC <= VDSWTCH
00330 #    undef VDSWTCH
00331 #   endif /* NUMCC <= VDSWTCH */
00332 #  endif /* VDSWTCH */
00333 #  ifdef VERASE2
00334 #   if NUMCC <= VERASE2
00335 #    undef VERASE2
00336 #   endif /* NUMCC <= VERASE2 */
00337 #  endif /* VERASE2 */
00338 #  ifdef VSTART
00339 #   if NUMCC <= VSTART
00340 #    undef VSTART
00341 #   endif /* NUMCC <= VSTART */
00342 #  endif /* VSTART */
00343 #  ifdef VSTOP
00344 #   if NUMCC <= VSTOP
00345 #    undef VSTOP
00346 #   endif /* NUMCC <= VSTOP */
00347 #  endif /* VSTOP */
00348 #  ifdef VWERASE
00349 #   if NUMCC <= VWERASE
00350 #    undef VWERASE
00351 #   endif /* NUMCC <= VWERASE */
00352 #  endif /* VWERASE */
00353 #  ifdef VSUSP
00354 #   if NUMCC <= VSUSP
00355 #    undef VSUSP
00356 #   endif /* NUMCC <= VSUSP */
00357 #  endif /* VSUSP */
00358 #  ifdef VDSUSP
00359 #   if NUMCC <= VDSUSP
00360 #    undef VDSUSP
00361 #   endif /* NUMCC <= VDSUSP */
00362 #  endif /* VDSUSP */
00363 #  ifdef VREPRINT
00364 #   if NUMCC <= VREPRINT
00365 #    undef VREPRINT
00366 #   endif /* NUMCC <= VREPRINT */
00367 #  endif /* VREPRINT */
00368 #  ifdef VDISCARD
00369 #   if NUMCC <= VDISCARD
00370 #    undef VDISCARD
00371 #   endif /* NUMCC <= VDISCARD */
00372 #  endif /* VDISCARD */
00373 #  ifdef VLNEXT
00374 #   if NUMCC <= VLNEXT
00375 #    undef VLNEXT
00376 #   endif /* NUMCC <= VLNEXT */
00377 #  endif /* VLNEXT */
00378 #  ifdef VSTATUS
00379 #   if NUMCC <= VSTATUS
00380 #    undef VSTATUS
00381 #   endif /* NUMCC <= VSTATUS */
00382 #  endif /* VSTATUS */
00383 #  ifdef VPAGE
00384 #   if NUMCC <= VPAGE
00385 #    undef VPAGE
00386 #   endif /* NUMCC <= VPAGE */
00387 #  endif /* VPAGE */
00388 #  ifdef VPGOFF
00389 #   if NUMCC <= VPGOFF
00390 #    undef VPGOFF
00391 #   endif /* NUMCC <= VPGOFF */
00392 #  endif /* VPGOFF */
00393 #  ifdef VKILL2
00394 #   if NUMCC <= VKILL2
00395 #    undef VKILL2
00396 #   endif /* NUMCC <= VKILL2 */
00397 #  endif /* VKILL2 */
00398 #  ifdef VBRK
00399 #   if NUMCC <= VBRK
00400 #    undef VBRK
00401 #   endif /* NUMCC <= VBRK */
00402 #  endif /* VBRK */
00403 #  ifdef VMIN
00404 #   if NUMCC <= VMIN
00405 #    undef VMIN
00406 #   endif /* NUMCC <= VMIN */
00407 #  endif /* VMIN */
00408 #  ifdef VTIME
00409 #   if NUMCC <= VTIME
00410 #    undef VTIME
00411 #   endif /* NUMCC <= VTIME */
00412 #  endif /* VTIME */
00413 # endif /* NUMCC */
00414 #endif /* !POSIX */
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  * Terminal dependend data structures
00446  */
00447 #define EX_IO 0         /* while we are executing       */
00448 #define ED_IO 1         /* while we are editing         */
00449 #define TS_IO 2         /* new mode from terminal       */
00450 #define QU_IO 2         /* used only for quoted chars   */
00451 #define NN_IO 3         /* The number of entries        */
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 /* _h_el_tty */

Generated on Tue Jul 5 14:11:39 2011 for ROOT_528-00b_version by  doxygen 1.5.1