1 /* Copyright 2014 Clerk Ma
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 void update_terminal(void)
33 void append_char (ASCII_code c)
35 str_pool[pool_ptr] = c;
39 void str_room(int val)
42 if (pool_ptr + val > current_pool_size)
43 str_pool = realloc_str_pool(increment_pool_size);
45 if (pool_ptr + val > current_pool_size)
46 overflow("pool size", current_pool_size - init_pool_ptr);
48 if (pool_ptr + val > pool_size)
49 overflow("pool size", pool_size - init_pool_ptr);
53 void flush_string (void)
56 pool_ptr = str_start[str_ptr];
59 void append_lc_hex (ASCII_code c)
64 append_char(c - 10 + 'a');
68 void print_err (const char * s)
70 if (interaction == error_stop_mode)
77 void prompt_input(const char * s)
83 void tex_help (unsigned int n, ...)
92 va_start(help_arg, n);
94 for (i = n - 1; i > -1; --i)
95 help_line[i] = va_arg(help_arg, char *);
102 if (interaction == error_stop_mode)
103 interaction = scroll_mode;
113 history = error_stop_mode;
117 void free_avail_(halfword p)
126 void node_list_display (integer p)
133 void tail_append_ (pointer val)
139 void check_full_save_stack(void)
141 if (save_ptr > max_save_stack)
143 max_save_stack = save_ptr;
145 #ifdef ALLOCATESAVESTACK
146 if (max_save_stack > current_save_size - 6)
147 save_stack = realloc_save_stack(increment_save_size);
149 if (max_save_stack > current_save_size - 6)
151 overflow("save size", current_save_size);
155 if (max_save_stack > save_size - 6)
157 overflow("save size", save_size);
164 void push_input(void)
166 if (input_ptr > max_in_stack)
168 max_in_stack = input_ptr;
170 #ifdef ALLOCATEINPUTSTACK
171 if (input_ptr == current_stack_size)
172 input_stack = realloc_input_stack(increment_stack_size);
174 if (input_ptr == current_stack_size)
176 overflow("input stack size", current_stack_size);
180 if (input_ptr == stack_size)
182 overflow("input stack size", stack_size);
188 input_stack[input_ptr] = cur_input;
195 cur_input = input_stack[input_ptr];
198 void ensure_dvi_open (void)
200 if (output_file_name == 0)
205 pack_job_name(".dvi");
207 while (!b_open_out(dvi_file))
208 prompt_file_name("file name for output", ".dvi");
210 output_file_name = b_make_name_string(dvi_file);
216 fbyte = getc(tfm_file);
219 void write_dvi(size_t a, size_t b)
221 if (fwrite((char *)&dvi_buf[a], sizeof(dvi_buf[a]),
222 (b - a + 1), dvi_file) != (b - a + 1))
223 FATAL_PERROR("\n! dvi file");
226 void dvi_out_(ASCII_code op)
228 dvi_buf[dvi_ptr] = op;
231 if (dvi_ptr == dvi_limit)
239 movement(cur_h - dvi_h, right1);
248 movement(cur_v - dvi_v, down1);
253 void set_cur_lang (void)
257 else if (language > 255)
263 void print_plus (int i, const char * s)
265 if (page_so_far[i] != 0)
268 print_scaled(page_so_far[i]);