175584Sru// -*- C++ -*- 2104862Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002 3104862Sru Free Software Foundation, Inc. 475584Sru Written by James Clark (jjc@jclark.com) 575584Sru 675584SruThis file is part of groff. 775584Sru 875584Srugroff is free software; you can redistribute it and/or modify it under 975584Sruthe terms of the GNU General Public License as published by the Free 1075584SruSoftware Foundation; either version 2, or (at your option) any later 1175584Sruversion. 1275584Sru 1375584Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY 1475584SruWARRANTY; without even the implied warranty of MERCHANTABILITY or 1575584SruFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1675584Srufor more details. 1775584Sru 1875584SruYou should have received a copy of the GNU General Public License along 1975584Sruwith groff; see the file COPYING. If not, write to the Free Software 20151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 2175584Sru 2275584Sruclass macro; 2375584Sru 2475584Sruclass charinfo { 2575584Sru static int next_index; 2675584Sru charinfo *translation; 2775584Sru int index; 2875584Sru int number; 2975584Sru macro *mac; 3075584Sru unsigned char special_translation; 3175584Sru unsigned char hyphenation_code; 3275584Sru unsigned char flags; 3375584Sru unsigned char ascii_code; 34104862Sru unsigned char asciify_code; 3575584Sru char not_found; 36104862Sru char transparent_translate; // non-zero means translation applies 3775584Sru // to transparent throughput 38104862Sru char translate_input; // non-zero means that asciify_code is 39104862Sru // active for .asciify (set by .trin) 40114402Sru char_mode mode; 4175584Srupublic: 4275584Sru enum { 4375584Sru ENDS_SENTENCE = 1, 4475584Sru BREAK_BEFORE = 2, 4575584Sru BREAK_AFTER = 4, 4675584Sru OVERLAPS_HORIZONTALLY = 8, 4775584Sru OVERLAPS_VERTICALLY = 16, 4875584Sru TRANSPARENT = 32, 4975584Sru NUMBERED = 64 50114402Sru }; 5175584Sru enum { 5275584Sru TRANSLATE_NONE, 5375584Sru TRANSLATE_SPACE, 5475584Sru TRANSLATE_DUMMY, 5575584Sru TRANSLATE_STRETCHABLE_SPACE, 5675584Sru TRANSLATE_HYPHEN_INDICATOR 5775584Sru }; 5875584Sru symbol nm; 5975584Sru charinfo(symbol s); 6075584Sru int get_index(); 6175584Sru int ends_sentence(); 6275584Sru int overlaps_vertically(); 6375584Sru int overlaps_horizontally(); 6475584Sru int can_break_before(); 6575584Sru int can_break_after(); 6675584Sru int transparent(); 6775584Sru unsigned char get_hyphenation_code(); 6875584Sru unsigned char get_ascii_code(); 69104862Sru unsigned char get_asciify_code(); 7075584Sru void set_hyphenation_code(unsigned char); 7175584Sru void set_ascii_code(unsigned char); 72104862Sru void set_asciify_code(unsigned char); 73104862Sru void set_translation_input(); 74104862Sru int get_translation_input(); 7575584Sru charinfo *get_translation(int = 0); 76104862Sru void set_translation(charinfo *, int, int); 7775584Sru void set_flags(unsigned char); 7875584Sru void set_special_translation(int, int); 7975584Sru int get_special_translation(int = 0); 80114402Sru macro *set_macro(macro *); 81114402Sru macro *setx_macro(macro *, char_mode); 8275584Sru macro *get_macro(); 8375584Sru int first_time_not_found(); 8475584Sru void set_number(int); 8575584Sru int get_number(); 8675584Sru int numbered(); 87114402Sru int is_normal(); 88104862Sru int is_fallback(); 89114402Sru int is_special(); 9075584Sru symbol *get_symbol(); 9175584Sru}; 9275584Sru 9375584Srucharinfo *get_charinfo(symbol); 9475584Sruextern charinfo *charset_table[]; 9575584Srucharinfo *get_charinfo_by_number(int); 9675584Sru 9775584Sruinline int charinfo::overlaps_horizontally() 9875584Sru{ 9975584Sru return flags & OVERLAPS_HORIZONTALLY; 10075584Sru} 10175584Sru 10275584Sruinline int charinfo::overlaps_vertically() 10375584Sru{ 10475584Sru return flags & OVERLAPS_VERTICALLY; 10575584Sru} 10675584Sru 10775584Sruinline int charinfo::can_break_before() 10875584Sru{ 10975584Sru return flags & BREAK_BEFORE; 11075584Sru} 11175584Sru 11275584Sruinline int charinfo::can_break_after() 11375584Sru{ 11475584Sru return flags & BREAK_AFTER; 11575584Sru} 11675584Sru 11775584Sruinline int charinfo::ends_sentence() 11875584Sru{ 11975584Sru return flags & ENDS_SENTENCE; 12075584Sru} 12175584Sru 12275584Sruinline int charinfo::transparent() 12375584Sru{ 12475584Sru return flags & TRANSPARENT; 12575584Sru} 12675584Sru 12775584Sruinline int charinfo::numbered() 12875584Sru{ 12975584Sru return flags & NUMBERED; 13075584Sru} 13175584Sru 132114402Sruinline int charinfo::is_normal() 133114402Sru{ 134114402Sru return mode == CHAR_NORMAL; 135114402Sru} 136114402Sru 137104862Sruinline int charinfo::is_fallback() 138104862Sru{ 139114402Sru return mode == CHAR_FALLBACK; 140104862Sru} 141104862Sru 142114402Sruinline int charinfo::is_special() 143114402Sru{ 144114402Sru return mode == CHAR_SPECIAL; 145114402Sru} 146114402Sru 14775584Sruinline charinfo *charinfo::get_translation(int transparent_throughput) 14875584Sru{ 14975584Sru return (transparent_throughput && !transparent_translate 15075584Sru ? 0 15175584Sru : translation); 15275584Sru} 15375584Sru 15475584Sruinline unsigned char charinfo::get_hyphenation_code() 15575584Sru{ 15675584Sru return hyphenation_code; 15775584Sru} 15875584Sru 15975584Sruinline unsigned char charinfo::get_ascii_code() 16075584Sru{ 16175584Sru return ascii_code; 16275584Sru} 16375584Sru 164104862Sruinline unsigned char charinfo::get_asciify_code() 165104862Sru{ 166104862Sru return (translate_input ? asciify_code : 0); 167104862Sru} 168104862Sru 16975584Sruinline void charinfo::set_flags(unsigned char c) 17075584Sru{ 17175584Sru flags = c; 17275584Sru} 17375584Sru 17475584Sruinline int charinfo::get_index() 17575584Sru{ 17675584Sru return index; 17775584Sru} 17875584Sru 179104862Sruinline void charinfo::set_translation_input() 180104862Sru{ 181104862Sru translate_input = 1; 182104862Sru} 183104862Sru 184104862Sruinline int charinfo::get_translation_input() 185104862Sru{ 186104862Sru return translate_input; 187104862Sru} 188104862Sru 18975584Sruinline int charinfo::get_special_translation(int transparent_throughput) 19075584Sru{ 19175584Sru return (transparent_throughput && !transparent_translate 19275584Sru ? int(TRANSLATE_NONE) 19375584Sru : special_translation); 19475584Sru} 19575584Sru 19675584Sruinline macro *charinfo::get_macro() 19775584Sru{ 19875584Sru return mac; 19975584Sru} 20075584Sru 20175584Sruinline int charinfo::first_time_not_found() 20275584Sru{ 20375584Sru if (not_found) 20475584Sru return 0; 20575584Sru else { 20675584Sru not_found = 1; 20775584Sru return 1; 20875584Sru } 20975584Sru} 21075584Sru 21175584Sruinline symbol *charinfo::get_symbol() 21275584Sru{ 21375584Sru return( &nm ); 21475584Sru} 215