bug, wrong value to getcount for 'z' command
[nvi.git] / vi / vs_refresh.c
blobeec4f9794eda52790335022442334c9b0dbbe538
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.39 1993/11/29 14:15:44 bostic Exp $ (Berkeley) $Date: 1993/11/29 14:15: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;
32 u_int paintbits;
35 * 1: Resize the screen.
37 * Notice that a resize is requested, and set up everything so that
38 * the file gets reinitialized. Done here, instead of in the vi loop
39 * because there may be other initialization that other screens need
40 * to do. The actual changing of the row/column values was done by
41 * calling the ex options code which put them into the environment,
42 * which is used by curses. Stupid, but ugly.
44 if (F_ISSET(sp, S_RESIZE)) {
45 /* Reinitialize curses. */
46 if (svi_curses_end(sp) || svi_curses_init(sp))
47 return (1);
49 /* Lose any svi_screens() cached information. */
50 SVP(sp)->ss_lno = OOBLNO;
53 * Fill the map, incidentally losing any svi_line()
54 * cached information.
56 if (sp->s_fill(sp, ep, sp->lno, P_FILL))
57 return (1);
58 F_CLR(sp, S_RESIZE | S_REFORMAT);
59 F_SET(sp, S_REDRAW);
63 * 2: Refresh related screens.
65 * If related screens share a view into a file, they may have been
66 * modified as well. Refresh any screens with paint or dirty bits
67 * set, or where messages are waiting.
69 paintbits = S_REDRAW | S_REFORMAT | S_REFRESH;
70 if (O_ISSET(sp, O_NUMBER))
71 paintbits |= S_RENUMBER;
72 for (tsp = sp->gp->dq.cqh_first;
73 tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
74 if (tsp != sp &&
75 (F_ISSET(tsp, paintbits) ||
76 F_ISSET(SVP(tsp), SVI_SCREENDIRTY) ||
77 tsp->msgq.lh_first != NULL &&
78 !F_ISSET(tsp->msgq.lh_first, M_EMPTY))) {
79 (void)svi_paint(tsp, tsp->ep);
80 F_CLR(SVP(tsp), SVI_SCREENDIRTY);
84 * 3: Refresh the current screen.
86 * Always refresh the current screen, it may be a cursor movement.
87 * Also, always do it last -- that way, S_REFRESH can be set in
88 * the current screen only, and the screen won't flash.
90 F_CLR(sp, SVI_SCREENDIRTY);
91 return (svi_paint(sp, ep));
95 * svi_paint --
96 * This is the guts of the vi curses screen code. The idea is that
97 * the SCR structure passed in contains the new coordinates of the
98 * screen. What makes this hard is that we don't know how big
99 * characters are, doing input can put the cursor in illegal places,
100 * and we're frantically trying to avoid repainting unless it's
101 * absolutely necessary. If you change this code, you'd better know
102 * what you're doing. It's subtle and quick to anger.
105 svi_paint(sp, ep)
106 SCR *sp;
107 EXF *ep;
109 CHNAME const *cname;
110 SMAP *smp, tmp;
111 SVI_PRIVATE *svp;
112 recno_t lastline, lcnt;
113 size_t cwtotal, cnt, len, x, y;
114 int ch, didpaint;
115 char *p;
117 #define LNO sp->lno
118 #define OLNO svp->olno
119 #define CNO sp->cno
120 #define OCNO svp->ocno
121 #define SCNO svp->sc_col
123 didpaint = 0;
124 svp = SVP(sp);
127 * 1: Reformat the lines.
129 * If the lines themselves have changed (:set list, for example),
130 * fill in the map from scratch. Adjust the screen that's being
131 * displayed if the leftright flag is set.
133 if (F_ISSET(sp, S_REFORMAT)) {
134 /* Toss svi_screens() cached information. */
135 SVP(sp)->ss_lno = OOBLNO;
137 /* Toss svi_line() cached information. */
138 if (svi_sm_fill(sp, ep, HMAP->lno, P_TOP))
139 return (1);
140 if (O_ISSET(sp, O_LEFTRIGHT) &&
141 (cnt = svi_screens(sp, ep, LNO, &CNO)) != 1)
142 for (smp = HMAP; smp <= TMAP; ++smp)
143 smp->off = cnt;
144 F_CLR(sp, S_REFORMAT);
145 F_SET(sp, S_REDRAW);
149 * 2: Line movement.
151 * Line changes can cause the top line to change as well. As
152 * before, if the movement is large, the screen is repainted.
154 * 2a: Tiny screens.
156 * Tiny screens cannot be permitted into the "scrolling" parts of
157 * the smap code for two reasons. If the screen size is 1 line,
158 * HMAP == TMAP and the code will quickly drop core. If the screen
159 * size is 2, none of the divisions by 2 will work, and scrolling
160 * won't work. In fact, because no line change will be less than
161 * HALFTEXT(sp), we always ending up "filling" the map, with a
162 * P_MIDDLE flag, which isn't what the user wanted. Tiny screens
163 * can go into the "fill" portions of the smap code, however.
165 if (sp->t_rows <= 2) {
166 if (LNO < HMAP->lno) {
167 if (svi_sm_fill(sp, ep, LNO, P_TOP))
168 return (1);
169 } else if (LNO > TMAP->lno)
170 if (svi_sm_fill(sp, ep, LNO, P_BOTTOM))
171 return (1);
172 if (sp->t_rows == 1) {
173 HMAP->off = svi_screens(sp, ep, LNO, &CNO);
174 goto paint;
176 F_SET(sp, S_REDRAW);
177 goto adjust;
181 * 2b: Small screens.
183 * Users can use the window, w300, w1200 and w9600 options to make
184 * the screen artificially small. The behavior of these options
185 * in the historic vi wasn't all that consistent, and, in fact, it
186 * was never documented how various screen movements affected the
187 * screen size. Generally, one of three things would happen:
188 * 1: The screen would expand in size, showing the line
189 * 2: The screen would scroll, showing the line
190 * 3: The screen would compress to its smallest size and
191 * repaint.
192 * In general, scrolling didn't cause compression (200^D was handled
193 * the same as ^D), movement to a specific line would (:N where N
194 * was 1 line below the screen caused a screen compress), and cursor
195 * movement would scroll if it was 11 lines or less, and compress if
196 * it was more than 11 lines. (And, no, I have no idea where the 11
197 * comes from.)
199 * What we do is try and figure out if the line is less than half of
200 * a full screen away. If it is, we expand the screen if there's
201 * room, and then scroll as necessary. The alternative is to compress
202 * and repaint.
204 * !!!
205 * This code is a special case from beginning to end. Unfortunately,
206 * home modems are still slow enough that it's worth having.
208 * XXX
209 * If the line a really long one, i.e. part of the line is on the
210 * screen but the column offset is not, we'll end up in the adjust
211 * code, when we should probably have compressed the screen.
213 if (ISSMALLSCREEN(sp))
214 if (LNO < HMAP->lno) {
215 lcnt = svi_sm_nlines(sp, ep, HMAP, LNO, sp->t_maxrows);
216 if (lcnt <= HALFSCREEN(sp))
217 for (; lcnt && sp->t_rows != sp->t_maxrows;
218 --lcnt, ++sp->t_rows) {
219 ++TMAP;
220 if (svi_sm_1down(sp, ep))
221 return (1);
223 else
224 goto small_fill;
225 } else if (LNO > TMAP->lno) {
226 lcnt = svi_sm_nlines(sp, ep, TMAP, LNO, sp->t_maxrows);
227 if (lcnt <= HALFSCREEN(sp))
228 for (; lcnt && sp->t_rows != sp->t_maxrows;
229 --lcnt, ++sp->t_rows) {
230 if (svi_sm_next(sp, ep, TMAP, TMAP + 1))
231 return (1);
232 ++TMAP;
233 if (svi_line(sp, ep, TMAP, NULL, NULL))
234 return (1);
236 else {
237 small_fill: MOVE(sp, INFOLINE(sp), 0);
238 clrtoeol();
239 for (; sp->t_rows > sp->t_minrows;
240 --sp->t_rows, --TMAP) {
241 MOVE(sp, TMAP - HMAP, 0);
242 clrtoeol();
244 if (svi_sm_fill(sp, ep, LNO, P_FILL))
245 return (1);
246 F_SET(sp, S_REDRAW);
247 goto adjust;
252 * 3a: Line down.
254 if (LNO >= HMAP->lno) {
255 if (LNO <= TMAP->lno)
256 goto adjust;
259 * If less than half a screen away, scroll down until the
260 * line is on the screen.
262 lcnt = svi_sm_nlines(sp, ep, TMAP, LNO, HALFTEXT(sp));
263 if (lcnt < HALFTEXT(sp)) {
264 while (lcnt--)
265 if (svi_sm_1up(sp, ep))
266 return (1);
267 goto adjust;
271 * If less than a full screen from the bottom of the file, put
272 * the last line of the file on the bottom of the screen. The
273 * calculation is safe because we know there's at least one
274 * full screen of lines, otherwise couldn't have gotten here.
276 if (file_lline(sp, ep, &lastline))
277 return (1);
278 tmp.lno = LNO;
279 tmp.off = 1;
280 lcnt = svi_sm_nlines(sp, ep, &tmp, lastline, sp->t_rows);
281 if (lcnt < sp->t_rows) {
282 if (svi_sm_fill(sp, ep, lastline, P_BOTTOM))
283 return (1);
284 F_SET(sp, S_REDRAW);
285 goto adjust;
289 * If more than a full screen from the last line of the file,
290 * put the new line in the middle of the screen.
292 goto middle;
296 * 3b: Line up.
298 * If less than half a screen away, scroll up until the line is
299 * the first line on the screen.
301 lcnt = svi_sm_nlines(sp, ep, HMAP, LNO, HALFTEXT(sp));
302 if (lcnt < HALFTEXT(sp)) {
303 while (lcnt--)
304 if (svi_sm_1down(sp, ep))
305 return (1);
306 goto adjust;
310 * If less than half a screen from the top of the file, put the first
311 * line of the file at the top of the screen. Otherwise, put the line
312 * in the middle of the screen.
314 tmp.lno = 1;
315 tmp.off = 1;
316 lcnt = svi_sm_nlines(sp, ep, &tmp, LNO, HALFTEXT(sp));
317 if (lcnt < HALFTEXT(sp)) {
318 if (svi_sm_fill(sp, ep, 1, P_TOP))
319 return (1);
320 } else
321 middle: if (svi_sm_fill(sp, ep, LNO, P_MIDDLE))
322 return (1);
323 F_SET(sp, S_REDRAW);
326 * At this point we know part of the line is on the screen. Since
327 * scrolling is done using logical lines, not physical, all of the
328 * line may not be on the screen. While that's not necessarily bad,
329 * if the part the cursor is on isn't there, we're going to lose.
330 * This can be tricky; if the line covers the entire screen, lno
331 * may be the same as both ends of the map, that's why we test BOTH
332 * the top and the bottom of the map. This isn't a problem for
333 * left-right scrolling, the cursor movement code handles the problem.
335 * There's a performance issue here if editing *really* long lines.
336 * This gets to the right spot by scrolling, and, in a binary, by
337 * scrolling hundreds of lines. If the adjustment looks like it's
338 * going to be a serious problem, refill the screen and repaint.
340 adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
341 (LNO == HMAP->lno || LNO == TMAP->lno)) {
342 cnt = svi_screens(sp, ep, LNO, &CNO);
343 if (LNO == HMAP->lno && cnt < HMAP->off)
344 if ((HMAP->off - cnt) > HALFTEXT(sp)) {
345 HMAP->off = cnt;
346 svi_sm_fill(sp, ep, OOBLNO, P_TOP);
347 F_SET(sp, S_REDRAW);
348 } else
349 while (cnt < HMAP->off)
350 if (svi_sm_1down(sp, ep))
351 return (1);
352 if (LNO == TMAP->lno && cnt > TMAP->off)
353 if ((cnt - TMAP->off) > HALFTEXT(sp)) {
354 TMAP->off = cnt;
355 svi_sm_fill(sp, ep, OOBLNO, P_BOTTOM);
356 F_SET(sp, S_REDRAW);
357 } else
358 while (cnt > TMAP->off)
359 if (svi_sm_1up(sp, ep))
360 return (1);
363 /* If the screen needs to be repainted, skip cursor optimization. */
364 if (F_ISSET(sp, S_REDRAW))
365 goto paint;
368 * 4: Cursor movements.
370 * Decide cursor position. If the line has changed, the cursor has
371 * moved over a tab, or don't know where the cursor was, reparse the
372 * line. Note, if we think that the cursor "hasn't moved", reparse
373 * the line. This is 'cause if it hasn't moved, we've almost always
374 * lost track of it.
376 * Otherwise, we've just moved over fixed-width characters, and can
377 * calculate the left/right scrolling and cursor movement without
378 * reparsing the line. Note that we don't know which (if any) of
379 * the characters between the old and new cursor positions changed.
381 * XXX
382 * With some work, it should be possible to handle tabs quickly, at
383 * least in obvious situations, like moving right and encountering
384 * a tab, without reparsing the whole line.
387 /* If the line we're working with has changed, reparse. */
388 if (F_ISSET(SVP(sp), SVI_CUR_INVALID) || LNO != OLNO) {
389 F_CLR(SVP(sp), SVI_CUR_INVALID);
390 goto slow;
393 /* Otherwise, if nothing's changed, go fast. */
394 if (CNO == OCNO)
395 goto fast;
398 * Get the current line. If this fails, we either have an empty
399 * file and can just repaint, or there's a real problem. This
400 * isn't a performance issue because there aren't any ways to get
401 * here repeatedly.
403 if ((p = file_gline(sp, ep, LNO, &len)) == NULL) {
404 if (file_lline(sp, ep, &lastline))
405 return (1);
406 if (lastline == 0)
407 goto slow;
408 GETLINE_ERR(sp, LNO);
409 return (1);
412 #ifdef DEBUG
413 /* This is just a test. */
414 if (CNO >= len && len != 0) {
415 msgq(sp, M_ERR, "Error: %s/%d: cno (%u) >= len (%u)",
416 tail(__FILE__), __LINE__, CNO, len);
417 return (1);
419 #endif
421 * The basic scheme here is to look at the characters in between
422 * the old and new positions and decide how big they are on the
423 * screen, and therefore, how many screen positions to move.
425 cname = sp->gp->cname;
426 if (CNO < OCNO) {
428 * 4a: Cursor moved left.
430 * Point to the old character. The old cursor position can
431 * be past EOL if, for example, we just deleted the rest of
432 * the line. In this case, since we don't know the width of
433 * the characters we traversed, we have to do it slowly.
435 p += OCNO;
436 cnt = (OCNO - CNO) + 1;
437 if (OCNO >= len)
438 goto slow;
441 * Quit sanity check -- it's hard to figure out exactly when
442 * we cross a screen boundary as we do in the cursor right
443 * movement. If cnt is so large that we're going to cross the
444 * boundary no matter what, stop now.
446 if (SCNO + 1 + MAX_CHARACTER_COLUMNS < cnt)
447 goto lscreen;
450 * Count up the widths of the characters. If it's a tab
451 * character, go do it the the slow way.
453 for (cwtotal = 0; cnt--; cwtotal += cname[ch].len)
454 if ((ch = *(u_char *)p--) == '\t')
455 goto slow;
458 * Decrement the screen cursor by the total width of the
459 * characters minus 1.
461 cwtotal -= 1;
464 * If we're moving left, and there's a wide character in the
465 * current position, go to the end of the character.
467 if (cname[ch].len > 1)
468 cwtotal -= cname[ch].len - 1;
471 * If the new column moved us out of the current screen,
472 * calculate a new screen.
474 if (SCNO < cwtotal) {
475 lscreen: if (O_ISSET(sp, O_LEFTRIGHT)) {
476 for (smp = HMAP; smp <= TMAP; ++smp)
477 --smp->off;
478 goto paint;
480 goto slow;
482 SCNO -= cwtotal;
483 } else {
485 * 4b: Cursor moved right.
487 * Point to the first character to the right.
489 p += OCNO + 1;
490 cnt = CNO - OCNO;
493 * Count up the widths of the characters. If it's a tab
494 * character, go do it the the slow way. If we cross a
495 * screen boundary, we can quit.
497 for (cwtotal = SCNO; cnt--;) {
498 if ((ch = *(u_char *)p++) == '\t')
499 goto slow;
500 if ((cwtotal += cname[ch].len) >= SCREEN_COLS(sp))
501 break;
505 * Increment the screen cursor by the total width of the
506 * characters.
508 SCNO = cwtotal;
511 * If the new column moved us out of the current screen,
512 * calculate a new screen.
514 if (SCNO >= SCREEN_COLS(sp)) {
515 if (O_ISSET(sp, O_LEFTRIGHT)) {
516 SCNO -= SCREEN_COLS(sp);
517 for (smp = HMAP; smp <= TMAP; ++smp)
518 ++smp->off;
519 goto paint;
521 goto slow;
526 * 4c: Fast cursor update.
528 * Retrieve the current cursor position, and correct it
529 * for split screens.
531 fast: getyx(stdscr, y, x);
532 y -= sp->woff;
533 goto number;
536 * 4d: Slow cursor update.
538 * Walk through the map and find the current line. If doing left-right
539 * scrolling and the cursor movement has changed the screen displayed,
540 * scroll the screen left or right, unless we're updating the info line
541 * in which case we just scroll that one line. Then update the screen
542 * lines for this file line until we have a new screen cursor position.
544 slow: for (smp = HMAP; smp->lno != LNO; ++smp);
545 if (O_ISSET(sp, O_LEFTRIGHT)) {
546 cnt = svi_screens(sp, ep, LNO, &CNO) % SCREEN_COLS(sp);
547 if (cnt != HMAP->off) {
548 if (ISINFOLINE(sp, smp))
549 smp->off = cnt;
550 else
551 for (smp = HMAP; smp <= TMAP; ++smp)
552 smp->off = cnt;
553 goto paint;
556 for (y = -1; smp <= TMAP && smp->lno == LNO; ++smp) {
557 if (svi_line(sp, ep, smp, &y, &SCNO))
558 return (1);
559 if (y != -1)
560 break;
562 goto number;
565 * 5: Repaint the entire screen.
567 * Lost big, do what you have to do. We flush the cache as S_REDRAW
568 * gets set when the screen isn't worth fixing, and it's simpler to
569 * repaint. So, don't trust anything that we think we know about it.
571 paint: for (smp = HMAP; smp <= TMAP; ++smp)
572 SMAP_FLUSH(smp);
573 for (smp = HMAP; smp <= TMAP; ++smp)
574 if (svi_line(sp, ep, smp, &y, &SCNO))
575 return (1);
577 * If it's a small screen and we're redrawing, clear the unused lines,
578 * ex may have overwritten them.
580 if (F_ISSET(sp, S_REDRAW)) {
581 if (ISSMALLSCREEN(sp))
582 for (cnt = sp->t_rows; cnt <= sp->t_maxrows; ++cnt) {
583 MOVE(sp, cnt, 0);
584 clrtoeol();
586 F_CLR(sp, S_REDRAW);
589 didpaint = 1;
592 * 6: Repaint the line numbers.
594 * If O_NUMBER is set and the S_RENUMBER bit is set, and we didn't
595 * repaint the screen, repaint all of the line numbers, they've
596 * changed.
598 number: if (O_ISSET(sp, O_NUMBER) && F_ISSET(sp, S_RENUMBER) && !didpaint) {
599 if (svi_number(sp, ep))
600 return (1);
601 F_CLR(sp, S_RENUMBER);
605 * 7: Refresh the screen.
607 * If the screen was corrupted, refresh it.
609 if (F_ISSET(sp, S_REFRESH)) {
610 wrefresh(curscr);
611 F_CLR(sp, S_REFRESH);
614 if (F_ISSET(sp, S_BELLSCHED))
615 svi_bell(sp);
617 * If the bottom line isn't in use by the colon command:
619 * Display any messages. Don't test S_UPDATE_MODE. The
620 * message printing routine set it to avoid anyone else
621 * destroying the message we're about to display.
623 * If the bottom line isn't in use by anyone, put out the
624 * standard status line.
626 if (!F_ISSET(SVP(sp), SVI_INFOLINE))
627 if (sp->msgq.lh_first != NULL &&
628 !F_ISSET(sp->msgq.lh_first, M_EMPTY))
629 svi_msgflush(sp);
630 else if (!F_ISSET(sp, S_UPDATE_MODE))
631 svi_modeline(sp, ep);
633 /* Update saved information. */
634 OCNO = CNO;
635 OLNO = LNO;
637 /* Place the cursor. */
638 MOVE(sp, y, SCNO);
640 /* Flush it all out. */
641 refresh();
643 return (0);
647 * svi_msgflush --
648 * Flush any accumulated messages.
650 static int
651 svi_msgflush(sp)
652 SCR *sp;
654 CH ikey;
655 CHAR_T ch;
656 CHNAME const *cname;
657 MSG *mp;
658 size_t chlen, len;
659 char *p;
661 #define MCONTMSG " [More ...]"
663 /* Display the messages. */
664 cname = sp->gp->cname;
665 for (mp = sp->msgq.lh_first, p = NULL;
666 mp != NULL && !F_ISSET(mp, M_EMPTY); mp = mp->q.le_next) {
667 p = mp->mbuf;
669 lcont: /* Move to the message line and clear it. */
670 MOVE(sp, INFOLINE(sp), 0);
671 clrtoeol();
674 * Turn on standout mode if requested, or, if we've split
675 * the screen and need a divider.
677 if (F_ISSET(mp, M_INV_VIDEO) ||
678 sp->q.cqe_next != (void *)&sp->gp->dq)
679 standout();
682 * Print up to the "more" message. Avoid the last character
683 * in the last line, some hardware doesn't like it.
685 if (svi_ncols(sp, p, mp->len, NULL) < sp->cols - 1)
686 len = sp->cols - 1;
687 else
688 len = (sp->cols - sizeof(MCONTMSG)) - 1;
689 for (;; ++p) {
690 if (!mp->len)
691 break;
692 ch = *(u_char *)p;
693 chlen = cname[ch].len;
694 if (chlen >= len)
695 break;
696 len -= chlen;
697 --mp->len;
698 ADDNSTR(cname[ch].name, chlen);
702 * If more, print continue message. If user key fails,
703 * keep showing the messages anyway.
705 if (mp->len || (mp->q.le_next != NULL &&
706 !F_ISSET(mp->q.le_next, M_EMPTY))) {
707 ADDNSTR(MCONTMSG, sizeof(MCONTMSG) - 1);
708 refresh();
709 for (;;) {
710 if (term_user_key(sp, &ikey) != INP_OK)
711 break;
712 if (ikey.value == K_CR ||
713 ikey.value == K_NL || isblank(ch))
714 break;
715 svi_bell(sp);
719 /* Turn off standout mode. */
720 if (F_ISSET(mp, M_INV_VIDEO) ||
721 sp->q.cqe_next != (void *)&sp->gp->dq)
722 standend();
724 if (mp->len)
725 goto lcont;
727 refresh();
728 F_SET(mp, M_EMPTY);
730 return (0);
733 #define RULERSIZE 15
734 #define MODESIZE (RULERSIZE + 15)
737 * svi_modeline --
738 * Update the mode line.
740 static int
741 svi_modeline(sp, ep)
742 SCR *sp;
743 EXF *ep;
745 char *s, buf[RULERSIZE];
747 MOVE(sp, INFOLINE(sp), 0);
748 clrtoeol();
750 /* Display a dividing line if not the bottom screen. */
751 if (sp->q.cqe_next != (void *)&sp->gp->dq)
752 svi_divider(sp);
754 /* Display the ruler. */
755 if (O_ISSET(sp, O_RULER) && sp->cols > RULERSIZE + 2) {
756 MOVE(sp, INFOLINE(sp), sp->cols / 2 - RULERSIZE / 2);
757 clrtoeol();
758 (void)snprintf(buf,
759 sizeof(buf), "%lu,%lu", sp->lno, sp->cno + 1);
760 ADDSTR(buf);
763 /* Show the modified bit. */
764 if (O_ISSET(sp, O_SHOWDIRTY) &&
765 F_ISSET(ep, F_MODIFIED) && sp->cols > MODESIZE) {
766 MOVE(sp, INFOLINE(sp), sp->cols - 9);
767 ADDSTR("*");
771 * Show the mode. Leave the last character blank, in case it's a
772 * really dumb terminal with hardware scroll. Second, don't try
773 * to *paint* the last character, SunOS 4.1.1 and Ultrix 4.2 curses
774 * won't let you paint the last character in the screen.
776 if (O_ISSET(sp, O_SHOWMODE) && sp->cols > MODESIZE) {
777 MOVE(sp, INFOLINE(sp), sp->cols - 8);
778 s = F_ISSET(sp, S_INPUT) ? " Input" : "Command";
779 ADDSTR(s);
782 return (0);
786 svi_divider(sp)
787 SCR *sp;
789 #define DIVIDESIZE 10
790 int dividesize;
791 char buf[DIVIDESIZE + 1];
793 dividesize = DIVIDESIZE > sp->cols ? sp->cols : DIVIDESIZE;
794 memset(buf, ' ', dividesize);
795 if (standout() == ERR)
796 return (1);
797 ADDNSTR(buf, dividesize);
798 if (standend() == ERR)
799 return (1);
800 return (0);