diff options
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 1199 |
1 files changed, 598 insertions, 601 deletions
diff --git a/src/edit.c b/src/edit.c index 4f53333cde..c67f67cb39 100644 --- a/src/edit.c +++ b/src/edit.c @@ -18,8 +18,8 @@ #define BACKSPACE_WORD_NOT_SPACE 3 #define BACKSPACE_LINE 4 -/* Set when doing something for completion that may call edit() recursively, - * which is not allowed. */ +// Set when doing something for completion that may call edit() recursively, +// which is not allowed. static int compl_busy = FALSE; @@ -79,30 +79,30 @@ static int ins_ctrl_ey(int tc); static char_u *do_insert_char_pre(int c); #endif -static colnr_T Insstart_textlen; /* length of line when insert started */ -static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */ -static int update_Insstart_orig = TRUE; /* set Insstart_orig to Insstart */ +static colnr_T Insstart_textlen; // length of line when insert started +static colnr_T Insstart_blank_vcol; // vcol for first inserted blank +static int update_Insstart_orig = TRUE; // set Insstart_orig to Insstart -static char_u *last_insert = NULL; /* the text of the previous insert, - K_SPECIAL and CSI are escaped */ -static int last_insert_skip; /* nr of chars in front of previous insert */ -static int new_insert_skip; /* nr of chars in front of current insert */ -static int did_restart_edit; /* "restart_edit" when calling edit() */ +static char_u *last_insert = NULL; // the text of the previous insert, + // K_SPECIAL and CSI are escaped +static int last_insert_skip; // nr of chars in front of previous insert +static int new_insert_skip; // nr of chars in front of current insert +static int did_restart_edit; // "restart_edit" when calling edit() #ifdef FEAT_CINDENT -static int can_cindent; /* may do cindenting on this line */ +static int can_cindent; // may do cindenting on this line #endif #ifdef FEAT_RIGHTLEFT -static int revins_on; /* reverse insert mode on */ -static int revins_chars; /* how much to skip after edit */ -static int revins_legal; /* was the last char 'legal'? */ -static int revins_scol; /* start column of revins session */ +static int revins_on; // reverse insert mode on +static int revins_chars; // how much to skip after edit +static int revins_legal; // was the last char 'legal'? +static int revins_scol; // start column of revins session #endif -static int ins_need_undo; /* call u_save() before inserting a - char. Set when edit() is called. - after that arrow_used is used. */ +static int ins_need_undo; // call u_save() before inserting a + // char. Set when edit() is called. + // after that arrow_used is used. static int did_add_space = FALSE; // auto_format() added an extra space // under the cursor @@ -131,7 +131,7 @@ static int dont_sync_undo = FALSE; // CTRL-G U prevents syncing undo for int edit( int cmdchar, - int startln, /* if set, insert at start of line */ + int startln, // if set, insert at start of line long count) { int c = 0; @@ -140,54 +140,54 @@ edit( int mincol; static linenr_T o_lnum = 0; int i; - int did_backspace = TRUE; /* previous char was backspace */ + int did_backspace = TRUE; // previous char was backspace #ifdef FEAT_CINDENT - int line_is_white = FALSE; /* line is empty before insert */ + int line_is_white = FALSE; // line is empty before insert #endif - linenr_T old_topline = 0; /* topline before insertion */ + linenr_T old_topline = 0; // topline before insertion #ifdef FEAT_DIFF int old_topfill = -1; #endif - int inserted_space = FALSE; /* just inserted a space */ + int inserted_space = FALSE; // just inserted a space int replaceState = REPLACE; - int nomove = FALSE; /* don't move cursor on return */ + int nomove = FALSE; // don't move cursor on return #ifdef FEAT_JOB_CHANNEL int cmdchar_todo = cmdchar; #endif - /* Remember whether editing was restarted after CTRL-O. */ + // Remember whether editing was restarted after CTRL-O. did_restart_edit = restart_edit; - /* sleep before redrawing, needed for "CTRL-O :" that results in an - * error message */ + // sleep before redrawing, needed for "CTRL-O :" that results in an + // error message check_for_delay(TRUE); - /* set Insstart_orig to Insstart */ + // set Insstart_orig to Insstart update_Insstart_orig = TRUE; #ifdef HAVE_SANDBOX - /* Don't allow inserting in the sandbox. */ + // Don't allow inserting in the sandbox. if (sandbox != 0) { emsg(_(e_sandbox)); return FALSE; } #endif - /* Don't allow changes in the buffer while editing the cmdline. The - * caller of getcmdline() may get confused. */ + // Don't allow changes in the buffer while editing the cmdline. The + // caller of getcmdline() may get confused. if (textlock != 0) { emsg(_(e_secure)); return FALSE; } - /* Don't allow recursive insert mode when busy with completion. */ + // Don't allow recursive insert mode when busy with completion. if (ins_compl_active() || compl_busy || pum_visible()) { emsg(_(e_secure)); return FALSE; } - ins_compl_clear(); /* clear stuff for CTRL-X mode */ + ins_compl_clear(); // clear stuff for CTRL-X mode /* * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". @@ -204,16 +204,16 @@ edit( else ptr = (char_u *)"i"; set_vim_var_string(VV_INSERTMODE, ptr, 1); - set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */ + set_vim_var_string(VV_CHAR, NULL, -1); // clear v:char #endif ins_apply_autocmds(EVENT_INSERTENTER); - /* Make sure the cursor didn't move. Do call check_cursor_col() in - * case the text was modified. Since Insert mode was not started yet - * a call to check_cursor_col() may move the cursor, especially with - * the "A" command, thus set State to avoid that. Also check that the - * line number is still valid (lines may have been deleted). - * Do not restore if v:char was set to a non-empty string. */ + // Make sure the cursor didn't move. Do call check_cursor_col() in + // case the text was modified. Since Insert mode was not started yet + // a call to check_cursor_col() may move the cursor, especially with + // the "A" command, thus set State to avoid that. Also check that the + // line number is still valid (lines may have been deleted). + // Do not restore if v:char was set to a non-empty string. if (!EQUAL_POS(curwin->w_cursor, save_cursor) #ifdef FEAT_EVAL && *get_vim_var_str(VV_CHAR) == NUL @@ -230,8 +230,8 @@ edit( } #ifdef FEAT_CONCEAL - /* Check if the cursor line needs redrawing before changing State. If - * 'concealcursor' is "n" it needs to be redrawn without concealing. */ + // Check if the cursor line needs redrawing before changing State. If + // 'concealcursor' is "n" it needs to be redrawn without concealing. conceal_check_cursor_line(); #endif @@ -258,7 +258,7 @@ edit( AppendNumberToRedobuff(count); if (cmdchar == 'V' || cmdchar == 'v') { - /* "gR" or "gr" command */ + // "gR" or "gr" command AppendCharToRedobuff('g'); AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R'); } @@ -268,10 +268,10 @@ edit( AppendCharToRedobuff('a'); else AppendCharToRedobuff(cmdchar); - if (cmdchar == 'g') /* "gI" command */ + if (cmdchar == 'g') // "gI" command AppendCharToRedobuff('I'); - else if (cmdchar == 'r') /* "r<CR>" command */ - count = 1; /* insert only one <CR> */ + else if (cmdchar == 'r') // "r<CR>" command + count = 1; // insert only one <CR> } } @@ -314,7 +314,7 @@ edit( clear_showcmd(); #endif #ifdef FEAT_RIGHTLEFT - /* there is no reverse replace mode */ + // there is no reverse replace mode revins_on = (State == INSERT && p_ri); if (revins_on) undisplay_dollar(); @@ -377,10 +377,10 @@ edit( else arrow_used = FALSE; - /* we are in insert mode now, don't need to start it anymore */ + // we are in insert mode now, don't need to start it anymore need_start_insertmode = FALSE; - /* Need to save the line for undo before inserting the first char. */ + // Need to save the line for undo before inserting the first char. ins_need_undo = TRUE; where_paste_started.lnum = 0; @@ -388,8 +388,8 @@ edit( can_cindent = TRUE; #endif #ifdef FEAT_FOLDING - /* The cursor line is not in a closed fold, unless 'insertmode' is set or - * restarting. */ + // The cursor line is not in a closed fold, unless 'insertmode' is set or + // restarting. if (!p_im && did_restart_edit == 0) foldOpenCursor(); #endif @@ -407,10 +407,10 @@ edit( change_warning(i == 0 ? 0 : i + 1); #ifdef CURSOR_SHAPE - ui_cursor_shape(); /* may show different cursor shape */ + ui_cursor_shape(); // may show different cursor shape #endif #ifdef FEAT_DIGRAPHS - do_digraph(-1); /* clear digraphs */ + do_digraph(-1); // clear digraphs #endif /* @@ -435,11 +435,11 @@ edit( { #ifdef FEAT_RIGHTLEFT if (!revins_legal) - revins_scol = -1; /* reset on illegal motions */ + revins_scol = -1; // reset on illegal motions else revins_legal = 0; #endif - if (arrow_used) /* don't repeat insert when arrow key used */ + if (arrow_used) // don't repeat insert when arrow key used count = 0; if (update_Insstart_orig) @@ -447,17 +447,17 @@ edit( if (stop_insert_mode && !pum_visible()) { - /* ":stopinsert" used or 'insertmode' reset */ + // ":stopinsert" used or 'insertmode' reset count = 0; goto doESCkey; } - /* set curwin->w_curswant for next K_DOWN or K_UP */ + // set curwin->w_curswant for next K_DOWN or K_UP if (!arrow_used) curwin->w_set_curswant = TRUE; - /* If there is no typeahead may check for timestamps (e.g., for when a - * menu invoked a shell command). */ + // If there is no typeahead may check for timestamps (e.g., for when a + // menu invoked a shell command). if (stuff_empty()) { did_check_timestamps = FALSE; @@ -471,18 +471,18 @@ edit( msg_scroll = FALSE; #ifdef FEAT_GUI - /* When 'mousefocus' is set a mouse movement may have taken us to - * another window. "need_mouse_correct" may then be set because of an - * autocommand. */ + // When 'mousefocus' is set a mouse movement may have taken us to + // another window. "need_mouse_correct" may then be set because of an + // autocommand. if (need_mouse_correct) gui_mouse_correct(); #endif #ifdef FEAT_FOLDING - /* Open fold at the cursor line, according to 'foldopen'. */ + // Open fold at the cursor line, according to 'foldopen'. if (fdo_flags & FDO_INSERT) foldOpenCursor(); - /* Close folds where the cursor isn't, according to 'foldclose' */ + // Close folds where the cursor isn't, according to 'foldclose' if (!char_avail()) foldCheckClose(); #endif @@ -546,12 +546,12 @@ edit( } } - /* May need to adjust w_topline to show the cursor. */ + // May need to adjust w_topline to show the cursor. update_topline(); did_backspace = FALSE; - validate_cursor(); /* may set must_redraw */ + validate_cursor(); // may set must_redraw /* * Redraw the display when no characters are waiting. @@ -571,22 +571,22 @@ edit( #endif #ifdef USE_ON_FLY_SCROLL - dont_scroll = FALSE; /* allow scrolling here */ + dont_scroll = FALSE; // allow scrolling here #endif /* * Get a character for Insert mode. Ignore K_IGNORE and K_NOP. */ if (c != K_CURSORHOLD) - lastc = c; /* remember the previous char for CTRL-D */ + lastc = c; // remember the previous char for CTRL-D - /* After using CTRL-G U the next cursor key will not break undo. */ + // After using CTRL-G U the next cursor key will not break undo. if (dont_sync_undo == MAYBE) dont_sync_undo = TRUE; else dont_sync_undo = FALSE; if (cmdchar == K_PS) - /* Got here from normal mode when bracketed paste started. */ + // Got here from normal mode when bracketed paste started. c = K_PS; else do @@ -602,12 +602,12 @@ edit( } } while (c == K_IGNORE || c == K_NOP); - /* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */ + // Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. did_cursorhold = TRUE; #ifdef FEAT_RIGHTLEFT if (p_hkmap && KeyTyped) - c = hkmap(c); /* Hebrew mode mapping */ + c = hkmap(c); // Hebrew mode mapping #endif /* @@ -620,18 +620,18 @@ edit( && curwin->w_cursor.col >= ins_compl_col() && ins_compl_has_shown_match()) { - /* BS: Delete one character from "compl_leader". */ + // BS: Delete one character from "compl_leader". if ((c == K_BS || c == Ctrl_H) && curwin->w_cursor.col > ins_compl_col() && (c = ins_compl_bs()) == NUL) continue; - /* When no match was selected or it was edited. */ + // When no match was selected or it was edited. if (!ins_compl_used_match()) { - /* CTRL-L: Add one character from the current match to - * "compl_leader". Except when at the original match and - * there is nothing to add, CTRL-L works like CTRL-P then. */ + // CTRL-L: Add one character from the current match to + // "compl_leader". Except when at the original match and + // there is nothing to add, CTRL-L works like CTRL-P then. if (c == Ctrl_L && (!ctrl_x_mode_line_or_eval() || ins_compl_long_shown_match())) @@ -640,12 +640,12 @@ edit( continue; } - /* A non-white character that fits in with the current - * completion: Add to "compl_leader". */ + // A non-white character that fits in with the current + // completion: Add to "compl_leader". if (ins_compl_accept_char(c)) { #if defined(FEAT_EVAL) - /* Trigger InsertCharPre. */ + // Trigger InsertCharPre. char_u *str = do_insert_char_pre(c); char_u *p; @@ -661,9 +661,9 @@ edit( continue; } - /* Pressing CTRL-Y selects the current match. When - * ins_compl_enter_selects() is set the Enter key does the - * same. */ + // Pressing CTRL-Y selects the current match. When + // ins_compl_enter_selects() is set the Enter key does the + // same. if ((c == Ctrl_Y || (ins_compl_enter_selects() && (c == CAR || c == K_KENTER || c == NL))) && stop_arrow() == OK) @@ -674,18 +674,18 @@ edit( } } - /* Prepare for or stop CTRL-X mode. This doesn't do completion, but - * it does fix up the text when finishing completion. */ + // Prepare for or stop CTRL-X mode. This doesn't do completion, but + // it does fix up the text when finishing completion. ins_compl_init_get_longest(); if (ins_compl_prep(c)) continue; - /* CTRL-\ CTRL-N goes to Normal mode, - * CTRL-\ CTRL-G goes to mode selected with 'insertmode', - * CTRL-\ CTRL-O is like CTRL-O but without moving the cursor. */ + // CTRL-\ CTRL-N goes to Normal mode, + // CTRL-\ CTRL-G goes to mode selected with 'insertmode', + // CTRL-\ CTRL-O is like CTRL-O but without moving the cursor. if (c == Ctrl_BSL) { - /* may need to redraw when no more chars available now */ + // may need to redraw when no more chars available now ins_redraw(FALSE); ++no_mapping; ++allow_keys; @@ -694,7 +694,7 @@ edit( --allow_keys; if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O) { - /* it's something else */ + // it's something else vungetc(c); c = Ctrl_BSL; } @@ -705,7 +705,7 @@ edit( if (c == Ctrl_O) { ins_ctrl_o(); - ins_at_eol = FALSE; /* cursor keeps its column */ + ins_at_eol = FALSE; // cursor keeps its column nomove = TRUE; } count = 0; @@ -722,17 +722,17 @@ edit( if (c == Ctrl_V || c == Ctrl_Q) { ins_ctrl_v(); - c = Ctrl_V; /* pretend CTRL-V is last typed character */ + c = Ctrl_V; // pretend CTRL-V is last typed character continue; } #ifdef FEAT_CINDENT if (cindent_on() && ctrl_x_mode_none()) { - /* A key name preceded by a bang means this key is not to be - * inserted. Skip ahead to the re-indenting below. - * A key name preceded by a star means that indenting has to be - * done before inserting the key. */ + // A key name preceded by a bang means this key is not to be + // inserted. Skip ahead to the re-indenting below. + // A key name preceded by a star means that indenting has to be + // done before inserting the key. line_is_white = inindent(0); if (in_cinkeys(c, '!', line_is_white)) goto force_cindent; @@ -768,18 +768,18 @@ edit( */ switch (c) { - case ESC: /* End input mode */ + case ESC: // End input mode if (echeck_abbr(ESC + ABBR_OFF)) break; - /* FALLTHROUGH */ + // FALLTHROUGH - case Ctrl_C: /* End input mode */ + case Ctrl_C: // End input mode #ifdef FEAT_CMDWIN if (c == Ctrl_C && cmdwin_type != 0) { - /* Close the cmdline window. */ + // Close the cmdline window. cmdwin_result = K_IGNORE; - got_int = FALSE; /* don't stop executing autocommands et al. */ + got_int = FALSE; // don't stop executing autocommands et al. nomove = TRUE; goto doESCkey; } @@ -801,13 +801,13 @@ edit( #ifdef UNIX do_intr: #endif - /* when 'insertmode' set, and not halfway a mapping, don't leave - * Insert mode */ + // when 'insertmode' set, and not halfway a mapping, don't leave + // Insert mode if (goto_im()) { if (got_int) { - (void)vgetc(); /* flush all buffers */ + (void)vgetc(); // flush all buffers got_int = FALSE; } else @@ -818,8 +818,8 @@ doESCkey: /* * This is the ONLY return from edit()! */ - /* Always update o_lnum, so that a "CTRL-O ." that adds a line - * still puts the cursor back after the inserted text. */ + // Always update o_lnum, so that a "CTRL-O ." that adds a line + // still puts the cursor back after the inserted text. if (ins_at_eol && gchar_cursor() == NUL) o_lnum = curwin->w_cursor.lnum; @@ -835,16 +835,16 @@ doESCkey: } continue; - case Ctrl_Z: /* suspend when 'insertmode' set */ + case Ctrl_Z: // suspend when 'insertmode' set if (!p_im) - goto normalchar; /* insert CTRL-Z as normal char */ + goto normalchar; // insert CTRL-Z as normal char do_cmdline_cmd((char_u *)"stop"); #ifdef CURSOR_SHAPE - ui_cursor_shape(); /* may need to update cursor shape */ + ui_cursor_shape(); // may need to update cursor shape #endif continue; - case Ctrl_O: /* execute one command */ + case Ctrl_O: // execute one command #ifdef FEAT_COMPL_FUNC if (ctrl_x_mode_omni()) goto docomplete; @@ -853,7 +853,7 @@ doESCkey: break; ins_ctrl_o(); - /* don't move the cursor left when 'virtualedit' has "onemore". */ + // don't move the cursor left when 'virtualedit' has "onemore". if (ve_flags & VE_ONEMORE) { ins_at_eol = FALSE; @@ -862,15 +862,15 @@ doESCkey: count = 0; goto doESCkey; - case K_INS: /* toggle insert/replace mode */ + case K_INS: // toggle insert/replace mode case K_KINS: ins_insert(replaceState); break; - case K_SELECT: /* end of Select mode mapping - ignore */ + case K_SELECT: // end of Select mode mapping - ignore break; - case K_HELP: /* Help key works like <ESC> <Help> */ + case K_HELP: // Help key works like <ESC> <Help> case K_F1: case K_XF1: stuffcharReadbuff(K_HELP); @@ -879,55 +879,55 @@ doESCkey: goto doESCkey; #ifdef FEAT_NETBEANS_INTG - case K_F21: /* NetBeans command */ - ++no_mapping; /* don't map the next key hits */ + case K_F21: // NetBeans command + ++no_mapping; // don't map the next key hits i = plain_vgetc(); --no_mapping; netbeans_keycommand(i); break; #endif - case K_ZERO: /* Insert the previously inserted text. */ + case K_ZERO: // Insert the previously inserted text. case NUL: case Ctrl_A: - /* For ^@ the trailing ESC will end the insert, unless there is an - * error. */ + // For ^@ the trailing ESC will end the insert, unless there is an + // error. if (stuff_inserted(NUL, 1L, (c == Ctrl_A)) == FAIL && c != Ctrl_A && !p_im) - goto doESCkey; /* quit insert mode */ + goto doESCkey; // quit insert mode inserted_space = FALSE; break; - case Ctrl_R: /* insert the contents of a register */ + case Ctrl_R: // insert the contents of a register ins_reg(); auto_format(FALSE, TRUE); inserted_space = FALSE; break; - case Ctrl_G: /* commands starting with CTRL-G */ + case Ctrl_G: // commands starting with CTRL-G ins_ctrl_g(); break; - case Ctrl_HAT: /* switch input mode and/or langmap */ + case Ctrl_HAT: // switch input mode and/or langmap ins_ctrl_hat(); break; #ifdef FEAT_RIGHTLEFT - case Ctrl__: /* switch between languages */ + case Ctrl__: // switch between languages if (!p_ari) goto normalchar; ins_ctrl_(); break; #endif - case Ctrl_D: /* Make indent one shiftwidth smaller. */ + case Ctrl_D: // Make indent one shiftwidth smaller. #if defined(FEAT_FIND_ID) if (ctrl_x_mode_path_defines()) goto docomplete; #endif - /* FALLTHROUGH */ + // FALLTHROUGH - case Ctrl_T: /* Make indent one shiftwidth greater. */ + case Ctrl_T: // Make indent one shiftwidth greater. if (c == Ctrl_T && ctrl_x_mode_thesaurus()) { if (has_compl_option(FALSE)) @@ -940,19 +940,19 @@ doESCkey: inserted_space = FALSE; break; - case K_DEL: /* delete character under the cursor */ + case K_DEL: // delete character under the cursor case K_KDEL: ins_del(); auto_format(FALSE, TRUE); break; - case K_BS: /* delete character before the cursor */ + case K_BS: // delete character before the cursor case Ctrl_H: did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space); auto_format(FALSE, TRUE); break; - case Ctrl_W: /* delete word before the cursor */ + case Ctrl_W: // delete word before the cursor #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0) { @@ -969,9 +969,9 @@ doESCkey: auto_format(FALSE, TRUE); break; - case Ctrl_U: /* delete all inserted text in current line */ + case Ctrl_U: // delete all inserted text in current line # ifdef FEAT_COMPL_FUNC - /* CTRL-X CTRL-U completes with 'completefunc'. */ + // CTRL-X CTRL-U completes with 'completefunc'. if (ctrl_x_mode_function()) goto docomplete; # endif @@ -980,7 +980,7 @@ doESCkey: inserted_space = FALSE; break; - case K_LEFTMOUSE: /* mouse keys */ + case K_LEFTMOUSE: // mouse keys case K_LEFTMOUSE_NM: case K_LEFTDRAG: case K_LEFTRELEASE: @@ -1001,30 +1001,30 @@ doESCkey: ins_mouse(c); break; - case K_MOUSEDOWN: /* Default action for scroll wheel up: scroll up */ + case K_MOUSEDOWN: // Default action for scroll wheel up: scroll up ins_mousescroll(MSCR_DOWN); break; - case K_MOUSEUP: /* Default action for scroll wheel down: scroll down */ + case K_MOUSEUP: // Default action for scroll wheel down: scroll down ins_mousescroll(MSCR_UP); break; - case K_MOUSELEFT: /* Scroll wheel left */ + case K_MOUSELEFT: // Scroll wheel left ins_mousescroll(MSCR_LEFT); break; - case K_MOUSERIGHT: /* Scroll wheel right */ + case K_MOUSERIGHT: // Scroll wheel right ins_mousescroll(MSCR_RIGHT); break; case K_PS: bracketed_paste(PASTE_INSERT, FALSE, NULL); if (cmdchar == K_PS) - /* invoked from normal mode, bail out */ + // invoked from normal mode, bail out goto doESCkey; break; case K_PE: - /* Got K_PE without K_PS, ignore. */ + // Got K_PE without K_PS, ignore. break; #ifdef FEAT_GUI_TABLINE @@ -1034,17 +1034,17 @@ doESCkey: break; #endif - case K_IGNORE: /* Something mapped to nothing */ + case K_IGNORE: // Something mapped to nothing break; - case K_CURSORHOLD: /* Didn't type something for a while. */ + case K_CURSORHOLD: // Didn't type something for a while. ins_apply_autocmds(EVENT_CURSORHOLDI); did_cursorhold = TRUE; break; #ifdef FEAT_GUI_MSWIN - /* On MS-Windows ignore <M-F4>, we get it when closing the window - * was cancelled. */ + // On MS-Windows ignore <M-F4>, we get it when closing the window + // was cancelled. case K_F4: if (mod_mask != MOD_MASK_ALT) goto normalchar; @@ -1061,45 +1061,45 @@ doESCkey: break; #endif - case K_HOME: /* <Home> */ + case K_HOME: // <Home> case K_KHOME: case K_S_HOME: case K_C_HOME: ins_home(c); break; - case K_END: /* <End> */ + case K_END: // <End> case K_KEND: case K_S_END: case K_C_END: ins_end(c); break; - case K_LEFT: /* <Left> */ + case K_LEFT: // <Left> if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) ins_s_left(); else ins_left(); break; - case K_S_LEFT: /* <S-Left> */ + case K_S_LEFT: // <S-Left> case K_C_LEFT: ins_s_left(); break; - case K_RIGHT: /* <Right> */ + case K_RIGHT: // <Right> if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) ins_s_right(); else ins_right(); break; - case K_S_RIGHT: /* <S-Right> */ + case K_S_RIGHT: // <S-Right> case K_C_RIGHT: ins_s_right(); break; - case K_UP: /* <Up> */ + case K_UP: // <Up> if (pum_visible()) goto docomplete; if (mod_mask & MOD_MASK_SHIFT) @@ -1108,7 +1108,7 @@ doESCkey: ins_up(FALSE); break; - case K_S_UP: /* <S-Up> */ + case K_S_UP: // <S-Up> case K_PAGEUP: case K_KPAGEUP: if (pum_visible()) @@ -1116,7 +1116,7 @@ doESCkey: ins_pageup(); break; - case K_DOWN: /* <Down> */ + case K_DOWN: // <Down> if (pum_visible()) goto docomplete; if (mod_mask & MOD_MASK_SHIFT) @@ -1125,7 +1125,7 @@ doESCkey: ins_down(FALSE); break; - case K_S_DOWN: /* <S-Down> */ + case K_S_DOWN: // <S-Down> case K_PAGEDOWN: case K_KPAGEDOWN: if (pum_visible()) @@ -1134,39 +1134,39 @@ doESCkey: break; #ifdef FEAT_DND - case K_DROP: /* drag-n-drop event */ + case K_DROP: // drag-n-drop event ins_drop(); break; #endif - case K_S_TAB: /* When not mapped, use like a normal TAB */ + case K_S_TAB: // When not mapped, use like a normal TAB c = TAB; - /* FALLTHROUGH */ + // FALLTHROUGH - case TAB: /* TAB or Complete patterns along path */ + case TAB: // TAB or Complete patterns along path #if defined(FEAT_FIND_ID) if (ctrl_x_mode_path_patterns()) goto docomplete; #endif inserted_space = FALSE; if (ins_tab()) - goto normalchar; /* insert TAB as a normal char */ + goto normalchar; // insert TAB as a normal char auto_format(FALSE, TRUE); break; - case K_KENTER: /* <Enter> */ + case K_KENTER: // <Enter> c = CAR; - /* FALLTHROUGH */ + // FALLTHROUGH case CAR: case NL: #if defined(FEAT_QUICKFIX) - /* In a quickfix window a <CR> jumps to the error under the - * cursor. */ + // In a quickfix window a <CR> jumps to the error under the + // cursor. if (bt_quickfix(curbuf) && c == CAR) { - if (curwin->w_llist_ref == NULL) /* quickfix window */ + if (curwin->w_llist_ref == NULL) // quickfix window do_cmdline_cmd((char_u *)".cc"); - else /* location list window */ + else // location list window do_cmdline_cmd((char_u *)".ll"); break; } @@ -1174,7 +1174,7 @@ doESCkey: #ifdef FEAT_CMDWIN if (cmdwin_type != 0) { - /* Execute the command in the cmdline window. */ + // Execute the command in the cmdline window. cmdwin_result = CAR; goto doESCkey; } @@ -1191,12 +1191,12 @@ doESCkey: } #endif if (ins_eol(c) == FAIL && !p_im) - goto doESCkey; /* out of memory */ + goto doESCkey; // out of memory auto_format(FALSE, FALSE); inserted_space = FALSE; break; - case Ctrl_K: /* digraph or keyword completion */ + case Ctrl_K: // digraph or keyword completion if (ctrl_x_mode_dictionary()) { if (has_compl_option(TRUE)) @@ -1210,30 +1210,30 @@ doESCkey: #endif goto normalchar; - case Ctrl_X: /* Enter CTRL-X mode */ + case Ctrl_X: // Enter CTRL-X mode ins_ctrl_x(); break; - case Ctrl_RSB: /* Tag name completion after ^X */ + case Ctrl_RSB: // Tag name completion after ^X if (!ctrl_x_mode_tags()) goto normalchar; goto docomplete; - case Ctrl_F: /* File name completion after ^X */ + case Ctrl_F: // File name completion after ^X if (!ctrl_x_mode_files()) goto normalchar; goto docomplete; - case 's': /* Spelling completion after ^X */ + case 's': // Spelling completion after ^X case Ctrl_S: if (!ctrl_x_mode_spell()) goto normalchar; goto docomplete; - case Ctrl_L: /* Whole line completion after ^X */ + case Ctrl_L: // Whole line completion after ^X if (!ctrl_x_mode_whole_line()) { - /* CTRL-L with 'insertmode' set: Leave Insert mode */ + // CTRL-L with 'insertmode' set: Leave Insert mode if (p_im) { if (echeck_abbr(Ctrl_L + ABBR_OFF)) @@ -1242,12 +1242,12 @@ doESCkey: } goto normalchar; } - /* FALLTHROUGH */ + // FALLTHROUGH - case Ctrl_P: /* Do previous/next pattern completion */ + case Ctrl_P: // Do previous/next pattern completion case Ctrl_N: - /* if 'complete' is empty then plain ^P is no longer special, - * but it is under other ^X modes */ + // if 'complete' is empty then plain ^P is no longer special, + // but it is under other ^X modes if (*curbuf->b_p_cpt == NUL && (ctrl_x_mode_normal() || ctrl_x_mode_whole_line()) && !(compl_cont_status & CONT_LOCAL)) @@ -1256,7 +1256,7 @@ doESCkey: docomplete: compl_busy = TRUE; #ifdef FEAT_FOLDING - disable_fold_update++; /* don't redraw folds here */ + disable_fold_update++; // don't redraw folds here #endif if (ins_complete(c, TRUE) == FAIL) compl_cont_status = 0; @@ -1266,14 +1266,14 @@ docomplete: compl_busy = FALSE; break; - case Ctrl_Y: /* copy from previous line or scroll down */ - case Ctrl_E: /* copy from next line or scroll up */ + case Ctrl_Y: // copy from previous line or scroll down + case Ctrl_E: // copy from next line or scroll up c = ins_ctrl_ey(c); break; default: #ifdef UNIX - if (c == intr_char) /* special interrupt char */ + if (c == intr_char) // special interrupt char goto do_intr; #endif @@ -1284,7 +1284,7 @@ normalchar: #if defined(FEAT_EVAL) if (!p_paste) { - /* Trigger InsertCharPre. */ + // Trigger InsertCharPre. char_u *str = do_insert_char_pre(c); char_u *p; @@ -1292,7 +1292,7 @@ normalchar: { if (*str != NUL && stop_arrow() != FAIL) { - /* Insert the new value of v:char literally. */ + // Insert the new value of v:char literally. for (p = str; *p != NUL; MB_PTR_ADV(p)) { c = PTR2CHAR(p); @@ -1307,14 +1307,14 @@ normalchar: c = NUL; } - /* If the new value is already inserted or an empty string - * then don't insert any character. */ + // If the new value is already inserted or an empty string + // then don't insert any character. if (c == NUL) break; } #endif #ifdef FEAT_SMARTINDENT - /* Try to perform smart-indenting. */ + // Try to perform smart-indenting. ins_try_si(c); #endif @@ -1330,9 +1330,9 @@ normalchar: Insstart_blank_vcol = get_nolist_virtcol(); } - /* Insert a normal character and check for abbreviations on a - * special character. Let CTRL-] expand abbreviations without - * inserting it. */ + // Insert a normal character and check for abbreviations on a + // special character. Let CTRL-] expand abbreviations without + // inserting it. if (vim_iswordc(c) || (!echeck_abbr( // Add ABBR_OFF for characters above 0x100, this is // what check_abbr() expects. @@ -1349,23 +1349,23 @@ normalchar: auto_format(FALSE, TRUE); #ifdef FEAT_FOLDING - /* When inserting a character the cursor line must never be in a - * closed fold. */ + // When inserting a character the cursor line must never be in a + // closed fold. foldOpenCursor(); #endif break; - } /* end of switch (c) */ + } // end of switch (c) - /* If typed something may trigger CursorHoldI again. */ + // If typed something may trigger CursorHoldI again. if (c != K_CURSORHOLD #ifdef FEAT_COMPL_FUNC - /* but not in CTRL-X mode, a script can't restore the state */ + // but not in CTRL-X mode, a script can't restore the state && ctrl_x_mode_normal() #endif ) did_cursorhold = FALSE; - /* If the cursor was moved we didn't just insert a space */ + // If the cursor was moved we didn't just insert a space if (arrow_used) inserted_space = FALSE; @@ -1379,14 +1379,14 @@ force_cindent: if (in_cinkeys(c, ' ', line_is_white)) { if (stop_arrow() == OK) - /* re-indent the current line */ + // re-indent the current line do_c_expr_indent(); } } -#endif /* FEAT_CINDENT */ +#endif // FEAT_CINDENT - } /* for (;;) */ - /* NOTREACHED */ + } // for (;;) + // NOTREACHED } int @@ -1414,8 +1414,8 @@ ins_redraw(int ready) // not busy with something if (char_avail()) return; - /* Trigger CursorMoved if the cursor moved. Not when the popup menu is - * visible, the command might delete it. */ + // Trigger CursorMoved if the cursor moved. Not when the popup menu is + // visible, the command might delete it. if (ready && (has_cursormovedI() # ifdef FEAT_PROP_POPUP || popup_visible @@ -1428,17 +1428,17 @@ ins_redraw(int ready) // not busy with something && !pum_visible()) { # ifdef FEAT_SYN_HL - /* Need to update the screen first, to make sure syntax - * highlighting is correct after making a change (e.g., inserting - * a "(". The autocommand may also require a redraw, so it's done - * again below, unfortunately. */ + // Need to update the screen first, to make sure syntax + // highlighting is correct after making a change (e.g., inserting + // a "(". The autocommand may also require a redraw, so it's done + // again below, unfortunately. if (syntax_present(curwin) && must_redraw) update_screen(0); # endif if (has_cursormovedI()) { - /* Make sure curswant is correct, an autocommand may call - * getcurpos(). */ + // Make sure curswant is correct, an autocommand may call + // getcurpos(). update_curswant(); ins_apply_autocmds(EVENT_CURSORMOVEDI); } |