vt100.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * vt100.h
  3. *
  4. * A simple class representing a vt100 terminal
  5. */
  6. /**
  7. \ingroup tinyrl
  8. \defgroup tinyrl_vt100 vt100
  9. @{
  10. \brief A simple class for controlling and interacting with a VT100 compatible
  11. terminal.
  12. This class has been implemented pragmatically in an as needed fashion, so
  13. doesn't support all the features of a VT100 terminal.
  14. */
  15. #ifndef _tinyrl_vt100_h
  16. #define _tinyrl_vt100_h
  17. #include <stdio.h>
  18. #include <stdarg.h>
  19. #include "lub/c_decl.h"
  20. #include "lub/types.h"
  21. _BEGIN_C_DECL
  22. typedef struct _tinyrl_vt100 tinyrl_vt100_t;
  23. /* define the Key codes */
  24. #define KEY_NUL 0 /**< ^@ Null character */
  25. #define KEY_SOH 1 /**< ^A Start of heading, = console interrupt */
  26. #define KEY_STX 2 /**< ^B Start of text, maintenance mode on HP console */
  27. #define KEY_ETX 3 /**< ^C End of text */
  28. #define KEY_EOT 4 /**< ^D End of transmission, not the same as ETB */
  29. #define KEY_ENQ 5 /**< ^E Enquiry, goes with ACK; old HP flow control */
  30. #define KEY_ACK 6 /**< ^F Acknowledge, clears ENQ logon hand */
  31. #define KEY_BEL 7 /**< ^G Bell, rings the bell... */
  32. #define KEY_BS 8 /**< ^H Backspace, works on HP terminals/computers */
  33. #define KEY_HT 9 /**< ^I Horizontal tab, move to next tab stop */
  34. #define KEY_LF 10 /**< ^J Line Feed */
  35. #define KEY_VT 11 /**< ^K Vertical tab */
  36. #define KEY_FF 12 /**< ^L Form Feed, page eject */
  37. #define KEY_CR 13 /**< ^M Carriage Return*/
  38. #define KEY_SO 14 /**< ^N Shift Out, alternate character set */
  39. #define KEY_SI 15 /**< ^O Shift In, resume defaultn character set */
  40. #define KEY_DLE 16 /**< ^P Data link escape */
  41. #define KEY_DC1 17 /**< ^Q XON, with XOFF to pause listings; "okay to send". */
  42. #define KEY_DC2 18 /**< ^R Device control 2, block-mode flow control */
  43. #define KEY_DC3 19 /**< ^S XOFF, with XON is TERM=18 flow control */
  44. #define KEY_DC4 20 /**< ^T Device control 4 */
  45. #define KEY_NAK 21 /**< ^U Negative acknowledge */
  46. #define KEY_SYN 22 /**< ^V Synchronous idle */
  47. #define KEY_ETB 23 /**< ^W End transmission block, not the same as EOT */
  48. #define KEY_CAN 24 /**< ^X Cancel line, MPE echoes !!! */
  49. #define KEY_EM 25 /**< ^Y End of medium, Control-Y interrupt */
  50. #define KEY_SUB 26 /**< ^Z Substitute */
  51. #define KEY_ESC 27 /**< ^[ Escape, next character is not echoed */
  52. #define KEY_FS 28 /**< ^\ File separator */
  53. #define KEY_GS 29 /**< ^] Group separator */
  54. #define KEY_RS 30 /**< ^^ Record separator, block-mode terminator */
  55. #define KEY_US 31 /**< ^_ Unit separator */
  56. #define KEY_DEL 127 /**< Delete (not a real control character...) */
  57. /**
  58. * This enumeration is used to identify the types of escape code
  59. */
  60. typedef enum
  61. {
  62. tinyrl_vt100_UNKNOWN, /**< Undefined escape sequence */
  63. tinyrl_vt100_CURSOR_UP, /**< Move the cursor up */
  64. tinyrl_vt100_CURSOR_DOWN, /**< Move the cursor down */
  65. tinyrl_vt100_CURSOR_LEFT, /**< Move the cursor left */
  66. tinyrl_vt100_CURSOR_RIGHT /**< Move the cursor right */
  67. } tinyrl_vt100_escape_t;
  68. extern tinyrl_vt100_t *
  69. tinyrl_vt100_new(
  70. FILE *instream,
  71. FILE *outstream
  72. );
  73. extern void
  74. tinyrl_vt100_delete(tinyrl_vt100_t *instance);
  75. /*lint -esym(534,tinyrl_vt100_printf) Ignoring return value of function */
  76. extern int
  77. tinyrl_vt100_printf(
  78. const tinyrl_vt100_t *instance,
  79. const char *fmt,
  80. ...
  81. );
  82. extern int
  83. tinyrl_vt100_vprintf(
  84. const tinyrl_vt100_t *instance,
  85. const char *fmt,
  86. va_list args
  87. );
  88. extern int
  89. tinyrl_vt100_oflush(
  90. const tinyrl_vt100_t *instance
  91. );
  92. extern int
  93. tinyrl_vt100_ierror(
  94. const tinyrl_vt100_t *instance
  95. );
  96. extern int
  97. tinyrl_vt100_oerror(
  98. const tinyrl_vt100_t *instance
  99. );
  100. extern int
  101. tinyrl_vt100_ieof(
  102. const tinyrl_vt100_t *instance
  103. );
  104. extern int
  105. tinyrl_vt100_getchar(
  106. const tinyrl_vt100_t *instance
  107. );
  108. extern unsigned
  109. tinyrl_vt100__get_width(
  110. const tinyrl_vt100_t *instance
  111. );
  112. extern unsigned
  113. tinyrl_vt100__get_height(
  114. const tinyrl_vt100_t *instance
  115. );
  116. extern void
  117. tinyrl_vt100__set_istream(
  118. tinyrl_vt100_t *instance,
  119. FILE *istream
  120. );
  121. extern FILE *
  122. tinyrl_vt100__get_istream(
  123. const tinyrl_vt100_t *instance
  124. );
  125. extern FILE *
  126. tinyrl_vt100__get_ostream(
  127. const tinyrl_vt100_t *instance
  128. );
  129. extern tinyrl_vt100_escape_t
  130. tinyrl_vt100_escape_decode(
  131. const tinyrl_vt100_t *instance
  132. );
  133. extern void
  134. tinyrl_vt100_ding(
  135. const tinyrl_vt100_t *instance
  136. );
  137. extern void
  138. tinyrl_vt100_attribute_reset(
  139. const tinyrl_vt100_t *instance
  140. );
  141. extern void
  142. tinyrl_vt100_attribute_bright(
  143. const tinyrl_vt100_t *instance
  144. );
  145. extern void
  146. tinyrl_vt100_attribute_dim(
  147. const tinyrl_vt100_t *instance
  148. );
  149. extern void
  150. tinyrl_vt100_attribute_underscore(
  151. const tinyrl_vt100_t *instance
  152. );
  153. extern void
  154. tinyrl_vt100_attribute_blink(
  155. const tinyrl_vt100_t *instance
  156. );
  157. extern void
  158. tinyrl_vt100_attribute_reverse(
  159. const tinyrl_vt100_t *instance
  160. );
  161. extern void
  162. tinyrl_vt100_attribute_hidden(
  163. const tinyrl_vt100_t *instance
  164. );
  165. extern void
  166. tinyrl_vt100_erase_line(
  167. const tinyrl_vt100_t *instance
  168. );
  169. extern void
  170. tinyrl_vt100_clear_screen(
  171. const tinyrl_vt100_t *instance
  172. );
  173. extern void
  174. tinyrl_vt100_cursor_back(
  175. const tinyrl_vt100_t *instance,
  176. unsigned count
  177. );
  178. extern void
  179. tinyrl_vt100_cursor_forward(
  180. const tinyrl_vt100_t *instance,
  181. unsigned count
  182. );
  183. extern void
  184. tinyrl_vt100_cursor_up(
  185. const tinyrl_vt100_t *instance,
  186. unsigned count
  187. );
  188. extern void
  189. tinyrl_vt100_cursor_down(
  190. const tinyrl_vt100_t *instance,
  191. unsigned count
  192. );
  193. extern void
  194. tinyrl_vt100_cursor_home(
  195. const tinyrl_vt100_t *instance
  196. );
  197. extern void
  198. tinyrl_vt100_cursor_save(
  199. const tinyrl_vt100_t *instance
  200. );
  201. extern void
  202. tinyrl_vt100_cursor_restore(
  203. const tinyrl_vt100_t *instance
  204. );
  205. extern void
  206. tinyrl_vt100_erase(
  207. const tinyrl_vt100_t *instance,
  208. unsigned count
  209. );
  210. _END_C_DECL
  211. #endif /* _tinyrl_vt100_h */
  212. /** @} tinyrl_vt100 */