/contrib/tcsh/ed.term.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 522 lines · 416 code · 42 blank · 64 comment · 68 complexity · 90817e8d3c9f08e4f609f754b41e76ae MD5 · raw file

  1. /* $Header: /p/tcsh/cvsroot/tcsh/ed.term.h,v 1.18 2007/07/05 14:13:06 christos Exp $ */
  2. /*
  3. * ed.term.h: Local terminal header
  4. */
  5. /*-
  6. * Copyright (c) 1980, 1991 The Regents of the University of California.
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the University nor the names of its contributors
  18. * may be used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. */
  33. #ifndef _h_ed_term
  34. #define _h_ed_term
  35. #define TO_CONTROL(A) ((A) & 037)
  36. #if defined(TERMIO) || defined(POSIX)
  37. /*
  38. * Aix compatible names
  39. */
  40. # if defined(VWERSE) && !defined(VWERASE)
  41. # define VWERASE VWERSE
  42. # endif /* VWERSE && !VWERASE */
  43. # if defined(VDISCRD) && !defined(VDISCARD)
  44. # define VDISCARD VDISCRD
  45. # endif /* VDISCRD && !VDISCARD */
  46. # if defined(VFLUSHO) && !defined(VDISCARD)
  47. # define VDISCARD VFLUSHO
  48. # endif /* VFLUSHO && VDISCARD */
  49. # if defined(VSTRT) && !defined(VSTART)
  50. # define VSTART VSTRT
  51. # endif /* VSTRT && ! VSTART */
  52. # if defined(VSTAT) && !defined(VSTATUS)
  53. # define VSTATUS VSTAT
  54. # endif /* VSTAT && ! VSTATUS */
  55. # ifndef ONLRET
  56. # define ONLRET 0
  57. # endif /* ONLRET */
  58. # ifndef TAB3
  59. # ifdef OXTABS
  60. # define TAB3 OXTABS
  61. # else
  62. # define TAB3 0
  63. # endif /* OXTABS */
  64. # endif /* !TAB3 */
  65. # if defined(OXTABS) && !defined(XTABS)
  66. # define XTABS OXTABS
  67. # endif /* OXTABS && !XTABS */
  68. # ifndef ONLCR
  69. # define ONLCR 0
  70. # endif /* ONLCR */
  71. # ifndef IEXTEN
  72. # define IEXTEN 0
  73. # endif /* IEXTEN */
  74. /*
  75. * emx garbage
  76. */
  77. # ifndef IDEFAULT
  78. # define IDEFAULT 0
  79. # endif /* IDEFAULT */
  80. # ifndef IDELETE
  81. # define IDELETE 0
  82. # endif /* IDELETE */
  83. # ifndef ECHOCTL
  84. # define ECHOCTL 0
  85. # endif /* ECHOCTL */
  86. # ifndef PARENB
  87. # define PARENB 0
  88. # endif /* PARENB */
  89. # ifndef EXTPROC
  90. # define EXTPROC 0
  91. # endif /* EXTPROC */
  92. # ifndef FLUSHO
  93. # define FLUSHO 0
  94. # endif /* FLUSHO */
  95. # if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
  96. # define _POSIX_VDISABLE VDISABLE
  97. # endif /* VDISABLE && ! _POSIX_VDISABLE */
  98. /*
  99. * Work around ISC's definition of IEXTEN which is
  100. * XCASE!
  101. */
  102. # ifdef ISC
  103. # if defined(IEXTEN) && defined(XCASE)
  104. # if IEXTEN == XCASE
  105. # undef IEXTEN
  106. # define IEXTEN 0
  107. # endif /* IEXTEN == XCASE */
  108. # endif /* IEXTEN && XCASE */
  109. # if defined(IEXTEN) && !defined(XCASE)
  110. # define XCASE IEXTEN
  111. # undef IEXTEN
  112. # define IEXTEN 0
  113. # endif /* IEXTEN && !XCASE */
  114. # endif /* ISC */
  115. /*
  116. * Work around convex weirdness where turning off IEXTEN makes us
  117. * lose all postprocessing!
  118. */
  119. #ifdef convex
  120. # if defined(IEXTEN) && IEXTEN != 0
  121. # undef IEXTEN
  122. # define IEXTEN 0
  123. # endif /* IEXTEN != 0 */
  124. #endif /* convex */
  125. # else /* SGTTY */
  126. # ifndef LPASS8
  127. # define LPASS8 0
  128. # endif /* LPASS8 */
  129. #endif /* TERMIO || POSIX */
  130. #ifndef _POSIX_VDISABLE
  131. # define _POSIX_VDISABLE ((unsigned char) -1)
  132. #endif /* _POSIX_VDISABLE */
  133. #if !defined(CREPRINT) && defined(CRPRNT)
  134. # define CREPRINT CRPRNT
  135. #endif /* !CREPRINT && CRPRNT */
  136. #if !defined(CDISCARD) && defined(CFLUSH)
  137. # define CDISCARD CFLUSH
  138. #endif /* !CDISCARD && CFLUSH */
  139. #if !defined(CDISCARD) && defined(CFLUSHO)
  140. # define CDISCARD CFLUSHO
  141. #endif /* !CDISCARD && CFLUSHO */
  142. /*
  143. * IRIX4.0 control macro is broken!
  144. * Ignore and undef all default tty chars defined and redefine only
  145. * the ones that are different in the IRIX file.
  146. */
  147. #if __STDC__ && defined(IRIS4D)
  148. # undef CINTR
  149. # define CINTR 0177 /* ^? */
  150. # undef CQUIT
  151. # undef CERASE
  152. # define CERASE TO_CONTROL('h')
  153. # undef CKILL
  154. # undef CEOF
  155. # undef CEOL
  156. # undef CEOL2
  157. # undef CSWTCH
  158. # define CSWTCH TO_CONTROL('z')
  159. # undef CDSWTCH
  160. # undef CERASE2
  161. # undef CSTART
  162. # undef CSTOP
  163. # undef CWERASE
  164. # undef CSUSP
  165. # undef CDSUSP
  166. # undef CREPRINT
  167. # undef CDISCARD
  168. # undef CLNEXT
  169. # undef CSTATUS
  170. # undef CPAGE
  171. # undef CPGOFF
  172. # undef CKILL2
  173. # undef CBRK
  174. # undef CMIN
  175. # undef CTIME
  176. #endif /* __STDC__ && IRIS4D */
  177. #ifndef CINTR
  178. # define CINTR TO_CONTROL('c')
  179. #endif /* CINTR */
  180. #ifndef CQUIT
  181. # define CQUIT 034 /* ^\ */
  182. #endif /* CQUIT */
  183. #ifndef CERASE
  184. # define CERASE 0177 /* ^? */
  185. #endif /* CERASE */
  186. #ifndef CKILL
  187. # define CKILL TO_CONTROL('u')
  188. #endif /* CKILL */
  189. #ifndef CEOF
  190. # define CEOF TO_CONTROL('d')
  191. #endif /* CEOF */
  192. #ifndef CEOL
  193. # define CEOL _POSIX_VDISABLE
  194. #endif /* CEOL */
  195. #ifndef CEOL2
  196. # define CEOL2 _POSIX_VDISABLE
  197. #endif /* CEOL2 */
  198. #ifndef CSWTCH
  199. # define CSWTCH _POSIX_VDISABLE
  200. #endif /* CSWTCH */
  201. #ifndef CDSWTCH
  202. # define CDSWTCH _POSIX_VDISABLE
  203. #endif /* CDSWTCH */
  204. #ifndef CERASE2
  205. # define CERASE2 _POSIX_VDISABLE
  206. #endif /* CERASE2 */
  207. #ifndef CSTART
  208. # define CSTART TO_CONTROL('q')
  209. #endif /* CSTART */
  210. #ifndef CSTOP
  211. # define CSTOP TO_CONTROL('s')
  212. #endif /* CSTOP */
  213. #ifndef CSUSP
  214. # define CSUSP TO_CONTROL('z')
  215. #endif /* CSUSP */
  216. #ifndef CDSUSP
  217. # define CDSUSP TO_CONTROL('y')
  218. #endif /* CDSUSP */
  219. #ifdef hpux
  220. # ifndef CREPRINT
  221. # define CREPRINT _POSIX_VDISABLE
  222. # endif /* CREPRINT */
  223. # ifndef CDISCARD
  224. # define CDISCARD _POSIX_VDISABLE
  225. # endif /* CDISCARD */
  226. # ifndef CLNEXT
  227. # define CLNEXT _POSIX_VDISABLE
  228. # endif /* CLNEXT */
  229. # ifndef CWERASE
  230. # define CWERASE _POSIX_VDISABLE
  231. # endif /* CWERASE */
  232. #else /* !hpux */
  233. # ifndef CREPRINT
  234. # define CREPRINT TO_CONTROL('r')
  235. # endif /* CREPRINT */
  236. # ifndef CDISCARD
  237. # define CDISCARD TO_CONTROL('o')
  238. # endif /* CDISCARD */
  239. # ifndef CLNEXT
  240. # define CLNEXT TO_CONTROL('v')
  241. # endif /* CLNEXT */
  242. # ifndef CWERASE
  243. # define CWERASE TO_CONTROL('w')
  244. # endif /* CWERASE */
  245. #endif /* hpux */
  246. #ifndef CSTATUS
  247. # define CSTATUS TO_CONTROL('t')
  248. #endif /* CSTATUS */
  249. #ifndef CPAGE
  250. # define CPAGE ' '
  251. #endif /* CPAGE */
  252. #ifndef CPGOFF
  253. # define CPGOFF TO_CONTROL('m')
  254. #endif /* CPGOFF */
  255. #ifndef CKILL2
  256. # define CKILL2 _POSIX_VDISABLE
  257. #endif /* CKILL2 */
  258. #ifndef CBRK
  259. # ifndef masscomp
  260. # define CBRK 0377
  261. # else
  262. # define CBRK '\0'
  263. # endif /* masscomp */
  264. #endif /* CBRK */
  265. #ifndef CMIN
  266. # define CMIN CEOF
  267. #endif /* CMIN */
  268. #ifndef CTIME
  269. # define CTIME CEOL
  270. #endif /* CTIME */
  271. /*
  272. * Fix for sun inconsistency. On termio VSUSP and the rest of the
  273. * ttychars > NCC are defined. So we undefine them.
  274. */
  275. #if defined(TERMIO) || defined(POSIX)
  276. # if defined(POSIX) && defined(NCCS)
  277. # define NUMCC NCCS
  278. # else
  279. # ifdef NCC
  280. # define NUMCC NCC
  281. # endif /* NCC */
  282. # endif /* POSIX && NCCS */
  283. # ifdef NUMCC
  284. # ifdef VINTR
  285. # if NUMCC <= VINTR
  286. # undef VINTR
  287. # endif /* NUMCC <= VINTR */
  288. # endif /* VINTR */
  289. # ifdef VQUIT
  290. # if NUMCC <= VQUIT
  291. # undef VQUIT
  292. # endif /* NUMCC <= VQUIT */
  293. # endif /* VQUIT */
  294. # ifdef VERASE
  295. # if NUMCC <= VERASE
  296. # undef VERASE
  297. # endif /* NUMCC <= VERASE */
  298. # endif /* VERASE */
  299. # ifdef VKILL
  300. # if NUMCC <= VKILL
  301. # undef VKILL
  302. # endif /* NUMCC <= VKILL */
  303. # endif /* VKILL */
  304. # ifdef VEOF
  305. # if NUMCC <= VEOF
  306. # undef VEOF
  307. # endif /* NUMCC <= VEOF */
  308. # endif /* VEOF */
  309. # ifdef VEOL
  310. # if NUMCC <= VEOL
  311. # undef VEOL
  312. # endif /* NUMCC <= VEOL */
  313. # endif /* VEOL */
  314. # ifdef VEOL2
  315. # if NUMCC <= VEOL2
  316. # undef VEOL2
  317. # endif /* NUMCC <= VEOL2 */
  318. # endif /* VEOL2 */
  319. # ifdef VSWTCH
  320. # if NUMCC <= VSWTCH
  321. # undef VSWTCH
  322. # endif /* NUMCC <= VSWTCH */
  323. # endif /* VSWTCH */
  324. # ifdef VDSWTCH
  325. # if NUMCC <= VDSWTCH
  326. # undef VDSWTCH
  327. # endif /* NUMCC <= VDSWTCH */
  328. # endif /* VDSWTCH */
  329. # ifdef VERASE2
  330. # if NUMCC <= VERASE2
  331. # undef VERASE2
  332. # endif /* NUMCC <= VERASE2 */
  333. # endif /* VERASE2 */
  334. # ifdef VSTART
  335. # if NUMCC <= VSTART
  336. # undef VSTART
  337. # endif /* NUMCC <= VSTART */
  338. # endif /* VSTART */
  339. # ifdef VSTOP
  340. # if NUMCC <= VSTOP
  341. # undef VSTOP
  342. # endif /* NUMCC <= VSTOP */
  343. # endif /* VSTOP */
  344. # ifdef VWERASE
  345. # if NUMCC <= VWERASE
  346. # undef VWERASE
  347. # endif /* NUMCC <= VWERASE */
  348. # endif /* VWERASE */
  349. # ifdef VSUSP
  350. # if NUMCC <= VSUSP
  351. # undef VSUSP
  352. # endif /* NUMCC <= VSUSP */
  353. # endif /* VSUSP */
  354. # ifdef VDSUSP
  355. # if NUMCC <= VDSUSP
  356. # undef VDSUSP
  357. # endif /* NUMCC <= VDSUSP */
  358. # endif /* VDSUSP */
  359. # ifdef VREPRINT
  360. # if NUMCC <= VREPRINT
  361. # undef VREPRINT
  362. # endif /* NUMCC <= VREPRINT */
  363. # endif /* VREPRINT */
  364. # ifdef VDISCARD
  365. # if NUMCC <= VDISCARD
  366. # undef VDISCARD
  367. # endif /* NUMCC <= VDISCARD */
  368. # endif /* VDISCARD */
  369. # ifdef VLNEXT
  370. # if NUMCC <= VLNEXT
  371. # undef VLNEXT
  372. # endif /* NUMCC <= VLNEXT */
  373. # endif /* VLNEXT */
  374. # ifdef VSTATUS
  375. # if NUMCC <= VSTATUS
  376. # undef VSTATUS
  377. # endif /* NUMCC <= VSTATUS */
  378. # endif /* VSTATUS */
  379. # ifdef VPAGE
  380. # if NUMCC <= VPAGE
  381. # undef VPAGE
  382. # endif /* NUMCC <= VPAGE */
  383. # endif /* VPAGE */
  384. # ifdef VPGOFF
  385. # if NUMCC <= VPGOFF
  386. # undef VPGOFF
  387. # endif /* NUMCC <= VPGOFF */
  388. # endif /* VPGOFF */
  389. # ifdef VKILL2
  390. # if NUMCC <= VKILL2
  391. # undef VKILL2
  392. # endif /* NUMCC <= VKILL2 */
  393. # endif /* VKILL2 */
  394. # ifdef VBRK
  395. # if NUMCC <= VBRK
  396. # undef VBRK
  397. # endif /* NUMCC <= VBRK */
  398. # endif /* VBRK */
  399. # ifdef VMIN
  400. # if NUMCC <= VMIN
  401. # undef VMIN
  402. # endif /* NUMCC <= VMIN */
  403. # endif /* VMIN */
  404. # ifdef VTIME
  405. # if NUMCC <= VTIME
  406. # undef VTIME
  407. # endif /* NUMCC <= VTIME */
  408. # endif /* VTIME */
  409. # endif /* NUMCC */
  410. #endif /* !POSIX */
  411. /*
  412. * fix for hpux10 inconsistency: it has VWERASE, but TIOCSLTC returns
  413. * EINVAL if one tries to change it
  414. * Also for RH6.2 on the alpha, defined TIOCGLTC, but does not have
  415. * struct ltchars
  416. */
  417. #if (defined(hpux) && defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT)) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__QNXNTO__)
  418. # undef TIOCGLTC /* not really needed */
  419. # undef TIOCSLTC
  420. #endif
  421. #define C_INTR 0
  422. #define C_QUIT 1
  423. #define C_ERASE 2
  424. #define C_KILL 3
  425. #define C_EOF 4
  426. #define C_EOL 5
  427. #define C_EOL2 6
  428. #define C_SWTCH 7
  429. #define C_DSWTCH 8
  430. #define C_ERASE2 9
  431. #define C_START 10
  432. #define C_STOP 11
  433. #define C_WERASE 12
  434. #define C_SUSP 13
  435. #define C_DSUSP 14
  436. #define C_REPRINT 15
  437. #define C_DISCARD 16
  438. #define C_LNEXT 17
  439. #define C_STATUS 18
  440. #define C_PAGE 19
  441. #define C_PGOFF 20
  442. #define C_KILL2 21
  443. #define C_BRK 22
  444. #define C_MIN 23
  445. #define C_TIME 24
  446. #define C_NCC 25
  447. #define C_SH(A) (1 << (A))
  448. /*
  449. * Terminal dependend data structures
  450. */
  451. typedef struct {
  452. #ifdef WINNT_NATIVE
  453. int dummy;
  454. #else /* !WINNT_NATIVE */
  455. # if defined(POSIX) || defined(TERMIO)
  456. # ifdef POSIX
  457. struct termios d_t;
  458. # else
  459. struct termio d_t;
  460. # endif /* POSIX */
  461. # else /* SGTTY */
  462. # ifdef TIOCGETP
  463. struct sgttyb d_t;
  464. # endif /* TIOCGETP */
  465. # ifdef TIOCGETC
  466. struct tchars d_tc;
  467. # endif /* TIOCGETC */
  468. # ifdef TIOCGPAGE
  469. struct ttypagestat d_pc;
  470. # endif /* TIOCGPAGE */
  471. # ifdef TIOCLGET
  472. int d_lb;
  473. # endif /* TIOCLGET */
  474. # endif /* POSIX || TERMIO */
  475. # ifdef TIOCGLTC
  476. struct ltchars d_ltc;
  477. # endif /* TIOCGLTC */
  478. #endif /* WINNT_NATIVE */
  479. } ttydata_t;
  480. #endif /* _h_ed_term */