home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / rn_4_3_blars.lzh / term.h < prev    next >
Text File  |  1990-11-03  |  8KB  |  272 lines

  1. /* $Header: term.h,v 4.3.2.2 90/04/06 20:35:34 sob Exp $
  2.  *
  3.  * $Log:    term.h,v $
  4.  * Revision 4.3.2.2  90/04/06  20:35:34  sob
  5.  * Added fixes for SCO Xenix sent by ronald@robobar.co.uk.
  6.  * 
  7.  * Revision 4.3.2.1  89/11/28  01:54:03  sob
  8.  * Added better support for SIGWINCH.
  9.  * 
  10.  * Revision 4.3.1.2  85/05/13  15:52:05  lwall
  11.  * Declared devtty on TERMIO system.
  12.  * 
  13.  * Revision 4.3.1.1  85/05/10  11:41:24  lwall
  14.  * Branch for patches.
  15.  * 
  16.  * Revision 4.3  85/05/01  11:51:36  lwall
  17.  * Baseline for release with 4.3bsd.
  18.  * 
  19.  */
  20.  
  21. #ifdef PUSHBACK
  22. EXT char circlebuf[PUSHSIZE];
  23. EXT int nextin INIT(0);
  24. EXT int nextout INIT(0);
  25. #ifdef PENDING
  26. #ifndef OSK
  27. #ifdef FIONREAD
  28. EXT long iocount INIT(0);
  29. #ifndef lint
  30. #define input_pending() (nextin!=nextout || (ioctl(0, FIONREAD, &iocount),(int)iocount))
  31. #else
  32. #define input_pending() bizarre
  33. #endif lint
  34. #else /* FIONREAD */
  35. #ifdef RDCHK
  36. #define input_pending() (rdchk(0) > 0)        /* boolean only */
  37. #else /*  RDCHK */
  38. int circfill();
  39. EXT int devtty INIT(0);
  40. #ifndef lint
  41. #define input_pending() (nextin!=nextout || circfill())
  42. #else
  43. #define input_pending() bizarre
  44. #endif lint
  45. #endif /* RDCHK */
  46. #endif FIONREAD
  47. #else /* OSK */
  48. #define devtty 0
  49. EXT int pendingchars;
  50. #define input_pending() ((pendingchars = _gs_rdy(0)) > 0 ? pendingchars : 0)
  51. #endif /* OSK */
  52. #else PENDING
  53. #ifndef lint
  54. #define input_pending() (nextin!=nextout)
  55. #else
  56. #define input_pending() bizarre
  57. #endif lint
  58. #endif PENDING
  59. #else PUSHBACK
  60. #ifdef PENDING
  61. #ifdef FIONREAD    /* must have FIONREAD or O_NDELAY for input_pending() */
  62. #define read_tty(addr,size) read(0,addr,size)
  63. #ifndef lint
  64. #define input_pending() (ioctl(0, FIONREAD, &iocount),(int)iocount)
  65. #else
  66. #define input_pending() bizarre
  67. #endif lint
  68. EXT long iocount INIT(0);
  69.  
  70. #else FIONREAD
  71.  
  72. #ifdef RDCHK
  73. #define input_pending() (rdchk(0) > 0)        /* boolean only */
  74. #else /*  RDCHK */
  75.  
  76. EXT int devtty INIT(0);
  77. EXT bool is_input INIT(FALSE);
  78. EXT char pending_ch INIT(0);
  79. #ifndef lint
  80. #define input_pending() (is_input || (is_input=read(devtty,&pending_ch,1)))
  81. #else
  82. #define input_pending() bizarre
  83. #endif lint
  84. #endif /*  RDCHK */
  85. #endif FIONREAD
  86. #else PENDING
  87. #define read_tty(addr,size) read(0,addr,size)
  88. #define input_pending() (FALSE)
  89. #endif PENDING
  90. #endif PUSHBACK
  91.  
  92. /* stuff wanted by terminal mode diddling routines */
  93.  
  94. #ifndef OSK
  95. #ifdef TERMIO
  96. EXT struct termio _tty, _oldtty;
  97. #else
  98. EXT struct sgttyb _tty;
  99. EXT int _res_flg INIT(0);
  100. #endif
  101. #else /* OSK */
  102. EXT struct sgbuf _tty, _oldtty;
  103. #endif /* OSK */
  104.  
  105. EXT int _tty_ch INIT(2);
  106. EXT bool bizarre INIT(FALSE);            /* do we need to restore terminal? */
  107.  
  108. /* terminal mode diddling routines */
  109.  
  110. #ifdef TERMIO
  111.  
  112. #define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
  113. #define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,stty(_tty_ch,&_tty))
  114. #define echo()     ((bizarre=1),_tty.c_lflag |= ECHO, ioctl(_tty_ch, TCSETA, &_tty))
  115. #define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, ioctl(_tty_ch, TCSETA, &_tty))
  116. #define nl()     ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
  117. #define nonl()     ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
  118. #define    savetty() (ioctl(_tty_ch, TCGETA, &_oldtty),ioctl(_tty_ch, TCGETA, &_tty))
  119. #define    resetty() ((bizarre=0),ioctl(_tty_ch, TCSETAF, &_oldtty))
  120. #define unflush_output()
  121.  
  122. #else
  123.  
  124. #ifndef OSK
  125.  
  126. #define raw()     ((bizarre=1),_tty.sg_flags|=RAW, stty(_tty_ch,&_tty))
  127. #define noraw()     ((bizarre=1),_tty.sg_flags&=~RAW,stty(_tty_ch,&_tty))
  128. #define crmode() ((bizarre=1),_tty.sg_flags |= CBREAK, stty(_tty_ch,&_tty))
  129. #define nocrmode() ((bizarre=1),_tty.sg_flags &= ~CBREAK,stty(_tty_ch,&_tty))
  130. #define echo()     ((bizarre=1),_tty.sg_flags |= ECHO, stty(_tty_ch, &_tty))
  131. #define noecho() ((bizarre=1),_tty.sg_flags &= ~ECHO, stty(_tty_ch, &_tty))
  132. #define nl()     ((bizarre=1),_tty.sg_flags |= CRMOD,stty(_tty_ch, &_tty))
  133. #define nonl()     ((bizarre=1),_tty.sg_flags &= ~CRMOD, stty(_tty_ch, &_tty))
  134. #define    savetty() (gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
  135. #define    resetty() ((bizarre=0),_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty))
  136. #ifdef LFLUSHO
  137. #ifndef lint
  138. EXT int lflusho INIT(LFLUSHO);
  139. #else
  140. EXT long lflusho INIT(LFLUSHO);
  141. #endif lint
  142. #define unflush_output() (ioctl(_tty_ch,TIOCLBIC,&lflusho))
  143. #else
  144. #define unflush_output()
  145. #endif LFLUSHO
  146.  
  147. #else /* OSK */
  148.  
  149. /* raw() and noraw() arn't used */
  150. #define crmode() ((bizarre=1), _tty.sg_bspch=0, _tty.sg_dlnch=0,\
  151.     _tty.sg_rlnch=0, _tty.sg_dulnch=0, _tty.sg_kbich=0, _tty.sg_kbach=0,\
  152.     _tty.sg_bsech=0, _tty.sg_bellch=0, _tty.sg_pause=0,\
  153.     _ss_opt(_tty_ch,&_tty))
  154. /* nocrmode() isn't used either */
  155. #define echo()     ((bizarre=1), _tty.sg_echo=1, _ss_opt(_tty_ch, &_tty))
  156. #define noecho() ((bizarre=1), _tty.sg_echo=0, _ss_opt(_tty_ch, &_tty))
  157. #define nl()     ((bizarre=1), _tty.sg_alf=1, _ss_opt(_tty_ch, &_tty))
  158. #define nonl()     ((bizarre=1), _tty.sg_alf=0, _ss_opt(_tty_ch, &_tty))
  159. #define    savetty() (_gs_opt(_tty_ch, &_tty), _gs_opt(_tty_ch, &_oldtty))
  160. #define    resetty() ((bizarre=0), _ss_opt(_tty_ch, &_oldtty))
  161. #define unflush_output()
  162.  
  163. #endif /* OSK */
  164.  
  165. #endif /* TERMIO */
  166.  
  167. #ifdef TIOCSTI
  168. #ifdef lint
  169. #define forceme(c) ioctl(_tty_ch,TIOCSTI,Null(long*))    /* ghad! */
  170. #else
  171. #define forceme(c) ioctl(_tty_ch,TIOCSTI,c) /* pass character in " " */
  172. #endif lint
  173. #else
  174. #define forceme(c)
  175. #endif
  176.  
  177. /* termcap stuff */
  178.  
  179. /*
  180.  * NOTE: if you don't have termlib you'll either have to define these strings
  181.  *    and the tputs routine, or you'll have to redefine the macros below
  182.  */
  183.  
  184. #ifdef HAVETERMLIB
  185. EXT char *BC INIT(Nullch);        /* backspace character */
  186. EXT char *UP INIT(Nullch);        /* move cursor up one line */
  187. EXT char *CR INIT(Nullch);        /* get to left margin, somehow */
  188. EXT char *VB INIT(Nullch);        /* visible bell */
  189. EXT char *CL INIT(Nullch);        /* home and clear screen */
  190. EXT char *CE INIT(Nullch);        /* clear to end of line */
  191. #ifdef CLEAREOL
  192. EXT char *CM INIT(Nullch);        /* cursor motion -- PWP */
  193. EXT char *HO INIT(Nullch);        /* home cursor -- PWP */
  194. EXT char *CD INIT(Nullch);        /* clear to end of display -- PWP */
  195. #endif CLEAREOL
  196. EXT char *SO INIT(Nullch);        /* begin standout mode */
  197. EXT char *SE INIT(Nullch);        /* end standout mode */
  198. EXT int SG INIT(0);        /* blanks left by SO and SE */
  199. EXT char *US INIT(Nullch);        /* start underline mode */
  200. EXT char *UE INIT(Nullch);        /* end underline mode */
  201. EXT char *UC INIT(Nullch);        /* underline a character, if that's how it's done */
  202. EXT int UG INIT(0);        /* blanks left by US and UE */
  203. EXT bool AM INIT(FALSE);        /* does terminal have automatic margins? */
  204. EXT bool XN INIT(FALSE);        /* does it eat 1st newline after automatic wrap? */
  205. #ifdef OSK            /* compiler bug */
  206. #define PC PC_
  207. #endif
  208. EXT char PC INIT(0);        /* pad character for use by tputs() */
  209. EXT short ospeed INIT(0);    /* terminal output speed, for use by tputs() */
  210. EXT int LINES INIT(0), COLS INIT(0);    /* size of screen */
  211. EXT int just_a_sec INIT(960);            /* 1 sec at current baud rate */
  212.                     /* (number of nulls) */
  213.  
  214. /* define a few handy macros */
  215.  
  216. #define backspace() tputs(BC,0,putchr) FLUSH
  217. #define clear() tputs(CL,LINES,putchr) FLUSH
  218. #define erase_eol() tputs(CE,1,putchr) FLUSH
  219. #ifdef CLEAREOL
  220. #define clear_rest() tputs(CD,LINES,putchr) FLUSH    /* PWP */
  221. #define maybe_eol() if(erase_screen&&can_home_clear)tputs(CE,1,putchr) FLUSH
  222. #endif CLEAREOL
  223. #define underline() tputs(US,1,putchr) FLUSH
  224. #define un_underline() tputs(UE,1,putchr) FLUSH
  225. #define underchar() tputs(UC,0,putchr) FLUSH
  226. #define standout() tputs(SO,1,putchr) FLUSH
  227. #define un_standout() tputs(SE,1,putchr) FLUSH
  228. #define up_line() tputs(UP,1,putchr) FLUSH
  229. #define carriage_return() tputs(CR,1,putchr) FLUSH
  230. #define dingaling() tputs(VB,1,putchr) FLUSH
  231. #else
  232.   ????????        /* up to you */
  233. #endif
  234.  
  235. EXT int page_line INIT(1);    /* line number for paging in print_line (origin 1) */
  236.  
  237. void    term_init();
  238. void    term_set();
  239. #ifdef PUSHBACK
  240. void    pushchar();
  241. void    mac_init();
  242. void    mac_line();
  243. void    show_macros();
  244. #endif
  245. char    putchr();    /* routine for tputs to call */
  246. bool    finish_command();
  247. void    eat_typeahead();
  248. void    settle_down();
  249. #ifndef read_tty
  250.     int        read_tty();
  251. #endif
  252. void    underprint();
  253. #ifdef NOFIREWORKS
  254.     void    no_sofire();
  255.     void    no_ulfire();
  256. #endif
  257. void    getcmd();
  258. int    get_anything();
  259. void    in_char();
  260. int    print_lines();
  261. void    page_init();
  262. void    pad();
  263. void    printcmd();
  264. void    rubout();
  265. void    reprint();
  266. #ifdef CLEAREOL
  267. void    home_cursor();
  268. #endif CLEAREOL
  269. #ifdef SIGWINCH
  270. int    winch_catcher();
  271. #endif /* SIGWINCH */
  272.