diff options
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 38ee0936aa..a050c95224 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3466,10 +3466,10 @@ static void display_showcmd(void) int len; len = (int)STRLEN(showcmd_buf); - if (len == 0) + if (len == 0) { showcmd_is_clear = true; - else { - screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); + } else { + grid_puts(&default_grid, showcmd_buf, (int)Rows - 1, sc_col, 0); showcmd_is_clear = false; } @@ -3477,7 +3477,8 @@ static void display_showcmd(void) * clear the rest of an old message by outputting up to SHOWCMD_COLS * spaces */ - screen_puts((char_u *)" " + len, (int)Rows - 1, sc_col + len, 0); + grid_puts(&default_grid, (char_u *)" " + len, (int)Rows - 1, + sc_col + len, 0); setcursor(); /* put cursor back where it belongs */ } @@ -3905,18 +3906,16 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) col_off1 = curwin_col_off(); col_off2 = col_off1 - curwin_col_off2(); - width1 = curwin->w_width - col_off1; - width2 = curwin->w_width - col_off2; + width1 = curwin->w_grid.Columns - col_off1; + width2 = curwin->w_grid.Columns - col_off2; if (width2 == 0) { width2 = 1; // Avoid divide by zero. } - if (curwin->w_width != 0) { - /* - * Instead of sticking at the last character of the buffer line we - * try to stick in the last column of the screen. - */ + if (curwin->w_grid.Columns != 0) { + // Instead of sticking at the last character of the buffer line we + // try to stick in the last column of the screen. if (curwin->w_curswant == MAXCOL) { atend = true; validate_virtcol(); @@ -4255,7 +4254,7 @@ dozet: /* "zH" - scroll screen right half-page */ case 'H': - cap->count1 *= curwin->w_width / 2; + cap->count1 *= curwin->w_grid.Columns / 2; FALLTHROUGH; /* "zh" - scroll screen to the right */ @@ -4270,8 +4269,8 @@ dozet: } break; - /* "zL" - scroll screen left half-page */ - case 'L': cap->count1 *= curwin->w_width / 2; + // "zL" - scroll screen left half-page + case 'L': cap->count1 *= curwin->w_grid.Columns / 2; FALLTHROUGH; /* "zl" - scroll screen to the left */ @@ -4307,11 +4306,12 @@ dozet: col = 0; /* like the cursor is in col 0 */ else getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col); - n = curwin->w_width - curwin_col_off(); - if (col + l_p_siso < n) + n = curwin->w_grid.Columns - curwin_col_off(); + if (col + l_p_siso < n) { col = 0; - else + } else { col = col + l_p_siso - n + 1; + } if (curwin->w_leftcol != col) { curwin->w_leftcol = col; redraw_later(NOT_VALID); @@ -5016,11 +5016,11 @@ static void nv_scroll(cmdarg_T *cap) /* Don't count filler lines above the window. */ used -= diff_check_fill(curwin, curwin->w_topline) - curwin->w_topfill; - validate_botline(); /* make sure w_empty_rows is valid */ - half = (curwin->w_height - curwin->w_empty_rows + 1) / 2; - 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 - * line" and half to be "above the next line". */ + validate_botline(); // make sure w_empty_rows is valid + half = (curwin->w_grid.Rows - curwin->w_empty_rows + 1) / 2; + 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 + // line" and half to be "above the next line". if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline + n) / 2 >= half) { --n; @@ -5032,9 +5032,10 @@ static void nv_scroll(cmdarg_T *cap) if (hasFolding(curwin->w_topline + n, NULL, &lnum)) n = lnum - curwin->w_topline; } - if (n > 0 && used > curwin->w_height) - --n; - } else { /* (cap->cmdchar == 'H') */ + if (n > 0 && used > curwin->w_grid.Rows) { + n--; + } + } else { // (cap->cmdchar == 'H') n = cap->count1 - 1; if (hasAnyFolding(curwin)) { /* Count a fold for one screen line. */ @@ -6747,9 +6748,9 @@ static void nv_g_cmd(cmdarg_T *cap) oap->motion_type = kMTCharWise; oap->inclusive = false; if (curwin->w_p_wrap - && curwin->w_width != 0 + && curwin->w_grid.Columns != 0 ) { - int width1 = curwin->w_width - curwin_col_off(); + int width1 = curwin->w_grid.Columns - curwin_col_off(); int width2 = width1 + curwin_col_off2(); validate_virtcol(); @@ -6761,10 +6762,11 @@ static void nv_g_cmd(cmdarg_T *cap) /* Go to the middle of the screen line. When 'number' or * 'relativenumber' is on and lines are wrapping the middle can be more * to the left. */ - if (cap->nchar == 'm') - i += (curwin->w_width - curwin_col_off() + if (cap->nchar == 'm') { + i += (curwin->w_grid.Columns - curwin_col_off() + ((curwin->w_p_wrap && i > 0) ? curwin_col_off2() : 0)) / 2; + } coladvance((colnr_T)i); if (flag) { do @@ -6808,11 +6810,11 @@ static void nv_g_cmd(cmdarg_T *cap) oap->motion_type = kMTCharWise; oap->inclusive = true; if (curwin->w_p_wrap - && curwin->w_width != 0 + && curwin->w_grid.Columns != 0 ) { curwin->w_curswant = MAXCOL; /* so we stay at the end */ if (cap->count1 == 1) { - int width1 = curwin->w_width - col_off; + int width1 = curwin->w_grid.Columns - col_off; int width2 = width1 + curwin_col_off2(); validate_virtcol(); @@ -6838,7 +6840,7 @@ static void nv_g_cmd(cmdarg_T *cap) } else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == false) clearopbeep(oap); } else { - i = curwin->w_leftcol + curwin->w_width - col_off - 1; + i = curwin->w_leftcol + curwin->w_grid.Columns - col_off - 1; coladvance((colnr_T)i); /* Make sure we stick in this column. */ @@ -7953,7 +7955,7 @@ static void get_op_vcol( colnr_T end; if (VIsual_mode != Ctrl_V - || (!initial && oap->end.col < curwin->w_width)) { + || (!initial && oap->end.col < curwin->w_grid.Columns)) { return; } |