To: vim_dev@googlegroups.com Subject: Patch 8.2.4911 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4911 Problem: The mode #defines are not clearly named. Solution: Prepend MODE_. Renumber them to put the mapped modes first. Files: src/vim.h, src/autocmd.c, src/buffer.c, src/change.c, src/charset.c, src/cindent.c, src/clipboard.c, src/debugger.c, src/digraph.c, src/drawline.c, src/drawscreen.c, src/edit.c, src/evalfunc.c, src/ex_cmds.c, src/ex_docmd.c, src/ex_getln.c, src/fileio.c, src/fold.c, src/getchar.c, src/globals.h, src/gui.c, src/gui_gtk.c, src/gui_w32.c, src/gui_xim.c, src/indent.c, src/insexpand.c, src/macros.h, src/main.c, src/map.c, src/menu.c, src/message.c, src/misc1.c, src/misc2.c, src/mouse.c, src/netbeans.c, src/normal.c, src/ops.c, src/option.c, src/os_unix.c, src/os_win32.c, src/popupmenu.c, src/search.c, src/tag.c, src/screen.c, src/term.c, src/terminal.c, src/textformat.c, src/window.c *** ../vim-8.2.4910/src/vim.h 2022-04-09 21:41:22.266689586 +0100 --- src/vim.h 2022-05-07 19:53:31.199235623 +0100 *************** *** 667,710 **** #define MSG_HIST 0x1000 /* ! * values for State * ! * The lower bits up to 0x20 are used to distinguish normal/visual/op_pending ! * and cmdline/insert+replace mode. This is used for mapping. If none of ! * these bits are set, no mapping is done. ! * The upper bits are used to distinguish between other states. ! */ ! #define NORMAL 0x01 // Normal mode, command expected ! #define VISUAL 0x02 // Visual mode - use get_real_state() ! #define OP_PENDING 0x04 // Normal mode, operator is pending - use // get_real_state() ! #define CMDLINE 0x08 // Editing command line ! #define INSERT 0x10 // Insert mode ! #define LANGMAP 0x20 // Language mapping, can be combined with ! // INSERT and CMDLINE ! ! #define REPLACE_FLAG 0x40 // Replace mode flag ! #define REPLACE (REPLACE_FLAG + INSERT) ! #define VREPLACE_FLAG 0x80 // Virtual-replace mode flag ! #define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT) ! #define LREPLACE (REPLACE_FLAG + LANGMAP) ! ! #define NORMAL_BUSY (0x100 + NORMAL) // Normal mode, busy with a command ! #define HITRETURN (0x200 + NORMAL) // waiting for return or command ! #define ASKMORE 0x300 // Asking if you want --more-- ! #define SETWSIZE 0x400 // window size has changed ! #define ABBREV 0x500 // abbreviation instead of mapping ! #define EXTERNCMD 0x600 // executing an external command ! #define SHOWMATCH (0x700 + INSERT) // show matching paren ! #define CONFIRM 0x800 // ":confirm" prompt ! #define SELECTMODE 0x1000 // Select mode, only for mappings ! #define TERMINAL 0x2000 // Terminal mode #define MODE_ALL 0xffff ! #define MODE_MAX_LENGTH 4 // max mode length returned in mode() ! ! // all mode bits used for mapping ! #define MAP_ALL_MODES (0x3f | SELECTMODE | TERMINAL) // directions #define FORWARD 1 --- 667,712 ---- #define MSG_HIST 0x1000 /* ! * Values for State. * ! * The lower bits up to 0x80 are used to distinguish normal/visual/op_pending ! * /cmdline/insert/replace/terminal mode. This is used for mapping. If none ! * of these bits are set, no mapping is done. See the comment above do_map(). ! * The upper bits are used to distinguish between other states and variants of ! * the base modes. ! */ ! #define MODE_NORMAL 0x01 // Normal mode, command expected ! #define MODE_VISUAL 0x02 // Visual mode - use get_real_state() ! #define MODE_OP_PENDING 0x04 // Normal mode, operator is pending - use // get_real_state() ! #define MODE_CMDLINE 0x08 // Editing the command line ! #define MODE_INSERT 0x10 // Insert mode, also for Replace mode ! #define MODE_LANGMAP 0x20 // Language mapping, can be combined with ! // MODE_INSERT and MODE_CMDLINE ! #define MODE_SELECT 0x40 // Select mode, use get_real_state() ! #define MODE_TERMINAL 0x80 // Terminal mode ! ! #define MAP_ALL_MODES 0xff // all mode bits used for mapping ! ! #define REPLACE_FLAG 0x100 // Replace mode flag ! #define MODE_REPLACE (REPLACE_FLAG | MODE_INSERT) ! #define VREPLACE_FLAG 0x200 // Virtual-replace mode flag ! #define MODE_VREPLACE (REPLACE_FLAG | VREPLACE_FLAG | MODE_INSERT) ! #define MODE_LREPLACE (REPLACE_FLAG | MODE_LANGMAP) ! ! #define MODE_NORMAL_BUSY (0x1000 | MODE_NORMAL) ! // Normal mode, busy with a command ! #define MODE_HITRETURN (0x2000 | MODE_NORMAL) ! // waiting for return or command ! #define MODE_ASKMORE 0x3000 // Asking if you want --more-- ! #define MODE_SETWSIZE 0x4000 // window size has changed ! #define MODE_EXTERNCMD 0x5000 // executing an external command ! #define MODE_SHOWMATCH (0x6000 | MODE_INSERT) // show matching paren ! #define MODE_CONFIRM 0x7000 // ":confirm" prompt #define MODE_ALL 0xffff ! #define MODE_MAX_LENGTH 4 // max mode length used by get_mode(), ! // including the terminating NUL // directions #define FORWARD 1 *************** *** 2484,2490 **** /* * Avoid clashes between Perl and Vim namespace. */ - # undef NORMAL # undef STRLEN # undef FF # undef OP_DELETE --- 2486,2491 ---- *** ../vim-8.2.4910/src/autocmd.c 2022-04-14 15:39:39.281754582 +0100 --- src/autocmd.c 2022-05-07 18:50:56.680217193 +0100 *************** *** 1758,1764 **** static int has_cursorhold(void) { ! return (first_autopat[(int)(get_real_state() == NORMAL_BUSY ? EVENT_CURSORHOLD : EVENT_CURSORHOLDI)] != NULL); } --- 1758,1764 ---- static int has_cursorhold(void) { ! return (first_autopat[(int)(get_real_state() == MODE_NORMAL_BUSY ? EVENT_CURSORHOLD : EVENT_CURSORHOLDI)] != NULL); } *************** *** 1777,1783 **** && !ins_compl_active()) { state = get_real_state(); ! if (state == NORMAL_BUSY || (state & INSERT) != 0) return TRUE; } return FALSE; --- 1777,1783 ---- && !ins_compl_active()) { state = get_real_state(); ! if (state == MODE_NORMAL_BUSY || (state & MODE_INSERT) != 0) return TRUE; } return FALSE; *** ../vim-8.2.4910/src/buffer.c 2022-05-07 11:28:02.189974238 +0100 --- src/buffer.c 2022-05-07 19:16:55.326028705 +0100 *************** *** 1774,1780 **** // another window, might be a timer doing something in another // window. if (prevbuf == curbuf ! && ((State & INSERT) == 0 || curbuf->b_nwindows <= 1)) u_sync(FALSE); close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf, unload ? action : (action == DOBUF_GOTO --- 1774,1780 ---- // another window, might be a timer doing something in another // window. if (prevbuf == curbuf ! && ((State & MODE_INSERT) == 0 || curbuf->b_nwindows <= 1)) u_sync(FALSE); close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf, unload ? action : (action == DOBUF_GOTO *************** *** 4700,4707 **** break; case STL_COLUMN: ! num = !(State & INSERT) && empty_line ! ? 0 : (int)wp->w_cursor.col + 1; break; case STL_VIRTCOL: --- 4700,4707 ---- break; case STL_COLUMN: ! num = (State & MODE_INSERT) == 0 && empty_line ! ? 0 : (int)wp->w_cursor.col + 1; break; case STL_VIRTCOL: *************** *** 4709,4716 **** virtcol = wp->w_virtcol + 1; // Don't display %V if it's the same as %c. if (opt == STL_VIRTCOL_ALT ! && (virtcol == (colnr_T)(!(State & INSERT) && empty_line ! ? 0 : (int)wp->w_cursor.col + 1))) break; num = (long)virtcol; break; --- 4709,4716 ---- virtcol = wp->w_virtcol + 1; // Don't display %V if it's the same as %c. if (opt == STL_VIRTCOL_ALT ! && (virtcol == (colnr_T)((State & MODE_INSERT) == 0 ! && empty_line ? 0 : (int)wp->w_cursor.col + 1))) break; num = (long)virtcol; break; *************** *** 4755,4763 **** case STL_OFFSET: #ifdef FEAT_BYTEOFF l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL); ! num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 ? ! 0L : l + 1 + (!(State & INSERT) && empty_line ? ! 0 : (int)wp->w_cursor.col); #endif break; --- 4755,4763 ---- case STL_OFFSET: #ifdef FEAT_BYTEOFF l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL); ! num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 ! ? 0L : l + 1 + ((State & MODE_INSERT) == 0 && empty_line ! ? 0 : (int)wp->w_cursor.col); #endif break; *** ../vim-8.2.4910/src/change.c 2022-05-07 14:53:40.443628505 +0100 --- src/change.c 2022-05-07 19:19:26.813760268 +0100 *************** *** 988,994 **** /* * Insert or replace a single character at the cursor position. ! * When in REPLACE or VREPLACE mode, replace any existing character. * Caller must have prepared for undo. * For multi-byte characters we get the whole character, the caller must * convert bytes to a character. --- 988,994 ---- /* * Insert or replace a single character at the cursor position. ! * When in MODE_REPLACE or MODE_VREPLACE state, replace any existing character. * Caller must have prepared for undo. * For multi-byte characters we get the whole character, the caller must * convert bytes to a character. *************** *** 1119,1125 **** // If we're in Insert or Replace mode and 'showmatch' is set, then briefly // show the match for right parens and braces. ! if (p_sm && (State & INSERT) && msg_silent == 0 && !ins_compl_active()) { --- 1119,1125 ---- // If we're in Insert or Replace mode and 'showmatch' is set, then briefly // show the match for right parens and braces. ! if (p_sm && (State & MODE_INSERT) && msg_silent == 0 && !ins_compl_active()) { *************** *** 1342,1351 **** /* * open_line: Add a new line below or above the current line. * ! * For VREPLACE mode, we only add a new line when we get to the end of the ! * file, otherwise we just start replacing the next line. * ! * Caller must take care of undo. Since VREPLACE may affect any number of * lines however, it may call u_save_cursor() again when starting to change a * new line. * "flags": OPENLINE_DELSPACES delete spaces after cursor --- 1342,1351 ---- /* * open_line: Add a new line below or above the current line. * ! * For MODE_VREPLACE state, we only add a new line when we get to the end of ! * the file, otherwise we just start replacing the next line. * ! * Caller must take care of undo. Since MODE_VREPLACE may affect any number of * lines however, it may call u_save_cursor() again when starting to change a * new line. * "flags": OPENLINE_DELSPACES delete spaces after cursor *************** *** 1416,1422 **** if (State & VREPLACE_FLAG) { ! // With VREPLACE we make a copy of the next line, which we will be // starting to replace. First make the new line empty and let vim play // with the indenting and comment leader to its heart's content. Then // we grab what it ended up putting on the new line, put back the --- 1416,1422 ---- if (State & VREPLACE_FLAG) { ! // With MODE_VREPLACE we make a copy of the next line, which we will be // starting to replace. First make the new line empty and let vim play // with the indenting and comment leader to its heart's content. Then // we grab what it ended up putting on the new line, put back the *************** *** 1430,1440 **** if (next_line == NULL) // out of memory! goto theend; ! // In VREPLACE mode, a NL replaces the rest of the line, and starts ! // replacing the next line, so push all of the characters left on the ! // line onto the replace stack. We'll push any other characters that ! // might be replaced at the start of the next line (due to autoindent ! // etc) a bit later. replace_push(NUL); // Call twice because BS over NL expects it replace_push(NUL); p = saved_line + curwin->w_cursor.col; --- 1430,1440 ---- if (next_line == NULL) // out of memory! goto theend; ! // In MODE_VREPLACE state, a NL replaces the rest of the line, and ! // starts replacing the next line, so push all of the characters left ! // on the line onto the replace stack. We'll push any other characters ! // that might be replaced at the start of the next line (due to ! // autoindent etc) a bit later. replace_push(NUL); // Call twice because BS over NL expects it replace_push(NUL); p = saved_line + curwin->w_cursor.col; *************** *** 1448,1454 **** saved_line[curwin->w_cursor.col] = NUL; } ! if ((State & INSERT) && !(State & VREPLACE_FLAG)) { p_extra = saved_line + curwin->w_cursor.col; #ifdef FEAT_SMARTINDENT --- 1448,1454 ---- saved_line[curwin->w_cursor.col] = NUL; } ! if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0) { p_extra = saved_line + curwin->w_cursor.col; #ifdef FEAT_SMARTINDENT *************** *** 2077,2083 **** } } ! // (State == INSERT || State == REPLACE), only when dir == FORWARD if (p_extra != NULL) { *p_extra = saved_char; // restore char that NUL replaced --- 2077,2083 ---- } } ! // (State == MODE_INSERT || State == MODE_REPLACE), only when dir == FORWARD if (p_extra != NULL) { *p_extra = saved_char; // restore char that NUL replaced *************** *** 2085,2092 **** // When 'ai' set or "flags" has OPENLINE_DELSPACES, skip to the first // non-blank. // ! // When in REPLACE mode, put the deleted blanks on the replace stack, ! // preceded by a NUL, so they can be put back when a BS is entered. if (REPLACE_NORMAL(State)) replace_push(NUL); // end of extra blanks if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) --- 2085,2093 ---- // When 'ai' set or "flags" has OPENLINE_DELSPACES, skip to the first // non-blank. // ! // When in MODE_REPLACE state, put the deleted blanks on the replace ! // stack, preceded by a NUL, so they can be put back when a BS is ! // entered. if (REPLACE_NORMAL(State)) replace_push(NUL); // end of extra blanks if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) *************** *** 2156,2162 **** mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); did_append = TRUE; #ifdef FEAT_PROP_POPUP ! if ((State & INSERT) && !(State & VREPLACE_FLAG)) // properties after the split move to the next line adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum, curwin->w_cursor.col + 1, 0); --- 2157,2163 ---- mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); did_append = TRUE; #ifdef FEAT_PROP_POPUP ! if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0) // properties after the split move to the next line adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum, curwin->w_cursor.col + 1, 0); *************** *** 2164,2170 **** } else { ! // In VREPLACE mode we are starting to replace the next line. curwin->w_cursor.lnum++; if (curwin->w_cursor.lnum >= Insstart.lnum + vr_lines_changed) { --- 2165,2171 ---- } else { ! // In MODE_VREPLACE state we are starting to replace the next line. curwin->w_cursor.lnum++; if (curwin->w_cursor.lnum >= Insstart.lnum + vr_lines_changed) { *************** *** 2212,2219 **** ai_col = curwin->w_cursor.col; ! // In REPLACE mode, for each character in the new indent, there must ! // be a NUL on the replace stack, for when it is deleted with BS if (REPLACE_NORMAL(State)) for (n = 0; n < (int)curwin->w_cursor.col; ++n) replace_push(NUL); --- 2213,2220 ---- ai_col = curwin->w_cursor.col; ! // In MODE_REPLACE state, for each character in the new indent, there ! // must be a NUL on the replace stack, for when it is deleted with BS if (REPLACE_NORMAL(State)) for (n = 0; n < (int)curwin->w_cursor.col; ++n) replace_push(NUL); *************** *** 2224,2231 **** #endif } ! // In REPLACE mode, for each character in the extra leader, there must be ! // a NUL on the replace stack, for when it is deleted with BS. if (REPLACE_NORMAL(State)) while (lead_len-- > 0) replace_push(NUL); --- 2225,2232 ---- #endif } ! // In MODE_REPLACE state, for each character in the extra leader, there ! // must be a NUL on the replace stack, for when it is deleted with BS. if (REPLACE_NORMAL(State)) while (lead_len-- > 0) replace_push(NUL); *************** *** 2234,2240 **** if (dir == FORWARD) { ! if (trunc_line || (State & INSERT)) { // truncate current line at cursor saved_line[curwin->w_cursor.col] = NUL; --- 2235,2241 ---- if (dir == FORWARD) { ! if (trunc_line || (State & MODE_INSERT)) { // truncate current line at cursor saved_line[curwin->w_cursor.col] = NUL; *************** *** 2270,2282 **** curwin->w_cursor.coladd = 0; #if defined(FEAT_LISP) || defined(FEAT_CINDENT) ! // In VREPLACE mode, we are handling the replace stack ourselves, so stop ! // fixthisline() from doing it (via change_indent()) by telling it we're in ! // normal INSERT mode. if (State & VREPLACE_FLAG) { vreplace_mode = State; // So we know to put things right later ! State = INSERT; } else vreplace_mode = 0; --- 2271,2283 ---- curwin->w_cursor.coladd = 0; #if defined(FEAT_LISP) || defined(FEAT_CINDENT) ! // In MODE_VREPLACE state, we are handling the replace stack ourselves, so ! // stop fixthisline() from doing it (via change_indent()) by telling it ! // we're in normal MODE_INSERT state. if (State & VREPLACE_FLAG) { vreplace_mode = State; // So we know to put things right later ! State = MODE_INSERT; } else vreplace_mode = 0; *************** *** 2305,2313 **** State = vreplace_mode; #endif ! // Finally, VREPLACE gets the stuff on the new line, then puts back the ! // original line, and inserts the new stuff char by char, pushing old stuff ! // onto the replace stack (via ins_char()). if (State & VREPLACE_FLAG) { // Put new line in p_extra --- 2306,2314 ---- State = vreplace_mode; #endif ! // Finally, MODE_VREPLACE gets the stuff on the new line, then puts back ! // the original line, and inserts the new stuff char by char, pushing old ! // stuff onto the replace stack (via ins_char()). if (State & VREPLACE_FLAG) { // Put new line in p_extra *** ../vim-8.2.4910/src/charset.c 2022-03-09 13:00:50.776824777 +0000 --- src/charset.c 2022-05-07 18:19:23.897373870 +0100 *************** *** 1300,1306 **** if (cursor != NULL) { if (*ptr == TAB ! && (State & NORMAL) && !wp->w_p_list && !virtual_active() && !(VIsual_active --- 1300,1306 ---- if (cursor != NULL) { if (*ptr == TAB ! && (State & MODE_NORMAL) && !wp->w_p_list && !virtual_active() && !(VIsual_active *** ../vim-8.2.4910/src/cindent.c 2022-04-17 14:18:07.364733158 +0100 --- src/cindent.c 2022-05-07 18:32:25.956882667 +0100 *************** *** 2114,2120 **** // inserting new stuff. // For unknown reasons the cursor might be past the end of the line, thus // check for that. ! if ((State & INSERT) && curwin->w_cursor.col < (colnr_T)STRLEN(linecopy) && linecopy[curwin->w_cursor.col] == ')') linecopy[curwin->w_cursor.col] = NUL; --- 2114,2120 ---- // inserting new stuff. // For unknown reasons the cursor might be past the end of the line, thus // check for that. ! if ((State & MODE_INSERT) && curwin->w_cursor.col < (colnr_T)STRLEN(linecopy) && linecopy[curwin->w_cursor.col] == ')') linecopy[curwin->w_cursor.col] = NUL; *** ../vim-8.2.4910/src/clipboard.c 2022-04-03 18:01:39.651574466 +0100 --- src/clipboard.c 2022-05-07 18:19:41.549362229 +0100 *************** *** 77,83 **** pos_T start, end; // If visual mode is only due to a redo command ("."), then ignore it ! if (!redo_VIsual_busy && VIsual_active && (State & NORMAL)) { if (LT_POS(VIsual, curwin->w_cursor)) { --- 77,83 ---- pos_T start, end; // If visual mode is only due to a redo command ("."), then ignore it ! if (!redo_VIsual_busy && VIsual_active && (State & MODE_NORMAL)) { if (LT_POS(VIsual, curwin->w_cursor)) { *************** *** 142,149 **** // selected area. There is no specific redraw command for this, // just redraw all windows on the current buffer. if (cbd->owned ! && (get_real_state() == VISUAL ! || get_real_state() == SELECTMODE) && (cbd == &clip_star ? clip_isautosel_star() : clip_isautosel_plus()) && HL_ATTR(HLF_V) != HL_ATTR(HLF_VNC)) --- 142,149 ---- // selected area. There is no specific redraw command for this, // just redraw all windows on the current buffer. if (cbd->owned ! && (get_real_state() == MODE_VISUAL ! || get_real_state() == MODE_SELECT) && (cbd == &clip_star ? clip_isautosel_star() : clip_isautosel_plus()) && HL_ATTR(HLF_V) != HL_ATTR(HLF_VNC)) *************** *** 195,202 **** // area. There is no specific redraw command for this, just redraw all // windows on the current buffer. if (was_owned ! && (get_real_state() == VISUAL ! || get_real_state() == SELECTMODE) && (cbd == &clip_star ? clip_isautosel_star() : clip_isautosel_plus()) && HL_ATTR(HLF_V) != HL_ATTR(HLF_VNC) --- 195,202 ---- // area. There is no specific redraw command for this, just redraw all // windows on the current buffer. if (was_owned ! && (get_real_state() == MODE_VISUAL ! || get_real_state() == MODE_SELECT) && (cbd == &clip_star ? clip_isautosel_star() : clip_isautosel_plus()) && HL_ATTR(HLF_V) != HL_ATTR(HLF_VNC) *************** *** 214,220 **** static void clip_copy_selection(Clipboard_T *clip) { ! if (VIsual_active && (State & NORMAL) && clip->available) { clip_update_selection(clip); clip_free_selection(clip); --- 214,220 ---- static void clip_copy_selection(Clipboard_T *clip) { ! if (VIsual_active && (State & MODE_NORMAL) && clip->available) { clip_update_selection(clip); clip_free_selection(clip); *** ../vim-8.2.4910/src/debugger.c 2022-03-10 13:29:16.912279861 +0000 --- src/debugger.c 2022-05-07 18:19:56.977352096 +0100 *************** *** 88,94 **** emsg_silent = FALSE; // display error messages redir_off = TRUE; // don't redirect debug commands ! State = NORMAL; debug_mode = TRUE; if (!debug_did_msg) --- 88,94 ---- emsg_silent = FALSE; // display error messages redir_off = TRUE; // don't redirect debug commands ! State = MODE_NORMAL; debug_mode = TRUE; if (!debug_did_msg) *** ../vim-8.2.4910/src/digraph.c 2022-03-19 12:56:42.529503830 +0000 --- src/digraph.c 2022-05-07 18:02:22.866193798 +0100 *************** *** 2566,2572 **** vim_snprintf((char *)buf, sizeof(buf), " %s %s", ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from, ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to); ! (void)do_map(2, buf, LANGMAP, FALSE); } p_cpo = save_cpo; --- 2566,2572 ---- vim_snprintf((char *)buf, sizeof(buf), " %s %s", ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from, ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to); ! (void)do_map(2, buf, MODE_LANGMAP, FALSE); } p_cpo = save_cpo; *************** *** 2597,2603 **** for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) { vim_snprintf((char *)buf, sizeof(buf), " %s", kp[i].from); ! (void)do_map(1, buf, LANGMAP, FALSE); } keymap_clear(&curbuf->b_kmap_ga); --- 2597,2603 ---- for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) { vim_snprintf((char *)buf, sizeof(buf), " %s", kp[i].from); ! (void)do_map(1, buf, MODE_LANGMAP, FALSE); } keymap_clear(&curbuf->b_kmap_ga); *** ../vim-8.2.4910/src/drawline.c 2022-03-23 14:55:19.709745872 +0000 --- src/drawline.c 2022-05-07 19:22:39.385456467 +0100 *************** *** 1963,1969 **** // In Insert mode only highlight a word that // doesn't touch the cursor. if (spell_hlf != HLF_COUNT ! && (State & INSERT) != 0 && wp->w_cursor.lnum == lnum && wp->w_cursor.col >= (colnr_T)(prev_ptr - line) --- 1963,1969 ---- // In Insert mode only highlight a word that // doesn't touch the cursor. if (spell_hlf != HLF_COUNT ! && (State & MODE_INSERT) && wp->w_cursor.lnum == lnum && wp->w_cursor.col >= (colnr_T)(prev_ptr - line) *************** *** 2595,2601 **** if (p_imst == IM_ON_THE_SPOT && xic != NULL && lnum == wp->w_cursor.lnum ! && (State & INSERT) && !p_imdisable && im_is_preediting() && draw_state == WL_LINE) --- 2595,2601 ---- if (p_imst == IM_ON_THE_SPOT && xic != NULL && lnum == wp->w_cursor.lnum ! && (State & MODE_INSERT) && !p_imdisable && im_is_preediting() && draw_state == WL_LINE) *** ../vim-8.2.4910/src/drawscreen.c 2022-04-09 12:39:51.559956642 +0100 --- src/drawscreen.c 2022-05-07 19:23:33.461376635 +0100 *************** *** 686,692 **** /* * Check if not in Insert mode and the line is empty (will show "0-1"). */ ! if (!(State & INSERT) && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL) empty_line = TRUE; --- 686,692 ---- /* * Check if not in Insert mode and the line is empty (will show "0-1"). */ ! if ((State & MODE_INSERT) == 0 && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL) empty_line = TRUE; *************** *** 2834,2840 **** // Return when there is nothing to do, screen updating is already // happening (recursive call), messages on the screen or still starting up. if (!doit || updating_screen ! || State == ASKMORE || State == HITRETURN || msg_scrolled #ifdef FEAT_GUI || gui.starting --- 2834,2840 ---- // Return when there is nothing to do, screen updating is already // happening (recursive call), messages on the screen or still starting up. if (!doit || updating_screen ! || State == MODE_ASKMORE || State == MODE_HITRETURN || msg_scrolled #ifdef FEAT_GUI || gui.starting *************** *** 2925,2931 **** schar_T *screenline2 = NULL; // copy from ScreenLines2[] redraw_later(type); ! if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY) || exiting) return ret; // Allocate space to save the text displayed in the command line area. --- 2925,2932 ---- schar_T *screenline2 = NULL; // copy from ScreenLines2[] redraw_later(type); ! if (msg_scrolled || (State != MODE_NORMAL && State != MODE_NORMAL_BUSY) ! || exiting) return ret; // Allocate space to save the text displayed in the command line area. *************** *** 3049,3061 **** { ++redrawing_for_callback; ! if (State == HITRETURN || State == ASKMORE || State == SETWSIZE ! || State == EXTERNCMD || State == CONFIRM || exmode_active) { if (do_message) repeat_message(); } ! else if (State & CMDLINE) { #ifdef FEAT_WILDMENU if (pum_visible()) --- 3050,3063 ---- { ++redrawing_for_callback; ! if (State == MODE_HITRETURN || State == MODE_ASKMORE ! || State == MODE_SETWSIZE || State == MODE_EXTERNCMD ! || State == MODE_CONFIRM || exmode_active) { if (do_message) repeat_message(); } ! else if (State & MODE_CMDLINE) { #ifdef FEAT_WILDMENU if (pum_visible()) *************** *** 3078,3084 **** redrawcmdline_ex(FALSE); } } ! else if (State & (NORMAL | INSERT | TERMINAL)) { update_topline(); validate_cursor(); --- 3080,3086 ---- redrawcmdline_ex(FALSE); } } ! else if (State & (MODE_NORMAL | MODE_INSERT | MODE_TERMINAL)) { update_topline(); validate_cursor(); *** ../vim-8.2.4910/src/edit.c 2022-05-05 20:46:41.407274630 +0100 --- src/edit.c 2022-05-07 19:25:49.689184815 +0100 *************** *** 142,148 **** int old_topfill = -1; #endif int inserted_space = FALSE; // just inserted a space ! int replaceState = REPLACE; int nomove = FALSE; // don't move cursor on return #ifdef FEAT_JOB_CHANNEL int cmdchar_todo = cmdchar; --- 142,148 ---- int old_topfill = -1; #endif int inserted_space = FALSE; // just inserted a space ! int replaceState = MODE_REPLACE; int nomove = FALSE; // don't move cursor on return #ifdef FEAT_JOB_CHANNEL int cmdchar_todo = cmdchar; *************** *** 218,224 **** int save_state = State; curwin->w_cursor = save_cursor; ! State = INSERT; check_cursor_col(); State = save_state; } --- 218,224 ---- int save_state = State; curwin->w_cursor = save_cursor; ! State = MODE_INSERT; check_cursor_col(); State = save_state; } *************** *** 272,288 **** if (cmdchar == 'R') { ! State = REPLACE; } else if (cmdchar == 'V' || cmdchar == 'v') { ! State = VREPLACE; ! replaceState = VREPLACE; orig_line_count = curbuf->b_ml.ml_line_count; vr_lines_changed = 1; } else ! State = INSERT; may_trigger_modechanged(); stop_insert_mode = FALSE; --- 272,288 ---- if (cmdchar == 'R') { ! State = MODE_REPLACE; } else if (cmdchar == 'V' || cmdchar == 'v') { ! State = MODE_VREPLACE; ! replaceState = MODE_VREPLACE; orig_line_count = curbuf->b_ml.ml_line_count; vr_lines_changed = 1; } else ! State = MODE_INSERT; may_trigger_modechanged(); stop_insert_mode = FALSE; *************** *** 304,310 **** * when hitting . */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) ! State |= LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); #endif --- 304,310 ---- * when hitting . */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) ! State |= MODE_LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); #endif *************** *** 315,321 **** #endif #ifdef FEAT_RIGHTLEFT // there is no reverse replace mode ! revins_on = (State == INSERT && p_ri); if (revins_on) undisplay_dollar(); revins_chars = 0; --- 315,321 ---- #endif #ifdef FEAT_RIGHTLEFT // there is no reverse replace mode ! revins_on = (State == MODE_INSERT && p_ri); if (revins_on) undisplay_dollar(); revins_chars = 0; *************** *** 1802,1809 **** /* * Truncate the space at the end of a line. This is to be used only in an ! * insert mode. It handles fixing the replace stack for REPLACE and VREPLACE ! * modes. */ void truncate_spaces(char_u *line) --- 1802,1809 ---- /* * Truncate the space at the end of a line. This is to be used only in an ! * insert mode. It handles fixing the replace stack for MODE_REPLACE and ! * MODE_VREPLACE modes. */ void truncate_spaces(char_u *line) *************** *** 1820,1828 **** } /* ! * Backspace the cursor until the given column. Handles REPLACE and VREPLACE ! * modes correctly. May also be used when not in insert mode at all. ! * Will attempt not to go before "col" even when there is a composing * character. */ void --- 1820,1828 ---- } /* ! * Backspace the cursor until the given column. Handles MODE_REPLACE and ! * MODE_VREPLACE modes correctly. May also be used when not in insert mode at ! * all. Will attempt not to go before "col" even when there is a composing * character. */ void *************** *** 1924,1930 **** break; #ifdef FEAT_CMDL_INFO ! if (!(State & CMDLINE) && MB_BYTE2LEN_CHECK(nc) == 1) add_to_showcmd(nc); #endif if (nc == 'x' || nc == 'X') --- 1924,1930 ---- break; #ifdef FEAT_CMDL_INFO ! if ((State & MODE_CMDLINE) == 0 && MB_BYTE2LEN_CHECK(nc) == 1) add_to_showcmd(nc); #endif if (nc == 'x' || nc == 'X') *************** *** 2099,2105 **** * - Otherwise: * - Don't do this if inserting a blank * - Don't do this if an existing character is being replaced, unless ! * we're in VREPLACE mode. * - Do this if the cursor is not on the line where insert started * or - 'formatoptions' doesn't have 'l' or the line was not too long * before the insert. --- 2099,2105 ---- * - Otherwise: * - Don't do this if inserting a blank * - Don't do this if an existing character is being replaced, unless ! * we're in MODE_VREPLACE state. * - Do this if the cursor is not on the line where insert started * or - 'formatoptions' doesn't have 'l' or the line was not too long * before the insert. *************** *** 2810,2816 **** // If we entered a fold, move to the beginning, unless in // Insert mode or when 'foldopen' contains "all": it will open // in a moment. ! if (n > 0 || !((State & INSERT) || (fdo_flags & FDO_ALL))) (void)hasFolding(lnum, &lnum, NULL); } if (lnum < 1) --- 2810,2816 ---- // If we entered a fold, move to the beginning, unless in // Insert mode or when 'foldopen' contains "all": it will open // in a moment. ! if (n > 0 || !((State & MODE_INSERT) || (fdo_flags & FDO_ALL))) (void)hasFolding(lnum, &lnum, NULL); } if (lnum < 1) *************** *** 3107,3113 **** /* * Pop bytes from the replace stack until a NUL is found, and insert them ! * before the cursor. Can only be used in REPLACE or VREPLACE mode. */ static void replace_pop_ins(void) --- 3107,3113 ---- /* * Pop bytes from the replace stack until a NUL is found, and insert them ! * before the cursor. Can only be used in MODE_REPLACE or MODE_VREPLACE state. */ static void replace_pop_ins(void) *************** *** 3115,3121 **** int cc; int oldState = State; ! State = NORMAL; // don't want REPLACE here while ((cc = replace_pop()) > 0) { mb_replace_pop_ins(cc); --- 3115,3121 ---- int cc; int oldState = State; ! State = MODE_NORMAL; // don't want MODE_REPLACE here while ((cc = replace_pop()) > 0) { mb_replace_pop_ins(cc); *************** *** 3545,3562 **** static void ins_ctrl_hat(void) { ! if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) { // ":lmap" mappings exists, Toggle use of ":lmap" mappings. ! if (State & LANGMAP) { curbuf->b_p_iminsert = B_IMODE_NONE; ! State &= ~LANGMAP; } else { curbuf->b_p_iminsert = B_IMODE_LMAP; ! State |= LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(FALSE); #endif --- 3545,3562 ---- static void ins_ctrl_hat(void) { ! if (map_to_exists_mode((char_u *)"", MODE_LANGMAP, FALSE)) { // ":lmap" mappings exists, Toggle use of ":lmap" mappings. ! if (State & MODE_LANGMAP) { curbuf->b_p_iminsert = B_IMODE_NONE; ! State &= ~MODE_LANGMAP; } else { curbuf->b_p_iminsert = B_IMODE_LMAP; ! State |= MODE_LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(FALSE); #endif *************** *** 3574,3580 **** else { curbuf->b_p_iminsert = B_IMODE_IM; ! State &= ~LANGMAP; im_set_active(TRUE); } } --- 3574,3580 ---- else { curbuf->b_p_iminsert = B_IMODE_IM; ! State &= ~MODE_LANGMAP; im_set_active(TRUE); } } *************** *** 3704,3715 **** // Disable IM to allow typing English directly for Normal mode commands. // When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as // well). ! if (!(State & LANGMAP)) im_save_status(&curbuf->b_p_iminsert); im_set_active(FALSE); #endif ! State = NORMAL; may_trigger_modechanged(); // need to position cursor again when on a TAB if (gchar_cursor() == TAB) --- 3704,3715 ---- // Disable IM to allow typing English directly for Normal mode commands. // When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as // well). ! if (!(State & MODE_LANGMAP)) im_save_status(&curbuf->b_p_iminsert); im_set_active(FALSE); #endif ! State = MODE_NORMAL; may_trigger_modechanged(); // need to position cursor again when on a TAB if (gchar_cursor() == TAB) *************** *** 3760,3766 **** ++curwin->w_cursor.col; } p_ri = !p_ri; ! revins_on = (State == INSERT && p_ri); if (revins_on) { revins_scol = curwin->w_cursor.col; --- 3760,3766 ---- ++curwin->w_cursor.col; } p_ri = !p_ri; ! revins_on = (State == MODE_INSERT && p_ri); if (revins_on) { revins_scol = curwin->w_cursor.col; *************** *** 3839,3852 **** #ifdef FEAT_EVAL set_vim_var_string(VV_INSERTMODE, (char_u *)((State & REPLACE_FLAG) ? "i" ! : replaceState == VREPLACE ? "v" : "r"), 1); #endif ins_apply_autocmds(EVENT_INSERTCHANGE); if (State & REPLACE_FLAG) ! State = INSERT | (State & LANGMAP); else ! State = replaceState | (State & LANGMAP); may_trigger_modechanged(); AppendCharToRedobuff(K_INS); showmode(); --- 3839,3852 ---- #ifdef FEAT_EVAL set_vim_var_string(VV_INSERTMODE, (char_u *)((State & REPLACE_FLAG) ? "i" ! : replaceState == MODE_VREPLACE ? "v" : "r"), 1); #endif ins_apply_autocmds(EVENT_INSERTCHANGE); if (State & REPLACE_FLAG) ! State = MODE_INSERT | (State & MODE_LANGMAP); else ! State = replaceState | (State & MODE_LANGMAP); may_trigger_modechanged(); AppendCharToRedobuff(K_INS); showmode(); *************** *** 4119,4138 **** dec_cursor(); /* ! * In REPLACE mode we have to put back the text that was replaced ! * by the NL. On the replace stack is first a NUL-terminated ! * sequence of characters that were deleted and then the ! * characters that NL replaced. */ if (State & REPLACE_FLAG) { /* ! * Do the next ins_char() in NORMAL state, to * prevent ins_char() from replacing characters and * avoiding showmatch(). */ oldState = State; ! State = NORMAL; /* * restore characters (blanks) deleted after cursor */ --- 4119,4138 ---- dec_cursor(); /* ! * In MODE_REPLACE mode we have to put back the text that was ! * replaced by the NL. On the replace stack is first a ! * NUL-terminated sequence of characters that were deleted and then ! * the characters that NL replaced. */ if (State & REPLACE_FLAG) { /* ! * Do the next ins_char() in MODE_NORMAL state, to * prevent ins_char() from replacing characters and * avoiding showmatch(). */ oldState = State; ! State = MODE_NORMAL; /* * restore characters (blanks) deleted after cursor */ *************** *** 4943,4949 **** /* * Insert the first space with ins_char(). It will delete one char in * replace mode. Insert the rest with ins_str(); it will not delete any ! * chars. For VREPLACE mode, we use ins_char() for all characters. */ ins_char(' '); while (--temp > 0) --- 4943,4949 ---- /* * Insert the first space with ins_char(). It will delete one char in * replace mode. Insert the rest with ins_str(); it will not delete any ! * chars. For MODE_VREPLACE state, we use ins_char() for all characters. */ ins_char(' '); while (--temp > 0) *************** *** 4979,4986 **** int save_list = curwin->w_p_list; /* ! * Get the current line. For VREPLACE mode, don't make real changes ! * yet, just work on a copy of the line. */ if (State & VREPLACE_FLAG) { --- 4979,4986 ---- int save_list = curwin->w_p_list; /* ! * Get the current line. For MODE_VREPLACE state, don't make real ! * changes yet, just work on a copy of the line. */ if (State & VREPLACE_FLAG) { *************** *** 5111,5119 **** cursor->col -= i; /* ! * In VREPLACE mode, we haven't changed anything yet. Do it now by ! * backspacing over the changed spacing and then inserting the new ! * spacing. */ if (State & VREPLACE_FLAG) { --- 5111,5119 ---- cursor->col -= i; /* ! * In MODE_VREPLACE state, we haven't changed anything yet. Do it ! * now by backspacing over the changed spacing and then inserting ! * the new spacing. */ if (State & VREPLACE_FLAG) { *************** *** 5159,5165 **** replace_push(NUL); /* ! * In VREPLACE mode, a NL replaces the rest of the line, and starts * replacing the next line, so we push all of the characters left on the * line onto the replace stack. This is not done here though, it is done * in open_line(). --- 5159,5165 ---- replace_push(NUL); /* ! * In MODE_VREPLACE state, a NL replaces the rest of the line, and starts * replacing the next line, so we push all of the characters left on the * line onto the replace stack. This is not done here though, it is done * in open_line(). *** ../vim-8.2.4910/src/evalfunc.c 2022-05-07 12:48:24.074194794 +0100 --- src/evalfunc.c 2022-05-07 18:07:04.541922018 +0100 *************** *** 10452,10458 **** f_wildmenumode(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { #ifdef FEAT_WILDMENU ! if (wild_menu_showing || ((State & CMDLINE) && cmdline_pum_active())) rettv->vval.v_number = 1; #endif } --- 10452,10458 ---- f_wildmenumode(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { #ifdef FEAT_WILDMENU ! if (wild_menu_showing || ((State & MODE_CMDLINE) && cmdline_pum_active())) rettv->vval.v_number = 1; #endif } *** ../vim-8.2.4910/src/ex_cmds.c 2022-04-14 20:43:52.638894555 +0100 --- src/ex_cmds.c 2022-05-07 19:26:23.101139402 +0100 *************** *** 3182,3188 **** redraw_curbuf_later(NOT_VALID); // redraw this buffer later } ! if (p_im && (State & INSERT) == 0) need_start_insertmode = TRUE; #ifdef FEAT_AUTOCHDIR --- 3182,3188 ---- redraw_curbuf_later(NOT_VALID); // redraw this buffer later } ! if (p_im && (State & MODE_INSERT) == 0) need_start_insertmode = TRUE; #ifdef FEAT_AUTOCHDIR *************** *** 3271,3279 **** if (empty && lnum == 1) lnum = 0; ! State = INSERT; // behave like in Insert mode if (curbuf->b_p_iminsert == B_IMODE_LMAP) ! State |= LANGMAP; for (;;) { --- 3271,3279 ---- if (empty && lnum == 1) lnum = 0; ! State = MODE_INSERT; // behave like in Insert mode if (curbuf->b_p_iminsert == B_IMODE_LMAP) ! State |= MODE_LANGMAP; for (;;) { *************** *** 3308,3316 **** { int save_State = State; ! // Set State to avoid the cursor shape to be set to INSERT mode ! // when getline() returns. ! State = CMDLINE; theline = eap->getline( #ifdef FEAT_EVAL eap->cstack->cs_looplevel > 0 ? -1 : --- 3308,3316 ---- { int save_State = State; ! // Set State to avoid the cursor shape to be set to MODE_INSERT ! // state when getline() returns. ! State = MODE_CMDLINE; theline = eap->getline( #ifdef FEAT_EVAL eap->cstack->cs_looplevel > 0 ? -1 : *************** *** 3366,3372 **** empty = FALSE; } } ! State = NORMAL; if (eap->forceit) curbuf->b_p_ai = !curbuf->b_p_ai; --- 3366,3372 ---- empty = FALSE; } } ! State = MODE_NORMAL; if (eap->forceit) curbuf->b_p_ai = !curbuf->b_p_ai; *************** *** 4183,4192 **** { int typed = 0; ! // change State to CONFIRM, so that the mouse works // properly save_State = State; ! State = CONFIRM; setmouse(); // disable mouse in xterm curwin->w_cursor.col = regmatch.startpos[0].col; if (curwin->w_p_crb) --- 4183,4192 ---- { int typed = 0; ! // change State to MODE_CONFIRM, so that the mouse works // properly save_State = State; ! State = MODE_CONFIRM; setmouse(); // disable mouse in xterm curwin->w_cursor.col = regmatch.startpos[0].col; if (curwin->w_p_crb) *** ../vim-8.2.4910/src/ex_docmd.c 2022-05-06 20:38:41.668040951 +0100 --- src/ex_docmd.c 2022-05-07 18:33:38.396838984 +0100 *************** *** 476,482 **** exmode_active = EXMODE_VIM; else exmode_active = EXMODE_NORMAL; ! State = NORMAL; may_trigger_modechanged(); // When using ":global /pat/ visual" and then "Q" we return to continue --- 476,482 ---- exmode_active = EXMODE_VIM; else exmode_active = EXMODE_NORMAL; ! State = MODE_NORMAL; may_trigger_modechanged(); // When using ":global /pat/ visual" and then "Q" we return to continue *************** *** 8328,8334 **** need_wait_return = FALSE; // When invoked from a callback or autocmd the command line may be active. ! if (State & CMDLINE) redrawcmdline(); out_flush(); --- 8328,8334 ---- need_wait_return = FALSE; // When invoked from a callback or autocmd the command line may be active. ! if (State & MODE_CMDLINE) redrawcmdline(); out_flush(); *************** *** 8676,8682 **** // Ignore the command when already in Insert mode. Inserting an // expression register that invokes a function can do this. ! if (State & INSERT) return; if (eap->cmdidx == CMD_startinsert) --- 8676,8682 ---- // Ignore the command when already in Insert mode. Inserting an // expression register that invokes a function can do this. ! if (State & MODE_INSERT) return; if (eap->cmdidx == CMD_startinsert) *** ../vim-8.2.4910/src/ex_getln.c 2022-05-07 17:45:12.414944752 +0100 --- src/ex_getln.c 2022-05-07 18:21:57.101274087 +0100 *************** *** 1150,1165 **** static void cmdline_toggle_langmap(long *b_im_ptr) { ! if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) { // ":lmap" mappings exists, toggle use of mappings. ! State ^= LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(FALSE); // Disable input method #endif if (b_im_ptr != NULL) { ! if (State & LANGMAP) *b_im_ptr = B_IMODE_LMAP; else *b_im_ptr = B_IMODE_NONE; --- 1150,1165 ---- static void cmdline_toggle_langmap(long *b_im_ptr) { ! if (map_to_exists_mode((char_u *)"", MODE_LANGMAP, FALSE)) { // ":lmap" mappings exists, toggle use of mappings. ! State ^= MODE_LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(FALSE); // Disable input method #endif if (b_im_ptr != NULL) { ! if (State & MODE_LANGMAP) *b_im_ptr = B_IMODE_LMAP; else *b_im_ptr = B_IMODE_NONE; *************** *** 1683,1689 **** */ msg_scroll = FALSE; ! State = CMDLINE; if (firstc == '/' || firstc == '?' || firstc == '@') { --- 1683,1689 ---- */ msg_scroll = FALSE; ! State = MODE_CMDLINE; if (firstc == '/' || firstc == '?' || firstc == '@') { *************** *** 1693,1699 **** else b_im_ptr = &curbuf->b_p_imsearch; if (*b_im_ptr == B_IMODE_LMAP) ! State |= LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(*b_im_ptr == B_IMODE_IM); #endif --- 1693,1699 ---- else b_im_ptr = &curbuf->b_p_imsearch; if (*b_im_ptr == B_IMODE_LMAP) ! State |= MODE_LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(*b_im_ptr == B_IMODE_IM); #endif *************** *** 3208,3214 **** static void redrawcmd_preedit(void) { ! if ((State & CMDLINE) && xic != NULL // && im_get_status() doesn't work when using SCIM && !p_imdisable --- 3208,3214 ---- static void redrawcmd_preedit(void) { ! if ((State & MODE_CMDLINE) && xic != NULL // && im_get_status() doesn't work when using SCIM && !p_imdisable *************** *** 4089,4095 **** static cmdline_info_T * get_ccline_ptr(void) { ! if ((State & CMDLINE) == 0) return NULL; if (ccline.cmdbuff != NULL) return &ccline; --- 4089,4095 ---- static cmdline_info_T * get_ccline_ptr(void) { ! if ((State & MODE_CMDLINE) == 0) return NULL; if (ccline.cmdbuff != NULL) return &ccline; *************** *** 4451,4458 **** { if (p_wc == TAB) { ! add_map((char_u *)" ", INSERT); ! add_map((char_u *)" a", NORMAL); } set_option_value_give_err((char_u *)"ft", 0L, (char_u *)"vim", OPT_LOCAL); --- 4451,4458 ---- { if (p_wc == TAB) { ! add_map((char_u *)" ", MODE_INSERT); ! add_map((char_u *)" a", MODE_NORMAL); } set_option_value_give_err((char_u *)"ft", 0L, (char_u *)"vim", OPT_LOCAL); *************** *** 4495,4501 **** // No Ex mode here! exmode_active = 0; ! State = NORMAL; setmouse(); // Reset here so it can be set by a CmdWinEnter autocommand. --- 4495,4501 ---- // No Ex mode here! exmode_active = 0; ! State = MODE_NORMAL; setmouse(); // Reset here so it can be set by a CmdWinEnter autocommand. *** ../vim-8.2.4910/src/fileio.c 2022-04-07 13:26:30.149944670 +0100 --- src/fileio.c 2022-05-07 19:30:19.352832480 +0100 *************** *** 2945,2951 **** // When starting to edit a new file which does not have encryption, clear // the 'key' option, except when starting up (called with -x argument) else if (newfile && *curbuf->b_p_key != NUL && !starting) ! set_option_value((char_u *)"key", 0L, (char_u *)"", OPT_LOCAL); return cryptkey; } --- 2945,2951 ---- // When starting to edit a new file which does not have encryption, clear // the 'key' option, except when starting up (called with -x argument) else if (newfile && *curbuf->b_p_key != NUL && !starting) ! set_option_value_give_err((char_u *)"key", 0L, (char_u *)"", OPT_LOCAL); return cryptkey; } *************** *** 4264,4270 **** } else #endif ! if (State > NORMAL_BUSY || (State & CMDLINE) || already_warned) { if (*mesg2 != NUL) { --- 4264,4271 ---- } else #endif ! if (State > MODE_NORMAL_BUSY || (State & MODE_CMDLINE) ! || already_warned) { if (*mesg2 != NUL) { *** ../vim-8.2.4910/src/fold.c 2022-04-23 13:50:11.155455199 +0100 --- src/fold.c 2022-05-07 19:30:34.244813814 +0100 *************** *** 1499,1505 **** line2 = line1 - amount_after - 1; // If appending a line in Insert mode, it should be included in the fold // just above the line. ! if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) --line1; foldMarkAdjustRecurse(&wp->w_folds, line1, line2, amount, amount_after); } --- 1499,1505 ---- line2 = line1 - amount_after - 1; // If appending a line in Insert mode, it should be included in the fold // just above the line. ! if ((State & MODE_INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) --line1; foldMarkAdjustRecurse(&wp->w_folds, line1, line2, amount, amount_after); } *************** *** 1523,1529 **** // In Insert mode an inserted line at the top of a fold is considered part // of the fold, otherwise it isn't. ! if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) top = line1 + 1; else top = line1; --- 1523,1529 ---- // In Insert mode an inserted line at the top of a fold is considered part // of the fold, otherwise it isn't. ! if ((State & MODE_INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) top = line1 + 1; else top = line1; *** ../vim-8.2.4910/src/getchar.c 2022-04-30 15:02:17.900266675 +0100 --- src/getchar.c 2022-05-07 19:32:12.992691721 +0100 *************** *** 1346,1352 **** static void may_sync_undo(void) { ! if ((!(State & (INSERT + CMDLINE)) || arrow_used) && scriptin[curscript] == NULL) u_sync(FALSE); } --- 1346,1352 ---- static void may_sync_undo(void) { ! if ((!(State & (MODE_INSERT | MODE_CMDLINE)) || arrow_used) && scriptin[curscript] == NULL) u_sync(FALSE); } *************** *** 1533,1539 **** int save_finish_op = finish_op; int save_msg_scroll = msg_scroll; ! State = NORMAL; msg_scroll = FALSE; // no msg scrolling in Normal mode restart_edit = 0; // don't go to Insert mode p_im = FALSE; // don't use 'insertmode' --- 1533,1539 ---- int save_finish_op = finish_op; int save_msg_scroll = msg_scroll; ! State = MODE_NORMAL; msg_scroll = FALSE; // no msg scrolling in Normal mode restart_edit = 0; // don't go to Insert mode p_im = FALSE; // don't use 'insertmode' *************** *** 2483,2492 **** || (p_remap && (typebuf.tb_noremap[typebuf.tb_off] & (RM_NONE|RM_ABBR)) == 0)) ! && !(p_paste && (State & (INSERT + CMDLINE))) ! && !(State == HITRETURN && (tb_c1 == CAR || tb_c1 == ' ')) ! && State != ASKMORE ! && State != CONFIRM && !at_ins_compl_key()) { #ifdef FEAT_GUI --- 2483,2492 ---- || (p_remap && (typebuf.tb_noremap[typebuf.tb_off] & (RM_NONE|RM_ABBR)) == 0)) ! && !(p_paste && (State & (MODE_INSERT | MODE_CMDLINE))) ! && !(State == MODE_HITRETURN && (tb_c1 == CAR || tb_c1 == ' ')) ! && State != MODE_ASKMORE ! && State != MODE_CONFIRM && !at_ins_compl_key()) { #ifdef FEAT_GUI *************** *** 2503,2510 **** nolmaplen = 2; else { ! LANGMAP_ADJUST(tb_c1, (State & (CMDLINE | INSERT)) == 0 ! && get_real_state() != SELECTMODE); nolmaplen = 0; } #endif --- 2503,2510 ---- nolmaplen = 2; else { ! LANGMAP_ADJUST(tb_c1, (State & (MODE_CMDLINE | MODE_INSERT)) == 0 ! && get_real_state() != MODE_SELECT); nolmaplen = 0; } #endif *************** *** 2537,2543 **** && (mp->m_mode & local_State) && !(mp->m_simplified && seenModifyOtherKeys && typebuf.tb_maplen == 0) ! && ((mp->m_mode & LANGMAP) == 0 || typebuf.tb_maplen == 0)) { #ifdef FEAT_LANGMAP int nomap = nolmaplen; --- 2537,2543 ---- && (mp->m_mode & local_State) && !(mp->m_simplified && seenModifyOtherKeys && typebuf.tb_maplen == 0) ! && ((mp->m_mode & MODE_LANGMAP) == 0 || typebuf.tb_maplen == 0)) { #ifdef FEAT_LANGMAP int nomap = nolmaplen; *************** *** 2644,2650 **** /* * Check for match with 'pastetoggle' */ ! if (*p_pt != NUL && mp == NULL && (State & (INSERT|NORMAL))) { for (mlen = 0; mlen < typebuf.tb_len && p_pt[mlen]; ++mlen) if (p_pt[mlen] != typebuf.tb_buf[typebuf.tb_off + mlen]) --- 2644,2650 ---- /* * Check for match with 'pastetoggle' */ ! if (*p_pt != NUL && mp == NULL && (State & (MODE_INSERT | MODE_NORMAL))) { for (mlen = 0; mlen < typebuf.tb_len && p_pt[mlen]; ++mlen) if (p_pt[mlen] != typebuf.tb_buf[typebuf.tb_off + mlen]) *************** *** 2659,2665 **** del_typebuf(mlen, 0); // remove the chars set_option_value_give_err((char_u *)"paste", (long)!p_paste, NULL, 0); ! if (!(State & INSERT)) { msg_col = 0; msg_row = Rows - 1; --- 2659,2665 ---- del_typebuf(mlen, 0); // remove the chars set_option_value_give_err((char_u *)"paste", (long)!p_paste, NULL, 0); ! if (!(State & MODE_INSERT)) { msg_col = 0; msg_row = Rows - 1; *************** *** 2792,2798 **** // to Visual mode temporarily. Append K_SELECT to switch // back to Select mode. if (VIsual_active && VIsual_select ! && (current_menu->modes & VISUAL)) { VIsual_select = FALSE; (void)ins_typebuf(K_SELECT_STRING, --- 2792,2798 ---- // to Visual mode temporarily. Append K_SELECT to switch // back to Select mode. if (VIsual_active && VIsual_select ! && (current_menu->modes & MODE_VISUAL)) { VIsual_select = FALSE; (void)ins_typebuf(K_SELECT_STRING, *************** *** 2848,2854 **** if (++*mapdepth >= p_mmd) { emsg(_(e_recursive_mapping)); ! if (State & CMDLINE) redrawcmdline(); else setcursor(); --- 2848,2854 ---- if (++*mapdepth >= p_mmd) { emsg(_(e_recursive_mapping)); ! if (State & MODE_CMDLINE) redrawcmdline(); else setcursor(); *************** *** 2862,2868 **** * In Select mode and a Visual mode mapping is used: Switch to Visual * mode temporarily. Append K_SELECT to switch back to Select mode. */ ! if (VIsual_active && VIsual_select && (mp->m_mode & VISUAL)) { VIsual_select = FALSE; (void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, TRUE, FALSE); --- 2862,2868 ---- * In Select mode and a Visual mode mapping is used: Switch to Visual * mode temporarily. Append K_SELECT to switch back to Select mode. */ ! if (VIsual_active && VIsual_select && (mp->m_mode & MODE_VISUAL)) { VIsual_select = FALSE; (void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, TRUE, FALSE); *************** *** 2913,2919 **** buf[2] = KE_IGNORE; buf[3] = NUL; map_str = vim_strsave(buf); ! if (State & CMDLINE) { // redraw the command below the error msg_didout = TRUE; --- 2913,2919 ---- buf[2] = KE_IGNORE; buf[3] = NUL; map_str = vim_strsave(buf); ! if (State & MODE_CMDLINE) { // redraw the command below the error msg_didout = TRUE; *************** *** 3139,3145 **** * really insert a CTRL-C. */ if ((c || typebuf.tb_maplen) ! && (State & (INSERT + CMDLINE))) c = ESC; else c = Ctrl_C; --- 3139,3145 ---- * really insert a CTRL-C. */ if ((c || typebuf.tb_maplen) ! && (State & (MODE_INSERT | MODE_CMDLINE))) c = ESC; else c = Ctrl_C; *************** *** 3223,3229 **** && !no_mapping && ex_normal_busy == 0 && typebuf.tb_maplen == 0 ! && (State & INSERT) && (p_timeout || (keylen == KEYLEN_PART_KEY && p_ttimeout)) && (c = inchar(typebuf.tb_buf + typebuf.tb_off --- 3223,3229 ---- && !no_mapping && ex_normal_busy == 0 && typebuf.tb_maplen == 0 ! && (State & MODE_INSERT) && (p_timeout || (keylen == KEYLEN_PART_KEY && p_ttimeout)) && (c = inchar(typebuf.tb_buf + typebuf.tb_off *************** *** 3239,3250 **** } #ifdef FEAT_GUI // may show a different cursor shape ! if (gui.in_use && State != NORMAL && !cmd_silent) { int save_State; save_State = State; ! State = NORMAL; gui_update_cursor(TRUE, FALSE); State = save_State; shape_changed = TRUE; --- 3239,3250 ---- } #ifdef FEAT_GUI // may show a different cursor shape ! if (gui.in_use && State != MODE_NORMAL && !cmd_silent) { int save_State; save_State = State; ! State = MODE_NORMAL; gui_update_cursor(TRUE, FALSE); State = save_State; shape_changed = TRUE; *************** *** 3353,3365 **** // For the cmdline window: Alternate between ESC and // CTRL-C: ESC for most situations and CTRL-C to close the // cmdline window. ! if (p_im && (State & INSERT)) c = Ctrl_L; #ifdef FEAT_TERMINAL else if (terminal_is_active()) c = K_CANCEL; #endif ! else if ((State & CMDLINE) #ifdef FEAT_CMDWIN || (cmdwin_type > 0 && tc == ESC) #endif --- 3353,3365 ---- // For the cmdline window: Alternate between ESC and // CTRL-C: ESC for most situations and CTRL-C to close the // cmdline window. ! if (p_im && (State & MODE_INSERT)) c = Ctrl_L; #ifdef FEAT_TERMINAL else if (terminal_is_active()) c = K_CANCEL; #endif ! else if ((State & MODE_CMDLINE) #ifdef FEAT_CMDWIN || (cmdwin_type > 0 && tc == ESC) #endif *************** *** 3390,3397 **** // changed text so far. Also for when 'lazyredraw' is set and // redrawing was postponed because there was something in the // input buffer (e.g., termresponse). ! if (((State & INSERT) != 0 || p_lz) && (State & CMDLINE) == 0 ! && advance && must_redraw != 0 && !need_wait_return) { update_screen(0); setcursor(); // put cursor back where it belongs --- 3390,3398 ---- // changed text so far. Also for when 'lazyredraw' is set and // redrawing was postponed because there was something in the // input buffer (e.g., termresponse). ! if (((State & MODE_INSERT) != 0 || p_lz) ! && (State & MODE_CMDLINE) == 0 ! && advance && must_redraw != 0 && !need_wait_return) { update_screen(0); setcursor(); // put cursor back where it belongs *************** *** 3408,3418 **** c1 = 0; if (typebuf.tb_len > 0 && advance && !exmode_active) { ! if (((State & (NORMAL | INSERT)) || State == LANGMAP) ! && State != HITRETURN) { // this looks nice when typing a dead character map ! if (State & INSERT && ptr2cells(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1) == 1) { --- 3409,3420 ---- c1 = 0; if (typebuf.tb_len > 0 && advance && !exmode_active) { ! if (((State & (MODE_NORMAL | MODE_INSERT)) ! || State == MODE_LANGMAP) ! && State != MODE_HITRETURN) { // this looks nice when typing a dead character map ! if (State & MODE_INSERT && ptr2cells(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1) == 1) { *************** *** 3439,3445 **** } // this looks nice when typing a dead character map ! if ((State & CMDLINE) #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) && cmdline_star == 0 #endif --- 3441,3447 ---- } // this looks nice when typing a dead character map ! if ((State & MODE_CMDLINE) #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) && cmdline_star == 0 #endif *************** *** 3486,3494 **** #endif if (c1 == 1) { ! if (State & INSERT) edit_unputchar(); ! if (State & CMDLINE) unputcmdline(); else setcursor(); // put cursor back where it belongs --- 3488,3496 ---- #endif if (c1 == 1) { ! if (State & MODE_INSERT) edit_unputchar(); ! if (State & MODE_CMDLINE) unputcmdline(); else setcursor(); // put cursor back where it belongs *************** *** 3529,3535 **** * if we return an ESC to exit insert mode, the message is deleted * if we don't return an ESC but deleted the message before, redisplay it */ ! if (advance && p_smd && msg_silent == 0 && (State & INSERT)) { if (c == ESC && !mode_deleted && !no_mapping && mode_displayed) { --- 3531,3537 ---- * if we return an ESC to exit insert mode, the message is deleted * if we don't return an ESC but deleted the message before, redisplay it */ ! if (advance && p_smd && msg_silent == 0 && (State & MODE_INSERT)) { if (c == ESC && !mode_deleted && !no_mapping && mode_displayed) { *************** *** 3617,3623 **** * recursive loop may result (write error in swapfile, hit-return, timeout * on char wait, flush swapfile, write error....). */ ! if (State != HITRETURN) { did_outofmem_msg = FALSE; // display out of memory message (again) did_swapwrite_msg = FALSE; // display swap file write error again --- 3619,3625 ---- * recursive loop may result (write error in swapfile, hit-return, timeout * on char wait, flush swapfile, write error....). */ ! if (State != MODE_HITRETURN) { did_outofmem_msg = FALSE; // display out of memory message (again) did_swapwrite_msg = FALSE; // display swap file write error again *** ../vim-8.2.4910/src/globals.h 2022-04-07 13:58:00.923085110 +0100 --- src/globals.h 2022-05-07 19:49:41.015489869 +0100 *************** *** 977,983 **** EXTERN pos_T Insstart_orig; /* ! * Stuff for VREPLACE mode. */ EXTERN int orig_line_count INIT(= 0); // Line count when "gR" started EXTERN int vr_lines_changed INIT(= 0); // #Lines changed by "gR" so far --- 977,983 ---- EXTERN pos_T Insstart_orig; /* ! * Stuff for MODE_VREPLACE state. */ EXTERN int orig_line_count INIT(= 0); // Line count when "gR" started EXTERN int vr_lines_changed INIT(= 0); // #Lines changed by "gR" so far *************** *** 1095,1108 **** /* * "State" is the main state of Vim. * There are other variables that modify the state: ! * "Visual_mode" When State is NORMAL or INSERT. ! * "finish_op" When State is NORMAL, after typing the operator and before ! * typing the motion command. * "motion_force" Last motion_force from do_pending_operator() * "debug_mode" Debug mode. */ ! EXTERN int State INIT(= NORMAL); // This is the current state of the ! // command interpreter. #ifdef FEAT_EVAL EXTERN int debug_mode INIT(= FALSE); #endif --- 1095,1108 ---- /* * "State" is the main state of Vim. * There are other variables that modify the state: ! * "Visual_mode" When State is MODE_NORMAL or MODE_INSERT. ! * "finish_op" When State is MODE_NORMAL, after typing the operator and ! * before typing the motion command. * "motion_force" Last motion_force from do_pending_operator() * "debug_mode" Debug mode. */ ! EXTERN int State INIT(= MODE_NORMAL); ! #ifdef FEAT_EVAL EXTERN int debug_mode INIT(= FALSE); #endif *** ../vim-8.2.4910/src/gui.c 2022-04-15 13:53:30.052708679 +0100 --- src/gui.c 2022-05-07 19:34:30.764525481 +0100 *************** *** 1207,1213 **** else #endif shape = &shape_table[get_shape_idx(FALSE)]; ! if (State & LANGMAP) id = shape->id_lm; else id = shape->id; --- 1207,1213 ---- else #endif shape = &shape_table[get_shape_idx(FALSE)]; ! if (State & MODE_LANGMAP) id = shape->id_lm; else id = shape->id; *************** *** 1580,1586 **** * At the "more" and ":confirm" prompt there is no redraw, put the cursor * at the last line here (why does it have to be one row too low?). */ ! if (State == ASKMORE || State == CONFIRM) gui.row = gui.num_rows; // Only comparing Rows and Columns may be sufficient, but let's stay on --- 1580,1586 ---- * At the "more" and ":confirm" prompt there is no redraw, put the cursor * at the last line here (why does it have to be one row too low?). */ ! if (State == MODE_ASKMORE || State == MODE_CONFIRM) gui.row = gui.num_rows; // Only comparing Rows and Columns may be sufficient, but let's stay on *************** *** 3192,3213 **** // Determine which mouse settings to look for based on the current mode switch (get_real_state()) { ! case NORMAL_BUSY: ! case OP_PENDING: # ifdef FEAT_TERMINAL ! case TERMINAL: # endif ! case NORMAL: checkfor = MOUSE_NORMAL; break; ! case VISUAL: checkfor = MOUSE_VISUAL; break; ! case SELECTMODE: checkfor = MOUSE_VISUAL; break; ! case REPLACE: ! case REPLACE+LANGMAP: ! case VREPLACE: ! case VREPLACE+LANGMAP: ! case INSERT: ! case INSERT+LANGMAP: checkfor = MOUSE_INSERT; break; ! case ASKMORE: ! case HITRETURN: // At the more- and hit-enter prompt pass the // mouse event for a click on or below the // message line. if (Y_2_ROW(y) >= msg_row) --- 3192,3214 ---- // Determine which mouse settings to look for based on the current mode switch (get_real_state()) { ! case MODE_NORMAL_BUSY: ! case MODE_OP_PENDING: # ifdef FEAT_TERMINAL ! case MODE_TERMINAL: # endif ! case MODE_NORMAL: checkfor = MOUSE_NORMAL; break; ! case MODE_VISUAL: checkfor = MOUSE_VISUAL; break; ! case MODE_SELECT: checkfor = MOUSE_VISUAL; break; ! case MODE_REPLACE: ! case MODE_REPLACE | MODE_LANGMAP: ! case MODE_VREPLACE: ! case MODE_VREPLACE | MODE_LANGMAP: ! case MODE_INSERT: ! case MODE_INSERT | MODE_LANGMAP: ! checkfor = MOUSE_INSERT; break; ! case MODE_ASKMORE: ! case MODE_HITRETURN: // At the more- and hit-enter prompt pass the // mouse event for a click on or below the // message line. if (Y_2_ROW(y) >= msg_row) *************** *** 3220,3227 **** * On the command line, use the clipboard selection on all lines * but the command line. But not when pasting. */ ! case CMDLINE: ! case CMDLINE+LANGMAP: if (Y_2_ROW(y) < cmdline_row && button != MOUSE_MIDDLE) checkfor = MOUSE_NONE; else --- 3221,3228 ---- * On the command line, use the clipboard selection on all lines * but the command line. But not when pasting. */ ! case MODE_CMDLINE: ! case MODE_CMDLINE | MODE_LANGMAP: if (Y_2_ROW(y) < cmdline_row && button != MOUSE_MIDDLE) checkfor = MOUSE_NONE; else *************** *** 3238,3244 **** * modes. Don't do this when dragging the status line, or extending a * Visual selection. */ ! if ((State == NORMAL || State == NORMAL_BUSY || (State & INSERT)) && Y_2_ROW(y) >= topframe->fr_height + firstwin->w_winrow && button != MOUSE_DRAG # ifdef FEAT_MOUSESHAPE --- 3239,3246 ---- * modes. Don't do this when dragging the status line, or extending a * Visual selection. */ ! if ((State == MODE_NORMAL || State == MODE_NORMAL_BUSY ! || (State & MODE_INSERT)) && Y_2_ROW(y) >= topframe->fr_height + firstwin->w_winrow && button != MOUSE_DRAG # ifdef FEAT_MOUSESHAPE *************** *** 3270,3276 **** if (!mouse_has(checkfor) || checkfor == MOUSE_COMMAND) { // Don't do modeless selection in Visual mode. ! if (checkfor != MOUSE_NONEF && VIsual_active && (State & NORMAL)) return; /* --- 3272,3278 ---- if (!mouse_has(checkfor) || checkfor == MOUSE_COMMAND) { // Don't do modeless selection in Visual mode. ! if (checkfor != MOUSE_NONEF && VIsual_active && (State & MODE_NORMAL)) return; /* *************** *** 3291,3297 **** { if (clip_star.state == SELECT_CLEARED) { ! if (State & CMDLINE) { col = msg_col; row = msg_row; --- 3293,3299 ---- { if (clip_star.state == SELECT_CLEARED) { ! if (State & MODE_CMDLINE) { col = msg_col; row = msg_row; *************** *** 4086,4102 **** #ifdef USE_ON_FLY_SCROLL current_scrollbar = sb_num; scrollbar_value = value; ! if (State & NORMAL) { gui_do_scroll(); setcursor(); } ! else if (State & INSERT) { ins_scroll(); setcursor(); } ! else if (State & CMDLINE) { if (msg_scrolled == 0) { --- 4088,4104 ---- #ifdef USE_ON_FLY_SCROLL current_scrollbar = sb_num; scrollbar_value = value; ! if (State & MODE_NORMAL) { gui_do_scroll(); setcursor(); } ! else if (State & MODE_INSERT) { ins_scroll(); setcursor(); } ! else if (State & MODE_CMDLINE) { if (msg_scrolled == 0) { *************** *** 4131,4141 **** #ifdef USE_ON_FLY_SCROLL scrollbar_value = value; ! if (State & NORMAL) gui_do_horiz_scroll(scrollbar_value, FALSE); ! else if (State & INSERT) ins_horscroll(); ! else if (State & CMDLINE) { if (msg_scrolled == 0) { --- 4133,4143 ---- #ifdef USE_ON_FLY_SCROLL scrollbar_value = value; ! if (State & MODE_NORMAL) gui_do_horiz_scroll(scrollbar_value, FALSE); ! else if (State & MODE_INSERT) ins_horscroll(); ! else if (State & MODE_CMDLINE) { if (msg_scrolled == 0) { *************** *** 4890,4897 **** // Only handle this when 'mousefocus' set and ... if (p_mousef && !hold_gui_events // not holding events ! && (State & (NORMAL|INSERT))// Normal/Visual/Insert mode ! && State != HITRETURN // but not hit-return prompt && msg_scrolled == 0 // no scrolled message && !need_mouse_correct // not moving the pointer && gui.in_focus) // gvim in focus --- 4892,4899 ---- // Only handle this when 'mousefocus' set and ... if (p_mousef && !hold_gui_events // not holding events ! && (State & (MODE_NORMAL | MODE_INSERT))// Normal/Visual/Insert mode ! && State != MODE_HITRETURN // but not hit-return prompt && msg_scrolled == 0 // no scrolled message && !need_mouse_correct // not moving the pointer && gui.in_focus) // gvim in focus *************** *** 5022,5028 **** if (wp == NULL) return NULL; #ifdef FEAT_MOUSESHAPE ! if (State == HITRETURN || State == ASKMORE) { if (Y_2_ROW(y) >= msg_row) update_mouseshape(SHAPE_IDX_MOREL); --- 5024,5030 ---- if (wp == NULL) return NULL; #ifdef FEAT_MOUSESHAPE ! if (State == MODE_HITRETURN || State == MODE_ASKMORE) { if (Y_2_ROW(y) >= msg_row) update_mouseshape(SHAPE_IDX_MOREL); *************** *** 5031,5040 **** } else if (row > wp->w_height) // below status line update_mouseshape(SHAPE_IDX_CLINE); ! else if (!(State & CMDLINE) && wp->w_vsep_width > 0 && col == wp->w_width && (row != wp->w_height || !stl_connected(wp)) && msg_scrolled == 0) update_mouseshape(SHAPE_IDX_VSEP); ! else if (!(State & CMDLINE) && wp->w_status_height > 0 && row == wp->w_height && msg_scrolled == 0) update_mouseshape(SHAPE_IDX_STATUS); else --- 5033,5042 ---- } else if (row > wp->w_height) // below status line update_mouseshape(SHAPE_IDX_CLINE); ! else if (!(State & MODE_CMDLINE) && wp->w_vsep_width > 0 && col == wp->w_width && (row != wp->w_height || !stl_connected(wp)) && msg_scrolled == 0) update_mouseshape(SHAPE_IDX_VSEP); ! else if (!(State & MODE_CMDLINE) && wp->w_status_height > 0 && row == wp->w_height && msg_scrolled == 0) update_mouseshape(SHAPE_IDX_STATUS); else *************** *** 5454,5460 **** // syntax HL if we were busy redrawing. did_emsg = save_did_emsg; ! if (State & (NORMAL | INSERT)) { gui_update_screen(); // update the screen msg_didout = 0; // overwrite any message --- 5456,5462 ---- // syntax HL if we were busy redrawing. did_emsg = save_did_emsg; ! if (State & (MODE_NORMAL | MODE_INSERT)) { gui_update_screen(); // update the screen msg_didout = 0; // overwrite any message *************** *** 5558,5564 **** * When the cursor is at the command line, add the file names to the * command line, don't edit the files. */ ! if (State & CMDLINE) { shorten_filenames(fnames, count); for (i = 0; i < count; ++i) --- 5560,5566 ---- * When the cursor is at the command line, add the file names to the * command line, don't edit the files. */ ! if (State & MODE_CMDLINE) { shorten_filenames(fnames, count); for (i = 0; i < count; ++i) *** ../vim-8.2.4910/src/gui_gtk.c 2022-03-20 15:42:57.533626860 +0000 --- src/gui_gtk.c 2022-05-07 18:08:58.841825686 +0100 *************** *** 691,697 **** char_u *tooltip; static int did_msg = FALSE; ! if (State & CMDLINE) return; menu = (vimmenu_T *)data; tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); --- 691,697 ---- char_u *tooltip; static int did_msg = FALSE; ! if (State & MODE_CMDLINE) return; menu = (vimmenu_T *)data; tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); *** ../vim-8.2.4910/src/gui_w32.c 2022-05-07 12:24:57.939638395 +0100 --- src/gui_w32.c 2022-05-07 19:35:21.588465182 +0100 *************** *** 1956,1962 **** } // In modes where we are not typing, dead keys should behave // normally ! else if (!(get_real_state() & (INSERT | CMDLINE | SELECTMODE))) { outputDeadKey_rePost(msg); return; --- 1956,1963 ---- } // In modes where we are not typing, dead keys should behave // normally ! else if ((get_real_state() ! & (MODE_INSERT | MODE_CMDLINE | MODE_SELECT)) == 0) { outputDeadKey_rePost(msg); return; *************** *** 4603,4609 **** if (((UINT) HIWORD(wParam) & (0xffff ^ (MF_MOUSESELECT + MF_BITMAP + MF_POPUP))) == MF_HILITE ! && (State & CMDLINE) == 0) { UINT idButton; vimmenu_T *pMenu; --- 4604,4610 ---- if (((UINT) HIWORD(wParam) & (0xffff ^ (MF_MOUSESELECT + MF_BITMAP + MF_POPUP))) == MF_HILITE ! && (State & MODE_CMDLINE) == 0) { UINT idButton; vimmenu_T *pMenu; *************** *** 5593,5600 **** im_set_position(gui.row, gui.col); // Disable langmap ! State &= ~LANGMAP; ! if (State & INSERT) { # if defined(FEAT_KEYMAP) // Unshown 'keymap' in status lines --- 5594,5601 ---- im_set_position(gui.row, gui.col); // Disable langmap ! State &= ~MODE_LANGMAP; ! if (State & MODE_INSERT) { # if defined(FEAT_KEYMAP) // Unshown 'keymap' in status lines *** ../vim-8.2.4910/src/gui_xim.c 2022-01-08 12:41:12.204795554 +0000 --- src/gui_xim.c 2022-05-07 19:36:12.904404750 +0100 *************** *** 156,162 **** static void init_preedit_start_col(void) { ! if (State & CMDLINE) preedit_start_col = cmdline_getvcol_cursor(); else if (curwin != NULL && curwin->w_buffer != NULL) getvcol(curwin, &curwin->w_cursor, &preedit_start_col, NULL, NULL); --- 156,162 ---- static void init_preedit_start_col(void) { ! if (State & MODE_CMDLINE) preedit_start_col = cmdline_getvcol_cursor(); else if (curwin != NULL && curwin->w_buffer != NULL) getvcol(curwin, &curwin->w_cursor, &preedit_start_col, NULL, NULL); *************** *** 420,426 **** return; } ! if (State & NORMAL #ifdef FEAT_TERMINAL && !term_use_loop() #endif --- 420,426 ---- return; } ! if (State & MODE_NORMAL #ifdef FEAT_TERMINAL && !term_use_loop() #endif *************** *** 446,455 **** { char_u backkey[] = {CSI, 'k', 'l'}; ! if (State & NORMAL) return; # ifdef FEAT_RIGHTLEFT ! if ((State & CMDLINE) == 0 && curwin != NULL && curwin->w_p_rl) backkey[2] = 'r'; # endif for (; num_move_back > 0; --num_move_back) --- 446,455 ---- { char_u backkey[] = {CSI, 'k', 'l'}; ! if (State & MODE_NORMAL) return; # ifdef FEAT_RIGHTLEFT ! if ((State & MODE_CMDLINE) == 0 && curwin != NULL && curwin->w_p_rl) backkey[2] = 'r'; # endif for (; num_move_back > 0; --num_move_back) *************** *** 471,477 **** vgetc_busy = TRUE; showmode(); vgetc_busy = old_vgetc_busy; ! if ((State & NORMAL) || (State & INSERT)) setcursor(); out_flush(); } --- 471,477 ---- vgetc_busy = TRUE; showmode(); vgetc_busy = old_vgetc_busy; ! if ((State & MODE_NORMAL) || (State & MODE_INSERT)) setcursor(); out_flush(); } *************** *** 1078,1084 **** // gtk_im_context_filter_keypress() in Normal mode. // And while doing :sh too. if (xic != NULL && !p_imdisable ! && (State & (INSERT | CMDLINE | NORMAL | EXTERNCMD)) != 0) { // Filter 'imactivatekey' and map it to CTRL-^. This way, Vim is // always aware of the current status of IM, and can even emulate --- 1078,1085 ---- // gtk_im_context_filter_keypress() in Normal mode. // And while doing :sh too. if (xic != NULL && !p_imdisable ! && (State & (MODE_INSERT | MODE_CMDLINE ! | MODE_NORMAL | MODE_EXTERNCMD))) { // Filter 'imactivatekey' and map it to CTRL-^. This way, Vim is // always aware of the current status of IM, and can even emulate *************** *** 1102,1122 **** if (event->type != GDK_KEY_PRESS) return TRUE; ! if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) { im_set_active(FALSE); // ":lmap" mappings exists, toggle use of mappings. ! State ^= LANGMAP; ! if (State & LANGMAP) { curbuf->b_p_iminsert = B_IMODE_NONE; ! State &= ~LANGMAP; } else { curbuf->b_p_iminsert = B_IMODE_LMAP; ! State |= LANGMAP; } return TRUE; } --- 1103,1123 ---- if (event->type != GDK_KEY_PRESS) return TRUE; ! if (map_to_exists_mode((char_u *)"", MODE_LANGMAP, FALSE)) { im_set_active(FALSE); // ":lmap" mappings exists, toggle use of mappings. ! State ^= MODE_LANGMAP; ! if (State & MODE_LANGMAP) { curbuf->b_p_iminsert = B_IMODE_NONE; ! State &= ~MODE_LANGMAP; } else { curbuf->b_p_iminsert = B_IMODE_LMAP; ! State |= MODE_LANGMAP; } return TRUE; } *** ../vim-8.2.4910/src/indent.c 2022-05-06 12:15:33.860427761 +0100 --- src/indent.c 2022-05-07 19:36:42.196370453 +0100 *************** *** 828,834 **** pos.lnum = 0; // In format_lines() (i.e. not insert mode), fo+=q is needed too... ! if ((State & INSERT) || has_format_option(FO_Q_COMS)) lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE); regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); --- 828,834 ---- pos.lnum = 0; // In format_lines() (i.e. not insert mode), fo+=q is needed too... ! if ((State & MODE_INSERT) || has_format_option(FO_Q_COMS)) lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE); regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); *************** *** 1276,1282 **** colnr_T orig_col = 0; // init for GCC char_u *new_line, *orig_line = NULL; // init for GCC ! // VREPLACE mode needs to know what the line was like before changing if (State & VREPLACE_FLAG) { orig_line = vim_strsave(ml_get_curline()); // Deal with NULL below --- 1276,1282 ---- colnr_T orig_col = 0; // init for GCC char_u *new_line, *orig_line = NULL; // init for GCC ! // MODE_VREPLACE state needs to know what the line was like before changing if (State & VREPLACE_FLAG) { orig_line = vim_strsave(ml_get_curline()); // Deal with NULL below *************** *** 1318,1324 **** // Avoid being called recursively. if (State & VREPLACE_FLAG) ! State = INSERT; shift_line(type == INDENT_DEC, round, 1, call_changed_bytes); State = save_State; } --- 1318,1324 ---- // Avoid being called recursively. if (State & VREPLACE_FLAG) ! State = MODE_INSERT; shift_line(type == INDENT_DEC, round, 1, call_changed_bytes); State = save_State; } *************** *** 1339,1345 **** insstart_less = MAXCOL; new_cursor_col += curwin->w_cursor.col; } ! else if (!(State & INSERT)) new_cursor_col = curwin->w_cursor.col; else { --- 1339,1345 ---- insstart_less = MAXCOL; new_cursor_col += curwin->w_cursor.col; } ! else if (!(State & MODE_INSERT)) new_cursor_col = curwin->w_cursor.col; else { *************** *** 1397,1403 **** changed_cline_bef_curs(); // May have to adjust the start of the insert. ! if (State & INSERT) { if (curwin->w_cursor.lnum == Insstart.lnum && Insstart.col != 0) { --- 1397,1403 ---- changed_cline_bef_curs(); // May have to adjust the start of the insert. ! if (State & MODE_INSERT) { if (curwin->w_cursor.lnum == Insstart.lnum && Insstart.col != 0) { *************** *** 1412,1420 **** ai_col -= insstart_less; } ! // For REPLACE mode, may have to fix the replace stack, if it's possible. ! // If the number of characters before the cursor decreased, need to pop a ! // few characters from the replace stack. // If the number of characters before the cursor increased, need to push a // few NULs onto the replace stack. if (REPLACE_NORMAL(State) && start_col >= 0) --- 1412,1420 ---- ai_col -= insstart_less; } ! // For MODE_REPLACE state, may have to fix the replace stack, if it's ! // possible. If the number of characters before the cursor decreased, need ! // to pop a few characters from the replace stack. // If the number of characters before the cursor increased, need to push a // few NULs onto the replace stack. if (REPLACE_NORMAL(State) && start_col >= 0) *************** *** 1436,1444 **** } } ! // For VREPLACE mode, we also have to fix the replace stack. In this case ! // it is always possible because we backspace over the whole line and then ! // put it back again the way we wanted it. if (State & VREPLACE_FLAG) { // If orig_line didn't allocate, just return. At least we did the job, --- 1436,1444 ---- } } ! // For MODE_VREPLACE state, we also have to fix the replace stack. In this ! // case it is always possible because we backspace over the whole line and ! // then put it back again the way we wanted it. if (State & VREPLACE_FLAG) { // If orig_line didn't allocate, just return. At least we did the job, *************** *** 1894,1900 **** // Pretend to be in Insert mode, allow cursor past end of line for "o" // command. save_State = State; ! State = INSERT; curwin->w_cursor = save_pos; curwin->w_curswant = save_curswant; curwin->w_set_curswant = save_set_curswant; --- 1894,1900 ---- // Pretend to be in Insert mode, allow cursor past end of line for "o" // command. save_State = State; ! State = MODE_INSERT; curwin->w_cursor = save_pos; curwin->w_curswant = save_curswant; curwin->w_set_curswant = save_set_curswant; *** ../vim-8.2.4910/src/insexpand.c 2022-04-09 18:17:30.056746549 +0100 --- src/insexpand.c 2022-05-07 18:35:25.040774806 +0100 *************** *** 2883,2889 **** || check_for_list_arg(argvars, 1) == FAIL)) return; ! if ((State & INSERT) == 0) { emsg(_(e_complete_can_only_be_used_in_insert_mode)); return; --- 2883,2889 ---- || check_for_list_arg(argvars, 1) == FAIL)) return; ! if ((State & MODE_INSERT) == 0) { emsg(_(e_complete_can_only_be_used_in_insert_mode)); return; *** ../vim-8.2.4910/src/macros.h 2022-03-27 20:04:16.025188554 +0100 --- src/macros.h 2022-05-07 18:11:29.013707566 +0100 *************** *** 216,222 **** #ifdef FEAT_RIGHTLEFT // Whether to draw the vertical bar on the right side of the cell. ! # define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl)) #endif /* --- 216,222 ---- #ifdef FEAT_RIGHTLEFT // Whether to draw the vertical bar on the right side of the cell. ! # define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & MODE_CMDLINE) || cmdmsg_rl)) #endif /* *** ../vim-8.2.4910/src/main.c 2022-04-15 13:53:30.052708679 +0100 --- src/main.c 2022-05-07 18:23:02.021232546 +0100 *************** *** 1181,1187 **** // exits while Vim is running in a console. if (!cmdwin && !noexmode && SETJMP(x_jump_env)) { ! State = NORMAL; VIsual_active = FALSE; got_int = TRUE; need_wait_return = FALSE; --- 1181,1187 ---- // exits while Vim is running in a console. if (!cmdwin && !noexmode && SETJMP(x_jump_env)) { ! State = MODE_NORMAL; VIsual_active = FALSE; got_int = TRUE; need_wait_return = FALSE; *************** *** 1239,1245 **** // Typed two CTRL-C in a row: go back to ex mode as if "Q" was // used and keep "got_int" set, so that it aborts ":g". exmode_active = EXMODE_NORMAL; ! State = NORMAL; } else if (!global_busy || !exmode_active) { --- 1239,1245 ---- // Typed two CTRL-C in a row: go back to ex mode as if "Q" was // used and keep "got_int" set, so that it aborts ":g". exmode_active = EXMODE_NORMAL; ! State = MODE_NORMAL; } else if (!global_busy || !exmode_active) { *** ../vim-8.2.4910/src/map.c 2022-05-04 18:51:38.174683651 +0100 --- src/map.c 2022-05-07 19:53:00.699269232 +0100 *************** *** 31,37 **** * Returns a value between 0 and 255, index in maphash. * Put Normal/Visual mode mappings mostly separately from Insert/Cmdline mode. */ ! #define MAP_HASH(mode, c1) (((mode) & (NORMAL + VISUAL + SELECTMODE + OP_PENDING + TERMINAL)) ? (c1) : ((c1) ^ 0x80)) /* * Get the start of the hashed map list for "state" and first character "c". --- 31,37 ---- * Returns a value between 0 and 255, index in maphash. * Put Normal/Visual mode mappings mostly separately from Insert/Cmdline mode. */ ! #define MAP_HASH(mode, c1) (((mode) & (MODE_NORMAL | MODE_VISUAL | MODE_SELECT | MODE_OP_PENDING | MODE_TERMINAL)) ? (c1) : ((c1) ^ 0x80)) /* * Get the start of the hashed map list for "state" and first character "c". *************** *** 101,132 **** ga_init2(&mapmode, 1, 7); ! if ((mode & (INSERT + CMDLINE)) == INSERT + CMDLINE) ga_append(&mapmode, '!'); // :map! ! else if (mode & INSERT) ga_append(&mapmode, 'i'); // :imap ! else if (mode & LANGMAP) ga_append(&mapmode, 'l'); // :lmap ! else if (mode & CMDLINE) ga_append(&mapmode, 'c'); // :cmap ! else if ((mode & (NORMAL + VISUAL + SELECTMODE + OP_PENDING)) ! == NORMAL + VISUAL + SELECTMODE + OP_PENDING) ga_append(&mapmode, ' '); // :map else { ! if (mode & NORMAL) ga_append(&mapmode, 'n'); // :nmap ! if (mode & OP_PENDING) ga_append(&mapmode, 'o'); // :omap ! if (mode & TERMINAL) ga_append(&mapmode, 't'); // :tmap ! if ((mode & (VISUAL + SELECTMODE)) == VISUAL + SELECTMODE) ga_append(&mapmode, 'v'); // :vmap else { ! if (mode & VISUAL) ga_append(&mapmode, 'x'); // :xmap ! if (mode & SELECTMODE) ga_append(&mapmode, 's'); // :smap } } --- 101,133 ---- ga_init2(&mapmode, 1, 7); ! if ((mode & (MODE_INSERT | MODE_CMDLINE)) == (MODE_INSERT | MODE_CMDLINE)) ga_append(&mapmode, '!'); // :map! ! else if (mode & MODE_INSERT) ga_append(&mapmode, 'i'); // :imap ! else if (mode & MODE_LANGMAP) ga_append(&mapmode, 'l'); // :lmap ! else if (mode & MODE_CMDLINE) ga_append(&mapmode, 'c'); // :cmap ! else if ((mode ! & (MODE_NORMAL | MODE_VISUAL | MODE_SELECT | MODE_OP_PENDING)) ! == (MODE_NORMAL | MODE_VISUAL | MODE_SELECT | MODE_OP_PENDING)) ga_append(&mapmode, ' '); // :map else { ! if (mode & MODE_NORMAL) ga_append(&mapmode, 'n'); // :nmap ! if (mode & MODE_OP_PENDING) ga_append(&mapmode, 'o'); // :omap ! if (mode & MODE_TERMINAL) ga_append(&mapmode, 't'); // :tmap ! if ((mode & (MODE_VISUAL | MODE_SELECT)) == (MODE_VISUAL | MODE_SELECT)) ga_append(&mapmode, 'v'); // :vmap else { ! if (mode & MODE_VISUAL) ga_append(&mapmode, 'x'); // :xmap ! if (mode & MODE_SELECT) ga_append(&mapmode, 's'); // :smap } } *************** *** 297,317 **** * arg is pointer to any arguments. Note: arg cannot be a read-only string, * it will be modified. * ! * for :map mode is NORMAL + VISUAL + SELECTMODE + OP_PENDING ! * for :map! mode is INSERT + CMDLINE ! * for :cmap mode is CMDLINE ! * for :imap mode is INSERT ! * for :lmap mode is LANGMAP ! * for :nmap mode is NORMAL ! * for :vmap mode is VISUAL + SELECTMODE ! * for :xmap mode is VISUAL ! * for :smap mode is SELECTMODE ! * for :omap mode is OP_PENDING ! * for :tmap mode is TERMINAL * ! * for :abbr mode is INSERT + CMDLINE ! * for :iabbr mode is INSERT ! * for :cabbr mode is CMDLINE * * Return 0 for success * 1 for invalid arguments --- 298,318 ---- * arg is pointer to any arguments. Note: arg cannot be a read-only string, * it will be modified. * ! * for :map mode is MODE_NORMAL | MODE_VISUAL | MODE_SELECT | MODE_OP_PENDING ! * for :map! mode is MODE_INSERT | MODE_CMDLINE ! * for :cmap mode is MODE_CMDLINE ! * for :imap mode is MODE_INSERT ! * for :lmap mode is MODE_LANGMAP ! * for :nmap mode is MODE_NORMAL ! * for :vmap mode is MODE_VISUAL | MODE_SELECT ! * for :xmap mode is MODE_VISUAL ! * for :smap mode is MODE_SELECT ! * for :omap mode is MODE_OP_PENDING ! * for :tmap mode is MODE_TERMINAL * ! * for :abbr mode is MODE_INSERT | MODE_CMDLINE ! * for :iabbr mode is MODE_INSERT ! * for :cabbr mode is MODE_CMDLINE * * Return 0 for success * 1 for invalid arguments *************** *** 872,901 **** p = *cmdp; modec = *p++; if (modec == 'i') ! mode = INSERT; // :imap else if (modec == 'l') ! mode = LANGMAP; // :lmap else if (modec == 'c') ! mode = CMDLINE; // :cmap else if (modec == 'n' && *p != 'o') // avoid :noremap ! mode = NORMAL; // :nmap else if (modec == 'v') ! mode = VISUAL + SELECTMODE; // :vmap else if (modec == 'x') ! mode = VISUAL; // :xmap else if (modec == 's') ! mode = SELECTMODE; // :smap else if (modec == 'o') ! mode = OP_PENDING; // :omap else if (modec == 't') ! mode = TERMINAL; // :tmap else { --p; if (forceit) ! mode = INSERT + CMDLINE; // :map ! else ! mode = VISUAL + SELECTMODE + NORMAL + OP_PENDING;// :map } *cmdp = p; --- 873,903 ---- p = *cmdp; modec = *p++; if (modec == 'i') ! mode = MODE_INSERT; // :imap else if (modec == 'l') ! mode = MODE_LANGMAP; // :lmap else if (modec == 'c') ! mode = MODE_CMDLINE; // :cmap else if (modec == 'n' && *p != 'o') // avoid :noremap ! mode = MODE_NORMAL; // :nmap else if (modec == 'v') ! mode = MODE_VISUAL | MODE_SELECT; // :vmap else if (modec == 'x') ! mode = MODE_VISUAL; // :xmap else if (modec == 's') ! mode = MODE_SELECT; // :smap else if (modec == 'o') ! mode = MODE_OP_PENDING; // :omap else if (modec == 't') ! mode = MODE_TERMINAL; // :tmap else { --p; if (forceit) ! mode = MODE_INSERT | MODE_CMDLINE; // :map ! else ! mode = MODE_VISUAL | MODE_SELECT | MODE_NORMAL | MODE_OP_PENDING; ! // :map } *cmdp = p; *************** *** 1002,1022 **** int mode = 0; if (vim_strchr(modechars, 'n') != NULL) ! mode |= NORMAL; if (vim_strchr(modechars, 'v') != NULL) ! mode |= VISUAL + SELECTMODE; if (vim_strchr(modechars, 'x') != NULL) ! mode |= VISUAL; if (vim_strchr(modechars, 's') != NULL) ! mode |= SELECTMODE; if (vim_strchr(modechars, 'o') != NULL) ! mode |= OP_PENDING; if (vim_strchr(modechars, 'i') != NULL) ! mode |= INSERT; if (vim_strchr(modechars, 'l') != NULL) ! mode |= LANGMAP; if (vim_strchr(modechars, 'c') != NULL) ! mode |= CMDLINE; return mode; } --- 1004,1024 ---- int mode = 0; if (vim_strchr(modechars, 'n') != NULL) ! mode |= MODE_NORMAL; if (vim_strchr(modechars, 'v') != NULL) ! mode |= MODE_VISUAL | MODE_SELECT; if (vim_strchr(modechars, 'x') != NULL) ! mode |= MODE_VISUAL; if (vim_strchr(modechars, 's') != NULL) ! mode |= MODE_SELECT; if (vim_strchr(modechars, 'o') != NULL) ! mode |= MODE_OP_PENDING; if (vim_strchr(modechars, 'i') != NULL) ! mode |= MODE_INSERT; if (vim_strchr(modechars, 'l') != NULL) ! mode |= MODE_LANGMAP; if (vim_strchr(modechars, 'c') != NULL) ! mode |= MODE_CMDLINE; return mode; } *************** *** 1192,1200 **** expand_mapmodes = get_map_mode(&cmd, forceit || isabbrev); else { ! expand_mapmodes = INSERT + CMDLINE; if (!isabbrev) ! expand_mapmodes += VISUAL + SELECTMODE + NORMAL + OP_PENDING; } expand_isabbrev = isabbrev; xp->xp_context = EXPAND_MAPPINGS; --- 1194,1203 ---- expand_mapmodes = get_map_mode(&cmd, forceit || isabbrev); else { ! expand_mapmodes = MODE_INSERT | MODE_CMDLINE; if (!isabbrev) ! expand_mapmodes += MODE_VISUAL | MODE_SELECT | MODE_NORMAL ! | MODE_OP_PENDING; } expand_isabbrev = isabbrev; xp->xp_context = EXPAND_MAPPINGS; *************** *** 1864,1938 **** cmd = "map"; switch (mp->m_mode) { ! case NORMAL + VISUAL + SELECTMODE + OP_PENDING: break; ! case NORMAL: c1 = 'n'; break; ! case VISUAL: c1 = 'x'; break; ! case SELECTMODE: c1 = 's'; break; ! case OP_PENDING: c1 = 'o'; break; ! case NORMAL + VISUAL: c1 = 'n'; c2 = 'x'; break; ! case NORMAL + SELECTMODE: c1 = 'n'; c2 = 's'; break; ! case NORMAL + OP_PENDING: c1 = 'n'; c2 = 'o'; break; ! case VISUAL + SELECTMODE: c1 = 'v'; break; ! case VISUAL + OP_PENDING: c1 = 'x'; c2 = 'o'; break; ! case SELECTMODE + OP_PENDING: c1 = 's'; c2 = 'o'; break; ! case NORMAL + VISUAL + SELECTMODE: c1 = 'n'; c2 = 'v'; break; ! case NORMAL + VISUAL + OP_PENDING: c1 = 'n'; c2 = 'x'; c3 = 'o'; break; ! case NORMAL + SELECTMODE + OP_PENDING: c1 = 'n'; c2 = 's'; c3 = 'o'; break; ! case VISUAL + SELECTMODE + OP_PENDING: c1 = 'v'; c2 = 'o'; break; ! case CMDLINE + INSERT: if (!abbr) cmd = "map!"; break; ! case CMDLINE: c1 = 'c'; break; ! case INSERT: c1 = 'i'; break; ! case LANGMAP: c1 = 'l'; break; ! case TERMINAL: c1 = 't'; break; default: --- 1867,1942 ---- cmd = "map"; switch (mp->m_mode) { ! case MODE_NORMAL | MODE_VISUAL | MODE_SELECT ! | MODE_OP_PENDING: break; ! case MODE_NORMAL: c1 = 'n'; break; ! case MODE_VISUAL: c1 = 'x'; break; ! case MODE_SELECT: c1 = 's'; break; ! case MODE_OP_PENDING: c1 = 'o'; break; ! case MODE_NORMAL | MODE_VISUAL: c1 = 'n'; c2 = 'x'; break; ! case MODE_NORMAL | MODE_SELECT: c1 = 'n'; c2 = 's'; break; ! case MODE_NORMAL | MODE_OP_PENDING: c1 = 'n'; c2 = 'o'; break; ! case MODE_VISUAL | MODE_SELECT: c1 = 'v'; break; ! case MODE_VISUAL | MODE_OP_PENDING: c1 = 'x'; c2 = 'o'; break; ! case MODE_SELECT | MODE_OP_PENDING: c1 = 's'; c2 = 'o'; break; ! case MODE_NORMAL | MODE_VISUAL | MODE_SELECT: c1 = 'n'; c2 = 'v'; break; ! case MODE_NORMAL | MODE_VISUAL | MODE_OP_PENDING: c1 = 'n'; c2 = 'x'; c3 = 'o'; break; ! case MODE_NORMAL | MODE_SELECT | MODE_OP_PENDING: c1 = 'n'; c2 = 's'; c3 = 'o'; break; ! case MODE_VISUAL | MODE_SELECT | MODE_OP_PENDING: c1 = 'v'; c2 = 'o'; break; ! case MODE_CMDLINE | MODE_INSERT: if (!abbr) cmd = "map!"; break; ! case MODE_CMDLINE: c1 = 'c'; break; ! case MODE_INSERT: c1 = 'i'; break; ! case MODE_LANGMAP: c1 = 'l'; break; ! case MODE_TERMINAL: c1 = 't'; break; default: *************** *** 2495,2503 **** int mode = 0; int tmode; int modec; ! const int MASK_V = VISUAL + SELECTMODE; ! const int MASK_MAP = VISUAL + SELECTMODE + NORMAL + OP_PENDING; ! const int MASK_BANG = INSERT + CMDLINE; if (*p == NUL) p = (char_u *)" "; // compatibility --- 2499,2508 ---- int mode = 0; int tmode; int modec; ! const int MASK_V = MODE_VISUAL | MODE_SELECT; ! const int MASK_MAP = MODE_VISUAL | MODE_SELECT | MODE_NORMAL ! | MODE_OP_PENDING; ! const int MASK_BANG = MODE_INSERT | MODE_CMDLINE; if (*p == NUL) p = (char_u *)" "; // compatibility *************** *** 2505,2518 **** { switch (modec) { ! case 'i': tmode = INSERT; break; ! case 'l': tmode = LANGMAP; break; ! case 'c': tmode = CMDLINE; break; ! case 'n': tmode = NORMAL; break; ! case 'x': tmode = VISUAL; break; ! case 's': tmode = SELECTMODE; break; ! case 'o': tmode = OP_PENDING; break; ! case 't': tmode = TERMINAL; break; case 'v': tmode = MASK_V; break; case '!': tmode = MASK_BANG; break; case ' ': tmode = MASK_MAP; break; --- 2510,2523 ---- { switch (modec) { ! case 'i': tmode = MODE_INSERT; break; ! case 'l': tmode = MODE_LANGMAP; break; ! case 'c': tmode = MODE_CMDLINE; break; ! case 'n': tmode = MODE_NORMAL; break; ! case 'x': tmode = MODE_VISUAL; break; ! case 's': tmode = MODE_SELECT; break; ! case 'o': tmode = MODE_OP_PENDING; break; ! case 't': tmode = MODE_TERMINAL; break; case 'v': tmode = MASK_V; break; case '!': tmode = MASK_BANG; break; case ' ': tmode = MASK_MAP; break; *************** *** 2672,2678 **** #if defined(MSWIN) || defined(MACOS_X) ! # define VIS_SEL (VISUAL+SELECTMODE) // abbreviation /* * Default mappings for some often used keys. --- 2677,2683 ---- #if defined(MSWIN) || defined(MACOS_X) ! # define VIS_SEL (MODE_VISUAL | MODE_SELECT) // abbreviation /* * Default mappings for some often used keys. *************** *** 2688,2696 **** static struct initmap initmappings[] = { // paste, copy and cut ! {(char_u *)" \"*P", NORMAL}, {(char_u *)" \"-d\"*P", VIS_SEL}, ! {(char_u *)" *", INSERT+CMDLINE}, {(char_u *)" \"*y", VIS_SEL}, {(char_u *)" \"*d", VIS_SEL}, {(char_u *)" \"*d", VIS_SEL}, --- 2693,2701 ---- static struct initmap initmappings[] = { // paste, copy and cut ! {(char_u *)" \"*P", MODE_NORMAL}, {(char_u *)" \"-d\"*P", VIS_SEL}, ! {(char_u *)" *", MODE_INSERT | MODE_CMDLINE}, {(char_u *)" \"*y", VIS_SEL}, {(char_u *)" \"*d", VIS_SEL}, {(char_u *)" \"*d", VIS_SEL}, *************** *** 2703,2726 **** // Use the Windows (CUA) keybindings. (Console) static struct initmap cinitmappings[] = { ! {(char_u *)"\316w ", NORMAL+VIS_SEL}, ! {(char_u *)"\316w ", INSERT+CMDLINE}, ! {(char_u *)"\316u ", NORMAL+VIS_SEL}, ! {(char_u *)"\316u ", INSERT+CMDLINE}, // paste, copy and cut # ifdef FEAT_CLIPBOARD ! {(char_u *)"\316\324 \"*P", NORMAL}, // SHIFT-Insert is "*P {(char_u *)"\316\324 \"-d\"*P", VIS_SEL}, // SHIFT-Insert is "-d"*P ! {(char_u *)"\316\324 \022\017*", INSERT}, // SHIFT-Insert is ^R^O* {(char_u *)"\316\325 \"*y", VIS_SEL}, // CTRL-Insert is "*y {(char_u *)"\316\327 \"*d", VIS_SEL}, // SHIFT-Del is "*d {(char_u *)"\316\330 \"*d", VIS_SEL}, // CTRL-Del is "*d {(char_u *)"\030 \"*d", VIS_SEL}, // CTRL-X is "*d # else ! {(char_u *)"\316\324 P", NORMAL}, // SHIFT-Insert is P {(char_u *)"\316\324 \"-dP", VIS_SEL}, // SHIFT-Insert is "-dP ! {(char_u *)"\316\324 \022\017\"", INSERT}, // SHIFT-Insert is ^R^O" {(char_u *)"\316\325 y", VIS_SEL}, // CTRL-Insert is y {(char_u *)"\316\327 d", VIS_SEL}, // SHIFT-Del is d {(char_u *)"\316\330 d", VIS_SEL}, // CTRL-Del is d --- 2708,2731 ---- // Use the Windows (CUA) keybindings. (Console) static struct initmap cinitmappings[] = { ! {(char_u *)"\316w ", MODE_NORMAL | VIS_SEL}, ! {(char_u *)"\316w ", MODE_INSERT | MODE_CMDLINE}, ! {(char_u *)"\316u ", MODE_NORMAL | VIS_SEL}, ! {(char_u *)"\316u ", MODE_INSERT | MODE_CMDLINE}, // paste, copy and cut # ifdef FEAT_CLIPBOARD ! {(char_u *)"\316\324 \"*P", MODE_NORMAL}, // SHIFT-Insert is "*P {(char_u *)"\316\324 \"-d\"*P", VIS_SEL}, // SHIFT-Insert is "-d"*P ! {(char_u *)"\316\324 \022\017*", MODE_INSERT}, // SHIFT-Insert is ^R^O* {(char_u *)"\316\325 \"*y", VIS_SEL}, // CTRL-Insert is "*y {(char_u *)"\316\327 \"*d", VIS_SEL}, // SHIFT-Del is "*d {(char_u *)"\316\330 \"*d", VIS_SEL}, // CTRL-Del is "*d {(char_u *)"\030 \"*d", VIS_SEL}, // CTRL-X is "*d # else ! {(char_u *)"\316\324 P", MODE_NORMAL}, // SHIFT-Insert is P {(char_u *)"\316\324 \"-dP", VIS_SEL}, // SHIFT-Insert is "-dP ! {(char_u *)"\316\324 \022\017\"", MODE_INSERT}, // SHIFT-Insert is ^R^O" {(char_u *)"\316\325 y", VIS_SEL}, // CTRL-Insert is y {(char_u *)"\316\327 d", VIS_SEL}, // SHIFT-Del is d {(char_u *)"\316\330 d", VIS_SEL}, // CTRL-Del is d *************** *** 2733,2741 **** { // Use the Standard MacOS binding. // paste, copy and cut ! {(char_u *)" \"*P", NORMAL}, {(char_u *)" \"-d\"*P", VIS_SEL}, ! {(char_u *)" *", INSERT+CMDLINE}, {(char_u *)" \"*y", VIS_SEL}, {(char_u *)" \"*d", VIS_SEL}, {(char_u *)" \"-d", VIS_SEL}, --- 2738,2746 ---- { // Use the Standard MacOS binding. // paste, copy and cut ! {(char_u *)" \"*P", MODE_NORMAL}, {(char_u *)" \"-d\"*P", VIS_SEL}, ! {(char_u *)" *", MODE_INSERT | MODE_CMDLINE}, {(char_u *)" \"*y", VIS_SEL}, {(char_u *)" \"*d", VIS_SEL}, {(char_u *)" \"-d", VIS_SEL}, *** ../vim-8.2.4910/src/menu.c 2022-04-03 18:01:39.655574461 +0100 --- src/menu.c 2022-05-07 19:42:49.759949224 +0100 *************** *** 1754,1762 **** { int idx; ! if ((state & INSERT)) idx = MENU_INDEX_INSERT; ! else if (state & CMDLINE) idx = MENU_INDEX_CMDLINE; #ifdef FEAT_TERMINAL else if (term_use_loop()) --- 1754,1762 ---- { int idx; ! if ((state & MODE_INSERT)) idx = MENU_INDEX_INSERT; ! else if (state & MODE_CMDLINE) idx = MENU_INDEX_CMDLINE; #ifdef FEAT_TERMINAL else if (term_use_loop()) *************** *** 1769,1779 **** else idx = MENU_INDEX_VISUAL; } ! else if (state == HITRETURN || state == ASKMORE) idx = MENU_INDEX_CMDLINE; else if (finish_op) idx = MENU_INDEX_OP_PENDING; ! else if ((state & NORMAL)) idx = MENU_INDEX_NORMAL; else idx = MENU_INDEX_INVALID; --- 1769,1779 ---- else idx = MENU_INDEX_VISUAL; } ! else if (state == MODE_HITRETURN || state == MODE_ASKMORE) idx = MENU_INDEX_CMDLINE; else if (finish_op) idx = MENU_INDEX_OP_PENDING; ! else if ((state & MODE_NORMAL)) idx = MENU_INDEX_NORMAL; else idx = MENU_INDEX_INVALID; *************** *** 1929,1943 **** return MENU_INDEX_SELECT; return MENU_INDEX_VISUAL; } ! if (State & INSERT) return MENU_INDEX_INSERT; ! if ((State & CMDLINE) || State == ASKMORE || State == HITRETURN) return MENU_INDEX_CMDLINE; if (finish_op) return MENU_INDEX_OP_PENDING; ! if (State & NORMAL) return MENU_INDEX_NORMAL; ! if (State & LANGMAP) // must be a "r" command, like Insert mode return MENU_INDEX_INSERT; return MENU_INDEX_INVALID; } --- 1929,1944 ---- return MENU_INDEX_SELECT; return MENU_INDEX_VISUAL; } ! if (State & MODE_INSERT) return MENU_INDEX_INSERT; ! if ((State & MODE_CMDLINE) || State == MODE_ASKMORE ! || State == MODE_HITRETURN) return MENU_INDEX_CMDLINE; if (finish_op) return MENU_INDEX_OP_PENDING; ! if (State & MODE_NORMAL) return MENU_INDEX_NORMAL; ! if (State & MODE_LANGMAP) // must be a "r" command, like Insert mode return MENU_INDEX_INSERT; return MENU_INDEX_INVALID; } *** ../vim-8.2.4910/src/message.c 2022-05-04 18:51:38.174683651 +0100 --- src/message.c 2022-05-07 19:43:23.971910640 +0100 *************** *** 1179,1185 **** // just changed. screenalloc(FALSE); ! State = HITRETURN; setmouse(); #ifdef USE_ON_FLY_SCROLL dont_scroll = TRUE; // disallow scrolling here --- 1179,1185 ---- // just changed. screenalloc(FALSE); ! State = MODE_HITRETURN; setmouse(); #ifdef USE_ON_FLY_SCROLL dont_scroll = TRUE; // disallow scrolling here *************** *** 1351,1357 **** (Rows - cmdline_row - 1) * Columns + sc_col) VIM_CLEAR(keep_msg); // don't redisplay message, it's too long ! if (tmpState == SETWSIZE) // got resize event while in vgetc() { starttermcap(); // start termcap before redrawing shell_resized(); --- 1351,1357 ---- (Rows - cmdline_row - 1) * Columns + sc_col) VIM_CLEAR(keep_msg); // don't redisplay message, it's too long ! if (tmpState == MODE_SETWSIZE) // got resize event while in vgetc() { starttermcap(); // start termcap before redrawing shell_resized(); *************** *** 1408,1414 **** set_keep_msg_from_hist(void) { if (keep_msg == NULL && last_msg_hist != NULL && msg_scrolled == 0 ! && (State & NORMAL)) set_keep_msg(last_msg_hist->msg, last_msg_hist->attr); } #endif --- 1408,1414 ---- set_keep_msg_from_hist(void) { if (keep_msg == NULL && last_msg_hist != NULL && msg_scrolled == 0 ! && (State & MODE_NORMAL)) set_keep_msg(last_msg_hist->msg, last_msg_hist->attr); } #endif *************** *** 2284,2290 **** */ if (lines_left > 0) --lines_left; ! if (p_more && lines_left == 0 && State != HITRETURN && !msg_no_more && !exmode_active) { #ifdef FEAT_CON_DIALOG --- 2284,2290 ---- */ if (lines_left > 0) --lines_left; ! if (p_more && lines_left == 0 && State != MODE_HITRETURN && !msg_no_more && !exmode_active) { #ifdef FEAT_CON_DIALOG *************** *** 2847,2853 **** // We get called recursively when a timer callback outputs a message. In // that case don't show another prompt. Also when at the hit-Enter prompt // and nothing was typed. ! if (entered || (State == HITRETURN && typed_char == 0)) return FALSE; entered = TRUE; --- 2847,2853 ---- // We get called recursively when a timer callback outputs a message. In // that case don't show another prompt. Also when at the hit-Enter prompt // and nothing was typed. ! if (entered || (State == MODE_HITRETURN && typed_char == 0)) return FALSE; entered = TRUE; *************** *** 2860,2866 **** mp_last = msg_sb_start(mp_last->sb_prev); } ! State = ASKMORE; setmouse(); if (typed_char == NUL) msg_moremsg(FALSE); --- 2860,2866 ---- mp_last = msg_sb_start(mp_last->sb_prev); } ! State = MODE_ASKMORE; setmouse(); if (typed_char == NUL) msg_moremsg(FALSE); *************** *** 2880,2886 **** #if defined(FEAT_MENU) && defined(FEAT_GUI) if (c == K_MENU) { ! int idx = get_menu_index(current_menu, ASKMORE); // Used a menu. If it starts with CTRL-Y, it must // be a "Copy" for the clipboard. Otherwise --- 2880,2886 ---- #if defined(FEAT_MENU) && defined(FEAT_GUI) if (c == K_MENU) { ! int idx = get_menu_index(current_menu, MODE_ASKMORE); // Used a menu. If it starts with CTRL-Y, it must // be a "Copy" for the clipboard. Otherwise *************** *** 3329,3357 **** } /* ! * Repeat the message for the current mode: ASKMORE, EXTERNCMD, CONFIRM or ! * exmode_active. */ void repeat_message(void) { ! if (State == ASKMORE) { msg_moremsg(TRUE); // display --more-- message again msg_row = Rows - 1; } #ifdef FEAT_CON_DIALOG ! else if (State == CONFIRM) { display_confirm_msg(); // display ":confirm" message again msg_row = Rows - 1; } #endif ! else if (State == EXTERNCMD) { windgoto(msg_row, msg_col); // put cursor back } ! else if (State == HITRETURN || State == SETWSIZE) { if (msg_row == Rows - 1) { --- 3329,3357 ---- } /* ! * Repeat the message for the current mode: MODE_ASKMORE, MODE_EXTERNCMD, ! * MODE_CONFIRM or exmode_active. */ void repeat_message(void) { ! if (State == MODE_ASKMORE) { msg_moremsg(TRUE); // display --more-- message again msg_row = Rows - 1; } #ifdef FEAT_CON_DIALOG ! else if (State == MODE_CONFIRM) { display_confirm_msg(); // display ":confirm" message again msg_row = Rows - 1; } #endif ! else if (State == MODE_EXTERNCMD) { windgoto(msg_row, msg_col); // put cursor back } ! else if (State == MODE_HITRETURN || State == MODE_SETWSIZE) { if (msg_row == Rows - 1) { *************** *** 3458,3464 **** * we have to redraw the window. * Do not do this if we are abandoning the file or editing the command line. */ ! if (!exiting && need_wait_return && !(State & CMDLINE)) { wait_return(FALSE); return FALSE; --- 3458,3464 ---- * we have to redraw the window. * Do not do this if we are abandoning the file or editing the command line. */ ! if (!exiting && need_wait_return && !(State & MODE_CMDLINE)) { wait_return(FALSE); return FALSE; *************** *** 3811,3817 **** #endif oldState = State; ! State = CONFIRM; setmouse(); // Ensure raw mode here. --- 3811,3817 ---- #endif oldState = State; ! State = MODE_CONFIRM; setmouse(); // Ensure raw mode here. *** ../vim-8.2.4910/src/misc1.c 2022-04-29 11:29:49.952300681 +0100 --- src/misc1.c 2022-05-07 19:44:31.179835090 +0100 *************** *** 455,467 **** /* * If *s is a TAB, and the TAB is not displayed as ^I, and we're not in ! * INSERT mode, then col must be adjusted so that it represents the last ! * screen position of the TAB. This only fixes an error when the TAB wraps ! * from one screen line to the next (when 'columns' is not a multiple of ! * 'ts') -- webb. */ ! if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || ! wp->w_lcs_chars.tab1)) col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL) - 1; /* --- 455,467 ---- /* * If *s is a TAB, and the TAB is not displayed as ^I, and we're not in ! * MODE_INSERT state, then col must be adjusted so that it represents the ! * last screen position of the TAB. This only fixes an error when the TAB ! * wraps from one screen line to the next (when 'columns' is not a multiple ! * of 'ts') -- webb. */ ! if (*s == TAB && (State & MODE_NORMAL) ! && (!wp->w_p_list || wp->w_lcs_chars.tab1)) col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL) - 1; /* *************** *** 595,601 **** #ifdef USE_ON_FLY_SCROLL dont_scroll = TRUE; // disallow scrolling here #endif ! State = CONFIRM; // mouse behaves like with :confirm setmouse(); // disables mouse for xterm ++no_mapping; ++allow_keys; // no mapping here, but recognize keys --- 595,601 ---- #ifdef USE_ON_FLY_SCROLL dont_scroll = TRUE; // disallow scrolling here #endif ! State = MODE_CONFIRM; // mouse behaves like with :confirm setmouse(); // disables mouse for xterm ++no_mapping; ++allow_keys; // no mapping here, but recognize keys *************** *** 656,673 **** buf[i++] = 's'; } } ! else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE ! || State == CONFIRM) { buf[i++] = 'r'; ! if (State == ASKMORE) buf[i++] = 'm'; ! else if (State == CONFIRM) buf[i++] = '?'; } ! else if (State == EXTERNCMD) buf[i++] = '!'; ! else if (State & INSERT) { if (State & VREPLACE_FLAG) { --- 656,674 ---- buf[i++] = 's'; } } ! else if (State == MODE_HITRETURN || State == MODE_ASKMORE ! || State == MODE_SETWSIZE ! || State == MODE_CONFIRM) { buf[i++] = 'r'; ! if (State == MODE_ASKMORE) buf[i++] = 'm'; ! else if (State == MODE_CONFIRM) buf[i++] = '?'; } ! else if (State == MODE_EXTERNCMD) buf[i++] = '!'; ! else if (State & MODE_INSERT) { if (State & VREPLACE_FLAG) { *************** *** 687,693 **** else if (ctrl_x_mode_not_defined_yet()) buf[i++] = 'x'; } ! else if ((State & CMDLINE) || exmode_active) { buf[i++] = 'c'; if (exmode_active == EXMODE_VIM) --- 688,694 ---- else if (ctrl_x_mode_not_defined_yet()) buf[i++] = 'x'; } ! else if ((State & MODE_CMDLINE) || exmode_active) { buf[i++] = 'c'; if (exmode_active == EXMODE_VIM) *************** *** 861,868 **** if (n == KEYLEN_REMOVED) // key code removed { ! if (must_redraw != 0 && !need_wait_return ! && (State & (CMDLINE|HITRETURN|ASKMORE)) == 0) { // Redrawing was postponed, do it now. update_screen(0); --- 862,869 ---- if (n == KEYLEN_REMOVED) // key code removed { ! if (must_redraw != 0 && !need_wait_return && (State ! & (MODE_CMDLINE | MODE_HITRETURN | MODE_ASKMORE)) == 0) { // Redrawing was postponed, do it now. update_screen(0); *************** *** 1014,1020 **** save_cmdline_row = cmdline_row; cmdline_row = 0; save_State = State; ! State = CMDLINE; // May show different mouse shape. setmouse(); --- 1015,1021 ---- save_cmdline_row = cmdline_row; cmdline_row = 0; save_State = State; ! State = MODE_CMDLINE; // May show different mouse shape. setmouse(); *** ../vim-8.2.4910/src/misc2.c 2022-05-02 22:53:41.380211031 +0100 --- src/misc2.c 2022-05-07 19:45:11.031790423 +0100 *************** *** 30,37 **** if (virtual_op != MAYBE) return virtual_op; return (cur_ve_flags == VE_ALL ! || ((cur_ve_flags & VE_BLOCK) && VIsual_active && VIsual_mode == Ctrl_V) ! || ((cur_ve_flags & VE_INSERT) && (State & INSERT))); } /* --- 30,38 ---- if (virtual_op != MAYBE) return virtual_op; return (cur_ve_flags == VE_ALL ! || ((cur_ve_flags & VE_BLOCK) && VIsual_active ! && VIsual_mode == Ctrl_V) ! || ((cur_ve_flags & VE_INSERT) && (State & MODE_INSERT))); } /* *************** *** 136,142 **** int head = 0; #endif ! one_more = (State & INSERT) || restart_edit != NUL || (VIsual_active && *p_sel != 'o') || ((get_ve_flags() & VE_ONEMORE) && wcol < MAXCOL); --- 137,143 ---- int head = 0; #endif ! one_more = (State & MODE_INSERT) || restart_edit != NUL || (VIsual_active && *p_sel != 'o') || ((get_ve_flags() & VE_ONEMORE) && wcol < MAXCOL); *************** *** 169,175 **** csize--; if (wcol / width > (colnr_T)csize / width ! && ((State & INSERT) == 0 || (int)wcol > csize + 1)) { // In case of line wrapping don't move the cursor beyond the // right screen edge. In Insert mode allow going just beyond --- 170,176 ---- csize--; if (wcol / width > (colnr_T)csize / width ! && ((State & MODE_INSERT) == 0 || (int)wcol > csize + 1)) { // In case of line wrapping don't move the cursor beyond the // right screen edge. In Insert mode allow going just beyond *************** *** 566,572 **** // - in Insert mode or restarting Insert mode // - in Visual mode and 'selection' isn't "old" // - 'virtualedit' is set ! if ((State & INSERT) || restart_edit || (VIsual_active && *p_sel != 'o') || (cur_ve_flags & VE_ONEMORE) || virtual_active()) --- 567,573 ---- // - in Insert mode or restarting Insert mode // - in Visual mode and 'selection' isn't "old" // - 'virtualedit' is set ! if ((State & MODE_INSERT) || restart_edit || (VIsual_active && *p_sel != 'o') || (cur_ve_flags & VE_ONEMORE) || virtual_active()) *************** *** 1836,1857 **** } /* ! * VISUAL, SELECTMODE and OP_PENDING State are never set, they are equal to ! * NORMAL State with a condition. This function returns the real State. */ int get_real_state(void) { ! if (State & NORMAL) { if (VIsual_active) { if (VIsual_select) ! return SELECTMODE; ! return VISUAL; } else if (finish_op) ! return OP_PENDING; } return State; } --- 1837,1859 ---- } /* ! * MODE_VISUAL, MODE_SELECT and MODE_OP_PENDING State are never set, they are ! * equal to MODE_NORMAL State with a condition. This function returns the real ! * State. */ int get_real_state(void) { ! if (State & MODE_NORMAL) { if (VIsual_active) { if (VIsual_select) ! return MODE_SELECT; ! return MODE_VISUAL; } else if (finish_op) ! return MODE_OP_PENDING; } return State; } *************** *** 2271,2277 **** get_shape_idx(int mouse) { #ifdef FEAT_MOUSESHAPE ! if (mouse && (State == HITRETURN || State == ASKMORE)) { # ifdef FEAT_GUI int x, y; --- 2273,2279 ---- get_shape_idx(int mouse) { #ifdef FEAT_MOUSESHAPE ! if (mouse && (State == MODE_HITRETURN || State == MODE_ASKMORE)) { # ifdef FEAT_GUI int x, y; *************** *** 2286,2300 **** if (mouse && drag_sep_line) return SHAPE_IDX_VDRAG; #endif ! if (!mouse && State == SHOWMATCH) return SHAPE_IDX_SM; if (State & VREPLACE_FLAG) return SHAPE_IDX_R; if (State & REPLACE_FLAG) return SHAPE_IDX_R; ! if (State & INSERT) return SHAPE_IDX_I; ! if (State & CMDLINE) { if (cmdline_at_end()) return SHAPE_IDX_C; --- 2288,2302 ---- if (mouse && drag_sep_line) return SHAPE_IDX_VDRAG; #endif ! if (!mouse && State == MODE_SHOWMATCH) return SHAPE_IDX_SM; if (State & VREPLACE_FLAG) return SHAPE_IDX_R; if (State & REPLACE_FLAG) return SHAPE_IDX_R; ! if (State & MODE_INSERT) return SHAPE_IDX_I; ! if (State & MODE_CMDLINE) { if (cmdline_at_end()) return SHAPE_IDX_C; *** ../vim-8.2.4910/src/mouse.c 2022-05-07 12:24:57.943638388 +0100 --- src/mouse.c 2022-05-07 19:45:55.675740511 +0100 *************** *** 269,275 **** if (!mouse_has(MOUSE_VISUAL)) return FALSE; } ! else if (State == NORMAL && !mouse_has(MOUSE_NORMAL)) return FALSE; } --- 269,275 ---- if (!mouse_has(MOUSE_VISUAL)) return FALSE; } ! else if (State == MODE_NORMAL && !mouse_has(MOUSE_NORMAL)) return FALSE; } *************** *** 355,361 **** // CTRL right mouse button does CTRL-T if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT) { ! if (State & INSERT) stuffcharReadbuff(Ctrl_O); if (count > 1) stuffnumReadbuff(count); --- 355,361 ---- // CTRL right mouse button does CTRL-T if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT) { ! if (State & MODE_INSERT) stuffcharReadbuff(Ctrl_O); if (count > 1) stuffnumReadbuff(count); *************** *** 399,405 **** // Middle mouse button does a 'put' of the selected text if (which_button == MOUSE_MIDDLE) { ! if (State == NORMAL) { // If an operator was pending, we don't know what the user wanted // to do. Go back to normal mode: Clear the operator and beep(). --- 399,405 ---- // Middle mouse button does a 'put' of the selected text if (which_button == MOUSE_MIDDLE) { ! if (State == MODE_NORMAL) { // If an operator was pending, we don't know what the user wanted // to do. Go back to normal mode: Clear the operator and beep(). *************** *** 430,436 **** // The rest is below jump_to_mouse() } ! else if ((State & INSERT) == 0) return FALSE; // Middle click in insert mode doesn't move the mouse, just insert the --- 430,436 ---- // The rest is below jump_to_mouse() } ! else if ((State & MODE_INSERT) == 0) return FALSE; // Middle click in insert mode doesn't move the mouse, just insert the *************** *** 438,444 **** // with do_put(). // Also paste at the cursor if the current mode isn't in 'mouse' (only // happens for the GUI). ! if ((State & INSERT) || !mouse_has(MOUSE_NORMAL)) { if (regname == '.') insert_reg(regname, TRUE); --- 438,444 ---- // with do_put(). // Also paste at the cursor if the current mode isn't in 'mouse' (only // happens for the GUI). ! if ((State & MODE_INSERT) || !mouse_has(MOUSE_NORMAL)) { if (regname == '.') insert_reg(regname, TRUE); *************** *** 645,651 **** } } ! if ((State & (NORMAL | INSERT)) && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) { if (which_button == MOUSE_LEFT) --- 645,651 ---- } } ! if ((State & (MODE_NORMAL | MODE_INSERT)) && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) { if (which_button == MOUSE_LEFT) *************** *** 838,844 **** } } // If Visual mode started in insert mode, execute "CTRL-O" ! else if ((State & INSERT) && VIsual_active) stuffcharReadbuff(Ctrl_O); // Middle mouse click: Put text before cursor. --- 838,844 ---- } } // If Visual mode started in insert mode, execute "CTRL-O" ! else if ((State & MODE_INSERT) && VIsual_active) stuffcharReadbuff(Ctrl_O); // Middle mouse click: Put text before cursor. *************** *** 895,901 **** else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)) { ! if (State & INSERT) stuffcharReadbuff(Ctrl_O); stuffcharReadbuff(Ctrl_RSB); got_click = FALSE; // ignore drag&release now --- 895,901 ---- else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)) { ! if (State & MODE_INSERT) stuffcharReadbuff(Ctrl_O); stuffcharReadbuff(Ctrl_RSB); got_click = FALSE; // ignore drag&release now *************** *** 905,911 **** // the mouse pointer else if ((mod_mask & MOD_MASK_SHIFT)) { ! if ((State & INSERT) || (VIsual_active && VIsual_select)) stuffcharReadbuff(Ctrl_O); if (which_button == MOUSE_LEFT) stuffcharReadbuff('*'); --- 905,911 ---- // the mouse pointer else if ((mod_mask & MOD_MASK_SHIFT)) { ! if ((State & MODE_INSERT) || (VIsual_active && VIsual_select)) stuffcharReadbuff(Ctrl_O); if (which_button == MOUSE_LEFT) stuffcharReadbuff('*'); *************** *** 934,940 **** } #endif } ! else if ((mod_mask & MOD_MASK_MULTI_CLICK) && (State & (NORMAL | INSERT)) && mouse_has(MOUSE_VISUAL)) { if (is_click || !VIsual_active) --- 934,941 ---- } #endif } ! else if ((mod_mask & MOD_MASK_MULTI_CLICK) ! && (State & (MODE_NORMAL | MODE_INSERT)) && mouse_has(MOUSE_VISUAL)) { if (is_click || !VIsual_active) *************** *** 1441,1453 **** if (VIsual_active) checkfor = MOUSE_VISUAL; ! else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) checkfor = MOUSE_RETURN; ! else if (State & INSERT) checkfor = MOUSE_INSERT; ! else if (State & CMDLINE) checkfor = MOUSE_COMMAND; ! else if (State == CONFIRM || State == EXTERNCMD) checkfor = ' '; // don't use mouse for ":confirm" or ":!cmd" else checkfor = MOUSE_NORMAL; // assume normal mode --- 1442,1455 ---- if (VIsual_active) checkfor = MOUSE_VISUAL; ! else if (State == MODE_HITRETURN || State == MODE_ASKMORE ! || State == MODE_SETWSIZE) checkfor = MOUSE_RETURN; ! else if (State & MODE_INSERT) checkfor = MOUSE_INSERT; ! else if (State & MODE_CMDLINE) checkfor = MOUSE_COMMAND; ! else if (State == MODE_CONFIRM || State == MODE_EXTERNCMD) checkfor = ' '; // don't use mouse for ":confirm" or ":!cmd" else checkfor = MOUSE_NORMAL; // assume normal mode *** ../vim-8.2.4910/src/netbeans.c 2022-01-04 19:57:50.930919989 +0000 --- src/netbeans.c 2022-05-07 18:55:28.672054813 +0100 *************** *** 1843,1849 **** out_flush_cursor(TRUE, FALSE); // Quit a hit-return or more prompt. ! if (State == HITRETURN || State == ASKMORE) { #ifdef FEAT_GUI_GTK if (gui.in_use && gtk_main_level() > 0) --- 1843,1849 ---- out_flush_cursor(TRUE, FALSE); // Quit a hit-return or more prompt. ! if (State == MODE_HITRETURN || State == MODE_ASKMORE) { #ifdef FEAT_GUI_GTK if (gui.in_use && gtk_main_level() > 0) *************** *** 2229,2235 **** out_flush_cursor(TRUE, FALSE); // Quit a hit-return or more prompt. ! if (State == HITRETURN || State == ASKMORE) { #ifdef FEAT_GUI_GTK if (gui.in_use && gtk_main_level() > 0) --- 2229,2235 ---- out_flush_cursor(TRUE, FALSE); // Quit a hit-return or more prompt. ! if (State == MODE_HITRETURN || State == MODE_ASKMORE) { #ifdef FEAT_GUI_GTK if (gui.in_use && gtk_main_level() > 0) *************** *** 2323,2329 **** strcpy(&keybuf[i], tok); vim_snprintf(cmdbuf, sizeof(cmdbuf), "<%s> :nbkey %s", keybuf, keybuf); ! do_map(0, (char_u *)cmdbuf, NORMAL, FALSE); } tok = strtok(NULL, " "); } --- 2323,2329 ---- strcpy(&keybuf[i], tok); vim_snprintf(cmdbuf, sizeof(cmdbuf), "<%s> :nbkey %s", keybuf, keybuf); ! do_map(0, (char_u *)cmdbuf, MODE_NORMAL, FALSE); } tok = strtok(NULL, " "); } *** ../vim-8.2.4910/src/normal.c 2022-05-06 11:44:03.811966282 +0100 --- src/normal.c 2022-05-07 18:51:28.716198039 +0100 *************** *** 391,397 **** { if (repl) { ! State = REPLACE; // pretend Replace mode #ifdef CURSOR_SHAPE ui_cursor_shape(); // show different cursor shape #endif --- 391,397 ---- { if (repl) { ! State = MODE_REPLACE; // pretend Replace mode #ifdef CURSOR_SHAPE ui_cursor_shape(); // show different cursor shape #endif *************** *** 402,410 **** --no_mapping; --allow_keys; if (repl) ! State = LREPLACE; else ! State = LANGMAP; langmap_active = TRUE; } #ifdef HAVE_INPUT_METHOD --- 402,410 ---- --no_mapping; --allow_keys; if (repl) ! State = MODE_LREPLACE; else ! State = MODE_LANGMAP; langmap_active = TRUE; } #ifdef HAVE_INPUT_METHOD *************** *** 413,419 **** if (lang && curbuf->b_p_iminsert == B_IMODE_IM) im_set_active(TRUE); #endif ! if ((State & INSERT) && !p_ek) { #ifdef FEAT_JOB_CHANNEL ch_log_output = TRUE; --- 413,419 ---- if (lang && curbuf->b_p_iminsert == B_IMODE_IM) im_set_active(TRUE); #endif ! if ((State & MODE_INSERT) && !p_ek) { #ifdef FEAT_JOB_CHANNEL ch_log_output = TRUE; *************** *** 426,432 **** *cp = plain_vgetc(); ! if ((State & INSERT) && !p_ek) { #ifdef FEAT_JOB_CHANNEL ch_log_output = TRUE; --- 426,432 ---- *cp = plain_vgetc(); ! if ((State & MODE_INSERT) && !p_ek) { #ifdef FEAT_JOB_CHANNEL ch_log_output = TRUE; *************** *** 441,447 **** // Undo the decrement done above ++no_mapping; ++allow_keys; ! State = NORMAL_BUSY; } #ifdef HAVE_INPUT_METHOD if (lang) --- 441,447 ---- // Undo the decrement done above ++no_mapping; ++allow_keys; ! State = MODE_NORMAL_BUSY; } #ifdef HAVE_INPUT_METHOD if (lang) *************** *** 452,458 **** } p_smd = save_smd; #endif ! State = NORMAL_BUSY; #ifdef FEAT_CMDL_INFO *need_flushbuf |= add_to_showcmd(*cp); #endif --- 452,458 ---- } p_smd = save_smd; #endif ! State = MODE_NORMAL_BUSY; #ifdef FEAT_CMDL_INFO *need_flushbuf |= add_to_showcmd(*cp); #endif *************** *** 606,612 **** // Draw the cursor with the right shape here if (restart_edit != 0) ! State = INSERT; // If need to redraw, and there is a "keep_msg", redraw before the // delay --- 606,612 ---- // Draw the cursor with the right shape here if (restart_edit != 0) ! State = MODE_INSERT; // If need to redraw, and there is a "keep_msg", redraw before the // delay *************** *** 714,720 **** mapped_len = typebuf_maplen(); ! State = NORMAL_BUSY; #ifdef USE_ON_FLY_SCROLL dont_scroll = FALSE; // allow scrolling here #endif --- 714,720 ---- mapped_len = typebuf_maplen(); ! State = MODE_NORMAL_BUSY; #ifdef USE_ON_FLY_SCROLL dont_scroll = FALSE; // allow scrolling here #endif *************** *** 731,737 **** * Get the command character from the user. */ c = safe_vgetc(); ! LANGMAP_ADJUST(c, get_real_state() != SELECTMODE); // If a mapping was started in Visual or Select mode, remember the length // of the mapping. This is used below to not return to Insert mode for as --- 731,737 ---- * Get the command character from the user. */ c = safe_vgetc(); ! LANGMAP_ADJUST(c, get_real_state() != MODE_SELECT); // If a mapping was started in Visual or Select mode, remember the length // of the mapping. This is used below to not return to Insert mode for as *************** *** 888,894 **** did_cursorhold = FALSE; } ! State = NORMAL; if (ca.nchar == ESC) { --- 888,894 ---- did_cursorhold = FALSE; } ! State = MODE_NORMAL; if (ca.nchar == ESC) { *************** *** 4873,4879 **** // composing characters for utf-8. for (n = cap->count1; n > 0; --n) { ! State = REPLACE; if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { int c = ins_copychar(curwin->w_cursor.lnum --- 4873,4879 ---- // composing characters for utf-8. for (n = cap->count1; n > 0; --n) { ! State = MODE_REPLACE; if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { int c = ins_copychar(curwin->w_cursor.lnum *************** *** 6831,6837 **** // Pretend Insert mode here to allow the cursor on the // character past the end of the line ! State = INSERT; coladvance((colnr_T)MAXCOL); State = save_State; } --- 6831,6837 ---- // Pretend Insert mode here to allow the cursor on the // character past the end of the line ! State = MODE_INSERT; coladvance((colnr_T)MAXCOL); State = save_State; } *************** *** 6983,6989 **** // Pretend Insert mode here to allow the cursor on the // character past the end of the line ! State = INSERT; coladvance(getviscol()); State = save_State; } --- 6983,6989 ---- // Pretend Insert mode here to allow the cursor on the // character past the end of the line ! State = MODE_INSERT; coladvance(getviscol()); State = save_State; } *** ../vim-8.2.4910/src/ops.c 2022-03-22 20:42:09.174172862 +0000 --- src/ops.c 2022-05-07 19:46:45.751684606 +0100 *************** *** 294,300 **** p_ri = 0; // don't want revins in indent #endif ! State = INSERT; // don't want REPLACE for State block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE); if (bd.is_short) return; --- 294,300 ---- p_ri = 0; // don't want revins in indent #endif ! State = MODE_INSERT; // don't want MODE_REPLACE for State block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE); if (bd.is_short) return; *************** *** 488,494 **** linenr_T lnum; // loop var int oldstate = State; ! State = INSERT; // don't want REPLACE for State s_len = (unsigned)STRLEN(s); for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++) --- 488,494 ---- linenr_T lnum; // loop var int oldstate = State; ! State = MODE_INSERT; // don't want MODE_REPLACE for State s_len = (unsigned)STRLEN(s); for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++) *************** *** 991,997 **** { int n = State; ! State = REPLACE; ins_char(c); State = n; // Backup to the replaced character. --- 991,997 ---- { int n = State; ! State = MODE_REPLACE; ins_char(c); State = n; // Backup to the replaced character. *************** *** 1842,1848 **** if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL && (cur_ve_flags & VE_ONEMORE) == 0 ! && !(restart_edit || (State & INSERT))) { // Put the cursor on the last character in the line. dec_cursor(); --- 1842,1848 ---- if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL && (cur_ve_flags & VE_ONEMORE) == 0 ! && !(restart_edit || (State & MODE_INSERT))) { // Put the cursor on the last character in the line. dec_cursor(); *** ../vim-8.2.4910/src/option.c 2022-04-15 13:53:30.040708711 +0100 --- src/option.c 2022-05-07 18:37:04.428715092 +0100 *************** *** 2915,2921 **** { if (p_im) { ! if ((State & INSERT) == 0) need_start_insertmode = TRUE; stop_insert_mode = FALSE; } --- 2915,2921 ---- { if (p_im) { ! if ((State & MODE_INSERT) == 0) need_start_insertmode = TRUE; stop_insert_mode = FALSE; } *************** *** 3110,3116 **** // Only de-activate it here, it will be enabled when changing mode. if (p_imdisable) im_set_active(FALSE); ! else if (State & INSERT) // When the option is set from an autocommand, it may need to take // effect right away. im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); --- 3110,3116 ---- // Only de-activate it here, it will be enabled when changing mode. if (p_imdisable) im_set_active(FALSE); ! else if (State & MODE_INSERT) // When the option is set from an autocommand, it may need to take // effect right away. im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); *** ../vim-8.2.4910/src/os_unix.c 2022-04-12 15:08:36.673207621 +0100 --- src/os_unix.c 2022-05-07 18:58:30.251946467 +0100 *************** *** 4976,4982 **** p_more_save = p_more; p_more = FALSE; old_State = State; ! State = EXTERNCMD; // don't redraw at window resize if ((options & SHELL_WRITE) && toshell_fd >= 0) { --- 4976,4982 ---- p_more_save = p_more; p_more = FALSE; old_State = State; ! State = MODE_EXTERNCMD; // don't redraw at window resize if ((options & SHELL_WRITE) && toshell_fd >= 0) { *** ../vim-8.2.4910/src/os_win32.c 2022-05-07 14:09:14.708852889 +0100 --- src/os_win32.c 2022-05-07 19:47:54.463608090 +0100 *************** *** 1678,1684 **** # ifdef FEAT_MBYTE_IME // May have to redraw if the cursor ends up in the wrong place. // Only when not peeking. ! if (State & CMDLINE && msg_row == Rows - 1 && msec != 0) { CONSOLE_SCREEN_BUFFER_INFO csbi; --- 1678,1684 ---- # ifdef FEAT_MBYTE_IME // May have to redraw if the cursor ends up in the wrong place. // Only when not peeking. ! if (State == MODE_CMDLINE && msg_row == Rows - 1 && msec != 0) { CONSOLE_SCREEN_BUFFER_INFO csbi; *** ../vim-8.2.4910/src/popupmenu.c 2022-04-15 13:53:30.052708679 +0100 --- src/popupmenu.c 2022-05-07 18:10:54.317734141 +0100 *************** *** 101,107 **** win_T *pvwin; #endif #ifdef FEAT_RIGHTLEFT ! int right_left = State == CMDLINE ? FALSE : curwin->w_p_rl; #endif do --- 101,107 ---- win_T *pvwin; #endif #ifdef FEAT_RIGHTLEFT ! int right_left = State == MODE_CMDLINE ? FALSE : curwin->w_p_rl; #endif do *************** *** 119,125 **** // Remember the essential parts of the window position and size, so we // can decide when to reposition the popup menu. pum_window = curwin; ! if (State == CMDLINE) // cmdline completion popup menu pum_win_row = cmdline_row; else --- 119,125 ---- // Remember the essential parts of the window position and size, so we // can decide when to reposition the popup menu. pum_window = curwin; ! if (State == MODE_CMDLINE) // cmdline completion popup menu pum_win_row = cmdline_row; else *************** *** 159,165 **** { // pum above "pum_win_row" ! if (State == CMDLINE) // for cmdline pum, no need for context lines context_lines = 0; else --- 159,165 ---- { // pum above "pum_win_row" ! if (State == MODE_CMDLINE) // for cmdline pum, no need for context lines context_lines = 0; else *************** *** 191,197 **** { // pum below "pum_win_row" ! if (State == CMDLINE) // for cmdline pum, no need for context lines context_lines = 0; else --- 191,197 ---- { // pum below "pum_win_row" ! if (State == MODE_CMDLINE) // for cmdline pum, no need for context lines context_lines = 0; else *************** *** 235,241 **** // Calculate column #ifdef FEAT_WILDMENU ! if (State == CMDLINE) // cmdline completion popup menu cursor_col = cmdline_compl_startcol(); else --- 235,241 ---- // Calculate column #ifdef FEAT_WILDMENU ! if (State == MODE_CMDLINE) // cmdline completion popup menu cursor_col = cmdline_compl_startcol(); else *** ../vim-8.2.4910/src/search.c 2022-04-16 20:42:36.624782044 +0100 --- src/search.c 2022-05-07 18:58:58.195929793 +0100 *************** *** 2860,2866 **** save_dollar_vcol = dollar_vcol; #ifdef CURSOR_SHAPE save_state = State; ! State = SHOWMATCH; ui_cursor_shape(); // may show different cursor shape #endif curwin->w_cursor = mpos; // move to matching char --- 2860,2866 ---- save_dollar_vcol = dollar_vcol; #ifdef CURSOR_SHAPE save_state = State; ! State = MODE_SHOWMATCH; ui_cursor_shape(); // may show different cursor shape #endif curwin->w_cursor = mpos; // move to matching char *** ../vim-8.2.4910/src/tag.c 2022-04-04 15:16:50.742014128 +0100 --- src/tag.c 2022-05-07 18:37:21.012705124 +0100 *************** *** 2642,2648 **** vim_strncpy(mfp, tagpp->tagname, len); // if wanted, re-read line to get long form too ! if (State & INSERT) st->get_searchpat = p_sft; } } --- 2642,2648 ---- vim_strncpy(mfp, tagpp->tagname, len); // if wanted, re-read line to get long form too ! if (State & MODE_INSERT) st->get_searchpat = p_sft; } } *** ../vim-8.2.4910/src/screen.c 2022-04-09 12:39:51.559956642 +0100 --- src/screen.c 2022-05-07 18:37:13.332709745 +0100 *************** *** 68,80 **** if (*wp->w_p_cocu == NUL) return FALSE; ! if (get_real_state() & VISUAL) c = 'v'; ! else if (State & INSERT) c = 'i'; ! else if (State & NORMAL) c = 'n'; ! else if (State & CMDLINE) c = 'c'; else return FALSE; --- 68,80 ---- if (*wp->w_p_cocu == NUL) return FALSE; ! if (get_real_state() & MODE_VISUAL) c = 'v'; ! else if (State & MODE_INSERT) c = 'i'; ! else if (State & MODE_NORMAL) c = 'n'; ! else if (State & MODE_CMDLINE) c = 'c'; else return FALSE; *************** *** 4164,4170 **** int sub_attr; do_mode = ((p_smd && msg_silent == 0) ! && ((State & INSERT) || restart_edit != NUL || VIsual_active)); if (do_mode || reg_recording != 0) --- 4164,4170 ---- int sub_attr; do_mode = ((p_smd && msg_silent == 0) ! && ((State & MODE_INSERT) || restart_edit != NUL || VIsual_active)); if (do_mode || reg_recording != 0) *************** *** 4238,4244 **** msg_puts_attr(_(" VREPLACE"), attr); else if (State & REPLACE_FLAG) msg_puts_attr(_(" REPLACE"), attr); ! else if (State & INSERT) { #ifdef FEAT_RIGHTLEFT if (p_ri) --- 4238,4244 ---- msg_puts_attr(_(" VREPLACE"), attr); else if (State & REPLACE_FLAG) msg_puts_attr(_(" REPLACE"), attr); ! else if (State & MODE_INSERT) { #ifdef FEAT_RIGHTLEFT if (p_ri) *************** *** 4258,4264 **** msg_puts_attr(_(" Hebrew"), attr); #endif #ifdef FEAT_KEYMAP ! if (State & LANGMAP) { # ifdef FEAT_ARABIC if (curwin->w_p_arab) --- 4258,4264 ---- msg_puts_attr(_(" Hebrew"), attr); #endif #ifdef FEAT_KEYMAP ! if (State & MODE_LANGMAP) { # ifdef FEAT_ARABIC if (curwin->w_p_arab) *************** *** 4270,4276 **** msg_puts_attr((char *)NameBuff, attr); } #endif ! if ((State & INSERT) && p_paste) msg_puts_attr(_(" (paste)"), attr); if (VIsual_active) --- 4270,4276 ---- msg_puts_attr((char *)NameBuff, attr); } #endif ! if ((State & MODE_INSERT) && p_paste) msg_puts_attr(_(" (paste)"), attr); if (VIsual_active) *** ../vim-8.2.4910/src/term.c 2022-05-07 14:09:14.708852889 +0100 --- src/term.c 2022-05-07 19:48:54.563541363 +0100 *************** *** 2180,2186 **** #if defined(EXITFREE) || defined(PROTO) # ifdef HAVE_DEL_CURTERM - # undef TERMINAL // name clash in term.h # include // declares cur_term # endif --- 2180,2185 ---- *************** *** 3468,3477 **** if (width < 0 || height < 0) // just checking... return; ! if (State == HITRETURN || State == SETWSIZE) { // postpone the resizing ! State = SETWSIZE; return; } --- 3467,3476 ---- if (width < 0 || height < 0) // just checking... return; ! if (State == MODE_HITRETURN || State == MODE_SETWSIZE) { // postpone the resizing ! State = MODE_SETWSIZE; return; } *************** *** 3507,3513 **** // screenalloc() (also invoked from screenclear()). That is because the // "busy" check above may skip this, but not screenalloc(). ! if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) screenclear(); else screen_start(); // don't know where cursor is now --- 3506,3513 ---- // screenalloc() (also invoked from screenclear()). That is because the // "busy" check above may skip this, but not screenalloc(). ! if (State != MODE_ASKMORE && State != MODE_EXTERNCMD ! && State != MODE_CONFIRM) screenclear(); else screen_start(); // don't know where cursor is now *************** *** 3529,3536 **** * Always need to call update_screen() or screenalloc(), to make * sure Rows/Columns and the size of ScreenLines[] is correct! */ ! if (State == ASKMORE || State == EXTERNCMD || State == CONFIRM ! || exmode_active) { screenalloc(FALSE); repeat_message(); --- 3529,3536 ---- * Always need to call update_screen() or screenalloc(), to make * sure Rows/Columns and the size of ScreenLines[] is correct! */ ! if (State == MODE_ASKMORE || State == MODE_EXTERNCMD ! || State == MODE_CONFIRM || exmode_active) { screenalloc(FALSE); repeat_message(); *************** *** 3539,3545 **** { if (curwin->w_p_scb) do_check_scrollbind(TRUE); ! if (State & CMDLINE) { update_screen(NOT_VALID); redrawcmdline(); --- 3539,3545 ---- { if (curwin->w_p_scb) do_check_scrollbind(TRUE); ! if (State & MODE_CMDLINE) { update_screen(NOT_VALID); redrawcmdline(); *************** *** 4056,4064 **** return; } ! if ((State & REPLACE) == REPLACE) { ! if (forced || showing_mode != REPLACE) { if (*T_CSR != NUL) p = T_CSR; // Replace mode cursor --- 4056,4064 ---- return; } ! if ((State & MODE_REPLACE) == MODE_REPLACE) { ! if (forced || showing_mode != MODE_REPLACE) { if (*T_CSR != NUL) p = T_CSR; // Replace mode cursor *************** *** 4067,4088 **** if (*p != NUL) { out_str(p); ! showing_mode = REPLACE; } } } ! else if (State & INSERT) { ! if ((forced || showing_mode != INSERT) && *T_CSI != NUL) { out_str(T_CSI); // Insert mode cursor ! showing_mode = INSERT; } } ! else if (forced || showing_mode != NORMAL) { out_str(T_CEI); // non-Insert mode cursor ! showing_mode = NORMAL; } } --- 4067,4088 ---- if (*p != NUL) { out_str(p); ! showing_mode = MODE_REPLACE; } } } ! else if (State & MODE_INSERT) { ! if ((forced || showing_mode != MODE_INSERT) && *T_CSI != NUL) { out_str(T_CSI); // Insert mode cursor ! showing_mode = MODE_INSERT; } } ! else if (forced || showing_mode != MODE_NORMAL) { out_str(T_CEI); // non-Insert mode cursor ! showing_mode = MODE_NORMAL; } } *************** *** 5400,5406 **** * Skip this position if p_ek is not set and tp[0] is an ESC and we * are in Insert mode. */ ! if (*tp == ESC && !p_ek && (State & INSERT)) continue; key_name[0] = NUL; // no key name found yet --- 5400,5406 ---- * Skip this position if p_ek is not set and tp[0] is an ESC and we * are in Insert mode. */ ! if (*tp == ESC && !p_ek && (State & MODE_INSERT)) continue; key_name[0] = NUL; // no key name found yet *** ../vim-8.2.4910/src/terminal.c 2022-05-07 16:38:20.489315665 +0100 --- src/terminal.c 2022-05-07 18:37:33.512697631 +0100 *************** *** 1267,1273 **** // cleared. // TODO: only update once in a while. ch_log(term->tl_job->jv_channel, "updating screen"); ! if (buffer == curbuf && (State & CMDLINE) == 0) { update_screen(VALID_NO_UPDATE); // update_screen() can be slow, check the terminal wasn't closed --- 1267,1273 ---- // cleared. // TODO: only update once in a while. ch_log(term->tl_job->jv_channel, "updating screen"); ! if (buffer == curbuf && (State & MODE_CMDLINE) == 0) { update_screen(VALID_NO_UPDATE); // update_screen() can be slow, check the terminal wasn't closed *************** *** 2129,2135 **** int modify_other_keys = curbuf->b_term->tl_vterm == NULL ? FALSE : vterm_is_modify_other_keys(curbuf->b_term->tl_vterm); ! State = TERMINAL; got_int = FALSE; #ifdef MSWIN ctrl_break_was_pressed = FALSE; --- 2129,2135 ---- int modify_other_keys = curbuf->b_term->tl_vterm == NULL ? FALSE : vterm_is_modify_other_keys(curbuf->b_term->tl_vterm); ! State = MODE_TERMINAL; got_int = FALSE; #ifdef MSWIN ctrl_break_was_pressed = FALSE; *************** *** 2508,2514 **** if (term_use_loop_check(TRUE)) { reset_VIsual_and_resel(); ! if (State & INSERT) stop_insert_mode = TRUE; } mouse_was_outside = FALSE; --- 2508,2514 ---- if (term_use_loop_check(TRUE)) { reset_VIsual_and_resel(); ! if (State & MODE_INSERT) stop_insert_mode = TRUE; } mouse_was_outside = FALSE; *** ../vim-8.2.4910/src/textformat.c 2022-05-07 15:43:48.969787528 +0100 --- src/textformat.c 2022-05-07 19:49:26.663505763 +0100 *************** *** 330,336 **** undisplay_dollar(); // Offset between cursor position and line break is used by replace ! // stack functions. VREPLACE does not use this, and backspaces // over the text instead. if (State & VREPLACE_FLAG) orig_col = startcol; // Will start backspacing from here --- 330,336 ---- undisplay_dollar(); // Offset between cursor position and line break is used by replace ! // stack functions. MODE_VREPLACE does not use this, and backspaces // over the text instead. if (State & VREPLACE_FLAG) orig_col = startcol; // Will start backspacing from here *************** *** 349,355 **** if (State & VREPLACE_FLAG) { ! // In VREPLACE mode, we will backspace over the text to be // wrapped, so save a copy now to put on the next line. saved_text = vim_strsave(ml_get_cursor()); curwin->w_cursor.col = orig_col; --- 349,355 ---- if (State & VREPLACE_FLAG) { ! // In MODE_VREPLACE state, we will backspace over the text to be // wrapped, so save a copy now to put on the next line. saved_text = vim_strsave(ml_get_cursor()); curwin->w_cursor.col = orig_col; *************** *** 428,434 **** if (State & VREPLACE_FLAG) { ! // In VREPLACE mode we have backspaced over the text to be // moved, now we re-insert it into the new line. ins_bytes(saved_text); vim_free(saved_text); --- 428,434 ---- if (State & VREPLACE_FLAG) { ! // In MODE_VREPLACE state we have backspaced over the text to be // moved, now we re-insert it into the new line. ins_bytes(saved_text); vim_free(saved_text); *************** *** 1143,1155 **** } // put cursor on last non-space ! State = NORMAL; // don't go past end-of-line coladvance((colnr_T)MAXCOL); while (curwin->w_cursor.col && vim_isspace(gchar_cursor())) dec_cursor(); // do the formatting, without 'showmode' ! State = INSERT; // for open_line() smd_save = p_smd; p_smd = FALSE; insertchar(NUL, INSCHAR_FORMAT --- 1143,1155 ---- } // put cursor on last non-space ! State = MODE_NORMAL; // don't go past end-of-line coladvance((colnr_T)MAXCOL); while (curwin->w_cursor.col && vim_isspace(gchar_cursor())) dec_cursor(); // do the formatting, without 'showmode' ! State = MODE_INSERT; // for open_line() smd_save = p_smd; p_smd = FALSE; insertchar(NUL, INSCHAR_FORMAT *** ../vim-8.2.4910/src/window.c 2022-05-04 22:12:34.125942208 +0100 --- src/window.c 2022-05-07 18:38:01.948680591 +0100 *************** *** 2259,2265 **** // When leaving the window (or closing the window) was done from a // callback we need to break out of the Insert mode loop and restart Insert // mode when entering the window again. ! if (State & INSERT) { stop_insert_mode = TRUE; if (win->w_buffer->b_prompt_insert == NUL) --- 2259,2265 ---- // When leaving the window (or closing the window) was done from a // callback we need to break out of the Insert mode loop and restart Insert // mode when entering the window again. ! if (State & MODE_INSERT) { stop_insert_mode = TRUE; if (win->w_buffer->b_prompt_insert == NUL) *************** *** 2281,2287 **** // When entering the prompt window restart Insert mode if we were in Insert // mode when we left it and not already in Insert mode. ! if ((State & INSERT) == 0) restart_edit = win->w_buffer->b_prompt_insert; } #endif --- 2281,2287 ---- // When entering the prompt window restart Insert mode if we were in Insert // mode when we left it and not already in Insert mode. ! if ((State & MODE_INSERT) == 0) restart_edit = win->w_buffer->b_prompt_insert; } #endif *** ../vim-8.2.4910/src/version.c 2022-05-07 17:45:12.414944752 +0100 --- src/version.c 2022-05-07 20:00:15.266791713 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4911, /**/ -- All true wisdom is found on T-shirts. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///