/contrib/groff/src/roff/troff/charinfo.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 214 lines · 167 code · 25 blank · 22 comment · 7 complexity · f4f10be412d558c29d924787bad0994d MD5 · raw file

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
  3. Free Software Foundation, Inc.
  4. Written by James Clark (jjc@jclark.com)
  5. This file is part of groff.
  6. groff is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 2, or (at your option) any later
  9. version.
  10. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with groff; see the file COPYING. If not, write to the Free Software
  16. Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
  17. class macro;
  18. class charinfo {
  19. static int next_index;
  20. charinfo *translation;
  21. int index;
  22. int number;
  23. macro *mac;
  24. unsigned char special_translation;
  25. unsigned char hyphenation_code;
  26. unsigned char flags;
  27. unsigned char ascii_code;
  28. unsigned char asciify_code;
  29. char not_found;
  30. char transparent_translate; // non-zero means translation applies
  31. // to transparent throughput
  32. char translate_input; // non-zero means that asciify_code is
  33. // active for .asciify (set by .trin)
  34. char_mode mode;
  35. public:
  36. enum {
  37. ENDS_SENTENCE = 1,
  38. BREAK_BEFORE = 2,
  39. BREAK_AFTER = 4,
  40. OVERLAPS_HORIZONTALLY = 8,
  41. OVERLAPS_VERTICALLY = 16,
  42. TRANSPARENT = 32,
  43. NUMBERED = 64
  44. };
  45. enum {
  46. TRANSLATE_NONE,
  47. TRANSLATE_SPACE,
  48. TRANSLATE_DUMMY,
  49. TRANSLATE_STRETCHABLE_SPACE,
  50. TRANSLATE_HYPHEN_INDICATOR
  51. };
  52. symbol nm;
  53. charinfo(symbol s);
  54. int get_index();
  55. int ends_sentence();
  56. int overlaps_vertically();
  57. int overlaps_horizontally();
  58. int can_break_before();
  59. int can_break_after();
  60. int transparent();
  61. unsigned char get_hyphenation_code();
  62. unsigned char get_ascii_code();
  63. unsigned char get_asciify_code();
  64. void set_hyphenation_code(unsigned char);
  65. void set_ascii_code(unsigned char);
  66. void set_asciify_code(unsigned char);
  67. void set_translation_input();
  68. int get_translation_input();
  69. charinfo *get_translation(int = 0);
  70. void set_translation(charinfo *, int, int);
  71. void set_flags(unsigned char);
  72. void set_special_translation(int, int);
  73. int get_special_translation(int = 0);
  74. macro *set_macro(macro *);
  75. macro *setx_macro(macro *, char_mode);
  76. macro *get_macro();
  77. int first_time_not_found();
  78. void set_number(int);
  79. int get_number();
  80. int numbered();
  81. int is_normal();
  82. int is_fallback();
  83. int is_special();
  84. symbol *get_symbol();
  85. };
  86. charinfo *get_charinfo(symbol);
  87. extern charinfo *charset_table[];
  88. charinfo *get_charinfo_by_number(int);
  89. inline int charinfo::overlaps_horizontally()
  90. {
  91. return flags & OVERLAPS_HORIZONTALLY;
  92. }
  93. inline int charinfo::overlaps_vertically()
  94. {
  95. return flags & OVERLAPS_VERTICALLY;
  96. }
  97. inline int charinfo::can_break_before()
  98. {
  99. return flags & BREAK_BEFORE;
  100. }
  101. inline int charinfo::can_break_after()
  102. {
  103. return flags & BREAK_AFTER;
  104. }
  105. inline int charinfo::ends_sentence()
  106. {
  107. return flags & ENDS_SENTENCE;
  108. }
  109. inline int charinfo::transparent()
  110. {
  111. return flags & TRANSPARENT;
  112. }
  113. inline int charinfo::numbered()
  114. {
  115. return flags & NUMBERED;
  116. }
  117. inline int charinfo::is_normal()
  118. {
  119. return mode == CHAR_NORMAL;
  120. }
  121. inline int charinfo::is_fallback()
  122. {
  123. return mode == CHAR_FALLBACK;
  124. }
  125. inline int charinfo::is_special()
  126. {
  127. return mode == CHAR_SPECIAL;
  128. }
  129. inline charinfo *charinfo::get_translation(int transparent_throughput)
  130. {
  131. return (transparent_throughput && !transparent_translate
  132. ? 0
  133. : translation);
  134. }
  135. inline unsigned char charinfo::get_hyphenation_code()
  136. {
  137. return hyphenation_code;
  138. }
  139. inline unsigned char charinfo::get_ascii_code()
  140. {
  141. return ascii_code;
  142. }
  143. inline unsigned char charinfo::get_asciify_code()
  144. {
  145. return (translate_input ? asciify_code : 0);
  146. }
  147. inline void charinfo::set_flags(unsigned char c)
  148. {
  149. flags = c;
  150. }
  151. inline int charinfo::get_index()
  152. {
  153. return index;
  154. }
  155. inline void charinfo::set_translation_input()
  156. {
  157. translate_input = 1;
  158. }
  159. inline int charinfo::get_translation_input()
  160. {
  161. return translate_input;
  162. }
  163. inline int charinfo::get_special_translation(int transparent_throughput)
  164. {
  165. return (transparent_throughput && !transparent_translate
  166. ? int(TRANSLATE_NONE)
  167. : special_translation);
  168. }
  169. inline macro *charinfo::get_macro()
  170. {
  171. return mac;
  172. }
  173. inline int charinfo::first_time_not_found()
  174. {
  175. if (not_found)
  176. return 0;
  177. else {
  178. not_found = 1;
  179. return 1;
  180. }
  181. }
  182. inline symbol *charinfo::get_symbol()
  183. {
  184. return( &nm );
  185. }