termattr.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* PDCurses */
  2. #include <curspriv.h>
  3. /*man-start**************************************************************
  4. termattr
  5. --------
  6. ### Synopsis
  7. int baudrate(void);
  8. char erasechar(void);
  9. bool has_ic(void);
  10. bool has_il(void);
  11. char killchar(void);
  12. char *longname(void);
  13. chtype termattrs(void);
  14. attr_t term_attrs(void);
  15. char *termname(void);
  16. int erasewchar(wchar_t *ch);
  17. int killwchar(wchar_t *ch);
  18. char wordchar(void);
  19. ### Description
  20. baudrate() is supposed to return the output speed of the terminal. In
  21. PDCurses, it simply returns INT_MAX.
  22. has_ic and has_il() return TRUE. These functions have meaning in some
  23. other implementations of curses.
  24. erasechar() and killchar() return ^H and ^U, respectively -- the
  25. ERASE and KILL characters. In other curses implementations, these may
  26. vary by terminal type. erasewchar() and killwchar() are the wide-
  27. character versions; they take a pointer to a location in which to
  28. store the character, and return OK or ERR.
  29. longname() returns a pointer to a static area containing a verbose
  30. description of the current terminal. The maximum length of the string
  31. is 128 characters. It is defined only after the call to initscr() or
  32. newterm().
  33. termname() returns a pointer to a static area containing a short
  34. description of the current terminal (14 characters).
  35. termattrs() returns a logical OR of all video attributes supported by
  36. the terminal.
  37. wordchar() is a PDCurses extension of the concept behind the
  38. functions erasechar() and killchar(), returning the "delete word"
  39. character, ^W.
  40. ### Portability
  41. X/Open ncurses NetBSD
  42. baudrate Y Y Y
  43. erasechar Y Y Y
  44. has_ic Y Y Y
  45. has_il Y Y Y
  46. killchar Y Y Y
  47. longname Y Y Y
  48. termattrs Y Y Y
  49. termname Y Y Y
  50. erasewchar Y Y Y
  51. killwchar Y Y Y
  52. term_attrs Y Y Y
  53. wordchar - - -
  54. **man-end****************************************************************/
  55. #include <string.h>
  56. #include <limits.h>
  57. int baudrate(void)
  58. {
  59. PDC_LOG(("baudrate() - called\n"));
  60. return INT_MAX;
  61. }
  62. char erasechar(void)
  63. {
  64. PDC_LOG(("erasechar() - called\n"));
  65. return _ECHAR; /* character delete char (^H) */
  66. }
  67. bool has_ic(void)
  68. {
  69. PDC_LOG(("has_ic() - called\n"));
  70. return TRUE;
  71. }
  72. bool has_il(void)
  73. {
  74. PDC_LOG(("has_il() - called\n"));
  75. return TRUE;
  76. }
  77. char killchar(void)
  78. {
  79. PDC_LOG(("killchar() - called\n"));
  80. return _DLCHAR; /* line delete char (^U) */
  81. }
  82. char *longname(void)
  83. {
  84. PDC_LOG(("longname() - called\n"));
  85. return ttytype + 9; /* skip "pdcurses|" */
  86. }
  87. chtype termattrs(void)
  88. {
  89. PDC_LOG(("termattrs() - called\n"));
  90. return SP ? SP->termattrs : (chtype)0;
  91. }
  92. attr_t term_attrs(void)
  93. {
  94. PDC_LOG(("term_attrs() - called\n"));
  95. return SP ? SP->termattrs : (attr_t)0;
  96. }
  97. char *termname(void)
  98. {
  99. static char _termname[14] = "pdcurses";
  100. PDC_LOG(("termname() - called\n"));
  101. return _termname;
  102. }
  103. char wordchar(void)
  104. {
  105. PDC_LOG(("wordchar() - called\n"));
  106. return _DWCHAR; /* word delete char */
  107. }
  108. #ifdef PDC_WIDE
  109. int erasewchar(wchar_t *ch)
  110. {
  111. PDC_LOG(("erasewchar() - called\n"));
  112. if (!ch)
  113. return ERR;
  114. *ch = (wchar_t)_ECHAR;
  115. return OK;
  116. }
  117. int killwchar(wchar_t *ch)
  118. {
  119. PDC_LOG(("killwchar() - called\n"));
  120. if (!ch)
  121. return ERR;
  122. *ch = (wchar_t)_DLCHAR;
  123. return OK;
  124. }
  125. #endif