patch-term_c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. $OpenBSD: patch-term_c,v 1.2 2013/12/06 16:06:50 jca Exp $
  2. --- term.c.orig Sat Jul 23 01:15:32 2005
  3. +++ term.c Fri Dec 6 03:30:13 2013
  4. @@ -19,6 +19,9 @@
  5. *
  6. */
  7. +#include <curses.h>
  8. +#include <term.h>
  9. +
  10. #include "logo.h"
  11. #include "globals.h"
  12. @@ -30,6 +33,9 @@
  13. #include <console.h>
  14. #endif
  15. +#ifdef HAVE_TERMIOS_H
  16. +#include <termios.h>
  17. +#else
  18. #ifdef HAVE_TERMIO_H
  19. #include <termio.h>
  20. #else
  21. @@ -37,6 +43,7 @@
  22. #include <sgtty.h>
  23. #endif
  24. #endif
  25. +#endif
  26. #undef TRUE
  27. #undef FALSE
  28. @@ -71,6 +78,9 @@ char cm_arr[40];
  29. char so_arr[40];
  30. char se_arr[40];
  31. +#ifdef HAVE_TERMIOS_H
  32. +struct termios tty_cooked, tty_cbreak;
  33. +#else
  34. #ifdef HAVE_TERMIO_H
  35. struct termio tty_cooked, tty_cbreak;
  36. #else
  37. @@ -78,6 +88,7 @@ struct termio tty_cooked, tty_cbreak;
  38. struct sgttyb tty_cooked, tty_cbreak;
  39. #endif
  40. #endif
  41. +#endif
  42. int interactive, tty_charmode;
  43. @@ -85,7 +96,7 @@ extern char **environ, *tgoto(), *tgetstr();
  44. char *termcap_ptr;
  45. -int termcap_putter(char ch) {
  46. +int termcap_putter(int ch) {
  47. *termcap_ptr++ = ch;
  48. return 0;
  49. }
  50. @@ -125,6 +136,13 @@ void term_init(void) {
  51. #endif /* WIN32 */
  52. #else
  53. if (interactive) {
  54. +#ifdef HAVE_TERMIOS_H
  55. + tcgetattr(0, &tty_cooked);
  56. + tty_cbreak = tty_cooked;
  57. + tty_cbreak.c_cc[VMIN] = '\01';
  58. + tty_cbreak.c_cc[VTIME] = '\0';
  59. + tty_cbreak.c_lflag &= ~(ECHO|ICANON);
  60. +#else
  61. #ifdef HAVE_TERMIO_H
  62. ioctl(0,TCGETA,(char *)(&tty_cooked));
  63. tty_cbreak = tty_cooked;
  64. @@ -137,6 +155,7 @@ void term_init(void) {
  65. tty_cbreak.sg_flags |= CBREAK;
  66. tty_cbreak.sg_flags &= ~ECHO;
  67. #endif
  68. +#endif
  69. }
  70. tty_charmode = 0;
  71. tgetent(bp, getenv("TERM"));
  72. @@ -181,11 +200,15 @@ void term_init(void) {
  73. void charmode_on() {
  74. #ifdef unix
  75. if ((readstream == stdin) && interactive && !tty_charmode) {
  76. +#ifdef HAVE_TERMIOS_H
  77. + tcsetattr(0, TCSANOW, &tty_cbreak);
  78. +#else /* !HAVE_TERMIOS_H */
  79. #ifdef HAVE_TERMIO_H
  80. ioctl(0,TCSETA,(char *)(&tty_cbreak));
  81. #else /* !HAVE_TERMIO_H */
  82. ioctl(0,TIOCSETP,(char *)(&tty_cbreak));
  83. #endif /* HAVE_TERMIO_H */
  84. +#endif /* HAVE_TERMIOS_H */
  85. tty_charmode++;
  86. }
  87. #endif /* unix */
  88. @@ -197,11 +220,15 @@ void charmode_on() {
  89. void charmode_off() {
  90. #ifdef unix
  91. if (tty_charmode) {
  92. +#ifdef HAVE_TERMIOS_H
  93. + tcsetattr(0, TCSANOW, &tty_cooked);
  94. +#else /* !HAVE_TERMIOS_H */
  95. #ifdef HAVE_TERMIO_H
  96. ioctl(0,TCSETA,(char *)(&tty_cooked));
  97. #else /* !HAVE_TERMIO_H */
  98. ioctl(0,TIOCSETP,(char *)(&tty_cooked));
  99. #endif /* HAVE_TERMIO_H */
  100. +#endif /* HAVE_TERMIOS_H */
  101. tty_charmode = 0;
  102. }
  103. #endif /* unix */