-> 1.03
[nvi.git] / vi / vs_refresh.c
blob4cbbd991faa36ee3fab459d444b6f9917cc435b7
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.43 1993/12/23 10:22:03 bostic Exp $ (Berkeley) $Date: 1993/12/23 10:22:03 $";
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: S_REFRESH
65 * If S_REFRESH is set in the current screen, repaint everything
66 * that we can find.
68 if (F_ISSET(sp, S_REFRESH))
69 for (tsp = sp->gp->dq.cqh_first;
70 tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
71 if (tsp != sp)
72 F_SET(tsp, S_REDRAW);
74 * 3: Related or dirtied screens, or screens with messages.
76 * If related screens share a view into a file, they may have been
77 * modified as well. Refresh any screens with paint or dirty bits
78 * set, or where messages are waiting. Finally, if we refresh any
79 * screens other than the current one, the cursor will be trashed.
81 paintbits = S_REDRAW | S_REFORMAT | S_REFRESH;
82 if (O_ISSET(sp, O_NUMBER))
83 paintbits |= S_RENUMBER;
84 for (tsp = sp->gp->dq.cqh_first;
85 tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
86 if (tsp != sp &&
87 (F_ISSET(tsp, paintbits) ||
88 F_ISSET(SVP(tsp), SVI_SCREENDIRTY) ||
89 tsp->msgq.lh_first != NULL &&
90 !F_ISSET(tsp->msgq.lh_first, M_EMPTY))) {
91 (void)svi_paint(tsp, tsp->ep);
92 F_CLR(SVP(tsp), SVI_SCREENDIRTY);
93 F_SET(SVP(sp), SVI_CUR_INVALID);
97 * 4: Refresh the current screen.
99 * Always refresh the current screen, it may be a cursor movement.
100 * Also, always do it last -- that way, S_REFRESH can be set in
101 * the current screen only, and the screen won't flash.
103 F_CLR(sp, SVI_SCREENDIRTY);
104 return (svi_paint(sp, ep));
108 * svi_paint --
109 * This is the guts of the vi curses screen code. The idea is that
110 * the SCR structure passed in contains the new coordinates of the
111 * screen. What makes this hard is that we don't know how big
112 * characters are, doing input can put the cursor in illegal places,
113 * and we're frantically trying to avoid repainting unless it's
114 * absolutely necessary. If you change this code, you'd better know
115 * what you're doing. It's subtle and quick to anger.
118 svi_paint(sp, ep)
119 SCR *sp;
120 EXF *ep;
122 CHNAME const *cname;
123 SMAP *smp, tmp;
124 SVI_PRIVATE *svp;
125 recno_t lastline, lcnt;
126 size_t cwtotal, cnt, len, x, y;
127 int ch, didpaint;
128 char *p;
130 #define LNO sp->lno
131 #define OLNO svp->olno
132 #define CNO sp->cno
133 #define OCNO svp->ocno
134 #define SCNO svp->sc_col
136 didpaint = 0;
137 svp = SVP(sp);
140 * 1: Reformat the lines.
142 * If the lines themselves have changed (:set list, for example),
143 * fill in the map from scratch. Adjust the screen that's being
144 * displayed if the leftright flag is set.
146 if (F_ISSET(sp, S_REFORMAT)) {
147 /* Toss svi_screens() cached information. */
148 SVP(sp)->ss_lno = OOBLNO;
150 /* Toss svi_line() cached information. */
151 if (svi_sm_fill(sp, ep, HMAP->lno, P_TOP))
152 return (1);
153 if (O_ISSET(sp, O_LEFTRIGHT) &&
154 (cnt = svi_screens(sp, ep, LNO, &CNO)) != 1)
155 for (smp = HMAP; smp <= TMAP; ++smp)
156 smp->off = cnt;
157 F_CLR(sp, S_REFORMAT);
158 F_SET(sp, S_REDRAW);
162 * 2: Line movement.
164 * Line changes can cause the top line to change as well. As
165 * before, if the movement is large, the screen is repainted.
167 * 2a: Tiny screens.
169 * Tiny screens cannot be permitted into the "scrolling" parts of
170 * the smap code for two reasons. If the screen size is 1 line,
171 * HMAP == TMAP and the code will quickly drop core. If the screen
172 * size is 2, none of the divisions by 2 will work, and scrolling
173 * won't work. In fact, because no line change will be less than
174 * HALFTEXT(sp), we always ending up "filling" the map, with a
175 * P_MIDDLE flag, which isn't what the user wanted. Tiny screens
176 * can go into the "fill" portions of the smap code, however.
178 if (sp->t_rows <= 2) {
179 if (LNO < HMAP->lno) {
180 if (svi_sm_fill(sp, ep, LNO, P_TOP))
181 return (1);
182 } else if (LNO > TMAP->lno)
183 if (svi_sm_fill(sp, ep, LNO, P_BOTTOM))
184 return (1);
185 if (sp->t_rows == 1) {
186 HMAP->off = svi_screens(sp, ep, LNO, &CNO);
187 goto paint;
189 F_SET(sp, S_REDRAW);
190 goto adjust;
194 * 2b: Small screens.
196 * Users can use the window, w300, w1200 and w9600 options to make
197 * the screen artificially small. The behavior of these options
198 * in the historic vi wasn't all that consistent, and, in fact, it
199 * was never documented how various screen movements affected the
200 * screen size. Generally, one of three things would happen:
201 * 1: The screen would expand in size, showing the line
202 * 2: The screen would scroll, showing the line
203 * 3: The screen would compress to its smallest size and
204 * repaint.
205 * In general, scrolling didn't cause compression (200^D was handled
206 * the same as ^D), movement to a specific line would (:N where N
207 * was 1 line below the screen caused a screen compress), and cursor
208 * movement would scroll if it was 11 lines or less, and compress if
209 * it was more than 11 lines. (And, no, I have no idea where the 11
210 * comes from.)
212 * What we do is try and figure out if the line is less than half of
213 * a full screen away. If it is, we expand the screen if there's
214 * room, and then scroll as necessary. The alternative is to compress
215 * and repaint.
217 * !!!
218 * This code is a special case from beginning to end. Unfortunately,
219 * home modems are still slow enough that it's worth having.
221 * XXX
222 * If the line a really long one, i.e. part of the line is on the
223 * screen but the column offset is not, we'll end up in the adjust
224 * code, when we should probably have compressed the screen.
226 if (ISSMALLSCREEN(sp))
227 if (LNO < HMAP->lno) {
228 lcnt = svi_sm_nlines(sp, ep, HMAP, LNO, sp->t_maxrows);
229 if (lcnt <= HALFSCREEN(sp))
230 for (; lcnt && sp->t_rows != sp->t_maxrows;
231 --lcnt, ++sp->t_rows) {
232 ++TMAP;
233 if (svi_sm_1down(sp, ep))
234 return (1);
236 else
237 goto small_fill;
238 } else if (LNO > TMAP->lno) {
239 lcnt = svi_sm_nlines(sp, ep, TMAP, LNO, sp->t_maxrows);
240 if (lcnt <= HALFSCREEN(sp))
241 for (; lcnt && sp->t_rows != sp->t_maxrows;
242 --lcnt, ++sp->t_rows) {
243 if (svi_sm_next(sp, ep, TMAP, TMAP + 1))
244 return (1);
245 ++TMAP;
246 if (svi_line(sp, ep, TMAP, NULL, NULL))
247 return (1);
249 else {
250 small_fill: MOVE(sp, INFOLINE(sp), 0);
251 clrtoeol();
252 for (; sp->t_rows > sp->t_minrows;
253 --sp->t_rows, --TMAP) {
254 MOVE(sp, TMAP - HMAP, 0);
255 clrtoeol();
257 if (svi_sm_fill(sp, ep, LNO, P_FILL))
258 return (1);
259 F_SET(sp, S_REDRAW);
260 goto adjust;
265 * 3a: Line down.
267 if (LNO >= HMAP->lno) {
268 if (LNO <= TMAP->lno)
269 goto adjust;
272 * If less than half a screen away, scroll down until the
273 * line is on the screen.
275 lcnt = svi_sm_nlines(sp, ep, TMAP, LNO, HALFTEXT(sp));
276 if (lcnt < HALFTEXT(sp)) {
277 while (lcnt--)
278 if (svi_sm_1up(sp, ep))
279 return (1);
280 goto adjust;
284 * If less than a full screen from the bottom of the file, put
285 * the last line of the file on the bottom of the screen. The
286 * calculation is safe because we know there's at least one
287 * full screen of lines, otherwise couldn't have gotten here.
289 if (file_lline(sp, ep, &lastline))
290 return (1);
291 tmp.lno = LNO;
292 tmp.off = 1;
293 lcnt = svi_sm_nlines(sp, ep, &tmp, lastline, sp->t_rows);
294 if (lcnt < sp->t_rows) {
295 if (svi_sm_fill(sp, ep, lastline, P_BOTTOM))
296 return (1);
297 F_SET(sp, S_REDRAW);
298 goto adjust;
302 * If more than a full screen from the last line of the file,
303 * put the new line in the middle of the screen.
305 goto middle;
309 * 3b: Line up.
311 * If less than half a screen away, scroll up until the line is
312 * the first line on the screen.
314 lcnt = svi_sm_nlines(sp, ep, HMAP, LNO, HALFTEXT(sp));
315 if (lcnt < HALFTEXT(sp)) {
316 while (lcnt--)
317 if (svi_sm_1down(sp, ep))
318 return (1);
319 goto adjust;
323 * If less than half a screen from the top of the file, put the first
324 * line of the file at the top of the screen. Otherwise, put the line
325 * in the middle of the screen.
327 tmp.lno = 1;
328 tmp.off = 1;
329 lcnt = svi_sm_nlines(sp, ep, &tmp, LNO, HALFTEXT(sp));
330 if (lcnt < HALFTEXT(sp)) {
331 if (svi_sm_fill(sp, ep, 1, P_TOP))
332 return (1);
333 } else
334 middle: if (svi_sm_fill(sp, ep, LNO, P_MIDDLE))
335 return (1);
336 F_SET(sp, S_REDRAW);
339 * At this point we know part of the line is on the screen. Since
340 * scrolling is done using logical lines, not physical, all of the
341 * line may not be on the screen. While that's not necessarily bad,
342 * if the part the cursor is on isn't there, we're going to lose.
343 * This can be tricky; if the line covers the entire screen, lno
344 * may be the same as both ends of the map, that's why we test BOTH
345 * the top and the bottom of the map. This isn't a problem for
346 * left-right scrolling, the cursor movement code handles the problem.
348 * There's a performance issue here if editing *really* long lines.
349 * This gets to the right spot by scrolling, and, in a binary, by
350 * scrolling hundreds of lines. If the adjustment looks like it's
351 * going to be a serious problem, refill the screen and repaint.
353 adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
354 (LNO == HMAP->lno || LNO == TMAP->lno)) {
355 cnt = svi_screens(sp, ep, LNO, &CNO);
356 if (LNO == HMAP->lno && cnt < HMAP->off)
357 if ((HMAP->off - cnt) > HALFTEXT(sp)) {
358 HMAP->off = cnt;
359 svi_sm_fill(sp, ep, OOBLNO, P_TOP);
360 F_SET(sp, S_REDRAW);
361 } else
362 while (cnt < HMAP->off)
363 if (svi_sm_1down(sp, ep))
364 return (1);
365 if (LNO == TMAP->lno && cnt > TMAP->off)
366 if ((cnt - TMAP->off) > HALFTEXT(sp)) {
367 TMAP->off = cnt;
368 svi_sm_fill(sp, ep, OOBLNO, P_BOTTOM);
369 F_SET(sp, S_REDRAW);
370 } else
371 while (cnt > TMAP->off)
372 if (svi_sm_1up(sp, ep))
373 return (1);
376 /* If the screen needs to be repainted, skip cursor optimization. */
377 if (F_ISSET(sp, S_REDRAW))
378 goto paint;
381 * 4: Cursor movements.
383 * Decide cursor position. If the line has changed, the cursor has
384 * moved over a tab, or don't know where the cursor was, reparse the
385 * line. Note, if we think that the cursor "hasn't moved", reparse
386 * the line. This is 'cause if it hasn't moved, we've almost always
387 * lost track of it.
389 * Otherwise, we've just moved over fixed-width characters, and can
390 * calculate the left/right scrolling and cursor movement without
391 * reparsing the line. Note that we don't know which (if any) of
392 * the characters between the old and new cursor positions changed.
394 * XXX
395 * With some work, it should be possible to handle tabs quickly, at
396 * least in obvious situations, like moving right and encountering
397 * a tab, without reparsing the whole line.
400 /* If the line we're working with has changed, reparse. */
401 if (F_ISSET(SVP(sp), SVI_CUR_INVALID) || LNO != OLNO) {
402 F_CLR(SVP(sp), SVI_CUR_INVALID);
403 goto slow;
406 /* Otherwise, if nothing's changed, go fast. */
407 if (CNO == OCNO)
408 goto fast;
411 * Get the current line. If this fails, we either have an empty
412 * file and can just repaint, or there's a real problem. This
413 * isn't a performance issue because there aren't any ways to get
414 * here repeatedly.
416 if ((p = file_gline(sp, ep, LNO, &len)) == NULL) {
417 if (file_lline(sp, ep, &lastline))
418 return (1);
419 if (lastline == 0)
420 goto slow;
421 GETLINE_ERR(sp, LNO);
422 return (1);
425 #ifdef DEBUG
426 /* This is just a test. */
427 if (CNO >= len && len != 0) {
428 msgq(sp, M_ERR, "Error: %s/%d: cno (%u) >= len (%u)",
429 tail(__FILE__), __LINE__, CNO, len);
430 return (1);
432 #endif
434 * The basic scheme here is to look at the characters in between
435 * the old and new positions and decide how big they are on the
436 * screen, and therefore, how many screen positions to move.
438 cname = sp->gp->cname;
439 if (CNO < OCNO) {
441 * 4a: Cursor moved left.
443 * Point to the old character. The old cursor position can
444 * be past EOL if, for example, we just deleted the rest of
445 * the line. In this case, since we don't know the width of
446 * the characters we traversed, we have to do it slowly.
448 p += OCNO;
449 cnt = (OCNO - CNO) + 1;
450 if (OCNO >= len)
451 goto slow;
454 * Quit sanity check -- it's hard to figure out exactly when
455 * we cross a screen boundary as we do in the cursor right
456 * movement. If cnt is so large that we're going to cross the
457 * boundary no matter what, stop now.
459 if (SCNO + 1 + MAX_CHARACTER_COLUMNS < cnt)
460 goto lscreen;
463 * Count up the widths of the characters. If it's a tab
464 * character, go do it the the slow way.
466 for (cwtotal = 0; cnt--; cwtotal += cname[ch].len)
467 if ((ch = *(u_char *)p--) == '\t')
468 goto slow;
471 * Decrement the screen cursor by the total width of the
472 * characters minus 1.
474 cwtotal -= 1;
477 * If we're moving left, and there's a wide character in the
478 * current position, go to the end of the character.
480 if (cname[ch].len > 1)
481 cwtotal -= cname[ch].len - 1;
484 * If the new column moved us out of the current screen,
485 * calculate a new screen.
487 if (SCNO < cwtotal) {
488 lscreen: if (O_ISSET(sp, O_LEFTRIGHT)) {
489 for (smp = HMAP; smp <= TMAP; ++smp)
490 --smp->off;
491 goto paint;
493 goto slow;
495 SCNO -= cwtotal;
496 } else {
498 * 4b: Cursor moved right.
500 * Point to the first character to the right.
502 p += OCNO + 1;
503 cnt = CNO - OCNO;
506 * Count up the widths of the characters. If it's a tab
507 * character, go do it the the slow way. If we cross a
508 * screen boundary, we can quit.
510 for (cwtotal = SCNO; cnt--;) {
511 if ((ch = *(u_char *)p++) == '\t')
512 goto slow;
513 if ((cwtotal += cname[ch].len) >= SCREEN_COLS(sp))
514 break;
518 * Increment the screen cursor by the total width of the
519 * characters.
521 SCNO = cwtotal;
524 * If the new column moved us out of the current screen,
525 * calculate a new screen.
527 if (SCNO >= SCREEN_COLS(sp)) {
528 if (O_ISSET(sp, O_LEFTRIGHT)) {
529 SCNO -= SCREEN_COLS(sp);
530 for (smp = HMAP; smp <= TMAP; ++smp)
531 ++smp->off;
532 goto paint;
534 goto slow;
539 * 4c: Fast cursor update.
541 * Retrieve the current cursor position, and correct it
542 * for split screens.
544 fast: getyx(stdscr, y, x);
545 y -= sp->woff;
546 goto number;
549 * 4d: Slow cursor update.
551 * Walk through the map and find the current line. If doing left-right
552 * scrolling and the cursor movement has changed the screen displayed,
553 * scroll the screen left or right, unless we're updating the info line
554 * in which case we just scroll that one line. Then update the screen
555 * lines for this file line until we have a new screen cursor position.
557 slow: for (smp = HMAP; smp->lno != LNO; ++smp);
558 if (O_ISSET(sp, O_LEFTRIGHT)) {
559 cnt = svi_screens(sp, ep, LNO, &CNO) % SCREEN_COLS(sp);
560 if (cnt != HMAP->off) {
561 if (ISINFOLINE(sp, smp))
562 smp->off = cnt;
563 else
564 for (smp = HMAP; smp <= TMAP; ++smp)
565 smp->off = cnt;
566 goto paint;
569 for (y = -1; smp <= TMAP && smp->lno == LNO; ++smp) {
570 if (svi_line(sp, ep, smp, &y, &SCNO))
571 return (1);
572 if (y != -1)
573 break;
575 goto number;
578 * 5: Repaint the entire screen.
580 * Lost big, do what you have to do. We flush the cache as S_REDRAW
581 * gets set when the screen isn't worth fixing, and it's simpler to
582 * repaint. So, don't trust anything that we think we know about it.
584 paint: for (smp = HMAP; smp <= TMAP; ++smp)
585 SMAP_FLUSH(smp);
586 for (smp = HMAP; smp <= TMAP; ++smp)
587 if (svi_line(sp, ep, smp, &y, &SCNO))
588 return (1);
590 * If it's a small screen and we're redrawing, clear the unused lines,
591 * ex may have overwritten them.
593 if (F_ISSET(sp, S_REDRAW)) {
594 if (ISSMALLSCREEN(sp))
595 for (cnt = sp->t_rows; cnt <= sp->t_maxrows; ++cnt) {
596 MOVE(sp, cnt, 0);
597 clrtoeol();
599 F_CLR(sp, S_REDRAW);
602 didpaint = 1;
605 * 6: Repaint the line numbers.
607 * If O_NUMBER is set and the S_RENUMBER bit is set, and we didn't
608 * repaint the screen, repaint all of the line numbers, they've
609 * changed.
611 number: if (O_ISSET(sp, O_NUMBER) && F_ISSET(sp, S_RENUMBER) && !didpaint) {
612 if (svi_number(sp, ep))
613 return (1);
614 F_CLR(sp, S_RENUMBER);
618 * 7: Refresh the screen.
620 * If the screen was corrupted, refresh it.
622 if (F_ISSET(sp, S_REFRESH)) {
623 wrefresh(curscr);
624 F_CLR(sp, S_REFRESH);
627 if (F_ISSET(sp, S_BELLSCHED))
628 svi_bell(sp);
630 * If the bottom line isn't in use by the colon command:
632 * Display any messages. Don't test S_UPDATE_MODE. The
633 * message printing routine set it to avoid anyone else
634 * destroying the message we're about to display.
636 * If the bottom line isn't in use by anyone, put out the
637 * standard status line.
639 if (!F_ISSET(SVP(sp), SVI_INFOLINE))
640 if (sp->msgq.lh_first != NULL &&
641 !F_ISSET(sp->msgq.lh_first, M_EMPTY))
642 svi_msgflush(sp);
643 else if (!F_ISSET(sp, S_UPDATE_MODE))
644 svi_modeline(sp, ep);
646 /* Update saved information. */
647 OCNO = CNO;
648 OLNO = LNO;
650 /* Place the cursor. */
651 MOVE(sp, y, SCNO);
653 /* Flush it all out. */
654 refresh();
656 return (0);
660 * svi_msgflush --
661 * Flush any accumulated messages.
663 static int
664 svi_msgflush(sp)
665 SCR *sp;
667 CH ikey;
668 CHAR_T ch;
669 CHNAME const *cname;
670 MSG *mp;
671 size_t chlen, len;
672 char *p;
674 #define MCONTMSG " [More ...]"
676 /* Display the messages. */
677 cname = sp->gp->cname;
678 for (mp = sp->msgq.lh_first, p = NULL;
679 mp != NULL && !F_ISSET(mp, M_EMPTY); mp = mp->q.le_next) {
680 p = mp->mbuf;
682 lcont: /* Move to the message line and clear it. */
683 MOVE(sp, INFOLINE(sp), 0);
684 clrtoeol();
687 * Turn on standout mode if requested, or, if we've split
688 * the screen and need a divider.
690 if (F_ISSET(mp, M_INV_VIDEO) ||
691 sp->q.cqe_next != (void *)&sp->gp->dq)
692 standout();
695 * Print up to the "more" message. Avoid the last character
696 * in the last line, some hardware doesn't like it.
698 if (svi_ncols(sp, p, mp->len, NULL) < sp->cols - 1)
699 len = sp->cols - 1;
700 else
701 len = (sp->cols - sizeof(MCONTMSG)) - 1;
702 for (;; ++p) {
703 if (!mp->len)
704 break;
705 ch = *(u_char *)p;
706 chlen = cname[ch].len;
707 if (chlen >= len)
708 break;
709 len -= chlen;
710 --mp->len;
711 ADDNSTR(cname[ch].name, chlen);
715 * If more, print continue message. If user key fails,
716 * keep showing the messages anyway.
718 if (mp->len || (mp->q.le_next != NULL &&
719 !F_ISSET(mp->q.le_next, M_EMPTY))) {
720 ADDNSTR(MCONTMSG, sizeof(MCONTMSG) - 1);
721 refresh();
722 for (;;) {
723 if (term_user_key(sp, &ikey) != INP_OK)
724 break;
725 if (ikey.value == K_CR ||
726 ikey.value == K_NL || ikey.ch == ' ')
727 break;
728 svi_bell(sp);
732 /* Turn off standout mode. */
733 if (F_ISSET(mp, M_INV_VIDEO) ||
734 sp->q.cqe_next != (void *)&sp->gp->dq)
735 standend();
737 if (mp->len)
738 goto lcont;
740 refresh();
741 F_SET(mp, M_EMPTY);
743 return (0);
746 #define RULERSIZE 15
747 #define MODESIZE (RULERSIZE + 15)
750 * svi_modeline --
751 * Update the mode line.
753 static int
754 svi_modeline(sp, ep)
755 SCR *sp;
756 EXF *ep;
758 char *s, buf[RULERSIZE];
760 MOVE(sp, INFOLINE(sp), 0);
761 clrtoeol();
763 /* Display a dividing line if not the bottom screen. */
764 if (sp->q.cqe_next != (void *)&sp->gp->dq)
765 svi_divider(sp);
767 /* Display the ruler. */
768 if (O_ISSET(sp, O_RULER) && sp->cols > RULERSIZE + 2) {
769 MOVE(sp, INFOLINE(sp), sp->cols / 2 - RULERSIZE / 2);
770 clrtoeol();
771 (void)snprintf(buf,
772 sizeof(buf), "%lu,%lu", sp->lno, sp->cno + 1);
773 ADDSTR(buf);
776 /* Show the modified bit. */
777 if (O_ISSET(sp, O_SHOWDIRTY) &&
778 F_ISSET(ep, F_MODIFIED) && sp->cols > MODESIZE) {
779 MOVE(sp, INFOLINE(sp), sp->cols - 9);
780 ADDSTR("*");
784 * Show the mode. Leave the last character blank, in case it's a
785 * really dumb terminal with hardware scroll. Second, don't try
786 * to *paint* the last character, SunOS 4.1.1 and Ultrix 4.2 curses
787 * won't let you paint the last character in the screen.
789 if (O_ISSET(sp, O_SHOWMODE) && sp->cols > MODESIZE) {
790 MOVE(sp, INFOLINE(sp), sp->cols - 8);
791 s = F_ISSET(sp, S_INPUT) ? " Input" : "Command";
792 ADDSTR(s);
795 return (0);
799 * svi_divider --
800 * Draw a dividing line between the screens.
803 svi_divider(sp)
804 SCR *sp;
806 size_t len;
808 #define DIVIDESTR "+=+=+=+=+=+=+=+"
809 len = sizeof(DIVIDESTR) - 1 > sp->cols ?
810 sp->cols : sizeof(DIVIDESTR) - 1;
811 ADDNSTR(DIVIDESTR, len);
812 return (0);