mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 16:58:17 +00:00
Merge pull request #13595 from teto/fix-filler
de curwinify some functions
This commit is contained in:
@@ -381,7 +381,7 @@ static void insert_enter(InsertState *s)
|
|||||||
|
|
||||||
// Need to recompute the cursor position, it might move when the cursor is
|
// Need to recompute the cursor position, it might move when the cursor is
|
||||||
// on a TAB or special character.
|
// on a TAB or special character.
|
||||||
curs_columns(true);
|
curs_columns(curwin, true);
|
||||||
|
|
||||||
// Enable langmap or IME, indicated by 'iminsert'.
|
// Enable langmap or IME, indicated by 'iminsert'.
|
||||||
// Note that IME may enabled/disabled without us noticing here, thus the
|
// Note that IME may enabled/disabled without us noticing here, thus the
|
||||||
@@ -594,7 +594,7 @@ static int insert_check(VimState *state)
|
|||||||
|
|
||||||
if (curwin->w_wcol < s->mincol - curbuf->b_p_ts
|
if (curwin->w_wcol < s->mincol - curbuf->b_p_ts
|
||||||
&& curwin->w_wrow == curwin->w_winrow
|
&& curwin->w_wrow == curwin->w_winrow
|
||||||
+ curwin->w_height_inner - 1 - get_scrolloff_value()
|
+ curwin->w_height_inner - 1 - get_scrolloff_value(curwin)
|
||||||
&& (curwin->w_cursor.lnum != curwin->w_topline
|
&& (curwin->w_cursor.lnum != curwin->w_topline
|
||||||
|| curwin->w_topfill > 0)) {
|
|| curwin->w_topfill > 0)) {
|
||||||
if (curwin->w_topfill > 0) {
|
if (curwin->w_topfill > 0) {
|
||||||
@@ -608,7 +608,7 @@ static int insert_check(VimState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// May need to adjust w_topline to show the cursor.
|
// May need to adjust w_topline to show the cursor.
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
|
|
||||||
s->did_backspace = false;
|
s->did_backspace = false;
|
||||||
|
|
||||||
@@ -1561,7 +1561,7 @@ void edit_putchar(int c, bool highlight)
|
|||||||
int attr;
|
int attr;
|
||||||
|
|
||||||
if (curwin->w_grid.chars != NULL || default_grid.chars != NULL) {
|
if (curwin->w_grid.chars != NULL || default_grid.chars != NULL) {
|
||||||
update_topline(); // just in case w_topline isn't valid
|
update_topline(curwin); // just in case w_topline isn't valid
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
if (highlight) {
|
if (highlight) {
|
||||||
attr = HL_ATTR(HLF_8);
|
attr = HL_ATTR(HLF_8);
|
||||||
@@ -1677,7 +1677,7 @@ void display_dollar(colnr_T col)
|
|||||||
// If on the last byte of a multi-byte move to the first byte.
|
// If on the last byte of a multi-byte move to the first byte.
|
||||||
char_u *p = get_cursor_line_ptr();
|
char_u *p = get_cursor_line_ptr();
|
||||||
curwin->w_cursor.col -= utf_head_off(p, p + col);
|
curwin->w_cursor.col -= utf_head_off(p, p + col);
|
||||||
curs_columns(false); // Recompute w_wrow and w_wcol
|
curs_columns(curwin, false); // Recompute w_wrow and w_wcol
|
||||||
if (curwin->w_wcol < curwin->w_grid.Columns) {
|
if (curwin->w_wcol < curwin->w_grid.Columns) {
|
||||||
edit_putchar('$', false);
|
edit_putchar('$', false);
|
||||||
dollar_vcol = curwin->w_virtcol;
|
dollar_vcol = curwin->w_virtcol;
|
||||||
@@ -5327,8 +5327,9 @@ static int ins_complete(int c, bool enable_pum)
|
|||||||
compl_curr_match->cp_number);
|
compl_curr_match->cp_number);
|
||||||
edit_submode_extra = match_ref;
|
edit_submode_extra = match_ref;
|
||||||
edit_submode_highl = HLF_R;
|
edit_submode_highl = HLF_R;
|
||||||
if (dollar_vcol >= 0)
|
if (dollar_vcol >= 0) {
|
||||||
curs_columns(FALSE);
|
curs_columns(curwin, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6158,7 +6159,7 @@ internal_format (
|
|||||||
curwin->w_p_lbr = has_lbr;
|
curwin->w_p_lbr = has_lbr;
|
||||||
|
|
||||||
if (!format_only && haveto_redraw) {
|
if (!format_only && haveto_redraw) {
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
redraw_curbuf_later(VALID);
|
redraw_curbuf_later(VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6807,7 +6808,7 @@ cursor_up (
|
|||||||
coladvance(curwin->w_curswant);
|
coladvance(curwin->w_curswant);
|
||||||
|
|
||||||
if (upd_topline) {
|
if (upd_topline) {
|
||||||
update_topline(); // make sure curwin->w_topline is valid
|
update_topline(curwin); // make sure curwin->w_topline is valid
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -6858,7 +6859,7 @@ cursor_down (
|
|||||||
coladvance(curwin->w_curswant);
|
coladvance(curwin->w_curswant);
|
||||||
|
|
||||||
if (upd_topline) {
|
if (upd_topline) {
|
||||||
update_topline(); // make sure curwin->w_topline is valid
|
update_topline(curwin); // make sure curwin->w_topline is valid
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
@@ -7070,7 +7070,7 @@ void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
check_cursor_col();
|
check_cursor_col();
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_curbuf) {
|
if (!is_curbuf) {
|
||||||
@@ -7782,13 +7782,13 @@ pos_T *var2fpos(const typval_T *const tv, const int dollar_lnum,
|
|||||||
if (name[0] == 'w' && dollar_lnum) {
|
if (name[0] == 'w' && dollar_lnum) {
|
||||||
pos.col = 0;
|
pos.col = 0;
|
||||||
if (name[1] == '0') { // "w0": first visible line
|
if (name[1] == '0') { // "w0": first visible line
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
// In silent Ex mode topline is zero, but that's not a valid line
|
// In silent Ex mode topline is zero, but that's not a valid line
|
||||||
// number; use one instead.
|
// number; use one instead.
|
||||||
pos.lnum = curwin->w_topline > 0 ? curwin->w_topline : 1;
|
pos.lnum = curwin->w_topline > 0 ? curwin->w_topline : 1;
|
||||||
return &pos;
|
return &pos;
|
||||||
} else if (name[1] == '$') { // "w$": last visible line
|
} else if (name[1] == '$') { // "w$": last visible line
|
||||||
validate_botline();
|
validate_botline(curwin);
|
||||||
// In silent Ex mode botline is zero, return zero then.
|
// In silent Ex mode botline is zero, return zero then.
|
||||||
pos.lnum = curwin->w_botline > 0 ? curwin->w_botline - 1 : 0;
|
pos.lnum = curwin->w_botline > 0 ? curwin->w_botline - 1 : 0;
|
||||||
return &pos;
|
return &pos;
|
||||||
|
@@ -2706,7 +2706,7 @@ int do_ecmd(
|
|||||||
if (topline == 0 && command == NULL) {
|
if (topline == 0 && command == NULL) {
|
||||||
*so_ptr = 999; // force cursor to be vertically centered in the window
|
*so_ptr = 999; // force cursor to be vertically centered in the window
|
||||||
}
|
}
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
curwin->w_scbind_pos = curwin->w_topline;
|
curwin->w_scbind_pos = curwin->w_topline;
|
||||||
*so_ptr = n;
|
*so_ptr = n;
|
||||||
redraw_curbuf_later(NOT_VALID); // redraw this buffer later
|
redraw_curbuf_later(NOT_VALID); // redraw this buffer later
|
||||||
@@ -3705,7 +3705,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
|||||||
+ len_change;
|
+ len_change;
|
||||||
highlight_match = TRUE;
|
highlight_match = TRUE;
|
||||||
|
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
update_screen(SOME_VALID);
|
update_screen(SOME_VALID);
|
||||||
highlight_match = false;
|
highlight_match = false;
|
||||||
@@ -5740,7 +5740,7 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr,
|
|||||||
|
|
||||||
redraw_later(curwin, SOME_VALID);
|
redraw_later(curwin, SOME_VALID);
|
||||||
win_enter(save_curwin, false); // Return to original window
|
win_enter(save_curwin, false); // Return to original window
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
|
|
||||||
// Update screen now.
|
// Update screen now.
|
||||||
int save_rd = RedrawingDisabled;
|
int save_rd = RedrawingDisabled;
|
||||||
|
@@ -7362,7 +7362,7 @@ static void ex_syncbind(exarg_T *eap)
|
|||||||
topline = curwin->w_topline;
|
topline = curwin->w_topline;
|
||||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||||
if (wp->w_p_scb && wp->w_buffer) {
|
if (wp->w_p_scb && wp->w_buffer) {
|
||||||
y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value();
|
y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(curwin);
|
||||||
if (topline > y) {
|
if (topline > y) {
|
||||||
topline = y;
|
topline = y;
|
||||||
}
|
}
|
||||||
@@ -8050,7 +8050,7 @@ static void ex_redraw(exarg_T *eap)
|
|||||||
RedrawingDisabled = 0;
|
RedrawingDisabled = 0;
|
||||||
p_lz = FALSE;
|
p_lz = FALSE;
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
if (eap->forceit) {
|
if (eap->forceit) {
|
||||||
redraw_all_later(NOT_VALID);
|
redraw_all_later(NOT_VALID);
|
||||||
}
|
}
|
||||||
@@ -8199,10 +8199,11 @@ static void ex_mark(exarg_T *eap)
|
|||||||
*/
|
*/
|
||||||
void update_topline_cursor(void)
|
void update_topline_cursor(void)
|
||||||
{
|
{
|
||||||
check_cursor(); /* put cursor on valid line */
|
check_cursor(); // put cursor on valid line
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
if (!curwin->w_p_wrap)
|
if (!curwin->w_p_wrap) {
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
|
}
|
||||||
update_curswant();
|
update_curswant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -523,7 +523,7 @@ static void may_do_incsearch_highlighting(int firstc, long count,
|
|||||||
// positioned in the same way as the actual search command
|
// positioned in the same way as the actual search command
|
||||||
restore_viewstate(&s->old_viewstate);
|
restore_viewstate(&s->old_viewstate);
|
||||||
changed_cline_bef_curs();
|
changed_cline_bef_curs();
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
|
|
||||||
if (found != 0) {
|
if (found != 0) {
|
||||||
pos_T save_pos = curwin->w_cursor;
|
pos_T save_pos = curwin->w_cursor;
|
||||||
@@ -1546,7 +1546,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count,
|
|||||||
set_search_match(&s->match_end);
|
set_search_match(&s->match_end);
|
||||||
curwin->w_cursor = s->match_start;
|
curwin->w_cursor = s->match_start;
|
||||||
changed_cline_bef_curs();
|
changed_cline_bef_curs();
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
highlight_match = true;
|
highlight_match = true;
|
||||||
save_viewstate(&s->old_viewstate);
|
save_viewstate(&s->old_viewstate);
|
||||||
@@ -2242,7 +2242,7 @@ static int command_line_changed(CommandLineState *s)
|
|||||||
// Restore the window "view".
|
// Restore the window "view".
|
||||||
curwin->w_cursor = s->is_state.save_cursor;
|
curwin->w_cursor = s->is_state.save_cursor;
|
||||||
restore_viewstate(&s->is_state.old_viewstate);
|
restore_viewstate(&s->is_state.old_viewstate);
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
|
|
||||||
redrawcmdline();
|
redrawcmdline();
|
||||||
|
|
||||||
|
@@ -5105,8 +5105,8 @@ void buf_reload(buf_T *buf, int orig_mode)
|
|||||||
curwin->w_topline = old_topline;
|
curwin->w_topline = old_topline;
|
||||||
curwin->w_cursor = old_cursor;
|
curwin->w_cursor = old_cursor;
|
||||||
check_cursor();
|
check_cursor();
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
keep_filetype = FALSE;
|
keep_filetype = false;
|
||||||
|
|
||||||
/* Update folds unless they are defined manually. */
|
/* Update folds unless they are defined manually. */
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
|
@@ -539,7 +539,7 @@ int main(int argc, char **argv)
|
|||||||
// When a startup script or session file setup for diff'ing and
|
// When a startup script or session file setup for diff'ing and
|
||||||
// scrollbind, sync the scrollbind now.
|
// scrollbind, sync the scrollbind now.
|
||||||
if (curwin->w_p_diff && curwin->w_p_scb) {
|
if (curwin->w_p_diff && curwin->w_p_scb) {
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
check_scrollbind((linenr_T)0, 0L);
|
check_scrollbind((linenr_T)0, 0L);
|
||||||
TIME_MSG("diff scrollbinding");
|
TIME_MSG("diff scrollbinding");
|
||||||
}
|
}
|
||||||
|
550
src/nvim/move.c
550
src/nvim/move.c
@@ -129,98 +129,99 @@ void redraw_for_cursorline(win_T *wp)
|
|||||||
*/
|
*/
|
||||||
void update_topline_redraw(void)
|
void update_topline_redraw(void)
|
||||||
{
|
{
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
if (must_redraw)
|
if (must_redraw) {
|
||||||
update_screen(0);
|
update_screen(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update curwin->w_topline to move the cursor onto the screen.
|
* Update curwin->w_topline to move the cursor onto the screen.
|
||||||
*/
|
*/
|
||||||
void update_topline(void)
|
void update_topline(win_T *wp)
|
||||||
{
|
{
|
||||||
linenr_T old_topline;
|
linenr_T old_topline;
|
||||||
int old_topfill;
|
int old_topfill;
|
||||||
bool check_topline = false;
|
bool check_topline = false;
|
||||||
bool check_botline = false;
|
bool check_botline = false;
|
||||||
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
|
long *so_ptr = wp->w_p_so >= 0 ? &wp->w_p_so : &p_so;
|
||||||
long save_so = *so_ptr;
|
long save_so = *so_ptr;
|
||||||
|
|
||||||
// If there is no valid screen and when the window height is zero just use
|
// If there is no valid screen and when the window height is zero just use
|
||||||
// the cursor line.
|
// the cursor line.
|
||||||
if (!default_grid.chars || curwin->w_height_inner == 0) {
|
if (!default_grid.chars || wp->w_height_inner == 0) {
|
||||||
curwin->w_topline = curwin->w_cursor.lnum;
|
wp->w_topline = wp->w_cursor.lnum;
|
||||||
curwin->w_botline = curwin->w_topline;
|
wp->w_botline = wp->w_topline;
|
||||||
curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
|
wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
|
||||||
curwin->w_viewport_invalid = true;
|
wp->w_viewport_invalid = true;
|
||||||
curwin->w_scbind_pos = 1;
|
wp->w_scbind_pos = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_cursor_moved(curwin);
|
check_cursor_moved(wp);
|
||||||
if (curwin->w_valid & VALID_TOPLINE)
|
if (wp->w_valid & VALID_TOPLINE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// When dragging with the mouse, don't scroll that quickly
|
// When dragging with the mouse, don't scroll that quickly
|
||||||
if (mouse_dragging > 0) {
|
if (mouse_dragging > 0) {
|
||||||
*so_ptr = mouse_dragging - 1;
|
*so_ptr = mouse_dragging - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_topline = curwin->w_topline;
|
old_topline = wp->w_topline;
|
||||||
old_topfill = curwin->w_topfill;
|
old_topfill = wp->w_topfill;
|
||||||
|
|
||||||
// If the buffer is empty, always set topline to 1.
|
// If the buffer is empty, always set topline to 1.
|
||||||
if (BUFEMPTY()) { // special case - file is empty
|
if (BUFEMPTY()) { // special case - file is empty
|
||||||
if (curwin->w_topline != 1) {
|
if (wp->w_topline != 1) {
|
||||||
redraw_later(curwin, NOT_VALID);
|
redraw_later(wp, NOT_VALID);
|
||||||
}
|
}
|
||||||
curwin->w_topline = 1;
|
wp->w_topline = 1;
|
||||||
curwin->w_botline = 2;
|
wp->w_botline = 2;
|
||||||
curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
|
wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
|
||||||
curwin->w_viewport_invalid = true;
|
wp->w_viewport_invalid = true;
|
||||||
curwin->w_scbind_pos = 1;
|
wp->w_scbind_pos = 1;
|
||||||
}
|
} else {
|
||||||
/*
|
// If the cursor is above or near the top of the window, scroll the window
|
||||||
* If the cursor is above or near the top of the window, scroll the window
|
// to show the line the cursor is in, with 'scrolloff' context.
|
||||||
* to show the line the cursor is in, with 'scrolloff' context.
|
if (wp->w_topline > 1) {
|
||||||
*/
|
// If the cursor is above topline, scrolling is always needed.
|
||||||
else {
|
// If the cursor is far below topline and there is no folding,
|
||||||
if (curwin->w_topline > 1) {
|
// scrolling down is never needed.
|
||||||
/* If the cursor is above topline, scrolling is always needed.
|
if (wp->w_cursor.lnum < wp->w_topline) {
|
||||||
* If the cursor is far below topline and there is no folding,
|
|
||||||
* scrolling down is never needed. */
|
|
||||||
if (curwin->w_cursor.lnum < curwin->w_topline)
|
|
||||||
check_topline = true;
|
check_topline = true;
|
||||||
else if (check_top_offset())
|
} else if (check_top_offset()) {
|
||||||
check_topline = true;
|
check_topline = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Check if there are more filler lines than allowed. */
|
// Check if there are more filler lines than allowed.
|
||||||
if (!check_topline && curwin->w_topfill > diff_check_fill(curwin,
|
if (!check_topline && wp->w_topfill > diff_check_fill(wp, wp->w_topline)) {
|
||||||
curwin->w_topline))
|
|
||||||
check_topline = true;
|
check_topline = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (check_topline) {
|
if (check_topline) {
|
||||||
int halfheight = curwin->w_height_inner / 2 - 1;
|
int halfheight = wp->w_height_inner / 2 - 1;
|
||||||
if (halfheight < 2) {
|
if (halfheight < 2) {
|
||||||
halfheight = 2;
|
halfheight = 2;
|
||||||
}
|
}
|
||||||
long n;
|
long n;
|
||||||
if (hasAnyFolding(curwin)) {
|
if (hasAnyFolding(wp)) {
|
||||||
/* Count the number of logical lines between the cursor and
|
// Count the number of logical lines between the cursor and
|
||||||
* topline + p_so (approximation of how much will be
|
// topline + p_so (approximation of how much will be
|
||||||
* scrolled). */
|
// scrolled).
|
||||||
n = 0;
|
n = 0;
|
||||||
for (linenr_T lnum = curwin->w_cursor.lnum;
|
for (linenr_T lnum = wp->w_cursor.lnum;
|
||||||
lnum < curwin->w_topline + *so_ptr; lnum++) {
|
lnum < wp->w_topline + *so_ptr; lnum++) {
|
||||||
n++;
|
n++;
|
||||||
// stop at end of file or when we know we are far off
|
// stop at end of file or when we know we are far off
|
||||||
if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight) {
|
assert(wp->w_buffer != 0);
|
||||||
|
if (lnum >= wp->w_buffer->b_ml.ml_line_count || n >= halfheight) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(void)hasFolding(lnum, NULL, &lnum);
|
(void)hasFoldingWin(wp, lnum, NULL, &lnum, true, NULL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
n = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum;
|
n = wp->w_topline + *so_ptr - wp->w_cursor.lnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we weren't very close to begin with, we scroll to put the
|
/* If we weren't very close to begin with, we scroll to put the
|
||||||
@@ -233,8 +234,8 @@ void update_topline(void)
|
|||||||
check_botline = true;
|
check_botline = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Make sure topline is the first line of a fold. */
|
// Make sure topline is the first line of a fold.
|
||||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
(void)hasFoldingWin(wp, wp->w_topline, &wp->w_topline, NULL, true, NULL);
|
||||||
check_botline = true;
|
check_botline = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,35 +249,36 @@ void update_topline(void)
|
|||||||
* for every small change.
|
* for every small change.
|
||||||
*/
|
*/
|
||||||
if (check_botline) {
|
if (check_botline) {
|
||||||
if (!(curwin->w_valid & VALID_BOTLINE_AP))
|
if (!(wp->w_valid & VALID_BOTLINE_AP)) {
|
||||||
validate_botline();
|
validate_botline(wp);
|
||||||
|
}
|
||||||
|
|
||||||
if (curwin->w_botline <= curbuf->b_ml.ml_line_count) {
|
assert(wp->w_buffer != 0);
|
||||||
if (curwin->w_cursor.lnum < curwin->w_botline) {
|
if (wp->w_botline <= wp->w_buffer->b_ml.ml_line_count) {
|
||||||
if (((long)curwin->w_cursor.lnum
|
if (wp->w_cursor.lnum < wp->w_botline) {
|
||||||
>= (long)curwin->w_botline - *so_ptr
|
if (((long)wp->w_cursor.lnum
|
||||||
|| hasAnyFolding(curwin)
|
>= (long)wp->w_botline - *so_ptr
|
||||||
)) {
|
|| hasAnyFolding(wp))) {
|
||||||
lineoff_T loff;
|
lineoff_T loff;
|
||||||
|
|
||||||
/* Cursor is (a few lines) above botline, check if there are
|
/* Cursor is (a few lines) above botline, check if there are
|
||||||
* 'scrolloff' window lines below the cursor. If not, need to
|
* 'scrolloff' window lines below the cursor. If not, need to
|
||||||
* scroll. */
|
* scroll. */
|
||||||
int n = curwin->w_empty_rows;
|
int n = wp->w_empty_rows;
|
||||||
loff.lnum = curwin->w_cursor.lnum;
|
loff.lnum = wp->w_cursor.lnum;
|
||||||
/* In a fold go to its last line. */
|
// In a fold go to its last line.
|
||||||
(void)hasFolding(loff.lnum, NULL, &loff.lnum);
|
(void)hasFoldingWin(wp, loff.lnum, NULL, &loff.lnum, true, NULL);
|
||||||
loff.fill = 0;
|
loff.fill = 0;
|
||||||
n += curwin->w_filler_rows;
|
n += wp->w_filler_rows;
|
||||||
loff.height = 0;
|
loff.height = 0;
|
||||||
while (loff.lnum < curwin->w_botline
|
while (loff.lnum < wp->w_botline
|
||||||
&& (loff.lnum + 1 < curwin->w_botline || loff.fill == 0)
|
&& (loff.lnum + 1 < wp->w_botline || loff.fill == 0)
|
||||||
) {
|
) {
|
||||||
n += loff.height;
|
n += loff.height;
|
||||||
if (n >= *so_ptr) {
|
if (n >= *so_ptr) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
botline_forw(&loff);
|
botline_forw(wp, &loff);
|
||||||
}
|
}
|
||||||
if (n >= *so_ptr) {
|
if (n >= *so_ptr) {
|
||||||
// sufficient context, no need to scroll
|
// sufficient context, no need to scroll
|
||||||
@@ -289,23 +291,23 @@ void update_topline(void)
|
|||||||
}
|
}
|
||||||
if (check_botline) {
|
if (check_botline) {
|
||||||
long line_count = 0;
|
long line_count = 0;
|
||||||
if (hasAnyFolding(curwin)) {
|
if (hasAnyFolding(wp)) {
|
||||||
/* Count the number of logical lines between the cursor and
|
// Count the number of logical lines between the cursor and
|
||||||
* botline - p_so (approximation of how much will be
|
// botline - p_so (approximation of how much will be
|
||||||
* scrolled). */
|
// scrolled).
|
||||||
for (linenr_T lnum = curwin->w_cursor.lnum;
|
for (linenr_T lnum = wp->w_cursor.lnum;
|
||||||
lnum >= curwin->w_botline - *so_ptr; lnum--) {
|
lnum >= wp->w_botline - *so_ptr; lnum--) {
|
||||||
line_count++;
|
line_count++;
|
||||||
// stop at end of file or when we know we are far off
|
// stop at end of file or when we know we are far off
|
||||||
if (lnum <= 0 || line_count > curwin->w_height_inner + 1) {
|
if (lnum <= 0 || line_count > wp->w_height_inner + 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(void)hasFolding(lnum, &lnum, NULL);
|
(void)hasFolding(lnum, &lnum, NULL);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
line_count = curwin->w_cursor.lnum - curwin->w_botline
|
line_count = wp->w_cursor.lnum - wp->w_botline + 1 + *so_ptr;
|
||||||
+ 1 + *so_ptr;
|
}
|
||||||
if (line_count <= curwin->w_height_inner + 1) {
|
if (line_count <= wp->w_height_inner + 1) {
|
||||||
scroll_cursor_bot(scrolljump_value(), false);
|
scroll_cursor_bot(scrolljump_value(), false);
|
||||||
} else {
|
} else {
|
||||||
scroll_cursor_halfway(false);
|
scroll_cursor_halfway(false);
|
||||||
@@ -313,25 +315,25 @@ void update_topline(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curwin->w_valid |= VALID_TOPLINE;
|
wp->w_valid |= VALID_TOPLINE;
|
||||||
curwin->w_viewport_invalid = true;
|
wp->w_viewport_invalid = true;
|
||||||
win_check_anchored_floats(curwin);
|
win_check_anchored_floats(wp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need to redraw when topline changed.
|
* Need to redraw when topline changed.
|
||||||
*/
|
*/
|
||||||
if (curwin->w_topline != old_topline
|
if (wp->w_topline != old_topline
|
||||||
|| curwin->w_topfill != old_topfill
|
|| wp->w_topfill != old_topfill
|
||||||
) {
|
) {
|
||||||
dollar_vcol = -1;
|
dollar_vcol = -1;
|
||||||
if (curwin->w_skipcol != 0) {
|
if (wp->w_skipcol != 0) {
|
||||||
curwin->w_skipcol = 0;
|
wp->w_skipcol = 0;
|
||||||
redraw_later(curwin, NOT_VALID);
|
redraw_later(wp, NOT_VALID);
|
||||||
} else {
|
} else {
|
||||||
redraw_later(curwin, VALID);
|
redraw_later(wp, VALID);
|
||||||
}
|
}
|
||||||
// May need to set w_skipcol when cursor in w_topline.
|
// May need to set w_skipcol when cursor in w_topline.
|
||||||
if (curwin->w_cursor.lnum == curwin->w_topline) {
|
if (wp->w_cursor.lnum == wp->w_topline) {
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -346,7 +348,7 @@ void update_topline_win(win_T* win)
|
|||||||
{
|
{
|
||||||
win_T *save_curwin;
|
win_T *save_curwin;
|
||||||
switch_win(&save_curwin, NULL, win, NULL, true);
|
switch_win(&save_curwin, NULL, win, NULL, true);
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
restore_win(save_curwin, NULL, true);
|
restore_win(save_curwin, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +370,7 @@ static int scrolljump_value(void)
|
|||||||
*/
|
*/
|
||||||
static bool check_top_offset(void)
|
static bool check_top_offset(void)
|
||||||
{
|
{
|
||||||
long so = get_scrolloff_value();
|
long so = get_scrolloff_value(curwin);
|
||||||
if (curwin->w_cursor.lnum < curwin->w_topline + so
|
if (curwin->w_cursor.lnum < curwin->w_topline + so
|
||||||
|| hasAnyFolding(curwin)
|
|| hasAnyFolding(curwin)
|
||||||
) {
|
) {
|
||||||
@@ -378,7 +380,7 @@ static bool check_top_offset(void)
|
|||||||
int n = curwin->w_topfill; // always have this context
|
int n = curwin->w_topfill; // always have this context
|
||||||
// Count the visible screen lines above the cursor line.
|
// Count the visible screen lines above the cursor line.
|
||||||
while (n < so) {
|
while (n < so) {
|
||||||
topline_back(&loff);
|
topline_back(curwin, &loff);
|
||||||
// Stop when included a line above the window.
|
// Stop when included a line above the window.
|
||||||
if (loff.lnum < curwin->w_topline
|
if (loff.lnum < curwin->w_topline
|
||||||
|| (loff.lnum == curwin->w_topline && loff.fill > 0)
|
|| (loff.lnum == curwin->w_topline && loff.fill > 0)
|
||||||
@@ -498,10 +500,11 @@ void changed_line_abv_curs_win(win_T *wp)
|
|||||||
/*
|
/*
|
||||||
* Make sure the value of curwin->w_botline is valid.
|
* Make sure the value of curwin->w_botline is valid.
|
||||||
*/
|
*/
|
||||||
void validate_botline(void)
|
void validate_botline(win_T *wp)
|
||||||
{
|
{
|
||||||
if (!(curwin->w_valid & VALID_BOTLINE))
|
if (!(wp->w_valid & VALID_BOTLINE)) {
|
||||||
comp_botline(curwin);
|
comp_botline(wp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -539,8 +542,9 @@ int cursor_valid(void)
|
|||||||
void validate_cursor(void)
|
void validate_cursor(void)
|
||||||
{
|
{
|
||||||
check_cursor_moved(curwin);
|
check_cursor_moved(curwin);
|
||||||
if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW))
|
if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW)) {
|
||||||
curs_columns(true);
|
curs_columns(curwin, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -720,8 +724,10 @@ int curwin_col_off2(void)
|
|||||||
// Compute curwin->w_wcol and curwin->w_virtcol.
|
// Compute curwin->w_wcol and curwin->w_virtcol.
|
||||||
// Also updates curwin->w_wrow and curwin->w_cline_row.
|
// Also updates curwin->w_wrow and curwin->w_cline_row.
|
||||||
// Also updates curwin->w_leftcol.
|
// Also updates curwin->w_leftcol.
|
||||||
|
// @param may_scroll when true, may scroll horizontally
|
||||||
void curs_columns(
|
void curs_columns(
|
||||||
int may_scroll /* when true, may scroll horizontally */
|
win_T *wp,
|
||||||
|
int may_scroll
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
@@ -729,136 +735,136 @@ void curs_columns(
|
|||||||
colnr_T startcol;
|
colnr_T startcol;
|
||||||
colnr_T endcol;
|
colnr_T endcol;
|
||||||
colnr_T prev_skipcol;
|
colnr_T prev_skipcol;
|
||||||
long so = get_scrolloff_value();
|
long so = get_scrolloff_value(wp);
|
||||||
long siso = get_sidescrolloff_value();
|
long siso = get_sidescrolloff_value(wp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First make sure that w_topline is valid (after moving the cursor).
|
* First make sure that w_topline is valid (after moving the cursor).
|
||||||
*/
|
*/
|
||||||
update_topline();
|
update_topline(wp);
|
||||||
|
|
||||||
// Next make sure that w_cline_row is valid.
|
// Next make sure that w_cline_row is valid.
|
||||||
if (!(curwin->w_valid & VALID_CROW)) {
|
if (!(wp->w_valid & VALID_CROW)) {
|
||||||
curs_rows(curwin);
|
curs_rows(wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the number of virtual columns.
|
* Compute the number of virtual columns.
|
||||||
*/
|
*/
|
||||||
if (curwin->w_cline_folded)
|
if (wp->w_cline_folded) {
|
||||||
/* In a folded line the cursor is always in the first column */
|
// In a folded line the cursor is always in the first column
|
||||||
startcol = curwin->w_virtcol = endcol = curwin->w_leftcol;
|
startcol = wp->w_virtcol = endcol = wp->w_leftcol;
|
||||||
else
|
} else {
|
||||||
getvvcol(curwin, &curwin->w_cursor,
|
getvvcol(wp, &wp->w_cursor, &startcol, &(wp->w_virtcol), &endcol);
|
||||||
&startcol, &(curwin->w_virtcol), &endcol);
|
}
|
||||||
|
|
||||||
/* remove '$' from change command when cursor moves onto it */
|
/* remove '$' from change command when cursor moves onto it */
|
||||||
if (startcol > dollar_vcol)
|
if (startcol > dollar_vcol)
|
||||||
dollar_vcol = -1;
|
dollar_vcol = -1;
|
||||||
|
|
||||||
int extra = curwin_col_off();
|
int extra = win_col_off(wp);
|
||||||
curwin->w_wcol = curwin->w_virtcol + extra;
|
wp->w_wcol = wp->w_virtcol + extra;
|
||||||
endcol += extra;
|
endcol += extra;
|
||||||
|
|
||||||
/*
|
// Now compute w_wrow, counting screen lines from w_cline_row.
|
||||||
* Now compute w_wrow, counting screen lines from w_cline_row.
|
wp->w_wrow = wp->w_cline_row;
|
||||||
*/
|
|
||||||
curwin->w_wrow = curwin->w_cline_row;
|
|
||||||
|
|
||||||
int textwidth = curwin->w_width_inner - extra;
|
int textwidth = wp->w_width_inner - extra;
|
||||||
if (textwidth <= 0) {
|
if (textwidth <= 0) {
|
||||||
// No room for text, put cursor in last char of window.
|
// No room for text, put cursor in last char of window.
|
||||||
curwin->w_wcol = curwin->w_width_inner - 1;
|
wp->w_wcol = wp->w_width_inner - 1;
|
||||||
curwin->w_wrow = curwin->w_height_inner - 1;
|
wp->w_wrow = wp->w_height_inner - 1;
|
||||||
} else if (curwin->w_p_wrap
|
} else if (wp->w_p_wrap
|
||||||
&& curwin->w_width_inner != 0
|
&& wp->w_width_inner != 0
|
||||||
) {
|
) {
|
||||||
width = textwidth + curwin_col_off2();
|
width = textwidth + win_col_off2(wp);
|
||||||
|
|
||||||
// long line wrapping, adjust curwin->w_wrow
|
// long line wrapping, adjust wp->w_wrow
|
||||||
if (curwin->w_wcol >= curwin->w_width_inner) {
|
if (wp->w_wcol >= wp->w_width_inner) {
|
||||||
// this same formula is used in validate_cursor_col()
|
// this same formula is used in validate_cursor_col()
|
||||||
n = (curwin->w_wcol - curwin->w_width_inner) / width + 1;
|
n = (wp->w_wcol - wp->w_width_inner) / width + 1;
|
||||||
curwin->w_wcol -= n * width;
|
wp->w_wcol -= n * width;
|
||||||
curwin->w_wrow += n;
|
wp->w_wrow += n;
|
||||||
|
|
||||||
/* When cursor wraps to first char of next line in Insert
|
/* When cursor wraps to first char of next line in Insert
|
||||||
* mode, the 'showbreak' string isn't shown, backup to first
|
* mode, the 'showbreak' string isn't shown, backup to first
|
||||||
* column */
|
* column */
|
||||||
if (*p_sbr && *get_cursor_pos_ptr() == NUL
|
if (*p_sbr && *get_cursor_pos_ptr() == NUL
|
||||||
&& curwin->w_wcol == (int)vim_strsize(p_sbr))
|
&& wp->w_wcol == (int)vim_strsize(p_sbr)) {
|
||||||
curwin->w_wcol = 0;
|
wp->w_wcol = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (may_scroll
|
||||||
/* No line wrapping: compute curwin->w_leftcol if scrolling is on and line
|
&& !wp->w_cline_folded
|
||||||
* is not folded.
|
) {
|
||||||
* If scrolling is off, curwin->w_leftcol is assumed to be 0 */
|
// No line wrapping: compute wp->w_leftcol if scrolling is on and line
|
||||||
else if (may_scroll
|
// is not folded.
|
||||||
&& !curwin->w_cline_folded
|
// If scrolling is off, wp->w_leftcol is assumed to be 0
|
||||||
) {
|
|
||||||
/*
|
// If Cursor is left of the screen, scroll rightwards.
|
||||||
* If Cursor is left of the screen, scroll rightwards.
|
// If Cursor is right of the screen, scroll leftwards
|
||||||
* If Cursor is right of the screen, scroll leftwards
|
// If we get closer to the edge than 'sidescrolloff', scroll a little
|
||||||
* If we get closer to the edge than 'sidescrolloff', scroll a little
|
// extra
|
||||||
* extra
|
|
||||||
*/
|
|
||||||
assert(siso <= INT_MAX);
|
assert(siso <= INT_MAX);
|
||||||
int off_left = startcol - curwin->w_leftcol - (int)siso;
|
int off_left = startcol - wp->w_leftcol - (int)siso;
|
||||||
int off_right =
|
int off_right =
|
||||||
endcol - curwin->w_leftcol - curwin->w_width_inner + (int)siso + 1;
|
endcol - wp->w_leftcol - wp->w_width_inner + (int)siso + 1;
|
||||||
if (off_left < 0 || off_right > 0) {
|
if (off_left < 0 || off_right > 0) {
|
||||||
int diff = (off_left < 0) ? -off_left: off_right;
|
int diff = (off_left < 0) ? -off_left: off_right;
|
||||||
|
|
||||||
/* When far off or not enough room on either side, put cursor in
|
/* When far off or not enough room on either side, put cursor in
|
||||||
* middle of window. */
|
* middle of window. */
|
||||||
int new_leftcol;
|
int new_leftcol;
|
||||||
if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left)
|
if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left) {
|
||||||
new_leftcol = curwin->w_wcol - extra - textwidth / 2;
|
new_leftcol = wp->w_wcol - extra - textwidth / 2;
|
||||||
else {
|
} else {
|
||||||
if (diff < p_ss) {
|
if (diff < p_ss) {
|
||||||
assert(p_ss <= INT_MAX);
|
assert(p_ss <= INT_MAX);
|
||||||
diff = (int)p_ss;
|
diff = (int)p_ss;
|
||||||
}
|
}
|
||||||
if (off_left < 0)
|
if (off_left < 0) {
|
||||||
new_leftcol = curwin->w_leftcol - diff;
|
new_leftcol = wp->w_leftcol - diff;
|
||||||
else
|
} else {
|
||||||
new_leftcol = curwin->w_leftcol + diff;
|
new_leftcol = wp->w_leftcol + diff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (new_leftcol < 0)
|
if (new_leftcol < 0)
|
||||||
new_leftcol = 0;
|
new_leftcol = 0;
|
||||||
if (new_leftcol != (int)curwin->w_leftcol) {
|
if (new_leftcol != (int)wp->w_leftcol) {
|
||||||
curwin->w_leftcol = new_leftcol;
|
wp->w_leftcol = new_leftcol;
|
||||||
win_check_anchored_floats(curwin);
|
win_check_anchored_floats(wp);
|
||||||
// screen has to be redrawn with new curwin->w_leftcol
|
// screen has to be redrawn with new wp->w_leftcol
|
||||||
redraw_later(curwin, NOT_VALID);
|
redraw_later(wp, NOT_VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curwin->w_wcol -= curwin->w_leftcol;
|
wp->w_wcol -= wp->w_leftcol;
|
||||||
} else if (curwin->w_wcol > (int)curwin->w_leftcol)
|
} else if (wp->w_wcol > (int)wp->w_leftcol) {
|
||||||
curwin->w_wcol -= curwin->w_leftcol;
|
wp->w_wcol -= wp->w_leftcol;
|
||||||
else
|
} else {
|
||||||
curwin->w_wcol = 0;
|
wp->w_wcol = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip over filler lines. At the top use w_topfill, there
|
/* Skip over filler lines. At the top use w_topfill, there
|
||||||
* may be some filler lines above the window. */
|
* may be some filler lines above the window. */
|
||||||
if (curwin->w_cursor.lnum == curwin->w_topline)
|
if (wp->w_cursor.lnum == wp->w_topline) {
|
||||||
curwin->w_wrow += curwin->w_topfill;
|
wp->w_wrow += wp->w_topfill;
|
||||||
else
|
} else {
|
||||||
curwin->w_wrow += diff_check_fill(curwin, curwin->w_cursor.lnum);
|
wp->w_wrow += diff_check_fill(wp, wp->w_cursor.lnum);
|
||||||
|
}
|
||||||
|
|
||||||
prev_skipcol = curwin->w_skipcol;
|
prev_skipcol = wp->w_skipcol;
|
||||||
|
|
||||||
int plines = 0;
|
int plines = 0;
|
||||||
if ((curwin->w_wrow >= curwin->w_height_inner
|
if ((wp->w_wrow >= wp->w_height_inner
|
||||||
|| ((prev_skipcol > 0
|
|| ((prev_skipcol > 0
|
||||||
|| curwin->w_wrow + so >= curwin->w_height_inner)
|
|| wp->w_wrow + so >= wp->w_height_inner)
|
||||||
&& (plines =
|
&& (plines =
|
||||||
plines_win_nofill(curwin, curwin->w_cursor.lnum, false)) - 1
|
plines_win_nofill(wp, wp->w_cursor.lnum, false)) - 1
|
||||||
>= curwin->w_height_inner))
|
>= wp->w_height_inner))
|
||||||
&& curwin->w_height_inner != 0
|
&& wp->w_height_inner != 0
|
||||||
&& curwin->w_cursor.lnum == curwin->w_topline
|
&& wp->w_cursor.lnum == wp->w_topline
|
||||||
&& width > 0
|
&& width > 0
|
||||||
&& curwin->w_width_inner != 0
|
&& wp->w_width_inner != 0
|
||||||
) {
|
) {
|
||||||
/* Cursor past end of screen. Happens with a single line that does
|
/* Cursor past end of screen. Happens with a single line that does
|
||||||
* not fit on screen. Find a skipcol to show the text around the
|
* not fit on screen. Find a skipcol to show the text around the
|
||||||
@@ -867,87 +873,88 @@ void curs_columns(
|
|||||||
* 2: Less than "p_so" lines below
|
* 2: Less than "p_so" lines below
|
||||||
* 3: both of them */
|
* 3: both of them */
|
||||||
extra = 0;
|
extra = 0;
|
||||||
if (curwin->w_skipcol + so * width > curwin->w_virtcol) {
|
if (wp->w_skipcol + so * width > wp->w_virtcol) {
|
||||||
extra = 1;
|
extra = 1;
|
||||||
}
|
}
|
||||||
// Compute last display line of the buffer line that we want at the
|
// Compute last display line of the buffer line that we want at the
|
||||||
// bottom of the window.
|
// bottom of the window.
|
||||||
if (plines == 0) {
|
if (plines == 0) {
|
||||||
plines = plines_win(curwin, curwin->w_cursor.lnum, false);
|
plines = plines_win(wp, wp->w_cursor.lnum, false);
|
||||||
}
|
}
|
||||||
plines--;
|
plines--;
|
||||||
if (plines > curwin->w_wrow + so) {
|
if (plines > wp->w_wrow + so) {
|
||||||
assert(so <= INT_MAX);
|
assert(so <= INT_MAX);
|
||||||
n = curwin->w_wrow + (int)so;
|
n = wp->w_wrow + (int)so;
|
||||||
} else {
|
} else {
|
||||||
n = plines;
|
n = plines;
|
||||||
}
|
}
|
||||||
if ((colnr_T)n >= curwin->w_height_inner + curwin->w_skipcol / width) {
|
if ((colnr_T)n >= wp->w_height_inner + wp->w_skipcol / width) {
|
||||||
extra += 2;
|
extra += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extra == 3 || plines < so * 2) {
|
if (extra == 3 || plines < so * 2) {
|
||||||
// not enough room for 'scrolloff', put cursor in the middle
|
// not enough room for 'scrolloff', put cursor in the middle
|
||||||
n = curwin->w_virtcol / width;
|
n = wp->w_virtcol / width;
|
||||||
if (n > curwin->w_height_inner / 2) {
|
if (n > wp->w_height_inner / 2) {
|
||||||
n -= curwin->w_height_inner / 2;
|
n -= wp->w_height_inner / 2;
|
||||||
} else {
|
} else {
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
// don't skip more than necessary
|
// don't skip more than necessary
|
||||||
if (n > plines - curwin->w_height_inner + 1) {
|
if (n > plines - wp->w_height_inner + 1) {
|
||||||
n = plines - curwin->w_height_inner + 1;
|
n = plines - wp->w_height_inner + 1;
|
||||||
}
|
}
|
||||||
curwin->w_skipcol = n * width;
|
wp->w_skipcol = n * width;
|
||||||
} else if (extra == 1) {
|
} else if (extra == 1) {
|
||||||
// less then 'scrolloff' lines above, decrease skipcol
|
// less then 'scrolloff' lines above, decrease skipcol
|
||||||
assert(so <= INT_MAX);
|
assert(so <= INT_MAX);
|
||||||
extra = (curwin->w_skipcol + (int)so * width - curwin->w_virtcol
|
extra = (wp->w_skipcol + (int)so * width - wp->w_virtcol
|
||||||
+ width - 1) / width;
|
+ width - 1) / width;
|
||||||
if (extra > 0) {
|
if (extra > 0) {
|
||||||
if ((colnr_T)(extra * width) > curwin->w_skipcol)
|
if ((colnr_T)(extra * width) > wp->w_skipcol) {
|
||||||
extra = curwin->w_skipcol / width;
|
extra = wp->w_skipcol / width;
|
||||||
curwin->w_skipcol -= extra * width;
|
}
|
||||||
|
wp->w_skipcol -= extra * width;
|
||||||
}
|
}
|
||||||
} else if (extra == 2) {
|
} else if (extra == 2) {
|
||||||
// less then 'scrolloff' lines below, increase skipcol
|
// less then 'scrolloff' lines below, increase skipcol
|
||||||
endcol = (n - curwin->w_height_inner + 1) * width;
|
endcol = (n - wp->w_height_inner + 1) * width;
|
||||||
while (endcol > curwin->w_virtcol) {
|
while (endcol > wp->w_virtcol) {
|
||||||
endcol -= width;
|
endcol -= width;
|
||||||
}
|
}
|
||||||
if (endcol > curwin->w_skipcol) {
|
if (endcol > wp->w_skipcol) {
|
||||||
curwin->w_skipcol = endcol;
|
wp->w_skipcol = endcol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
curwin->w_wrow -= curwin->w_skipcol / width;
|
wp->w_wrow -= wp->w_skipcol / width;
|
||||||
if (curwin->w_wrow >= curwin->w_height_inner) {
|
if (wp->w_wrow >= wp->w_height_inner) {
|
||||||
// small window, make sure cursor is in it
|
// small window, make sure cursor is in it
|
||||||
extra = curwin->w_wrow - curwin->w_height_inner + 1;
|
extra = wp->w_wrow - wp->w_height_inner + 1;
|
||||||
curwin->w_skipcol += extra * width;
|
wp->w_skipcol += extra * width;
|
||||||
curwin->w_wrow -= extra;
|
wp->w_wrow -= extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extra could be either positive or negative
|
// extra could be either positive or negative
|
||||||
extra = ((int)prev_skipcol - (int)curwin->w_skipcol) / width;
|
extra = ((int)prev_skipcol - (int)wp->w_skipcol) / width;
|
||||||
win_scroll_lines(curwin, 0, extra);
|
win_scroll_lines(wp, 0, extra);
|
||||||
} else {
|
} else {
|
||||||
curwin->w_skipcol = 0;
|
wp->w_skipcol = 0;
|
||||||
}
|
}
|
||||||
if (prev_skipcol != curwin->w_skipcol) {
|
if (prev_skipcol != wp->w_skipcol) {
|
||||||
redraw_later(curwin, NOT_VALID);
|
redraw_later(wp, NOT_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Redraw when w_virtcol changes and 'cursorcolumn' is set */
|
// Redraw when w_virtcol changes and 'cursorcolumn' is set
|
||||||
if (curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0
|
if (wp->w_p_cuc && (wp->w_valid & VALID_VIRTCOL) == 0
|
||||||
&& !pum_visible()) {
|
&& !pum_visible()) {
|
||||||
redraw_later(curwin, SOME_VALID);
|
redraw_later(wp, SOME_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise
|
// now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise
|
||||||
curwin->w_valid_leftcol = curwin->w_leftcol;
|
wp->w_valid_leftcol = wp->w_leftcol;
|
||||||
|
|
||||||
curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
|
wp->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute the screen position of text character at "pos" in window "wp"
|
/// Compute the screen position of text character at "pos" in window "wp"
|
||||||
@@ -1231,7 +1238,7 @@ void scrolldown_clamp(void)
|
|||||||
end_row += curwin->w_cline_height - 1 -
|
end_row += curwin->w_cline_height - 1 -
|
||||||
curwin->w_virtcol / curwin->w_width_inner;
|
curwin->w_virtcol / curwin->w_width_inner;
|
||||||
}
|
}
|
||||||
if (end_row < curwin->w_height_inner - get_scrolloff_value()) {
|
if (end_row < curwin->w_height_inner - get_scrolloff_value(curwin)) {
|
||||||
if (can_fill) {
|
if (can_fill) {
|
||||||
++curwin->w_topfill;
|
++curwin->w_topfill;
|
||||||
check_topfill(curwin, true);
|
check_topfill(curwin, true);
|
||||||
@@ -1271,7 +1278,7 @@ void scrollup_clamp(void)
|
|||||||
validate_virtcol();
|
validate_virtcol();
|
||||||
start_row -= curwin->w_virtcol / curwin->w_width_inner;
|
start_row -= curwin->w_virtcol / curwin->w_width_inner;
|
||||||
}
|
}
|
||||||
if (start_row >= get_scrolloff_value()) {
|
if (start_row >= get_scrolloff_value(curwin)) {
|
||||||
if (curwin->w_topfill > 0) {
|
if (curwin->w_topfill > 0) {
|
||||||
curwin->w_topfill--;
|
curwin->w_topfill--;
|
||||||
} else {
|
} else {
|
||||||
@@ -1289,22 +1296,22 @@ void scrollup_clamp(void)
|
|||||||
* Returns the height of the added line in "lp->height".
|
* Returns the height of the added line in "lp->height".
|
||||||
* Lines above the first one are incredibly high: MAXCOL.
|
* Lines above the first one are incredibly high: MAXCOL.
|
||||||
*/
|
*/
|
||||||
static void topline_back(lineoff_T *lp)
|
static void topline_back(win_T *wp, lineoff_T *lp)
|
||||||
{
|
{
|
||||||
if (lp->fill < diff_check_fill(curwin, lp->lnum)) {
|
if (lp->fill < diff_check_fill(wp, lp->lnum)) {
|
||||||
/* Add a filler line. */
|
// Add a filler line
|
||||||
++lp->fill;
|
lp->fill++;
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
} else {
|
} else {
|
||||||
--lp->lnum;
|
--lp->lnum;
|
||||||
lp->fill = 0;
|
lp->fill = 0;
|
||||||
if (lp->lnum < 1)
|
if (lp->lnum < 1) {
|
||||||
lp->height = MAXCOL;
|
lp->height = MAXCOL;
|
||||||
else if (hasFolding(lp->lnum, &lp->lnum, NULL))
|
} else if (hasFolding(lp->lnum, &lp->lnum, NULL)) {
|
||||||
/* Add a closed fold */
|
// Add a closed fold
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
else {
|
} else {
|
||||||
lp->height = plines_nofill(lp->lnum);
|
lp->height = plines_win_nofill(wp, lp->lnum, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1315,22 +1322,23 @@ static void topline_back(lineoff_T *lp)
|
|||||||
* Returns the height of the added line in "lp->height".
|
* Returns the height of the added line in "lp->height".
|
||||||
* Lines below the last one are incredibly high.
|
* Lines below the last one are incredibly high.
|
||||||
*/
|
*/
|
||||||
static void botline_forw(lineoff_T *lp)
|
static void botline_forw(win_T *wp, lineoff_T *lp)
|
||||||
{
|
{
|
||||||
if (lp->fill < diff_check_fill(curwin, lp->lnum + 1)) {
|
if (lp->fill < diff_check_fill(wp, lp->lnum + 1)) {
|
||||||
/* Add a filler line. */
|
// Add a filler line.
|
||||||
++lp->fill;
|
lp->fill++;
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
} else {
|
} else {
|
||||||
++lp->lnum;
|
++lp->lnum;
|
||||||
lp->fill = 0;
|
lp->fill = 0;
|
||||||
if (lp->lnum > curbuf->b_ml.ml_line_count) {
|
assert(wp->w_buffer != 0);
|
||||||
|
if (lp->lnum > wp->w_buffer->b_ml.ml_line_count) {
|
||||||
lp->height = MAXCOL;
|
lp->height = MAXCOL;
|
||||||
} else if (hasFolding(lp->lnum, NULL, &lp->lnum)) {
|
} else if (hasFoldingWin(wp, lp->lnum, NULL, &lp->lnum, true, NULL)) {
|
||||||
// Add a closed fold
|
// Add a closed fold
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
} else {
|
} else {
|
||||||
lp->height = plines_nofill(lp->lnum);
|
lp->height = plines_win_nofill(wp, lp->lnum, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1374,7 +1382,7 @@ void scroll_cursor_top(int min_scroll, int always)
|
|||||||
linenr_T old_topline = curwin->w_topline;
|
linenr_T old_topline = curwin->w_topline;
|
||||||
linenr_T old_topfill = curwin->w_topfill;
|
linenr_T old_topfill = curwin->w_topfill;
|
||||||
linenr_T new_topline;
|
linenr_T new_topline;
|
||||||
int off = (int)get_scrolloff_value();
|
int off = (int)get_scrolloff_value(curwin);
|
||||||
|
|
||||||
if (mouse_dragging > 0)
|
if (mouse_dragging > 0)
|
||||||
off = mouse_dragging - 1;
|
off = mouse_dragging - 1;
|
||||||
@@ -1518,7 +1526,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
int old_valid = curwin->w_valid;
|
int old_valid = curwin->w_valid;
|
||||||
int old_empty_rows = curwin->w_empty_rows;
|
int old_empty_rows = curwin->w_empty_rows;
|
||||||
linenr_T cln = curwin->w_cursor.lnum; // Cursor Line Number
|
linenr_T cln = curwin->w_cursor.lnum; // Cursor Line Number
|
||||||
long so = get_scrolloff_value();
|
long so = get_scrolloff_value(curwin);
|
||||||
|
|
||||||
if (set_topbot) {
|
if (set_topbot) {
|
||||||
used = 0;
|
used = 0;
|
||||||
@@ -1528,7 +1536,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
curwin->w_topline > 1;
|
curwin->w_topline > 1;
|
||||||
curwin->w_topline = loff.lnum) {
|
curwin->w_topline = loff.lnum) {
|
||||||
loff.lnum = curwin->w_topline;
|
loff.lnum = curwin->w_topline;
|
||||||
topline_back(&loff);
|
topline_back(curwin, &loff);
|
||||||
if (loff.height == MAXCOL
|
if (loff.height == MAXCOL
|
||||||
|| used + loff.height > curwin->w_height_inner) {
|
|| used + loff.height > curwin->w_height_inner) {
|
||||||
break;
|
break;
|
||||||
@@ -1542,8 +1550,9 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
|| curwin->w_topfill != old_topfill
|
|| curwin->w_topfill != old_topfill
|
||||||
)
|
)
|
||||||
curwin->w_valid &= ~(VALID_WROW|VALID_CROW);
|
curwin->w_valid &= ~(VALID_WROW|VALID_CROW);
|
||||||
} else
|
} else {
|
||||||
validate_botline();
|
validate_botline(curwin);
|
||||||
|
}
|
||||||
|
|
||||||
/* The lines of the cursor line itself are always used. */
|
/* The lines of the cursor line itself are always used. */
|
||||||
used = plines_nofill(cln);
|
used = plines_nofill(cln);
|
||||||
@@ -1586,8 +1595,8 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add one line above */
|
// Add one line above
|
||||||
topline_back(&loff);
|
topline_back(curwin, &loff);
|
||||||
if (loff.height == MAXCOL) {
|
if (loff.height == MAXCOL) {
|
||||||
used = MAXCOL;
|
used = MAXCOL;
|
||||||
} else {
|
} else {
|
||||||
@@ -1609,8 +1618,8 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (boff.lnum < curbuf->b_ml.ml_line_count) {
|
if (boff.lnum < curbuf->b_ml.ml_line_count) {
|
||||||
/* Add one line below */
|
// Add one line below
|
||||||
botline_forw(&boff);
|
botline_forw(curwin, &boff);
|
||||||
used += boff.height;
|
used += boff.height;
|
||||||
if (used > curwin->w_height_inner) {
|
if (used > curwin->w_height_inner) {
|
||||||
break;
|
break;
|
||||||
@@ -1647,7 +1656,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
boff.lnum = curwin->w_topline - 1;
|
boff.lnum = curwin->w_topline - 1;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < scrolled && boff.lnum < curwin->w_botline; ) {
|
for (i = 0; i < scrolled && boff.lnum < curwin->w_botline; ) {
|
||||||
botline_forw(&boff);
|
botline_forw(curwin, &boff);
|
||||||
i += boff.height;
|
i += boff.height;
|
||||||
++line_count;
|
++line_count;
|
||||||
}
|
}
|
||||||
@@ -1701,7 +1710,7 @@ void scroll_cursor_halfway(int atend)
|
|||||||
while (topline > 1) {
|
while (topline > 1) {
|
||||||
if (below <= above) { /* add a line below the cursor first */
|
if (below <= above) { /* add a line below the cursor first */
|
||||||
if (boff.lnum < curbuf->b_ml.ml_line_count) {
|
if (boff.lnum < curbuf->b_ml.ml_line_count) {
|
||||||
botline_forw(&boff);
|
botline_forw(curwin, &boff);
|
||||||
used += boff.height;
|
used += boff.height;
|
||||||
if (used > curwin->w_height_inner) {
|
if (used > curwin->w_height_inner) {
|
||||||
break;
|
break;
|
||||||
@@ -1714,12 +1723,13 @@ void scroll_cursor_halfway(int atend)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (below > above) { /* add a line above the cursor */
|
if (below > above) { // add a line above the cursor
|
||||||
topline_back(&loff);
|
topline_back(curwin, &loff);
|
||||||
if (loff.height == MAXCOL)
|
if (loff.height == MAXCOL) {
|
||||||
used = MAXCOL;
|
used = MAXCOL;
|
||||||
else
|
} else {
|
||||||
used += loff.height;
|
used += loff.height;
|
||||||
|
}
|
||||||
if (used > curwin->w_height_inner) {
|
if (used > curwin->w_height_inner) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1751,8 +1761,8 @@ void cursor_correct(void)
|
|||||||
* How many lines we would like to have above/below the cursor depends on
|
* How many lines we would like to have above/below the cursor depends on
|
||||||
* whether the first/last line of the file is on screen.
|
* whether the first/last line of the file is on screen.
|
||||||
*/
|
*/
|
||||||
int above_wanted = (int)get_scrolloff_value();
|
int above_wanted = (int)get_scrolloff_value(curwin);
|
||||||
int below_wanted = (int)get_scrolloff_value();
|
int below_wanted = (int)get_scrolloff_value(curwin);
|
||||||
if (mouse_dragging > 0) {
|
if (mouse_dragging > 0) {
|
||||||
above_wanted = mouse_dragging - 1;
|
above_wanted = mouse_dragging - 1;
|
||||||
below_wanted = mouse_dragging - 1;
|
below_wanted = mouse_dragging - 1;
|
||||||
@@ -1764,7 +1774,7 @@ void cursor_correct(void)
|
|||||||
below_wanted = max_off;
|
below_wanted = max_off;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
validate_botline();
|
validate_botline(curwin);
|
||||||
if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1
|
if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1
|
||||||
&& mouse_dragging == 0) {
|
&& mouse_dragging == 0) {
|
||||||
below_wanted = 0;
|
below_wanted = 0;
|
||||||
@@ -1848,21 +1858,19 @@ int onepage(Direction dir, long count)
|
|||||||
int retval = OK;
|
int retval = OK;
|
||||||
lineoff_T loff;
|
lineoff_T loff;
|
||||||
linenr_T old_topline = curwin->w_topline;
|
linenr_T old_topline = curwin->w_topline;
|
||||||
long so = get_scrolloff_value();
|
long so = get_scrolloff_value(curwin);
|
||||||
|
|
||||||
if (curbuf->b_ml.ml_line_count == 1) { /* nothing to do */
|
if (curbuf->b_ml.ml_line_count == 1) { /* nothing to do */
|
||||||
beep_flush();
|
beep_flush();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; count > 0; --count) {
|
for (; count > 0; count--) {
|
||||||
validate_botline();
|
validate_botline(curwin);
|
||||||
/*
|
// It's an error to move a page up when the first line is already on
|
||||||
* It's an error to move a page up when the first line is already on
|
// the screen. It's an error to move a page down when the last line
|
||||||
* the screen. It's an error to move a page down when the last line
|
// is on the screen and the topline is 'scrolloff' lines from the
|
||||||
* is on the screen and the topline is 'scrolloff' lines from the
|
// last line.
|
||||||
* last line.
|
|
||||||
*/
|
|
||||||
if (dir == FORWARD
|
if (dir == FORWARD
|
||||||
? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - so)
|
? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - so)
|
||||||
&& curwin->w_botline > curbuf->b_ml.ml_line_count)
|
&& curwin->w_botline > curbuf->b_ml.ml_line_count)
|
||||||
@@ -1945,11 +1953,12 @@ int onepage(Direction dir, long count)
|
|||||||
* at the bottom of the window. */
|
* at the bottom of the window. */
|
||||||
n = 0;
|
n = 0;
|
||||||
while (n <= curwin->w_height_inner && loff.lnum >= 1) {
|
while (n <= curwin->w_height_inner && loff.lnum >= 1) {
|
||||||
topline_back(&loff);
|
topline_back(curwin, &loff);
|
||||||
if (loff.height == MAXCOL)
|
if (loff.height == MAXCOL) {
|
||||||
n = MAXCOL;
|
n = MAXCOL;
|
||||||
else
|
} else {
|
||||||
n += loff.height;
|
n += loff.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (loff.lnum < 1) { /* at begin of file */
|
if (loff.lnum < 1) { /* at begin of file */
|
||||||
curwin->w_topline = 1;
|
curwin->w_topline = 1;
|
||||||
@@ -1958,11 +1967,11 @@ int onepage(Direction dir, long count)
|
|||||||
} else {
|
} else {
|
||||||
/* Go two lines forward again. */
|
/* Go two lines forward again. */
|
||||||
topline_botline(&loff);
|
topline_botline(&loff);
|
||||||
botline_forw(&loff);
|
botline_forw(curwin, &loff);
|
||||||
botline_forw(&loff);
|
botline_forw(curwin, &loff);
|
||||||
botline_topline(&loff);
|
botline_topline(&loff);
|
||||||
/* We're at the wrong end of a fold now. */
|
// We're at the wrong end of a fold now.
|
||||||
(void)hasFolding(loff.lnum, &loff.lnum, NULL);
|
(void)hasFoldingWin(curwin, loff.lnum, &loff.lnum, NULL, true, NULL);
|
||||||
|
|
||||||
/* Always scroll at least one line. Avoid getting stuck on
|
/* Always scroll at least one line. Avoid getting stuck on
|
||||||
* very long lines. */
|
* very long lines. */
|
||||||
@@ -2046,10 +2055,11 @@ static void get_scroll_overlap(lineoff_T *lp, int dir)
|
|||||||
return; /* no overlap */
|
return; /* no overlap */
|
||||||
|
|
||||||
lineoff_T loff0 = *lp;
|
lineoff_T loff0 = *lp;
|
||||||
if (dir > 0)
|
if (dir > 0) {
|
||||||
botline_forw(lp);
|
botline_forw(curwin, lp);
|
||||||
else
|
} else {
|
||||||
topline_back(lp);
|
topline_back(curwin, lp);
|
||||||
|
}
|
||||||
int h2 = lp->height;
|
int h2 = lp->height;
|
||||||
if (h2 == MAXCOL || h2 + h1 > min_height) {
|
if (h2 == MAXCOL || h2 + h1 > min_height) {
|
||||||
*lp = loff0; /* no overlap */
|
*lp = loff0; /* no overlap */
|
||||||
@@ -2057,10 +2067,11 @@ static void get_scroll_overlap(lineoff_T *lp, int dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lineoff_T loff1 = *lp;
|
lineoff_T loff1 = *lp;
|
||||||
if (dir > 0)
|
if (dir > 0) {
|
||||||
botline_forw(lp);
|
botline_forw(curwin, lp);
|
||||||
else
|
} else {
|
||||||
topline_back(lp);
|
topline_back(curwin, lp);
|
||||||
|
}
|
||||||
int h3 = lp->height;
|
int h3 = lp->height;
|
||||||
if (h3 == MAXCOL || h3 + h2 > min_height) {
|
if (h3 == MAXCOL || h3 + h2 > min_height) {
|
||||||
*lp = loff0; /* no overlap */
|
*lp = loff0; /* no overlap */
|
||||||
@@ -2068,10 +2079,11 @@ static void get_scroll_overlap(lineoff_T *lp, int dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lineoff_T loff2 = *lp;
|
lineoff_T loff2 = *lp;
|
||||||
if (dir > 0)
|
if (dir > 0) {
|
||||||
botline_forw(lp);
|
botline_forw(curwin, lp);
|
||||||
else
|
} else {
|
||||||
topline_back(lp);
|
topline_back(curwin, lp);
|
||||||
|
}
|
||||||
int h4 = lp->height;
|
int h4 = lp->height;
|
||||||
if (h4 == MAXCOL || h4 + h3 + h2 > min_height || h3 + h2 + h1 > min_height)
|
if (h4 == MAXCOL || h4 + h3 + h2 > min_height || h3 + h2 + h1 > min_height)
|
||||||
*lp = loff1; /* 1 line overlap */
|
*lp = loff1; /* 1 line overlap */
|
||||||
@@ -2094,8 +2106,8 @@ void halfpage(bool flag, linenr_T Prenum)
|
|||||||
int n = curwin->w_p_scr <= curwin->w_height_inner ? (int)curwin->w_p_scr
|
int n = curwin->w_p_scr <= curwin->w_height_inner ? (int)curwin->w_p_scr
|
||||||
: curwin->w_height_inner;
|
: curwin->w_height_inner;
|
||||||
|
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
validate_botline();
|
validate_botline(curwin);
|
||||||
int room = curwin->w_empty_rows + curwin->w_filler_rows;
|
int room = curwin->w_empty_rows + curwin->w_filler_rows;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
/*
|
/*
|
||||||
@@ -2255,7 +2267,7 @@ void do_check_cursorbind(void)
|
|||||||
|
|
||||||
// Only scroll when 'scrollbind' hasn't done this.
|
// Only scroll when 'scrollbind' hasn't done this.
|
||||||
if (!curwin->w_p_scb) {
|
if (!curwin->w_p_scb) {
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
}
|
}
|
||||||
curwin->w_redr_status = true;
|
curwin->w_redr_status = true;
|
||||||
}
|
}
|
||||||
|
@@ -1261,7 +1261,7 @@ static void normal_redraw(NormalState *s)
|
|||||||
{
|
{
|
||||||
// Before redrawing, make sure w_topline is correct, and w_leftcol
|
// Before redrawing, make sure w_topline is correct, and w_leftcol
|
||||||
// if lines don't wrap, and w_skipcol if lines wrap.
|
// if lines don't wrap, and w_skipcol if lines wrap.
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
|
|
||||||
// If the cursor moves horizontally when 'concealcursor' is active, then the
|
// If the cursor moves horizontally when 'concealcursor' is active, then the
|
||||||
@@ -1341,7 +1341,7 @@ static int normal_check(VimState *state)
|
|||||||
} else if (do_redraw || stuff_empty()) {
|
} else if (do_redraw || stuff_empty()) {
|
||||||
// Need to make sure w_topline and w_leftcol are correct before
|
// Need to make sure w_topline and w_leftcol are correct before
|
||||||
// normal_check_window_scrolled() is called.
|
// normal_check_window_scrolled() is called.
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
|
|
||||||
normal_check_cursor_moved(s);
|
normal_check_cursor_moved(s);
|
||||||
normal_check_text_changed(s);
|
normal_check_text_changed(s);
|
||||||
@@ -2629,7 +2629,7 @@ do_mouse (
|
|||||||
|
|
||||||
/* Set global flag that we are extending the Visual area with mouse
|
/* Set global flag that we are extending the Visual area with mouse
|
||||||
* dragging; temporarily minimize 'scrolloff'. */
|
* dragging; temporarily minimize 'scrolloff'. */
|
||||||
if (VIsual_active && is_drag && get_scrolloff_value()) {
|
if (VIsual_active && is_drag && get_scrolloff_value(curwin)) {
|
||||||
// In the very first line, allow scrolling one line
|
// In the very first line, allow scrolling one line
|
||||||
if (mouse_row == 0) {
|
if (mouse_row == 0) {
|
||||||
mouse_dragging = 2;
|
mouse_dragging = 2;
|
||||||
@@ -4136,7 +4136,7 @@ void scroll_redraw(int up, long count)
|
|||||||
scrollup(count, true) :
|
scrollup(count, true) :
|
||||||
scrolldown(count, true);
|
scrolldown(count, true);
|
||||||
|
|
||||||
if (get_scrolloff_value()) {
|
if (get_scrolloff_value(curwin)) {
|
||||||
// Adjust the cursor position for 'scrolloff'. Mark w_topline as
|
// Adjust the cursor position for 'scrolloff'. Mark w_topline as
|
||||||
// valid, otherwise the screen jumps back at the end of the file.
|
// valid, otherwise the screen jumps back at the end of the file.
|
||||||
cursor_correct();
|
cursor_correct();
|
||||||
@@ -4186,7 +4186,7 @@ static void nv_zet(cmdarg_T *cap)
|
|||||||
int old_fen = curwin->w_p_fen;
|
int old_fen = curwin->w_p_fen;
|
||||||
bool undo = false;
|
bool undo = false;
|
||||||
|
|
||||||
int l_p_siso = (int)get_sidescrolloff_value();
|
int l_p_siso = (int)get_sidescrolloff_value(curwin);
|
||||||
assert(l_p_siso <= INT_MAX);
|
assert(l_p_siso <= INT_MAX);
|
||||||
|
|
||||||
if (ascii_isdigit(nchar)) {
|
if (ascii_isdigit(nchar)) {
|
||||||
@@ -4254,12 +4254,13 @@ dozet:
|
|||||||
/* "z+", "z<CR>" and "zt": put cursor at top of screen */
|
/* "z+", "z<CR>" and "zt": put cursor at top of screen */
|
||||||
case '+':
|
case '+':
|
||||||
if (cap->count0 == 0) {
|
if (cap->count0 == 0) {
|
||||||
/* No count given: put cursor at the line below screen */
|
// No count given: put cursor at the line below screen
|
||||||
validate_botline(); /* make sure w_botline is valid */
|
validate_botline(curwin); // make sure w_botline is valid
|
||||||
if (curwin->w_botline > curbuf->b_ml.ml_line_count)
|
if (curwin->w_botline > curbuf->b_ml.ml_line_count) {
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
else
|
} else {
|
||||||
curwin->w_cursor.lnum = curwin->w_botline;
|
curwin->w_cursor.lnum = curwin->w_botline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
case NL:
|
case NL:
|
||||||
@@ -5054,7 +5055,7 @@ static void nv_scroll(cmdarg_T *cap)
|
|||||||
setpcmark();
|
setpcmark();
|
||||||
|
|
||||||
if (cap->cmdchar == 'L') {
|
if (cap->cmdchar == 'L') {
|
||||||
validate_botline(); /* make sure curwin->w_botline is valid */
|
validate_botline(curwin); // make sure curwin->w_botline is valid
|
||||||
curwin->w_cursor.lnum = curwin->w_botline - 1;
|
curwin->w_cursor.lnum = curwin->w_botline - 1;
|
||||||
if (cap->count1 - 1 >= curwin->w_cursor.lnum)
|
if (cap->count1 - 1 >= curwin->w_cursor.lnum)
|
||||||
curwin->w_cursor.lnum = 1;
|
curwin->w_cursor.lnum = 1;
|
||||||
@@ -5075,7 +5076,7 @@ static void nv_scroll(cmdarg_T *cap)
|
|||||||
/* Don't count filler lines above the window. */
|
/* Don't count filler lines above the window. */
|
||||||
used -= diff_check_fill(curwin, curwin->w_topline)
|
used -= diff_check_fill(curwin, curwin->w_topline)
|
||||||
- curwin->w_topfill;
|
- curwin->w_topfill;
|
||||||
validate_botline(); // make sure w_empty_rows is valid
|
validate_botline(curwin); // make sure w_empty_rows is valid
|
||||||
half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2;
|
half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2;
|
||||||
for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) {
|
for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) {
|
||||||
// Count half he number of filler lines to be "below this
|
// Count half he number of filler lines to be "below this
|
||||||
@@ -6654,16 +6655,15 @@ static void nv_g_cmd(cmdarg_T *cap)
|
|||||||
VIsual = curwin->w_cursor;
|
VIsual = curwin->w_cursor;
|
||||||
curwin->w_cursor = tpos;
|
curwin->w_cursor = tpos;
|
||||||
check_cursor();
|
check_cursor();
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
/*
|
// When called from normal "g" command: start Select mode when
|
||||||
* When called from normal "g" command: start Select mode when
|
// 'selectmode' contains "cmd". When called for K_SELECT, always
|
||||||
* 'selectmode' contains "cmd". When called for K_SELECT, always
|
// start Select mode.
|
||||||
* start Select mode.
|
if (cap->arg) {
|
||||||
*/
|
|
||||||
if (cap->arg)
|
|
||||||
VIsual_select = true;
|
VIsual_select = true;
|
||||||
else
|
} else {
|
||||||
may_start_select('c');
|
may_start_select('c');
|
||||||
|
}
|
||||||
setmouse();
|
setmouse();
|
||||||
redraw_curbuf_later(INVERTED);
|
redraw_curbuf_later(INVERTED);
|
||||||
showmode();
|
showmode();
|
||||||
|
@@ -7159,20 +7159,20 @@ dict_T *get_winbuf_options(const int bufopt)
|
|||||||
|
|
||||||
/// Return the effective 'scrolloff' value for the current window, using the
|
/// Return the effective 'scrolloff' value for the current window, using the
|
||||||
/// global value when appropriate.
|
/// global value when appropriate.
|
||||||
long get_scrolloff_value(void)
|
long get_scrolloff_value(win_T *wp)
|
||||||
{
|
{
|
||||||
// Disallow scrolloff in terminal-mode. #11915
|
// Disallow scrolloff in terminal-mode. #11915
|
||||||
if (State & TERM_FOCUS) {
|
if (State & TERM_FOCUS) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return curwin->w_p_so < 0 ? p_so : curwin->w_p_so;
|
return wp->w_p_so < 0 ? p_so : wp->w_p_so;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the effective 'sidescrolloff' value for the current window, using the
|
/// Return the effective 'sidescrolloff' value for the current window, using the
|
||||||
/// global value when appropriate.
|
/// global value when appropriate.
|
||||||
long get_sidescrolloff_value(void)
|
long get_sidescrolloff_value(win_T *wp)
|
||||||
{
|
{
|
||||||
return curwin->w_p_siso < 0 ? p_siso : curwin->w_p_siso;
|
return wp->w_p_siso < 0 ? p_siso : wp->w_p_siso;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary get_vimoption(String name, Error *err)
|
Dictionary get_vimoption(String name, Error *err)
|
||||||
|
@@ -809,7 +809,7 @@ static int pum_set_selected(int n, int repeat)
|
|||||||
no_u_sync++;
|
no_u_sync++;
|
||||||
win_enter(curwin_save, true);
|
win_enter(curwin_save, true);
|
||||||
no_u_sync--;
|
no_u_sync--;
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the screen before drawing the popup menu.
|
// Update the screen before drawing the popup menu.
|
||||||
|
@@ -3696,7 +3696,7 @@ void ex_copen(exarg_T *eap)
|
|||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
check_cursor();
|
check_cursor();
|
||||||
update_topline(); // scroll to show the line
|
update_topline(curwin); // scroll to show the line
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the cursor in the quickfix window to "lnum".
|
// Move the cursor in the quickfix window to "lnum".
|
||||||
@@ -3710,7 +3710,7 @@ static void qf_win_goto(win_T *win, linenr_T lnum)
|
|||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
curwin->w_cursor.coladd = 0;
|
curwin->w_cursor.coladd = 0;
|
||||||
curwin->w_curswant = 0;
|
curwin->w_curswant = 0;
|
||||||
update_topline(); // scroll to show the line
|
update_topline(curwin); // scroll to show the line
|
||||||
redraw_later(curwin, VALID);
|
redraw_later(curwin, VALID);
|
||||||
curwin->w_redr_status = true; // update ruler
|
curwin->w_redr_status = true; // update ruler
|
||||||
curwin = old_curwin;
|
curwin = old_curwin;
|
||||||
|
@@ -683,7 +683,7 @@ void conceal_check_cursor_line(void)
|
|||||||
redrawWinline(curwin, curwin->w_cursor.lnum);
|
redrawWinline(curwin, curwin->w_cursor.lnum);
|
||||||
// Need to recompute cursor column, e.g., when starting Visual mode
|
// Need to recompute cursor column, e.g., when starting Visual mode
|
||||||
// without concealing. */
|
// without concealing. */
|
||||||
curs_columns(true);
|
curs_columns(curwin, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1698,7 +1698,7 @@ static void win_update(win_T *wp, Providers *providers)
|
|||||||
const int new_wcol = wp->w_wcol;
|
const int new_wcol = wp->w_wcol;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
curwin->w_valid &= ~VALID_TOPLINE;
|
curwin->w_valid &= ~VALID_TOPLINE;
|
||||||
update_topline(); // may invalidate w_botline again
|
update_topline(curwin); // may invalidate w_botline again
|
||||||
|
|
||||||
if (old_wcol != new_wcol
|
if (old_wcol != new_wcol
|
||||||
&& (wp->w_valid & (VALID_WCOL|VALID_WROW))
|
&& (wp->w_valid & (VALID_WCOL|VALID_WROW))
|
||||||
@@ -7380,7 +7380,7 @@ void screen_resize(int width, int height)
|
|||||||
cmdline_pum_display(false);
|
cmdline_pum_display(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
if (pum_drawn()) {
|
if (pum_drawn()) {
|
||||||
// TODO(bfredl): ins_compl_show_pum wants to redraw the screen first.
|
// TODO(bfredl): ins_compl_show_pum wants to redraw the screen first.
|
||||||
// For now make sure the nested update_screen(0) won't redraw the
|
// For now make sure the nested update_screen(0) won't redraw the
|
||||||
|
@@ -4540,7 +4540,7 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid,
|
|||||||
|
|
||||||
// Might need to scroll the old window before switching, e.g., when the
|
// Might need to scroll the old window before switching, e.g., when the
|
||||||
// cursor was moved.
|
// cursor was moved.
|
||||||
update_topline();
|
update_topline(curwin);
|
||||||
|
|
||||||
// may have to copy the buffer options when 'cpo' contains 'S'
|
// may have to copy the buffer options when 'cpo' contains 'S'
|
||||||
if (wp->w_buffer != curbuf) {
|
if (wp->w_buffer != curbuf) {
|
||||||
@@ -5873,10 +5873,10 @@ void scroll_to_fraction(win_T *wp, int prev_height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wp == curwin) {
|
if (wp == curwin) {
|
||||||
if (get_scrolloff_value()) {
|
if (get_scrolloff_value(wp)) {
|
||||||
update_topline();
|
update_topline(wp);
|
||||||
}
|
}
|
||||||
curs_columns(false); // validate w_wrow
|
curs_columns(wp, false); // validate w_wrow
|
||||||
}
|
}
|
||||||
if (prev_height > 0) {
|
if (prev_height > 0) {
|
||||||
wp->w_prev_fraction_row = wp->w_wrow;
|
wp->w_prev_fraction_row = wp->w_wrow;
|
||||||
@@ -5932,8 +5932,8 @@ void win_set_inner_size(win_T *wp)
|
|||||||
changed_line_abv_curs_win(wp);
|
changed_line_abv_curs_win(wp);
|
||||||
invalidate_botline_win(wp);
|
invalidate_botline_win(wp);
|
||||||
if (wp == curwin) {
|
if (wp == curwin) {
|
||||||
update_topline();
|
update_topline(wp);
|
||||||
curs_columns(true); // validate w_wrow
|
curs_columns(wp, true); // validate w_wrow
|
||||||
}
|
}
|
||||||
redraw_later(wp, NOT_VALID);
|
redraw_later(wp, NOT_VALID);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user