texprinting.h /size: 5874 b    last modification: 2025-02-21 11:03
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 // fi_unit,    /* todo */
42 // fil_unit,
43 // fill_unit,
44 // filll_unit,
45 // filll_unit,
46} spec_units;
47
48/*tex
49    Some of these can go away because we stepwise implement usage of |tex_print_format| instead of
50    a multitude of specific calls. It's one of these thing I do when I'm bored.
51
52    todo : check tex_print_ln
53    todo : check tex_print_nl
54    todo : check tex_print_str_nl
55
56*/
57
58extern void        tex_print_ln               (void);   /* always forces a newline */
59extern void        tex_print_char             (int s);
60extern void        tex_print_tex_str          (int s);
61extern void        tex_print_tex_str_esc      (strnumber s);
62extern void        tex_print_nlp              (void);   /* flushes a line if we're doing one */
63extern void        tex_print_banner           (void);
64extern void        tex_print_log_banner       (void);
65extern void        tex_print_version_banner   (void);
66extern void        tex_print_int              (int n);
67extern void        tex_print_hex              (long long n);
68extern void        tex_print_uhex             (long long n);
69extern void        tex_print_qhex             (long long n);
70extern void        tex_print_roman_int        (int n);
71extern void        tex_print_current_string   (void);
72extern void        tex_print_cs_checked       (halfword p);                    /*tex Also does the |IMPOSSIBLE| etc. */
73extern void        tex_print_cs               (halfword p);                    /*tex Only does the undefined case. */
74extern void        tex_print_cs_name          (halfword p);                    /*tex Only prints known ones. */
75extern void        tex_print_str              (const char *s);
76extern void        tex_print_str_esc          (const char *s);
77extern void        tex_print_posit            (halfword d); 
78extern void        tex_print_dimension        (scaled d, int unit);            /*tex prints a dimension with pt */
79extern void        tex_print_sparse_dimension (scaled d, int unit);            /*tex prints a dimension with pt */
80extern void        tex_print_unit             (int unit);                      /*tex prints a glue component */
81extern void        tex_print_glue             (scaled d, int order, int unit); /*tex prints a glue component */
82extern void        tex_print_spec             (int p, int unit);               /*tex prints a glue specification */
83extern void        tex_print_fontspec         (int p);
84extern void        tex_print_mathspec         (int p);
85extern void        tex_print_font_identifier  (halfword f);
86extern void        tex_print_font_specifier   (halfword e);                    /*tex this is an eq table entry */
87extern void        tex_print_font             (halfword f);
88extern void        tex_print_char_identifier  (halfword c);
89extern void        tex_print_token_list       (const char *s, halfword p);     /*tex prints token list data in braces */
90extern void        tex_print_rule_dimension   (scaled d);                      /*tex prints dimension in rule node */
91extern void        tex_print_group            (int e);
92extern void        tex_print_format           (const char *format, ...);       /*tex similar to the one we use for errors */
93extern const char *tex_print_format_args      (const char *format, va_list args);
94extern void        tex_begin_diagnostic       (void);
95extern void        tex_print_levels           (void);
96extern void        tex_end_diagnostic         (void);
97extern void        tex_show_box               (halfword p);
98extern void        tex_short_display          (halfword p);                    /*tex prints highlights of list |p| */                                            
99extern void        tex_print_message          (const char *s);
100
101static inline int tex_single_letter(strnumber s)
102{
103    return (
104          (str_length(s) == 1)
105     || ( (str_length(s) == 4) && *(str_string(s) ) >= 0xF0)
106     || ( (str_length(s) == 3) && *(str_string(s) ) >= 0xE0)
107     || ( (str_length(s) == 2) && *(str_string(s) ) >= 0xC0)
108    );
109}
110
111static inline int tex_is_active_cs(strnumber s)
112{
113    if (s && str_length(s) > 3) {
114        const unsigned char *ss = str_string(s); // or signed and active_character ... 
115        return (ss[0] == active_first) && (ss[1] == active_second) && (ss[2] == active_third);
116    } else {
117        return 0;
118    }
119}
120
121static inline void tex_aux_show_group_count(int n)
122{
123    for (int i = 1; i <= n; i++) {
124        tex_print_str("{}");
125    }
126}
127
128# endif
129