home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / groff / troff / charinfo.h next >
Encoding:
C/C++ Source or Header  |  1991-04-30  |  3.2 KB  |  158 lines

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