1 /* $NetBSD: vs_refresh.c,v 1.6 2014/01/26 21:43:45 christos Exp $ */
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
13 #include <sys/cdefs.h>
16 static const char sccsid
[] = "Id: vs_refresh.c,v 10.50 2001/06/25 15:19:37 skimo Exp (Berkeley) Date: 2001/06/25 15:19:37 ";
19 __RCSID("$NetBSD: vs_refresh.c,v 1.6 2014/01/26 21:43:45 christos Exp $");
22 #include <sys/types.h>
23 #include <sys/queue.h>
26 #include <bitstring.h>
33 #include "../common/common.h"
36 #define UPDATE_CURSOR 0x01 /* Update the cursor. */
37 #define UPDATE_SCREEN 0x02 /* Flush to screen. */
39 static void vs_modeline
__P((SCR
*));
40 static int vs_paint
__P((SCR
*, u_int
));
44 * Refresh all screens.
46 * PUBLIC: int vs_refresh __P((SCR *, int));
49 vs_refresh(SCR
*sp
, int forcepaint
)
54 u_int priv_paint
, pub_paint
;
59 * 1: Refresh the screen.
61 * If SC_SCR_REDRAW is set in the current screen, repaint everything
62 * that we can find, including status lines.
64 if (F_ISSET(sp
, SC_SCR_REDRAW
))
65 TAILQ_FOREACH(tsp
, &sp
->wp
->scrq
, q
)
67 F_SET(tsp
, SC_SCR_REDRAW
| SC_STATUS
);
70 * 2: Related or dirtied screens, or screens with messages.
72 * If related screens share a view into a file, they may have been
73 * modified as well. Refresh any screens that aren't exiting that
74 * have paint or dirty bits set. Always update their screens, we
75 * are not likely to get another chance. Finally, if we refresh any
76 * screens other than the current one, the cursor will be trashed.
78 pub_paint
= SC_SCR_REFORMAT
| SC_SCR_REDRAW
;
79 priv_paint
= VIP_CUR_INVALID
| VIP_N_REFRESH
;
80 if (O_ISSET(sp
, O_NUMBER
))
81 priv_paint
|= VIP_N_RENUMBER
;
82 TAILQ_FOREACH(tsp
, &sp
->wp
->scrq
, q
)
83 if (tsp
!= sp
&& !F_ISSET(tsp
, SC_EXIT
| SC_EXIT_FORCE
) &&
84 (F_ISSET(tsp
, pub_paint
) ||
85 F_ISSET(VIP(tsp
), priv_paint
))) {
87 (F_ISSET(VIP(tsp
), VIP_CUR_INVALID
) ?
88 UPDATE_CURSOR
: 0) | UPDATE_SCREEN
);
89 F_SET(VIP(sp
), VIP_CUR_INVALID
);
93 * 3: Refresh the current screen.
95 * Always refresh the current screen, it may be a cursor movement.
96 * Also, always do it last -- that way, SC_SCR_REDRAW can be set
97 * in the current screen only, and the screen won't flash.
99 if (vs_paint(sp
, UPDATE_CURSOR
| (!forcepaint
&&
100 F_ISSET(sp
, SC_SCR_VI
) && KEYS_WAITING(sp
) ? 0 : UPDATE_SCREEN
)))
104 * 4: Paint any missing status lines.
107 * This is fairly evil. Status lines are written using the vi message
108 * mechanism, since we have no idea how long they are. Since we may be
109 * painting screens other than the current one, we don't want to make
110 * the user wait. We depend heavily on there not being any other lines
111 * currently waiting to be displayed and the message truncation code in
112 * the msgq_status routine working.
114 * And, finally, if we updated any status lines, make sure the cursor
115 * gets back to where it belongs.
118 TAILQ_FOREACH(tsp
, &sp
->wp
->scrq
, q
)
119 if (F_ISSET(tsp
, SC_STATUS
)) {
121 vs_resolve(tsp
, sp
, 0);
124 (void)gp
->scr_refresh(sp
, 0);
127 * A side-effect of refreshing the screen is that it's now ready
128 * for everything else, i.e. messages.
130 F_SET(sp
, SC_SCR_VI
);
136 * This is the guts of the vi curses screen code. The idea is that
137 * the SCR structure passed in contains the new coordinates of the
138 * screen. What makes this hard is that we don't know how big
139 * characters are, doing input can put the cursor in illegal places,
140 * and we're frantically trying to avoid repainting unless it's
141 * absolutely necessary. If you change this code, you'd better know
142 * what you're doing. It's subtle and quick to anger.
145 vs_paint(SCR
*sp
, u_int flags
)
150 db_recno_t lastline
, lcnt
;
151 size_t cwtotal
, cnt
, len
, notused
, off
, y
;
152 int ch
= 0, didpaint
, isempty
, leftright_warp
;
155 #define LNO sp->lno /* Current file line. */
156 #define OLNO vip->olno /* Remembered file line. */
157 #define CNO sp->cno /* Current file column. */
158 #define OCNO vip->ocno /* Remembered file column. */
159 #define SCNO vip->sc_col /* Current screen column. */
165 didpaint
= leftright_warp
= 0;
168 * 5: Reformat the lines.
170 * If the lines themselves have changed (:set list, for example),
171 * fill in the map from scratch. Adjust the screen that's being
172 * displayed if the leftright flag is set.
174 if (F_ISSET(sp
, SC_SCR_REFORMAT
)) {
175 /* Invalidate the line size cache. */
178 /* Toss vs_line() cached information. */
179 if (F_ISSET(sp
, SC_SCR_TOP
)) {
180 if (vs_sm_fill(sp
, LNO
, P_TOP
))
183 else if (F_ISSET(sp
, SC_SCR_CENTER
)) {
184 if (vs_sm_fill(sp
, LNO
, P_MIDDLE
))
187 if (vs_sm_fill(sp
, OOBLNO
, P_TOP
))
189 F_SET(sp
, SC_SCR_REDRAW
);
195 * Line changes can cause the top line to change as well. As
196 * before, if the movement is large, the screen is repainted.
200 * Users can use the window, w300, w1200 and w9600 options to make
201 * the screen artificially small. The behavior of these options
202 * in the historic vi wasn't all that consistent, and, in fact, it
203 * was never documented how various screen movements affected the
204 * screen size. Generally, one of three things would happen:
205 * 1: The screen would expand in size, showing the line
206 * 2: The screen would scroll, showing the line
207 * 3: The screen would compress to its smallest size and
209 * In general, scrolling didn't cause compression (200^D was handled
210 * the same as ^D), movement to a specific line would (:N where N
211 * was 1 line below the screen caused a screen compress), and cursor
212 * movement would scroll if it was 11 lines or less, and compress if
213 * it was more than 11 lines. (And, no, I have no idea where the 11
216 * What we do is try and figure out if the line is less than half of
217 * a full screen away. If it is, we expand the screen if there's
218 * room, and then scroll as necessary. The alternative is to compress
222 * This code is a special case from beginning to end. Unfortunately,
223 * home modems are still slow enough that it's worth having.
226 * If the line a really long one, i.e. part of the line is on the
227 * screen but the column offset is not, we'll end up in the adjust
228 * code, when we should probably have compressed the screen.
231 if (LNO
< HMAP
->lno
) {
232 lcnt
= vs_sm_nlines(sp
, HMAP
, LNO
, sp
->t_maxrows
);
233 if (lcnt
<= HALFSCREEN(sp
))
234 for (; lcnt
&& sp
->t_rows
!= sp
->t_maxrows
;
235 --lcnt
, ++sp
->t_rows
) {
242 } else if (LNO
> TMAP
->lno
) {
243 lcnt
= vs_sm_nlines(sp
, TMAP
, LNO
, sp
->t_maxrows
);
244 if (lcnt
<= HALFSCREEN(sp
))
245 for (; lcnt
&& sp
->t_rows
!= sp
->t_maxrows
;
246 --lcnt
, ++sp
->t_rows
) {
247 if (vs_sm_next(sp
, TMAP
, TMAP
+ 1))
250 if (vs_line(sp
, TMAP
, NULL
, NULL
))
254 small_fill
: (void)gp
->scr_move(sp
, LASTLINE(sp
), 0);
255 (void)gp
->scr_clrtoeol(sp
);
256 for (; sp
->t_rows
> sp
->t_minrows
;
257 --sp
->t_rows
, --TMAP
) {
258 (void)gp
->scr_move(sp
, TMAP
- HMAP
, 0);
259 (void)gp
->scr_clrtoeol(sp
);
261 if (vs_sm_fill(sp
, LNO
, P_FILL
))
263 F_SET(sp
, SC_SCR_REDRAW
);
270 * 6b: Line down, or current screen.
272 if (LNO
>= HMAP
->lno
) {
273 /* Current screen. */
274 if (LNO
<= TMAP
->lno
)
276 if (F_ISSET(sp
, SC_SCR_TOP
))
278 if (F_ISSET(sp
, SC_SCR_CENTER
))
282 * If less than half a screen above the line, scroll down
283 * until the line is on the screen.
285 lcnt
= vs_sm_nlines(sp
, TMAP
, LNO
, HALFTEXT(sp
));
286 if (lcnt
< HALFTEXT(sp
)) {
296 * 6c: If not on the current screen, may request center or top.
298 if (F_ISSET(sp
, SC_SCR_TOP
))
300 if (F_ISSET(sp
, SC_SCR_CENTER
))
306 lcnt
= vs_sm_nlines(sp
, HMAP
, LNO
, HALFTEXT(sp
));
307 if (lcnt
< HALFTEXT(sp
)) {
309 * If less than half a screen below the line, scroll up until
310 * the line is the first line on the screen. Special check so
311 * that if the screen has been emptied, we refill it.
313 if (db_exist(sp
, HMAP
->lno
)) {
321 * If less than a half screen from the bottom of the file,
322 * put the last line of the file on the bottom of the screen.
324 bottom
: if (db_last(sp
, &lastline
))
327 tmp
.coff
= HMAP
->coff
;
329 lcnt
= vs_sm_nlines(sp
, &tmp
, lastline
+1, sp
->t_rows
);
330 if (lcnt
< HALFTEXT(sp
)) {
331 if (vs_sm_fill(sp
, lastline
, P_BOTTOM
))
333 F_SET(sp
, SC_SCR_REDRAW
);
336 /* It's not close, just put the line in the middle. */
341 * If less than half a screen from the top of the file, put the first
342 * line of the file at the top of the screen. Otherwise, put the line
343 * in the middle of the screen.
346 tmp
.coff
= HMAP
->coff
;
348 lcnt
= vs_sm_nlines(sp
, &tmp
, LNO
, HALFTEXT(sp
));
349 if (lcnt
< HALFTEXT(sp
)) {
350 if (vs_sm_fill(sp
, 1, P_TOP
))
353 middle
: if (vs_sm_fill(sp
, LNO
, P_MIDDLE
))
356 top
: if (vs_sm_fill(sp
, LNO
, P_TOP
))
359 F_SET(sp
, SC_SCR_REDRAW
);
362 * At this point we know part of the line is on the screen. Since
363 * scrolling is done using logical lines, not physical, all of the
364 * line may not be on the screen. While that's not necessarily bad,
365 * if the part the cursor is on isn't there, we're going to lose.
366 * This can be tricky; if the line covers the entire screen, lno
367 * may be the same as both ends of the map, that's why we test BOTH
368 * the top and the bottom of the map. This isn't a problem for
369 * left-right scrolling, the cursor movement code handles the problem.
371 * There's a performance issue here if editing *really* long lines.
372 * This gets to the right spot by scrolling, and, in a binary, by
373 * scrolling hundreds of lines. If the adjustment looks like it's
374 * going to be a serious problem, refill the screen and repaint.
376 adjust
: if (!O_ISSET(sp
, O_LEFTRIGHT
) &&
377 (LNO
== HMAP
->lno
|| LNO
== TMAP
->lno
)) {
378 cnt
= vs_screens(sp
, LNO
, &CNO
);
379 if (LNO
== HMAP
->lno
&& cnt
< HMAP
->soff
) {
380 if ((HMAP
->soff
- cnt
) > HALFTEXT(sp
)) {
382 vs_sm_fill(sp
, OOBLNO
, P_TOP
);
383 F_SET(sp
, SC_SCR_REDRAW
);
385 while (cnt
< HMAP
->soff
)
389 if (LNO
== TMAP
->lno
&& cnt
> TMAP
->soff
) {
390 if ((cnt
- TMAP
->soff
) > HALFTEXT(sp
)) {
392 vs_sm_fill(sp
, OOBLNO
, P_BOTTOM
);
393 F_SET(sp
, SC_SCR_REDRAW
);
395 while (cnt
> TMAP
->soff
)
402 * If the screen needs to be repainted, skip cursor optimization.
403 * However, in the code above we skipped leftright scrolling on
404 * the grounds that the cursor code would handle it. Make sure
405 * the right screen is up.
407 if (F_ISSET(sp
, SC_SCR_REDRAW
)) {
408 if (O_ISSET(sp
, O_LEFTRIGHT
))
414 * 7: Cursor movements (current screen only).
416 if (!LF_ISSET(UPDATE_CURSOR
))
420 * Decide cursor position. If the line has changed, the cursor has
421 * moved over a tab, or don't know where the cursor was, reparse the
422 * line. Otherwise, we've just moved over fixed-width characters,
423 * and can calculate the left/right scrolling and cursor movement
424 * without reparsing the line. Note that we don't know which (if any)
425 * of the characters between the old and new cursor positions changed.
428 * With some work, it should be possible to handle tabs quickly, at
429 * least in obvious situations, like moving right and encountering
430 * a tab, without reparsing the whole line.
432 * If the line we're working with has changed, reread it..
434 if (F_ISSET(vip
, VIP_CUR_INVALID
) || LNO
!= OLNO
)
437 /* Otherwise, if nothing's changed, ignore the cursor. */
442 * Get the current line. If this fails, we either have an empty
443 * file and can just repaint, or there's a real problem. This
444 * isn't a performance issue because there aren't any ways to get
447 if (db_eget(sp
, LNO
, &p
, &len
, &isempty
)) {
454 /* Sanity checking. */
455 if (CNO
>= len
&& len
!= 0) {
456 msgq(sp
, M_ERR
, "Error: %s/%d: cno (%u) >= len (%u)",
457 tail(__FILE__
), __LINE__
, CNO
, len
);
462 * The basic scheme here is to look at the characters in between
463 * the old and new positions and decide how big they are on the
464 * screen, and therefore, how many screen positions to move.
468 * 7a: Cursor moved left.
470 * Point to the old character. The old cursor position can
471 * be past EOL if, for example, we just deleted the rest of
472 * the line. In this case, since we don't know the width of
473 * the characters we traversed, we have to do it slowly.
476 cnt
= (OCNO
- CNO
) + 1;
481 * Quick sanity check -- it's hard to figure out exactly when
482 * we cross a screen boundary as we do in the cursor right
483 * movement. If cnt is so large that we're going to cross the
484 * boundary no matter what, stop now.
486 if (SCNO
+ 1 + MAX_CHARACTER_COLUMNS
< cnt
)
490 * Count up the widths of the characters. If it's a tab
491 * character, go do it the the slow way.
493 for (cwtotal
= 0; cnt
--; cwtotal
+= KEY_COL(sp
, ch
))
494 if ((ch
= *(UCHAR_T
*)p
--) == '\t')
498 * Decrement the screen cursor by the total width of the
499 * characters minus 1.
504 * If we're moving left, and there's a wide character in the
505 * current position, go to the end of the character.
507 if (KEY_COL(sp
, ch
) > 1)
508 cwtotal
-= KEY_COL(sp
, ch
) - 1;
511 * If the new column moved us off of the current logical line,
512 * calculate a new one. If doing leftright scrolling, we've
513 * moved off of the current screen, as well.
520 * 7b: Cursor moved right.
522 * Point to the first character to the right.
528 * Count up the widths of the characters. If it's a tab
529 * character, go do it the the slow way. If we cross a
530 * screen boundary, we can quit.
532 for (cwtotal
= SCNO
; cnt
--;) {
533 if ((ch
= *(UCHAR_T
*)p
++) == '\t')
535 if ((cwtotal
+= KEY_COL(sp
, ch
)) >= SCREEN_COLS(sp
))
540 * Increment the screen cursor by the total width of the
545 /* See screen change comment in section 6a. */
546 if (SCNO
>= SCREEN_COLS(sp
))
551 * 7c: Fast cursor update.
553 * We have the current column, retrieve the current row.
555 fast
: (void)gp
->scr_cursor(sp
, &y
, ¬used
);
559 * 7d: Slow cursor update.
561 * Walk through the map and find the current line.
563 slow
: for (smp
= HMAP
; smp
->lno
!= LNO
; ++smp
);
566 * 7e: Leftright scrolling adjustment.
568 * If doing left-right scrolling and the cursor movement has changed
569 * the displayed screen, scroll the screen left or right, unless we're
570 * updating the info line in which case we just scroll that one line.
571 * We adjust the offset up or down until we have a window that covers
572 * the current column, making sure that we adjust differently for the
573 * first screen as compared to subsequent ones.
575 if (O_ISSET(sp
, O_LEFTRIGHT
)) {
577 * Get the screen column for this character, and correct
578 * for the number option offset.
580 cnt
= vs_columns(sp
, NULL
, LNO
, &CNO
, NULL
);
581 if (O_ISSET(sp
, O_NUMBER
))
582 cnt
-= O_NUMBER_LENGTH
;
584 /* Adjust the window towards the beginning of the line. */
588 if (off
>= O_VAL(sp
, O_SIDESCROLL
))
589 off
-= O_VAL(sp
, O_SIDESCROLL
);
594 } while (off
>= cnt
);
598 /* Adjust the window towards the end of the line. */
599 if ((off
== 0 && off
+ SCREEN_COLS(sp
) < cnt
) ||
600 (off
!= 0 && off
+ sp
->cols
< cnt
)) {
602 off
+= O_VAL(sp
, O_SIDESCROLL
);
603 } while (off
+ sp
->cols
< cnt
);
605 shifted
: /* Fill in screen map with the new offset. */
606 if (F_ISSET(sp
, SC_TINPUT_INFO
))
609 for (smp
= HMAP
; smp
<= TMAP
; ++smp
)
617 * We may have jumped here to adjust a leftright screen because
618 * redraw was set. If so, we have to paint the entire screen.
620 if (F_ISSET(sp
, SC_SCR_REDRAW
))
625 * Update the screen lines for this particular file line until we
626 * have a new screen cursor position.
629 vip
->sc_smap
= NULL
; smp
<= TMAP
&& smp
->lno
== LNO
; ++smp
) {
630 if (vs_line(sp
, smp
, &y
, &SCNO
))
632 if (y
!= (size_t)-1) {
640 * 8: Repaint the entire screen.
642 * Lost big, do what you have to do. We flush the cache, since
643 * SC_SCR_REDRAW gets set when the screen isn't worth fixing, and
644 * it's simpler to repaint. So, don't trust anything that we
645 * think we know about it.
647 paint
: for (smp
= HMAP
; smp
<= TMAP
; ++smp
)
649 for (y
= -1, vip
->sc_smap
= NULL
, smp
= HMAP
; smp
<= TMAP
; ++smp
) {
650 if (vs_line(sp
, smp
, &y
, &SCNO
))
652 if (y
!= (size_t)-1 && vip
->sc_smap
== NULL
)
656 * If it's a small screen and we're redrawing, clear the unused lines,
657 * ex may have overwritten them.
659 if (F_ISSET(sp
, SC_SCR_REDRAW
) && IS_SMALL(sp
))
660 for (cnt
= sp
->t_rows
; cnt
<= sp
->t_maxrows
; ++cnt
) {
661 (void)gp
->scr_move(sp
, cnt
, 0);
662 (void)gp
->scr_clrtoeol(sp
);
669 * Sanity checking. When the repainting code messes up, the usual
670 * result is we don't repaint the cursor and so sc_smap will be
671 * NULL. If we're debugging, die, otherwise restart from scratch.
674 if (vip
->sc_smap
== NULL
) {
675 fprintf(stderr
, "smap error\n");
680 if (vip
->sc_smap
== NULL
) {
681 F_SET(sp
, SC_SCR_REFORMAT
);
682 return (vs_paint(sp
, flags
));
687 * 9: Set the remembered cursor values.
693 * 10: Repaint the line numbers.
695 * If O_NUMBER is set and the VIP_N_RENUMBER bit is set, and we
696 * didn't repaint the screen, repaint all of the line numbers,
699 number
: if (O_ISSET(sp
, O_NUMBER
) &&
700 F_ISSET(vip
, VIP_N_RENUMBER
) && !didpaint
&& vs_number(sp
))
704 * 11: Update the mode line, position the cursor, and flush changes.
706 * If we warped the screen, we have to refresh everything.
709 LF_SET(UPDATE_CURSOR
| UPDATE_SCREEN
);
711 if (LF_ISSET(UPDATE_SCREEN
) && !IS_ONELINE(sp
) &&
712 !F_ISSET(vip
, VIP_S_MODELINE
) && !F_ISSET(sp
, SC_TINPUT_INFO
))
715 if (LF_ISSET(UPDATE_CURSOR
)) {
716 (void)gp
->scr_move(sp
, y
, SCNO
);
720 * If the screen shifted, we recalculate the "most favorite"
721 * cursor position. Vi won't know that we've warped the
722 * screen, so it's going to have a wrong idea about where the
723 * cursor should be. This is vi's problem, and fixing it here
724 * is a gross layering violation.
727 (void)vs_column(sp
, &sp
->rcm
);
730 if (LF_ISSET(UPDATE_SCREEN
))
731 (void)gp
->scr_refresh(sp
, F_ISSET(vip
, VIP_N_EX_PAINT
));
733 /* 12: Clear the flags that are handled by this routine. */
734 F_CLR(sp
, SC_SCR_CENTER
| SC_SCR_REDRAW
| SC_SCR_REFORMAT
| SC_SCR_TOP
);
735 F_CLR(vip
, VIP_CUR_INVALID
|
736 VIP_N_EX_PAINT
| VIP_N_REFRESH
| VIP_N_RENUMBER
| VIP_S_MODELINE
);
749 * Update the mode line.
754 static const char * const modes
[] = {
755 "215|Append", /* SM_APPEND */
756 "216|Change", /* SM_CHANGE */
757 "217|Command", /* SM_COMMAND */
758 "218|Insert", /* SM_INSERT */
759 "219|Replace", /* SM_REPLACE */
762 size_t cols
, curcol
, curlen
, endpoint
, len
, midpoint
;
763 const char *t
= NULL
;
770 * We put down the file name, the ruler, the mode and the dirty flag.
771 * If there's not enough room, there's not enough room, we don't play
772 * any special games. We try to put the ruler in the middle and the
773 * mode and dirty flag at the end.
776 * Leave the last character blank, in case it's a really dumb terminal
777 * with hardware scroll. Second, don't paint the last character in the
778 * screen, SunOS 4.1.1 and Ultrix 4.2 curses won't let you.
780 * Move to the last line on the screen.
782 (void)gp
->scr_move(sp
, LASTLINE(sp
), 0);
784 /* If more than one screen in the display, show the file name. */
787 for (p
= sp
->frp
->name
; *p
!= '\0'; ++p
);
788 for (ellipsis
= 0, cols
= sp
->cols
/ 2; --p
> sp
->frp
->name
;) {
793 if ((curlen
+= KEY_LEN(sp
, *p
)) > cols
) {
796 KEY_LEN(sp
, '.') * 3 + KEY_LEN(sp
, ' ');
797 while (curlen
> cols
) {
799 curlen
-= KEY_LEN(sp
, *p
);
806 (void)gp
->scr_addstr(sp
,
807 (const char *)KEY_NAME(sp
, '.'),
809 (void)gp
->scr_addstr(sp
,
810 (const char *)KEY_NAME(sp
, ' '), KEY_LEN(sp
, ' '));
812 for (; *p
!= '\0'; ++p
)
813 (void)gp
->scr_addstr(sp
,
814 (const char *)KEY_NAME(sp
, *p
), KEY_LEN(sp
, *p
));
817 /* Clear the rest of the line. */
818 (void)gp
->scr_clrtoeol(sp
);
821 * Display the ruler. If we're not at the midpoint yet, move there.
822 * Otherwise, add in two extra spaces.
824 * Adjust the current column for the fact that the editor uses it as
825 * a zero-based number.
828 * Assume that numbers, commas, and spaces only take up a single
829 * column on the screen.
832 if (O_ISSET(sp
, O_RULER
)) {
833 vs_column(sp
, &curcol
);
835 snprintf(buf
, sizeof(buf
), "%lu,%lu",
836 (unsigned long)sp
->lno
, (unsigned long)curcol
+ 1);
838 midpoint
= (cols
- ((len
+ 1) / 2)) / 2;
839 if (curlen
< midpoint
) {
840 (void)gp
->scr_move(sp
, LASTLINE(sp
), midpoint
);
842 } else if (curlen
+ 2 + len
< cols
) {
843 (void)gp
->scr_addstr(sp
, " ", 2);
846 (void)gp
->scr_addstr(sp
, buf
, len
);
850 * Display the mode and the modified flag, as close to the end of the
851 * line as possible, but guaranteeing at least two spaces between the
852 * ruler and the modified flag.
856 if (O_ISSET(sp
, O_SHOWMODE
)) {
857 if (F_ISSET(sp
->ep
, F_MODIFIED
))
859 t
= msg_cat(sp
, modes
[sp
->showmode
], &len
);
863 if (endpoint
> curlen
+ 2) {
864 (void)gp
->scr_move(sp
, LASTLINE(sp
), endpoint
);
865 if (O_ISSET(sp
, O_SHOWMODE
)) {
866 if (F_ISSET(sp
->ep
, F_MODIFIED
))
867 (void)gp
->scr_addstr(sp
,
868 (const char *)KEY_NAME(sp
, '*'),
870 (void)gp
->scr_addstr(sp
, t
, len
);