add svi_column so svi can return sc_col to vi/v_ntext.c
[nvi.git] / vi / vs_refresh.c
blobc36f2e6035dec1660f8b2dae46caa5e824beaf42
1 /*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char sccsid[] = "$Id: vs_refresh.c,v 8.33 1993/11/19 10:55:44 bostic Exp $ (Berkeley) $Date: 1993/11/19 10:55:44 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include <ctype.h>
15 #include <curses.h>
16 #include <stdlib.h>
17 #include <string.h>
19 #include "vi.h"
20 #include "svi_screen.h"
21 #include "sex/sex_screen.h"
23 static int svi_modeline __P((SCR *, EXF *));
24 static int svi_msgflush __P((SCR *));
26 int
27 svi_refresh(sp, ep)
28 SCR *sp;
29 EXF *ep;
31 SCR *tsp;
34 * 1: Resize the screen.
36 * Notice that a resize is requested, and set up everything so that
37 * the file gets reinitialized. Done here, instead of in the vi loop
38 * because there may be other initialization that other screens need
39 * to do. The actual changing of the row/column values was done by
40 * calling the ex options code which put them into the environment,
41 * which is used by curses. Stupid, but ugly.
43 if (F_ISSET(sp, S_RESIZE)) {
44 /* Reinitialize curses. */
45 if (svi_curses_end(sp) || svi_curses_init(sp))
46 return (1);
48 /* Lose any svi_screens() cached information. */
49 SVP(sp)->ss_lno = OOBLNO;
52 * Fill the map, incidentally losing any svi_line()
53 * cached information.
55 if (sp->s_fill(sp, ep, sp->lno, P_FILL))
56 return (1);
57 F_CLR(sp, S_RESIZE | S_REFORMAT);
58 F_SET(sp, S_REDRAW);
62 * 2: Refresh related screens.
64 * If related screens share a view into a file, they may have been
65 * modified as well. Refresh them if the dirty bit is set.
67 for (tsp = sp->gp->dq.cqh_first;
68 tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
69 if (sp != tsp &&
70 (F_ISSET(tsp, S_REDRAW | S_REFORMAT | S_REFRESH) ||
71 tsp->ep == ep && F_ISSET(SVP(tsp), SVI_SCREENDIRTY))) {
72 (void)svi_paint(tsp, tsp->ep);
73 F_CLR(SVP(tsp), SVI_SCREENDIRTY);
77 * 3: Refresh the current screen.
79 * Always refresh the current screen, it may be a cursor movement.
80 * Also, always do it last -- that way, S_REFRESH can be set in
81 * the current screen only, and the screen won't flash.
83 F_CLR(sp, SVI_SCREENDIRTY);
84 return (svi_paint(sp, ep));
88 * svi_paint --
89 * This is the guts of the vi curses screen code. The idea is that
90 * the SCR structure passed in contains the new coordinates of the
91 * screen. What makes this hard is that we don't know how big
92 * characters are, doing input can put the cursor in illegal places,
93 * and we're frantically trying to avoid repainting unless it's
94 * absolutely necessary. If you change this code, you'd better know
95 * what you're doing. It's subtle and quick to anger.
97 int
98 svi_paint(sp, ep)
99 SCR *sp;
100 EXF *ep;
102 CHNAME const *cname;
103 SMAP *smp, tmp;
104 recno_t lastline, lcnt;
105 size_t cwtotal, cnt, len, x, y;
106 int ch;
107 char *p;
109 #define LNO sp->lno
110 #define OLNO sp->olno
111 #define CNO sp->cno
112 #define OCNO sp->ocno
113 #define SCNO sp->sc_col
116 * 1: Reformat the lines.
118 * If the lines themselves have changed (:set list, for example),
119 * fill in the map from scratch. Adjust the screen that's being
120 * displayed if the leftright flag is set.
122 if (F_ISSET(sp, S_REFORMAT)) {
123 /* Toss svi_screens() cached information. */
124 SVP(sp)->ss_lno = OOBLNO;
126 /* Toss svi_line() cached information. */
127 if (svi_sm_fill(sp, ep, HMAP->lno, P_TOP))
128 return (1);
129 if (O_ISSET(sp, O_LEFTRIGHT) &&
130 (cnt = svi_screens(sp, ep, LNO, &CNO)) != 1)
131 for (smp = HMAP; smp <= TMAP; ++smp)
132 smp->off = cnt;
133 F_CLR(sp, S_REFORMAT);
134 F_SET(sp, S_REDRAW);
138 * 2: Line movement.
140 * Line changes can cause the top line to change as well. As
141 * before, if the movement is large, the screen is repainted.
143 * 2a: Tiny screens.
145 * Tiny screens cannot be permitted into the "scrolling" parts of
146 * the smap code for two reasons. If the screen size is 1 line,
147 * HMAP == TMAP and the code will quickly drop core. If the screen
148 * size is 2, none of the divisions by 2 will work, and scrolling
149 * won't work. In fact, because no line change will be less than
150 * HALFTEXT(sp), we always ending up "filling" the map, with a
151 * P_MIDDLE flag, which isn't what the user wanted. Tiny screens
152 * can go into the "fill" portions of the smap code, however.
154 if (sp->t_rows <= 2) {
155 if (LNO < HMAP->lno) {
156 if (svi_sm_fill(sp, ep, LNO, P_TOP))
157 return (1);
158 } else if (LNO > TMAP->lno)
159 if (svi_sm_fill(sp, ep, LNO, P_BOTTOM))
160 return (1);
161 if (sp->t_rows == 1) {
162 HMAP->off = svi_screens(sp, ep, LNO, &CNO);
163 goto paint;
165 F_SET(sp, S_REDRAW);
166 goto adjust;
170 * 2b: Small screens.
172 * Users can use the window, w300, w1200 and w9600 options to make
173 * the screen artificially small. The behavior of these options
174 * in the historic vi wasn't all that consistent, and, in fact, it
175 * was never documented how various screen movements affected the
176 * screen size. Generally, one of three things would happen:
177 * 1: The screen would expand in size, showing the line
178 * 2: The screen would scroll, showing the line
179 * 3: The screen would compress to its smallest size and
180 * repaint.
181 * In general, scrolling didn't cause compression (200^D was handled
182 * the same as ^D), movement to a specific line would (:N where N
183 * was 1 line below the screen caused a screen compress), and cursor
184 * movement would scroll if it was 11 lines or less, and compress if
185 * it was more than 11 lines. (And, no, I have no idea where the 11
186 * comes from.)
188 * What we do is try and figure out if the line is less than half of
189 * a full screen away. If it is, we expand the screen if there's
190 * room, and then scroll as necessary. The alternative is to compress
191 * and repaint.
193 * !!!
194 * This code is a special case from beginning to end. Unfortunately,
195 * home modems are still slow enough that it's worth having.
197 * XXX
198 * If the line a really long one, i.e. part of the line is on the
199 * screen but the column offset is not, we'll end up in the adjust
200 * code, when we should probably have compressed the screen.
202 if (ISSMALLSCREEN(sp))
203 if (LNO < HMAP->lno) {
204 lcnt = svi_sm_nlines(sp, ep, HMAP, LNO, sp->t_maxrows);
205 if (lcnt <= HALFSCREEN(sp))
206 for (; lcnt && sp->t_rows != sp->t_maxrows;
207 --lcnt, ++sp->t_rows) {
208 ++TMAP;
209 if (svi_sm_1down(sp, ep))
210 return (1);
212 else
213 goto small_fill;
214 } else if (LNO > TMAP->lno) {
215 lcnt = svi_sm_nlines(sp, ep, TMAP, LNO, sp->t_maxrows);
216 if (lcnt <= HALFSCREEN(sp))
217 for (; lcnt && sp->t_rows != sp->t_maxrows;
218 --lcnt, ++sp->t_rows) {
219 if (svi_sm_next(sp, ep, TMAP, TMAP + 1))
220 return (1);
221 ++TMAP;
222 if (svi_line(sp, ep, TMAP, NULL, NULL))
223 return (1);
225 else {
226 small_fill: MOVE(sp, INFOLINE(sp), 0);
227 clrtoeol();
228 for (; sp->t_rows > sp->t_minrows;
229 --sp->t_rows, --TMAP) {
230 MOVE(sp, TMAP - HMAP, 0);
231 clrtoeol();
233 if (svi_sm_fill(sp, ep, LNO, P_FILL))
234 return (1);
235 F_SET(sp, S_REDRAW);
236 goto adjust;
241 * 3a: Line down.
243 if (LNO >= HMAP->lno) {
244 if (LNO <= TMAP->lno)
245 goto adjust;
248 * If less than half a screen away, scroll down until the
249 * line is on the screen.
251 lcnt = svi_sm_nlines(sp, ep, TMAP, LNO, HALFTEXT(sp));
252 if (lcnt < HALFTEXT(sp)) {
253 while (lcnt--)
254 if (svi_sm_1up(sp, ep))
255 return (1);
256 goto adjust;
260 * If less than a full screen from the bottom of the file, put
261 * the last line of the file on the bottom of the screen. The
262 * calculation is safe because we know there's at least one
263 * full screen of lines, otherwise couldn't have gotten here.
265 if (file_lline(sp, ep, &lastline))
266 return (1);
267 tmp.lno = LNO;
268 tmp.off = 1;
269 lcnt = svi_sm_nlines(sp, ep, &tmp, lastline, sp->t_rows);
270 if (lcnt < sp->t_rows) {
271 if (svi_sm_fill(sp, ep, lastline, P_BOTTOM))
272 return (1);
273 F_SET(sp, S_REDRAW);
274 goto adjust;
278 * If more than a full screen from the last line of the file,
279 * put the new line in the middle of the screen.
281 goto middle;
285 * 3b: Line up.
287 * If less than half a screen away, scroll up until the line is
288 * the first line on the screen.
290 lcnt = svi_sm_nlines(sp, ep, HMAP, LNO, HALFTEXT(sp));
291 if (lcnt < HALFTEXT(sp)) {
292 while (lcnt--)
293 if (svi_sm_1down(sp, ep))
294 return (1);
295 goto adjust;
299 * If less than half a screen from the top of the file, put the first
300 * line of the file at the top of the screen. Otherwise, put the line
301 * in the middle of the screen.
303 tmp.lno = 1;
304 tmp.off = 1;
305 lcnt = svi_sm_nlines(sp, ep, &tmp, LNO, HALFTEXT(sp));
306 if (lcnt < HALFTEXT(sp)) {
307 if (svi_sm_fill(sp, ep, 1, P_TOP))
308 return (1);
309 } else
310 middle: if (svi_sm_fill(sp, ep, LNO, P_MIDDLE))
311 return (1);
312 F_SET(sp, S_REDRAW);
315 * At this point we know part of the line is on the screen. Since
316 * scrolling is done using logical lines, not physical, all of the
317 * line may not be on the screen. While that's not necessarily bad,
318 * if the part the cursor is on isn't there, we're going to lose.
319 * This can be tricky; if the line covers the entire screen, lno
320 * may be the same as both ends of the map, that's why we test BOTH
321 * the top and the bottom of the map. This isn't a problem for
322 * left-right scrolling, the cursor movement code handles the problem.
324 * There's a performance issue here if editing *really* long lines.
325 * This gets to the right spot by scrolling, and, in a binary, by
326 * scrolling hundreds of lines. If the adjustment looks like it's
327 * going to be a serious problem, refill the screen and repaint.
329 adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
330 (LNO == HMAP->lno || LNO == TMAP->lno)) {
331 cnt = svi_screens(sp, ep, LNO, &CNO);
332 if (LNO == HMAP->lno && cnt < HMAP->off)
333 if ((HMAP->off - cnt) > HALFTEXT(sp)) {
334 HMAP->off = cnt;
335 svi_sm_fill(sp, ep, OOBLNO, P_TOP);
336 F_SET(sp, S_REDRAW);
337 } else
338 while (cnt < HMAP->off)
339 if (svi_sm_1down(sp, ep))
340 return (1);
341 if (LNO == TMAP->lno && cnt > TMAP->off)
342 if ((cnt - TMAP->off) > HALFTEXT(sp)) {
343 TMAP->off = cnt;
344 svi_sm_fill(sp, ep, OOBLNO, P_BOTTOM);
345 F_SET(sp, S_REDRAW);
346 } else
347 while (cnt > TMAP->off)
348 if (svi_sm_1up(sp, ep))
349 return (1);
352 /* If the screen needs to be repainted, skip cursor optimization. */
353 if (F_ISSET(sp, S_REDRAW))
354 goto paint;
357 * 4: Cursor movements.
359 * Decide cursor position. If the line has changed, the cursor has
360 * moved over a tab, or don't know where the cursor was, reparse the
361 * line. Note, if we think that the cursor "hasn't moved", reparse
362 * the line. This is 'cause if it hasn't moved, we've almost always
363 * lost track of it.
365 * Otherwise, we've just moved over fixed-width characters, and can
366 * calculate the left/right scrolling and cursor movement without
367 * reparsing the line. Note that we don't know which (if any) of
368 * the characters between the old and new cursor positions changed.
370 * XXX
371 * With some work, it should be possible to handle tabs quickly, at
372 * least in obvious situations, like moving right and encountering
373 * a tab, without reparsing the whole line.
376 /* If the line we're working with has changed, reparse. */
377 if (F_ISSET(SVP(sp), SVI_CUR_INVALID) || LNO != OLNO) {
378 F_CLR(SVP(sp), SVI_CUR_INVALID);
379 goto slow;
382 /* Otherwise, if nothing's changed, go fast. */
383 if (CNO == OCNO)
384 goto fast;
387 * Get the current line. If this fails, we either have an empty
388 * file and can just repaint, or there's a real problem. This
389 * isn't a performance issue because there aren't any ways to get
390 * here repeatedly.
392 if ((p = file_gline(sp, ep, LNO, &len)) == NULL) {
393 if (file_lline(sp, ep, &lastline))
394 return (1);
395 if (lastline == 0)
396 goto slow;
397 GETLINE_ERR(sp, LNO);
398 return (1);
401 #ifdef DEBUG
402 /* This is just a test. */
403 if (CNO >= len && len != 0) {
404 msgq(sp, M_ERR, "Error: %s/%d: cno (%u) >= len (%u)",
405 tail(__FILE__), __LINE__, CNO, len);
406 return (1);
408 #endif
410 * The basic scheme here is to look at the characters in between
411 * the old and new positions and decide how big they are on the
412 * screen, and therefore, how many screen positions to move.
414 cname = sp->cname;
415 if (CNO < OCNO) {
417 * 4a: Cursor moved left.
419 * Point to the old character. The old cursor position can
420 * be past EOL if, for example, we just deleted the rest of
421 * the line. In this case, since we don't know the width of
422 * the characters we traversed, we have to do it slowly.
424 p += OCNO;
425 cnt = (OCNO - CNO) + 1;
426 if (OCNO >= len)
427 goto slow;
430 * Quit sanity check -- it's hard to figure out exactly when
431 * we cross a screen boundary as we do in the cursor right
432 * movement. If cnt is so large that we're going to cross the
433 * boundary no matter what, stop now.
435 if (SCNO + 1 + MAX_CHARACTER_COLUMNS < cnt)
436 goto lscreen;
439 * Count up the widths of the characters. If it's a tab
440 * character, go do it the the slow way.
442 for (cwtotal = 0; cnt--; cwtotal += cname[ch].len)
443 if ((ch = *(u_char *)p--) == '\t')
444 goto slow;
447 * Decrement the screen cursor by the total width of the
448 * characters minus 1.
450 cwtotal -= 1;
453 * If we're moving left, and there's a wide character in the
454 * current position, go to the end of the character.
456 if (cname[ch].len > 1)
457 cwtotal -= cname[ch].len - 1;
460 * If the new column moved us out of the current screen,
461 * calculate a new screen.
463 if (SCNO < cwtotal) {
464 lscreen: if (O_ISSET(sp, O_LEFTRIGHT)) {
465 for (smp = HMAP; smp <= TMAP; ++smp)
466 --smp->off;
467 goto paint;
469 goto slow;
471 SCNO -= cwtotal;
472 } else {
474 * 4b: Cursor moved right.
476 * Point to the first character to the right.
478 p += OCNO + 1;
479 cnt = CNO - OCNO;
482 * Count up the widths of the characters. If it's a tab
483 * character, go do it the the slow way. If we cross a
484 * screen boundary, we can quit.
486 for (cwtotal = SCNO; cnt--;) {
487 if ((ch = *(u_char *)p++) == '\t')
488 goto slow;
489 if ((cwtotal += cname[ch].len) >= SCREEN_COLS(sp))
490 break;
494 * Increment the screen cursor by the total width of the
495 * characters.
497 SCNO = cwtotal;
500 * If the new column moved us out of the current screen,
501 * calculate a new screen.
503 if (SCNO >= SCREEN_COLS(sp)) {
504 if (O_ISSET(sp, O_LEFTRIGHT)) {
505 SCNO -= SCREEN_COLS(sp);
506 for (smp = HMAP; smp <= TMAP; ++smp)
507 ++smp->off;
508 goto paint;
510 goto slow;
514 fast: getyx(stdscr, y, x); /* Just move the cursor. */
515 y -= sp->woff; /* Correct for split screens. */
516 goto update;
518 slow: /* Find the current line in the map. */
519 for (smp = HMAP; smp->lno != LNO; ++smp);
522 * If doing left-right scrolling and the cursor movement has changed
523 * the screen being displayed, scroll it. If we're painting the info
524 * line, however, just scroll that single line.
526 if (O_ISSET(sp, O_LEFTRIGHT)) {
527 cnt = svi_screens(sp, ep, LNO, &CNO) % SCREEN_COLS(sp);
528 if (cnt != HMAP->off) {
529 if (ISINFOLINE(sp, smp))
530 smp->off = cnt;
531 else
532 for (smp = HMAP; smp <= TMAP; ++smp)
533 smp->off = cnt;
534 goto paint;
539 * Update screen lines for this file line until we have a new
540 * screen cursor position.
542 for (y = -1; smp <= TMAP && smp->lno == LNO; ++smp) {
543 if (svi_line(sp, ep, smp, &y, &SCNO))
544 return (1);
545 if (y != -1)
546 break;
549 /* Not too bad, move the cursor. */
550 goto update;
553 * Lost big, do what you have to do. We flush the cache since
554 * S_REDRAW gets set when the screen isn't worth fixing, and
555 * it's simpler to just repaint. So, don't trust anything that
556 * we think we know about it.
558 paint: for (smp = HMAP; smp <= TMAP; ++smp)
559 SMAP_FLUSH(smp);
560 for (smp = HMAP; smp <= TMAP; ++smp)
561 if (svi_line(sp, ep, smp, &y, &SCNO))
562 return (1);
565 * If it's a small screen and we're redrawing, clear the unused
566 * lines, ex may have overwritten them.
568 if (F_ISSET(sp, S_REDRAW)) {
569 if (ISSMALLSCREEN(sp))
570 for (cnt = sp->t_rows; cnt <= sp->t_maxrows; ++cnt) {
571 MOVE(sp, cnt, 0);
572 clrtoeol();
574 F_CLR(sp, S_REDRAW);
577 /* Update saved information. */
578 update: OCNO = CNO;
579 OLNO = LNO;
581 /* Refresh the screen. */
582 if (F_ISSET(sp, S_REFRESH)) {
583 wrefresh(curscr);
584 F_CLR(sp, S_REFRESH);
588 * If there are any keys waiting, we don't ring the bell or update
589 * the messages. The reason is that there may be multiple messages,
590 * and we're going to get the wrong key as a message delimiter.
592 * XXX
593 * This is wrong. If you type quickly enough, the status message
594 * for a screen may not be displayed during a split command because
595 * there were keys waiting so we switched screens without ever
596 * displaying it. Maybe the split code should flush messages?
598 if (!sex_key_wait(sp)) {
599 if (F_ISSET(sp, S_BELLSCHED))
600 svi_bell(sp);
602 * If the bottom line isn't in use by the colon command:
604 * Display any messages. Don't test S_UPDATE_MODE. The
605 * message printing routine set it to avoid anyone else
606 * destroying the message we're about to display.
608 * If the bottom line isn't in use by anyone, put out the
609 * standard status line.
611 if (!F_ISSET(SVP(sp), SVI_INFOLINE))
612 if (sp->msgq.lh_first != NULL &&
613 !F_ISSET(sp->msgq.lh_first, M_EMPTY))
614 svi_msgflush(sp);
615 else if (!F_ISSET(sp, S_UPDATE_MODE))
616 svi_modeline(sp, ep);
619 /* Place the cursor. */
620 MOVE(sp, y, SCNO);
622 /* Flush it all out. */
623 refresh();
625 return (0);
629 * svi_msgflush --
630 * Flush any accumulated messages.
632 static int
633 svi_msgflush(sp)
634 SCR *sp;
636 CHAR_T ch;
637 CHNAME const *cname;
638 MSG *mp;
639 size_t chlen, len;
640 char *p;
642 #define MCONTMSG " [More ...]"
644 /* Display the messages. */
645 cname = sp->cname;
646 for (mp = sp->msgq.lh_first, p = NULL;
647 mp != NULL && !F_ISSET(mp, M_EMPTY); mp = mp->q.le_next) {
649 p = mp->mbuf;
651 lcont: /* Move to the message line and clear it. */
652 MOVE(sp, INFOLINE(sp), 0);
653 clrtoeol();
656 * Turn on standout mode if requested, or, if we've split
657 * the screen and need a divider.
659 if (F_ISSET(mp, M_INV_VIDEO) ||
660 sp->q.cqe_next != (void *)&sp->gp->dq)
661 standout();
664 * Print up to the "more" message. Avoid the last character
665 * in the last line, some hardware doesn't like it.
667 if (svi_ncols(sp, p, mp->len, NULL) < sp->cols - 1)
668 len = sp->cols - 1;
669 else
670 len = (sp->cols - sizeof(MCONTMSG)) - 1;
671 for (;; ++p) {
672 if (!mp->len)
673 break;
674 ch = *(u_char *)p;
675 chlen = cname[ch].len;
676 if (chlen >= len)
677 break;
678 len -= chlen;
679 --mp->len;
680 ADDNSTR(cname[ch].name, chlen);
684 * If more, print continue message. If user key fails,
685 * keep showing the messages anyway.
687 if (mp->len || (mp->q.le_next != NULL &&
688 !F_ISSET(mp->q.le_next, M_EMPTY))) {
689 ADDNSTR(MCONTMSG, sizeof(MCONTMSG) - 1);
690 refresh();
691 for (;;) {
692 if (term_key(sp, &ch, 0) != INP_OK)
693 break;
694 if (sp->special[ch] == K_CR ||
695 sp->special[ch] == K_NL || isblank(ch))
696 break;
697 svi_bell(sp);
701 /* Turn off standout mode. */
702 if (F_ISSET(mp, M_INV_VIDEO) ||
703 sp->q.cqe_next != (void *)&sp->gp->dq)
704 standend();
706 if (mp->len)
707 goto lcont;
709 refresh();
710 F_SET(mp, M_EMPTY);
712 return (0);
715 #define RULERSIZE 15
716 #define MODESIZE (RULERSIZE + 15)
719 * svi_modeline --
720 * Update the mode line.
722 static int
723 svi_modeline(sp, ep)
724 SCR *sp;
725 EXF *ep;
727 char *s, buf[RULERSIZE];
729 MOVE(sp, INFOLINE(sp), 0);
730 clrtoeol();
732 /* Display the dividing line. */
733 if (sp->q.cqe_next != (void *)&sp->gp->dq)
734 svi_divider(sp);
736 /* Display the ruler. */
737 if (O_ISSET(sp, O_RULER) && sp->cols > RULERSIZE + 2) {
738 MOVE(sp, INFOLINE(sp), sp->cols / 2 - RULERSIZE / 2);
739 clrtoeol();
740 (void)snprintf(buf,
741 sizeof(buf), "%lu,%lu", sp->lno, sp->cno + 1);
742 ADDSTR(buf);
745 /* Show the modified bit. */
746 if (O_ISSET(sp, O_SHOWDIRTY) &&
747 F_ISSET(ep, F_MODIFIED) && sp->cols > MODESIZE) {
748 MOVE(sp, INFOLINE(sp), sp->cols - 9);
749 ADDSTR("*");
753 * Show the mode. Leave the last character blank, in case it's a
754 * really dumb terminal with hardware scroll. Second, don't try
755 * to *paint* the last character, SunOS 4.1.1 and Ultrix 4.2 curses
756 * won't let you paint the last character in the screen.
758 if (O_ISSET(sp, O_SHOWMODE) && sp->cols > MODESIZE) {
759 MOVE(sp, INFOLINE(sp), sp->cols - 8);
760 s = F_ISSET(sp, S_INPUT) ? " Input" : "Command";
761 ADDSTR(s);
764 return (0);
768 svi_divider(sp)
769 SCR *sp;
771 #define DIVIDESIZE 10
772 int dividesize;
773 char buf[DIVIDESIZE + 1];
775 dividesize = DIVIDESIZE > sp->cols ? sp->cols : DIVIDESIZE;
776 memset(buf, ' ', dividesize);
777 if (standout() == ERR)
778 return (1);
779 ADDNSTR(buf, dividesize);
780 if (standend() == ERR)
781 return (1);
782 return (0);