2 * Copyright (c) 1988 Mark Nudleman
3 * Copyright (c) 1988, 1993
4 * The Regents of the University of California. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the University of
17 * California, Berkeley and its contributors.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 static char sccsid[] = "@(#)output.c 8.1 (Berkeley) 6/6/93";
40 * High level routines dealing with the output to the screen.
46 int errmsgs; /* Count of messages displayed by error() */
49 extern int sc_width, sc_height;
50 extern int ul_width, ue_width;
51 extern int so_width, se_width;
52 extern int bo_width, be_width;
54 extern int screen_trashed;
55 extern int any_display;
58 /* display the line which is in the line buffer. */
64 extern int auto_wrap, ignaw;
69 * Don't output if a signal is pending.
79 for (p = line; *p != '\0'; p++)
85 column += ul_width +1;
93 column += bo_width +1;
104 } while ((column % tabstop) != 0);
114 * Control characters arrive here as the
115 * normal character [CARAT_CHAR(c)] with
116 * the 0200 bit set. See pappend().
128 if (column < sc_width || !auto_wrap || ignaw)
132 static char obuf[1024];
133 static char *ob = obuf;
136 * Flush buffered output.
145 if (write(1, obuf, n) != n)
151 * Purge any pending output.
160 * Output a character.
165 if (ob >= &obuf[sizeof(obuf)])
181 static char return_to_continue[] = "(press RETURN)";
184 * Output a message in the lower left corner of the screen
185 * and wait for carriage return.
195 * Nothing has been displayed yet. Output this message on
196 * error output (file descriptor 2) and don't wait for a
197 * keystroke to continue.
199 * This has the desirable effect of producing all error
200 * messages on error output if standard output is directed
201 * to a file. It also does the same if we never produce
202 * any real output; for example, if the input file(s) cannot
203 * be opened. If we do eventually produce output, code in
204 * edit() makes sure these messages can be seen before they
205 * are overwritten or scrolled away.
207 (void)write(2, s, strlen(s));
208 (void)write(2, "\n", 1);
219 putstr(return_to_continue);
222 if ((ch = getchr()) != '\n') {
229 if (strlen(s) + sizeof(return_to_continue) +
230 so_width + se_width + 1 > sc_width)
232 * Printing the message has probably scrolled the screen.
233 * {{ Unless the terminal doesn't have auto margins,
234 * in which case we just hammered on the right margin. }}
240 static char intr_to_abort[] = "... (interrupt to abort)";
249 putstr(intr_to_abort);