diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-09-20 13:42:37 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-09-22 13:48:46 +0200 |
commit | 3a7cb72dcbe4aaaed47999ab5afaf3d1cb8d4df8 (patch) | |
tree | 534581de3060c6c2ed9d000636a27295295e653e /src/nvim/edit.c | |
parent | b7763d7f6b7fdcabe06658c664457df8bc147563 (diff) | |
download | rneovim-3a7cb72dcbe4aaaed47999ab5afaf3d1cb8d4df8.tar.gz rneovim-3a7cb72dcbe4aaaed47999ab5afaf3d1cb8d4df8.tar.bz2 rneovim-3a7cb72dcbe4aaaed47999ab5afaf3d1cb8d4df8.zip |
refactor(grid): properly namespace and separate stateful grid functions
This is a step in an ongoing refactor where the "grid_puts" and
"grid_put_linebuf" code paths will share more of the implementation (in
particular for delta calculation, doublewidth and 'arabicshape'
handling). But it also makes sense by its own as a cleanup, and is thus
committed separately.
Before this change many of the low level grid functions grid_puts,
grid_fill etc could both be used in a standalone fashion but also as
part of a batched line update which would be finally transmitted as a
single grid_line call (via ui_line() ). This was initially useful to
quickly refactor pre-existing vim code to use batched logic safely.
However, this pattern is not really helpful for maintainable and newly
written code, where the "grid" and "row" arguments are just needlessly
repeated. This simplifies these calls to just use grid and row as
specified in the initial grid_line_start(grid, row) call.
This also makes the intent clear whether any grid_puts() call is actually
part of a batch or not, which is better in the long run when more things
get refactored to use effective (properly batched) updates.
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 216f8a67db..520d3bc2b3 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1449,6 +1449,7 @@ void edit_putchar(int c, bool highlight) // save the character to be able to put it back if (pc_status == PC_STATUS_UNSET) { + // TODO(bfredl): save the schar_T instead grid_getbytes(&curwin->w_grid, pc_row, pc_col, pc_bytes, &pc_attr); pc_status = PC_STATUS_SET; } @@ -1532,7 +1533,7 @@ void edit_unputchar(void) if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT) { redrawWinline(curwin, curwin->w_cursor.lnum); } else { - grid_puts(&curwin->w_grid, pc_bytes, pc_row, pc_col, pc_attr); + grid_puts(&curwin->w_grid, pc_bytes, -1, pc_row, pc_col, pc_attr); } } } @@ -3485,7 +3486,8 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) // Otherwise remove the mode message. if (reg_recording != 0 || restart_edit != NUL) { showmode(); - } else if (p_smd && (got_int || !skip_showmode())) { + } else if (p_smd && (got_int || !skip_showmode()) + && !(p_ch == 0 && !ui_has(kUIMessages))) { msg(""); } // Exit Insert mode |