mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 10:31:48 +00:00
fix(ruler)!: consistent width in last line and statusline
Problem: Traditionally, the ruler in the last line is one cell shorter than in the statusline, leaving the last cell of the screen blank. According to code comments, this is in order to prevent unwanted scrolling on "some" (unspecified, but presumably ancient) terminals. Berkeley vi is more specific in its `vs_modeline` function: dumb terminals with hardware scroll, SunOS 4.1.1 and Ultrix 4.2 curses. (n)curses still has a similar limitation in `(w)addstr`, but apparently only for historical reasons. Maintaining the different widths leads to awkward inconsistencies when the ruler is configured with 'rulerformat', except for the special case where it contains a top-level `%=`. Shifting the ruler in the last line to the left would be a solution, but the empty cell at the end doesn't seem to be relevant anymore. Solution: extend the ruler in the last line all the way to the right edge of the screen, just like in the statusline. The exact same amount of place will be available to the rest of the UI as before. BREAKING CHANGE: - the default ruler width is now 18 cells - the last cell of the screen is no longer empty Closes #41076
This commit is contained in:
@@ -1125,7 +1125,7 @@ static void recording_mode(int hl_id)
|
||||
msg_puts_hl(s, hl_id, false);
|
||||
}
|
||||
|
||||
#define COL_RULER 17 // columns needed by standard ruler
|
||||
#define COL_RULER 18 // columns needed by standard ruler
|
||||
|
||||
/// Compute columns for ruler and shown command. 'sc_col' is also used to
|
||||
/// decide what the maximum length of a message on the status line can be.
|
||||
@@ -1138,7 +1138,7 @@ void comp_col(void)
|
||||
sc_col = 0;
|
||||
ru_col = 0;
|
||||
if (p_ru) {
|
||||
ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
|
||||
ru_col = (ru_wid ? ru_wid : COL_RULER);
|
||||
// no last status line, adjust sc_col
|
||||
if (!last_has_status) {
|
||||
sc_col = ru_col;
|
||||
|
||||
@@ -7312,7 +7312,7 @@ local options = {
|
||||
The format of this option is like that of 'statusline'.
|
||||
This option cannot be set in a modeline when 'modelineexpr' is off.
|
||||
|
||||
The default ruler width is 17 characters. To make the ruler 15
|
||||
The default ruler width is 18 characters. To make the ruler 15
|
||||
characters wide, put "%15(" at the start and "%)" at the end.
|
||||
Example: >vim
|
||||
set rulerformat=%15(%c%V\ %p%%%)
|
||||
|
||||
@@ -338,7 +338,6 @@ static void win_redr_stl_expr(win_T *wp, bool draw_winbar, bool draw_ruler, bool
|
||||
if (!in_status_line) {
|
||||
row = Rows - 1;
|
||||
grid = grid_adjust(&msg_grid_adj, &row, &col);
|
||||
maxwidth--; // writing in last column may cause scrolling
|
||||
fillchar = schar_from_ascii(' ');
|
||||
group = HLF_MSG;
|
||||
}
|
||||
@@ -557,14 +556,9 @@ void redraw_ruler(void)
|
||||
(int)virtcol + 1);
|
||||
|
||||
// Add a "50%" if there is room for it.
|
||||
// On the last line, don't print in the last column (scrolls the
|
||||
// screen up on some terminals).
|
||||
char rel_pos[RULER_BUF_LEN];
|
||||
int rel_poslen = get_rel_pos(wp, rel_pos, RULER_BUF_LEN);
|
||||
int n1 = bufferlen + vim_strsize(rel_pos);
|
||||
if (wp->w_status_height == 0 && !is_stl_global && !ui_has(kUIMessages)) {
|
||||
n1++; // can't use last char of screen
|
||||
}
|
||||
|
||||
int this_ru_col = ru_col - (Columns - width);
|
||||
// Never use more than half the window/screen width, leave the other half
|
||||
|
||||
Reference in New Issue
Block a user