2 * High level routines dealing with the output to the screen.
7 public int errmsgs; /* Count of messages displayed by error() */
12 extern int so_s_width, so_e_width;
13 extern int screen_trashed;
14 extern int any_display;
16 extern int output_mode;
20 * Display the line which is in the line buffer.
33 * Don't output if a signal is pending.
41 for (i = 0; (c = gline(i, &a)) != '\0'; i++)
46 * Changing attributes.
47 * Display the exit sequence for the old attribute
48 * and the enter sequence for the new one.
52 case UNDERLINE: ul_exit(); break;
53 case BOLD: bo_exit(); break;
54 case BLINK: bl_exit(); break;
58 case UNDERLINE: ul_enter(); break;
59 case BOLD: bo_enter(); break;
60 case BLINK: bl_enter(); break;
64 if (curr_attr == INVIS)
73 static char obuf[1024];
74 static char *ob = obuf;
77 * Flush buffered output.
79 * If we haven't displayed any file data yet,
80 * output messages on error output (file descriptor 2),
81 * otherwise output on standard output (file descriptor 1).
83 * This has the desirable effect of producing all
84 * error messages on error output if standard output
85 * is directed to a file. It also does the same if
86 * we never produce any real output; for example, if
87 * the input file(s) cannot be opened. If we do
88 * eventually produce output, code in edit() makes
89 * sure these messages can be seen before they are
90 * overwritten or scrolled away.
110 fd = (any_display) ? 1 : 2;
111 if (write(fd, obuf, n) != n)
117 * Output a character.
123 if (ob >= &obuf[sizeof(obuf)])
151 * Output an integer in a given radix.
154 iprintnum(num, radix)
169 *s++ = (num % radix) + '0';
170 } while ((num /= radix) != 0);
182 * This function implements printf-like functionality
183 * using a more portable argument list mechanism than printf's.
217 col += iprintnum(n, 10);
226 * Output a message in the lower left corner of the screen
227 * and wait for carriage return.
236 static char return_to_continue[] = " (press RETURN)";
248 col += iprintf(fmt, parg);
256 putstr(return_to_continue);
258 col += sizeof(return_to_continue) + so_e_width;
261 while ((c = getchr()) != '\n' && c != '\r')
265 if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR)
272 * Printing the message has probably scrolled the screen.
273 * {{ Unless the terminal doesn't have auto margins,
274 * in which case we just hammered on the right margin. }}
281 static char intr_to_abort[] = "... (interrupt to abort)";
284 * Output a message in the lower left corner of the screen
285 * and don't wait for carriage return.
286 * Usually used to warn that we are beginning a potentially
287 * time-consuming operation.
297 (void) iprintf(fmt, parg);
298 putstr(intr_to_abort);
305 * Output a message in the lower left corner of the screen
306 * and return a single-character response.
322 (void) iprintf(fmt, parg);