To: vim-dev@vim.org Subject: Patch 5.6.048 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6.048 Problem: CTRL-R in Command-line mode is documented to insert text as typed, but inserts text literally. Solution: Make CTRL-R insert text as typed, use CTRL-R CTRL-R to insert literally. This is consistent with Insert mode. But characters that end Command-line mode are inserted literally. Files: runtime/doc/index.txt, runtime/doc/cmdline.txt, src/ex_getln.c, src/ops.c, src/proto/ops.pro *** ../vim-5.6.47/runtime/doc/index.txt Sun Jan 16 14:12:56 2000 --- runtime/doc/index.txt Sat Apr 1 20:57:07 2000 *************** *** 1,4 **** ! *index.txt* For Vim version 5.6. Last change: 2000 Jan 01 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *index.txt* For Vim version 5.6. Last change: 2000 Apr 01 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 831,838 **** |c_CTRL-P| CTRL-P after using 'wildchar' with multiple matches: go to previous match, otherwise: same as |c_CTRL-Q| CTRL-Q same as CTRL-V (used for terminal control flow) ! |c_CTRL-R| CTRL-R {0-9a-z"%#*:=} ! insert the contents of a register CTRL-S (used for terminal control flow) |c_CTRL-U| CTRL-U remove all characters |c_CTRL-V| CTRL-V insert next non-digit literally, insert three --- 831,842 ---- |c_CTRL-P| CTRL-P after using 'wildchar' with multiple matches: go to previous match, otherwise: same as |c_CTRL-Q| CTRL-Q same as CTRL-V (used for terminal control flow) ! |c_CTRL-R| CTRL-R {0-9a-z"%#*:= CTRL-F CTRL-P CTRL-W CTRL-A} ! insert the contents of a register or object ! under the cursor as if typed ! |c_CTRL-R_CTRL-R| CTRL-R CTRL-R {0-9a-z"%#*:= CTRL-F CTRL-P CTRL-W CTRL-A} ! insert the contents of a register or object ! under the cursor literally CTRL-S (used for terminal control flow) |c_CTRL-U| CTRL-U remove all characters |c_CTRL-V| CTRL-V insert next non-digit literally, insert three *** ../vim-5.6.47/runtime/doc/cmdline.txt Sun Jan 16 14:12:53 2000 --- runtime/doc/cmdline.txt Sat Apr 1 21:11:03 2000 *************** *** 1,4 **** ! *cmdline.txt* For Vim version 5.6. Last change: 2000 Jan 09 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *cmdline.txt* For Vim version 5.6. Last change: 2000 Apr 01 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 119,126 **** Insert the contents of a numbered or named register. Between typing CTRL-R and the second character '"' will be displayed to indicate that you are expected to enter the name of a ! register. The text is inserted as if you typed it, but ! mappings and abbreviations are not used. Special registers: '"' the unnamed register, containing the text of the last delete or yank '%' the current file name --- 119,132 ---- Insert the contents of a numbered or named register. Between typing CTRL-R and the second character '"' will be displayed to indicate that you are expected to enter the name of a ! register. ! The text is inserted as if you typed it, but mappings and ! abbreviations are not used. Characters that end the command ! line are inserted literally (, , , ). A ! or CTRL-W could still end the command line though, and ! remaining characters will then be interpreted in another mode, ! which might not be what you intended. ! Special registers: '"' the unnamed register, containing the text of the last delete or yank '%' the current file name *************** *** 147,152 **** --- 153,166 ---- CTRL-F and CTRL-P: {only when +file_in_path feature is included} + *c_CTRL-R_CTRL-R* *c__* + CTRL-R CTRL-R {0-9a-z"%#:-=. CTRL-F CTRL-P CTRL-W CTRL-A} + Insert register or object under the cursor. Works like + |c_CTRL-R| but inserts the text literally. For example, if + register a contains "xy^Hz" (where ^H is a backspace), + "CTRL-R a" will insert "xz" while "CTRL-R CTRL-R a" will + insert "xy^Hz". + CTRL-J *c_CTRL-J* *c_* *c_* or start entered command *c_* *** ../vim-5.6.47/src/ex_getln.c Sat Mar 25 17:13:09 2000 --- src/ex_getln.c Sat Apr 1 20:30:58 2000 *************** *** 726,732 **** #endif putcmdline('"'); ++no_mapping; ! c = safe_vgetc(); --no_mapping; #ifdef WANT_EVAL /* --- 726,734 ---- #endif putcmdline('"'); ++no_mapping; ! i = c = safe_vgetc(); /* CTRL-R */ ! if (c == Ctrl('R')) ! c = safe_vgetc(); /* CTRL-R CTRL-R */ --no_mapping; #ifdef WANT_EVAL /* *************** *** 754,760 **** } #endif if (c != ESC) /* use ESC to cancel inserting register */ ! cmdline_paste(c); redrawcmd(); goto cmdline_changed; --- 756,762 ---- } #endif if (c != ESC) /* use ESC to cancel inserting register */ ! cmdline_paste(c, i == Ctrl('R')); redrawcmd(); goto cmdline_changed; *************** *** 826,835 **** goto cmdline_not_changed; /* Ignore mouse */ # ifdef USE_GUI if (gui.in_use) ! cmdline_paste('*'); else # endif ! cmdline_paste(0); redrawcmd(); goto cmdline_changed; --- 828,837 ---- goto cmdline_not_changed; /* Ignore mouse */ # ifdef USE_GUI if (gui.in_use) ! cmdline_paste('*', TRUE); else # endif ! cmdline_paste(0, TRUE); redrawcmd(); goto cmdline_changed; *** ../vim-5.6.47/src/ops.c Mon Dec 13 16:07:36 1999 --- src/ops.c Sat Apr 1 21:08:46 2000 *************** *** 86,91 **** --- 86,92 ---- static int put_in_typebuf __ARGS((char_u *s, int colon)); static void stuffescaped __ARGS((char_u *arg)); static int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg)); + static void cmdline_paste_str __ARGS((char_u *s, int literally)); static void free_yank __ARGS((long)); static void free_yank_all __ARGS((void)); static void block_prep __ARGS((OPARG *oap, struct block_def *, linenr_t, int)); *************** *** 1171,1178 **** * return FAIL for failure, OK otherwise */ int ! cmdline_paste(regname) int regname; { long i; char_u *arg; --- 1172,1180 ---- * return FAIL for failure, OK otherwise */ int ! cmdline_paste(regname, literally) int regname; + int literally; /* Insert text literally instead of "as typed" */ { long i; char_u *arg; *************** *** 1198,1207 **** { if (arg == NULL) return FAIL; ! i = put_on_cmdline(arg, -1, TRUE); if (allocated) vim_free(arg); ! return (int)i; } get_yank_register(regname, FALSE); --- 1200,1209 ---- { if (arg == NULL) return FAIL; ! cmdline_paste_str(arg, literally); if (allocated) vim_free(arg); ! return (int)OK; } get_yank_register(regname, FALSE); *************** *** 1210,1222 **** for (i = 0; i < y_current->y_size; ++i) { ! put_on_cmdline(y_current->y_array[i], -1, FALSE); /* insert ^M between lines and after last line if type is MLINE */ if (y_current->y_type == MLINE || i < y_current->y_size - 1) ! put_on_cmdline((char_u *)"\r", 1, FALSE); } return OK; } /* --- 1212,1252 ---- for (i = 0; i < y_current->y_size; ++i) { ! cmdline_paste_str(y_current->y_array[i], literally); /* insert ^M between lines and after last line if type is MLINE */ if (y_current->y_type == MLINE || i < y_current->y_size - 1) ! cmdline_paste_str((char_u *)"\r", literally); } return OK; + } + + /* + * Put a string on the command line. + * When "literally" is TRUE, insert literally. + * When "literally" is FALSE, insert as typed, but don't leave the command + * line. + */ + static void + cmdline_paste_str(s, literally) + char_u *s; + int literally; + { + if (literally) + put_on_cmdline(s, -1, TRUE); + else + while (*s) + { + if (*s == Ctrl('V') && s[1]) + stuffcharReadbuff(*s++); + else if (*s == ESC || *s == Ctrl('C') || *s == CR || *s == NL + #ifdef UNIX + || *s == intr_char + #endif + || (*s == Ctrl('\\') && s[1] == Ctrl('N'))) + stuffcharReadbuff(Ctrl('V')); + stuffcharReadbuff(*s++); + } } /* *** ../vim-5.6.47/src/proto/ops.pro Sun Jan 16 14:22:46 2000 --- src/proto/ops.pro Sat Apr 1 20:59:39 2000 *************** *** 13,19 **** int do_record __ARGS((int c)); int do_execreg __ARGS((int regname, int colon, int addcr)); int insert_reg __ARGS((int regname, int literally)); ! int cmdline_paste __ARGS((int regname)); int op_delete __ARGS((OPARG *oap)); int op_replace __ARGS((OPARG *oap, int c)); void op_tilde __ARGS((OPARG *oap)); --- 13,19 ---- int do_record __ARGS((int c)); int do_execreg __ARGS((int regname, int colon, int addcr)); int insert_reg __ARGS((int regname, int literally)); ! int cmdline_paste __ARGS((int regname, int literally)); int op_delete __ARGS((OPARG *oap)); int op_replace __ARGS((OPARG *oap, int c)); void op_tilde __ARGS((OPARG *oap)); *** ../vim-5.6.47/src/version.c Fri Mar 31 19:36:49 2000 --- src/version.c Sat Apr 1 21:12:33 2000 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 48, /**/ -- It is illegal for a driver to be blindfolded while operating a vehicle. [real standing law in Alabama, United States of America] /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\ \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/