diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
commit | d5f194ce780c95821a855aca3c19426576d28ae0 (patch) | |
tree | d45f461b19f9118ad2bb1f440a7a08973ad18832 /src/nvim/normal.c | |
parent | c5d770d311841ea5230426cc4c868e8db27300a8 (diff) | |
parent | 44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff) | |
download | rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.gz rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.bz2 rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.zip |
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 55aa385b33..7d0080622d 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -52,6 +52,7 @@ #include "nvim/mark_defs.h" #include "nvim/math.h" #include "nvim/mbyte.h" +#include "nvim/mbyte_defs.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" #include "nvim/memory.h" @@ -96,7 +97,7 @@ typedef struct { bool previous_got_int; // `got_int` was true bool cmdwin; // command-line window normal mode bool noexmode; // true if the normal mode was pushed from - // ex mode(:global or :visual for example) + // ex mode (:global or :visual for example) bool toplevel; // top-level normal mode oparg_T oa; // operator arguments cmdarg_T ca; // command arguments @@ -503,9 +504,9 @@ bool op_pending(void) /// Normal state entry point. This is called on: /// /// - Startup, In this case the function never returns. -/// - The command-line window is opened(`q:`). Returns when `cmdwin_result` != 0. +/// - The command-line window is opened (`q:`). Returns when `cmdwin_result` != 0. /// - The :visual command is called from :global in ex mode, `:global/PAT/visual` -/// for example. Returns when re-entering ex mode(because ex mode recursion is +/// for example. Returns when re-entering ex mode (because ex mode recursion is /// not allowed) /// /// This used to be called main_loop() on main.c @@ -641,8 +642,7 @@ static bool normal_need_redraw_mode_message(NormalState *s) return ( // 'showmode' is set and messages can be printed ((p_smd && msg_silent == 0 - // must restart insert mode(ctrl+o or ctrl+l) or we just entered visual - // mode + // must restart insert mode (ctrl+o or ctrl+l) or just entered visual mode && (restart_edit != 0 || (VIsual_active && s->old_pos.lnum == curwin->w_cursor.lnum && s->old_pos.col == curwin->w_cursor.col)) @@ -812,7 +812,7 @@ static void normal_get_additional_char(NormalState *s) // There is a busy wait here when typing "f<C-\>" and then // something different from CTRL-N. Can't be avoided. while ((s->c = vpeekc()) <= 0 && towait > 0) { - do_sleep(towait > 50 ? 50 : towait); + do_sleep(towait > 50 ? 50 : towait, false); towait -= 50; } if (s->c > 0) { @@ -1348,7 +1348,7 @@ static void normal_check_folds(NormalState *s) if (hasAnyFolding(curwin) && !char_avail()) { foldCheckClose(); - if (fdo_flags & FDO_ALL) { + if (fdo_flags & kOptFdoFlagAll) { foldOpenCursor(); } } @@ -1372,10 +1372,6 @@ static void normal_redraw(NormalState *s) } } - if (need_maketitle) { - maketitle(); - } - curbuf->b_last_used = time(NULL); // Display message after redraw. If an external message is still visible, @@ -2310,7 +2306,7 @@ static void nv_gd(oparg_T *oap, int nchar, int thisblock) return; } - if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagSearch) && KeyTyped && oap->op_type == OP_NOP) { foldOpenCursor(); } // clear any search statistics @@ -3752,7 +3748,7 @@ static void nv_right(cmdarg_T *cap) } } } - if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped + if (n != cap->count1 && (fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } @@ -3811,7 +3807,7 @@ static void nv_left(cmdarg_T *cap) break; } } - if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped + if (n != cap->count1 && (fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } @@ -3929,7 +3925,7 @@ static void nv_dollar(cmdarg_T *cap) if (cursor_down(cap->count1 - 1, cap->oap->op_type == OP_NOP) == false) { clearopbeep(cap->oap); - } else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) { + } else if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -4016,7 +4012,7 @@ static int normal_search(cmdarg_T *cap, int dir, char *pat, size_t patlen, int o cap->oap->motion_type = kMTLineWise; } curwin->w_cursor.coladd = 0; - if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) { + if (cap->oap->op_type == OP_NOP && (fdo_flags & kOptFdoFlagSearch) && KeyTyped) { foldOpenCursor(); } } @@ -4065,7 +4061,7 @@ static void nv_csearch(cmdarg_T *cap) curwin->w_cursor.coladd = 0; } adjust_for_sel(cap); - if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -4181,7 +4177,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) setpcmark(); curwin->w_cursor = *pos; curwin->w_set_curswant = true; - if ((fdo_flags & FDO_BLOCK) && KeyTyped + if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } @@ -4261,7 +4257,7 @@ static void nv_brackets(cmdarg_T *cap) if (cap->oap->op_type == OP_NOP) { beginline(BL_WHITE | BL_FIX); } - if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -4319,7 +4315,7 @@ static void nv_brackets(cmdarg_T *cap) } curwin->w_set_curswant = true; } - if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) { + if (cap->oap->op_type == OP_NOP && (fdo_flags & kOptFdoFlagSearch) && KeyTyped) { foldOpenCursor(); } } else { @@ -4371,7 +4367,7 @@ static void nv_percent(cmdarg_T *cap) } if (cap->oap->op_type == OP_NOP && lnum != curwin->w_cursor.lnum - && (fdo_flags & FDO_PERCENT) + && (fdo_flags & kOptFdoFlagPercent) && KeyTyped) { foldOpenCursor(); } @@ -4395,7 +4391,7 @@ static void nv_brace(cmdarg_T *cap) // Don't leave the cursor on the NUL past end of line. adjust_cursor(cap->oap); curwin->w_cursor.coladd = 0; - if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -4426,7 +4422,7 @@ static void nv_findpar(cmdarg_T *cap) } curwin->w_cursor.coladd = 0; - if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagBlock) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -4864,7 +4860,7 @@ static void nv_optrans(cmdarg_T *cap) static void nv_gomark(cmdarg_T *cap) { int name; - MarkMove flags = jop_flags & JOP_VIEW ? kMarkSetView : 0; // flags for moving to the mark + MarkMove flags = jop_flags & kOptJopFlagView ? kMarkSetView : 0; // flags for moving to the mark if (cap->oap->op_type != OP_NOP) { // When there is a pending operator, do not restore the view as this is usually unexpected. flags = 0; @@ -4893,7 +4889,7 @@ static void nv_gomark(cmdarg_T *cap) if (cap->oap->op_type == OP_NOP && move_res & kMarkMoveSuccess && (move_res & kMarkSwitchedBuf || move_res & kMarkChangedCursor) - && (fdo_flags & FDO_MARK) + && (fdo_flags & kOptFdoFlagMark) && old_KeyTyped) { foldOpenCursor(); } @@ -4904,7 +4900,7 @@ static void nv_gomark(cmdarg_T *cap) static void nv_pcmark(cmdarg_T *cap) { fmark_T *fm = NULL; - MarkMove flags = jop_flags & JOP_VIEW ? kMarkSetView : 0; // flags for moving to the mark + MarkMove flags = jop_flags & kOptJopFlagView ? kMarkSetView : 0; // flags for moving to the mark MarkMoveRes move_res = 0; // Result from moving to the mark const bool old_KeyTyped = KeyTyped; // getting file may reset it. @@ -4943,7 +4939,7 @@ static void nv_pcmark(cmdarg_T *cap) } if (cap->oap->op_type == OP_NOP && (move_res & kMarkSwitchedBuf || move_res & kMarkChangedLine) - && (fdo_flags & FDO_MARK) + && (fdo_flags & kOptFdoFlagMark) && old_KeyTyped) { foldOpenCursor(); } @@ -5042,6 +5038,9 @@ static void nv_visual(cmdarg_T *cap) assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX); curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1; curwin->w_cursor.lnum = lnum; + if (*p_sel == 'e') { + curwin->w_curswant++; + } coladvance(curwin, curwin->w_curswant); } else { curwin->w_set_curswant = true; @@ -5094,7 +5093,7 @@ static void n_start_visual_mode(int c) // Corner case: the 0 position in a tab may change when going into // virtualedit. Recalculate curwin->w_cursor to avoid bad highlighting. // - if (c == Ctrl_V && (get_ve_flags(curwin) & VE_BLOCK) && gchar_cursor() == TAB) { + if (c == Ctrl_V && (get_ve_flags(curwin) & kOptVeFlagBlock) && gchar_cursor() == TAB) { validate_virtcol(curwin); coladvance(curwin, curwin->w_virtcol); } @@ -5561,7 +5560,7 @@ static void nv_g_cmd(cmdarg_T *cap) // "gs": Goto sleep. case 's': - do_sleep(cap->count1 * 1000); + do_sleep(cap->count1 * 1000, false); break; // "ga": Display the ascii value of the character under the @@ -5915,7 +5914,7 @@ static void nv_bck_word(cmdarg_T *cap) curwin->w_set_curswant = true; if (bck_word(cap->count1, cap->arg, false) == false) { clearopbeep(cap->oap); - } else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) { + } else if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -5975,7 +5974,7 @@ static void nv_wordcmd(cmdarg_T *cap) clearopbeep(cap->oap); } else { adjust_for_sel(cap); - if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -5993,7 +5992,7 @@ static void adjust_cursor(oparg_T *oap) if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL && (!VIsual_active || *p_sel == 'o') && !virtual_active(curwin) - && (get_ve_flags(curwin) & VE_ONEMORE) == 0) { + && (get_ve_flags(curwin) & kOptVeFlagOnemore) == 0) { curwin->w_cursor.col--; // prevent cursor from moving on the trail byte mb_adjust_cursor(); @@ -6008,7 +6007,7 @@ static void nv_beginline(cmdarg_T *cap) cap->oap->motion_type = kMTCharWise; cap->oap->inclusive = false; beginline(cap->arg); - if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagHor) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } ins_at_eol = false; // Don't move cursor past eol (only necessary in a @@ -6097,7 +6096,7 @@ static void nv_goto(cmdarg_T *cap) lnum = MIN(MAX(lnum, 1), curbuf->b_ml.ml_line_count); curwin->w_cursor.lnum = lnum; beginline(BL_SOL | BL_FIX); - if ((fdo_flags & FDO_JUMP) && KeyTyped && cap->oap->op_type == OP_NOP) { + if ((fdo_flags & kOptFdoFlagJump) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } } @@ -6167,7 +6166,7 @@ static void nv_esc(cmdarg_T *cap) curwin->w_set_curswant = true; redraw_curbuf_later(UPD_INVERTED); } else if (no_reason) { - vim_beep(BO_ESC); + vim_beep(kOptBoFlagEsc); } clearop(cap->oap); } @@ -6176,7 +6175,7 @@ static void nv_esc(cmdarg_T *cap) void set_cursor_for_append_to_line(void) { curwin->w_set_curswant = true; - if (get_ve_flags(curwin) == VE_ALL) { + if (get_ve_flags(curwin) == kOptVeFlagAll) { const int save_State = State; // Pretend Insert mode here to allow the cursor on the // character past the end of the line @@ -6501,7 +6500,8 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) int regname = cap->oap->regname; bool keep_registers = cap->cmdchar == 'P'; // '+' and '*' could be the same selection - bool clipoverwrite = (regname == '+' || regname == '*') && (cb_flags & CB_UNNAMEDMASK); + bool clipoverwrite = (regname == '+' || regname == '*') + && (cb_flags & (kOptCbFlagUnnamed | kOptCbFlagUnnamedplus)); if (regname == 0 || regname == '"' || clipoverwrite || ascii_isdigit(regname) || regname == '-') { // The delete might overwrite the register we want to put, save it first @@ -6624,8 +6624,8 @@ static void nv_event(cmdarg_T *cap) // `input_get` branch was not executed (!multiqueue_empty(loop.events), which // could have `may_garbage_collect` set to true in `normal_check`). // - // That is because here we may run code that calls `input_get` - // later(`f_confirm` or `get_keystroke` for example), but in these cases it is + // That is because here we may run code that calls `input_get` later + // (`f_confirm` or `get_keystroke` for example), but in these cases it is // not safe to perform garbage collection because there could be unreferenced // lists or dicts being used. may_garbage_collect = false; |