texprinting.h /size: 5660 b    last modification: 2024-01-16 10:22
1/*
2    See license.txt in the root of this project.
3*/
4
5# ifndef LMT_PRINTING_H
6# define LMT_PRINTING_H
7
8typedef enum selector_settings {
9    no_print_selector_code,             /*tex |selector| setting that makes data disappear */
10    terminal_selector_code,             /*tex printing is destined for the terminal only */
11    logfile_selector_code,              /*tex printing is destined for the transcript file only */
12    terminal_and_logfile_selector_code, /*tex normal |selector| setting */
13    pseudo_selector_code,               /*tex special |selector| setting for |show_context| */
14    new_string_selector_code,           /*tex printing is deflected to the string pool */
15    luabuffer_selector_code,
16} selector_settings;
17
18typedef struct print_state_info {
19    FILE          *logfile;
20    char          *loggable_info;
21    int            selector;
22    int            terminal_offset;
23    int            logfile_offset;
24    int            new_string_line;
25    int            tally;
26    unsigned char  trick_buffer[max_error_line + 1]; /* padded */
27    int            trick_count;
28    int            first_count;
29    int            saved_selector;
30    int            font_in_short_display; /*tex an internal font number */
31    FILE          *saved_logfile;
32    int            saved_logfile_offset;
33} print_state_info;
34
35extern print_state_info lmt_print_state;
36
37typedef enum spec_units {
38    no_unit,
39    pt_unit,
40    mu_unit,
41} spec_units;
42
43/*tex
44    Some of these can go away because we stepwise implement usage of |tex_print_format| instead of
45    a multitude of specific calls. It's one of these thing I do when I'm bored.
46
47    todo : check tex_print_ln
48    todo : check tex_print_nl
49    todo : check tex_print_str_nl
50
51*/
52
53extern void        tex_print_ln               (void);   /* always forces a newline */
54extern void        tex_print_char             (int s);
55extern void        tex_print_tex_str          (int s);
56extern void        tex_print_tex_str_esc      (strnumber s);
57extern void        tex_print_nlp              (void);   /* flushes a line if we're doing one */
58extern void        tex_print_banner           (void);
59extern void        tex_print_log_banner       (void);
60extern void        tex_print_version_banner   (void);
61extern void        tex_print_int              (int n);
62extern void        tex_print_hex              (long long n);
63extern void        tex_print_uhex             (long long n);
64extern void        tex_print_qhex             (long long n);
65extern void        tex_print_roman_int        (int n);
66extern void        tex_print_current_string   (void);
67extern void        tex_print_cs_checked       (halfword p);                    /*tex Also does the |IMPOSSIBLE| etc. */
68extern void        tex_print_cs               (halfword p);                    /*tex Only does the undefined case. */
69extern void        tex_print_cs_name          (halfword p);                    /*tex Only prints known ones. */
70extern void        tex_print_str              (const char *s);
71extern void        tex_print_str_esc          (const char *s);
72extern void        tex_print_posit            (halfword d); 
73extern void        tex_print_dimension        (scaled d, int unit);            /*tex prints a dimension with pt */
74extern void        tex_print_sparse_dimension (scaled d, int unit);            /*tex prints a dimension with pt */
75extern void        tex_print_unit             (int unit);                      /*tex prints a glue component */
76extern void        tex_print_glue             (scaled d, int order, int unit); /*tex prints a glue component */
77extern void        tex_print_spec             (int p, int unit);               /*tex prints a glue specification */
78extern void        tex_print_fontspec         (int p);
79extern void        tex_print_mathspec         (int p);
80extern void        tex_print_font_identifier  (halfword f);
81extern void        tex_print_font_specifier   (halfword e);                    /*tex this is an eq table entry */
82extern void        tex_print_font             (halfword f);
83extern void        tex_print_char_identifier  (halfword c);
84extern void        tex_print_token_list       (const char *s, halfword p);     /*tex prints token list data in braces */
85extern void        tex_print_rule_dimension   (scaled d);                      /*tex prints dimension in rule node */
86extern void        tex_print_group            (int e);
87extern void        tex_print_format           (const char *format, ...);       /*tex similar to the one we use for errors */
88extern const char *tex_print_format_args      (const char *format, va_list args);
89extern void        tex_begin_diagnostic       (void);
90extern void        tex_print_levels           (void);
91extern void        tex_end_diagnostic         (void);
92extern void        tex_show_box               (halfword p);
93extern void        tex_short_display          (halfword p);                    /*tex prints highlights of list |p| */                                            
94extern void        tex_print_message          (const char *s);
95
96static inline int tex_single_letter(strnumber s)
97{
98    return (
99          (str_length(s) == 1)
100     || ( (str_length(s) == 4) && *(str_string(s) ) >= 0xF0)
101     || ( (str_length(s) == 3) && *(str_string(s) ) >= 0xE0)
102     || ( (str_length(s) == 2) && *(str_string(s) ) >= 0xC0)
103    );
104}
105
106static inline int tex_is_active_cs(strnumber s)
107{
108    if (s && str_length(s) > 3) {
109        const unsigned char *ss = str_string(s); // or signed and active_character ... 
110        return (ss[0] == active_first) && (ss[1] == active_second) && (ss[2] == active_third);
111    } else {
112        return 0;
113    }
114}
115
116# endif
117