Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

133 rindas
4.2 KiB

  1. //
  2. // Neercs
  3. //
  4. #if !defined __TERM_TERM_H__
  5. #define __TERM_TERM_H__
  6. #include "term/pty.h"
  7. struct Iso2022Conversion
  8. {
  9. Iso2022Conversion() { Reset(); }
  10. void Reset();
  11. /* cs = coding system/coding method: */
  12. /* (with standard return) */
  13. /* '@' = ISO-2022, */
  14. /* 'G' = UTF-8 without implementation level, */
  15. /* '8' = UTF-8 (Linux console and imitators), */
  16. /* and many others that are rarely used; */
  17. /* (without standard return) */
  18. /* '/G' = UTF-8 Level 1, */
  19. /* '/H' = UTF-8 Level 2, */
  20. /* '/I' = UTF-8 Level 3, */
  21. /* and many others that are rarely used */
  22. uint32_t cs;
  23. /* ctrl8bit = allow 8-bit controls */
  24. uint8_t ctrl8bit;
  25. /* cn[0] = C0 control charset (0x00 ... 0x1f):
  26. * '@' = ISO 646,
  27. * '~' = empty,
  28. * and many others that are rarely used */
  29. /* cn[1] = C1 control charset (0x80 ... 0x9f):
  30. * 'C' = ISO 6429-1983,
  31. * '~' = empty,
  32. * and many others that are rarely used */
  33. uint32_t cn[2];
  34. /* glr[0] = GL graphic charset (94-char. 0x21 ... 0x7e,
  35. * 94x94-char. 0x21/0x21 ... 0x7e/0x7e),
  36. * and
  37. * glr[1] = GR graphic charset (94-char. 0xa1 ... 0xfe,
  38. * 96-char. 0xa0 ... 0xff,
  39. * 94x94-char. 0xa1/0xa1 ... 0xfe/0xfe,
  40. * 96x96-char. 0xa0/0xa0 ... 0xff/0xff):
  41. * 0 = G0, 1 = G1, 2 = G2, 3 = G3 */
  42. uint8_t glr[2];
  43. /* gn[i] = G0/G1/G2/G3 graphic charset state:
  44. * (94-char. sets)
  45. * '0' = DEC ACS (VT100 and imitators),
  46. * 'B' = US-ASCII,
  47. * and many others that are rarely used for e.g. various national ASCII variations;
  48. * (96-char. sets)
  49. * '.A' = ISO 8859-1 "Latin 1" GR,
  50. * '.~' = empty 96-char. set,
  51. * and many others that are rarely used for e.g. ISO 8859-n GR;
  52. * (double-byte 94x94-charsets)
  53. * '$@' = Japanese Character Set ("old JIS") (JIS C 6226:1978),
  54. * '$A' = Chinese Character Set (GB 2312),
  55. * '$B' = Japanese Character Set (JIS X0208/JIS C 6226:1983),
  56. * '$C' = Korean Graphic Character Set (KSC 5601:1987),
  57. * '$D' = Supplementary Japanese Graphic Character Set (JIS X0212),
  58. * '$E' = CCITT Chinese Set (GB 2312 + GB 8565),
  59. * '$G' = CNS 11643 plane 1,
  60. * '$H' = CNS 11643 plane 2,
  61. * '$I' = CNS 11643 plane 3,
  62. * '$J' = CNS 11643 plane 4,
  63. * '$K' = CNS 11643 plane 5,
  64. * '$L' = CNS 11643 plane 6,
  65. * '$M' = CNS 11643 plane 7,
  66. * '$O' = JIS X 0213 plane 1,
  67. * '$P' = JIS X 0213 plane 2,
  68. * '$Q' = JIS X 0213-2004 Plane 1,
  69. * and many others that are rarely used for e.g. traditional
  70. * ideographic Vietnamese and BlissSymbolics;
  71. * (double-byte 96x96-charsets)
  72. * none standardized or in use on terminals AFAIK (Mule does use
  73. * some internally)
  74. */
  75. uint32_t gn[4];
  76. /* ss = single-shift state: 0 = GL, 2 = G2, 3 = G3 */
  77. uint8_t ss;
  78. };
  79. class Term : public Entity
  80. {
  81. public:
  82. Term(ivec2 size);
  83. ~Term();
  84. char const *GetName() { return "<term>"; }
  85. caca_canvas_t *GetCaca() { return m_caca; }
  86. protected:
  87. virtual void TickGame(float seconds);
  88. virtual void TickDraw(float seconds);
  89. private:
  90. /* Terminal emulation main entry point */
  91. size_t ReadAnsi(void const *data, size_t size);
  92. size_t SendAnsi(char const *str);
  93. /* Utility functions for terminal emulation */
  94. void ReadGrcm(unsigned int argc, unsigned int const *argv);
  95. inline int ReadChar(unsigned char c, int *x, int *y);
  96. inline int ReadDuplet(unsigned char const *buffer, unsigned int *skip,
  97. int top, int bottom, int width, int height);
  98. private:
  99. Pty *m_pty;
  100. caca_canvas_t *m_caca;
  101. ivec2 m_size;
  102. /* Terminal attributes */
  103. char *m_title;
  104. int m_bell, m_init, m_report_mouse;
  105. int m_changed; /* content was updated */
  106. Iso2022Conversion m_conv_state; /* charset mess */
  107. uint8_t m_fg, m_bg; /* ANSI-context fg/bg */
  108. uint8_t m_dfg, m_dbg; /* Default fg/bg */
  109. uint8_t m_bold, m_blink, m_italics, m_negative, m_concealed, m_underline;
  110. uint8_t m_faint, m_strike, m_proportional; /* unsupported */
  111. uint32_t m_clearattr;
  112. /* Mostly for fancy shit */
  113. void DrawFancyShit();
  114. float m_time;
  115. };
  116. #endif // __TERM_TERM_H__