From e4a136f713753e6ace97f419be562567f1ce535f Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 12 Apr 2023 22:22:37 +0200 Subject: [PATCH] feat(ex_cmds)!: remove :behave just use the individual options instead. set selection=exclusive set selectmode=mouse,key set mousemodel=popup set keymodel=startsel,stopsel --- runtime/doc/builtin.txt | 1 - runtime/doc/index.txt | 1 - runtime/doc/news.txt | 7 +++++ runtime/doc/options.txt | 21 -------------- runtime/doc/usr_09.txt | 38 ++++---------------------- runtime/doc/vim_diff.txt | 1 + runtime/mswin.vim | 5 +++- src/nvim/cmdexpand.c | 18 ------------ src/nvim/ex_cmds.lua | 6 ---- src/nvim/ex_docmd.c | 18 ------------ src/nvim/usercmd.c | 1 - src/nvim/vim.h | 1 - test/old/testdir/test_alot.vim | 1 - test/old/testdir/test_behave.vim | 29 -------------------- test/old/testdir/test_cmdline.vim | 24 ---------------- test/old/testdir/test_usercommands.vim | 5 ---- test/old/testdir/test_visual.vim | 4 +-- 17 files changed, 19 insertions(+), 162 deletions(-) delete mode 100644 test/old/testdir/test_behave.vim diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 0e04e9035b..3c940ccfa2 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -3003,7 +3003,6 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* arglist file names in argument list augroup autocmd groups buffer buffer names - behave |:behave| suboptions breakpoint |:breakadd| and |:breakdel| suboptions cmdline |cmdline-completion| result color color schemes diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 174683a8c3..fbd3fccec0 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1159,7 +1159,6 @@ tag command action ~ |:badd| :bad[d] add buffer to the buffer list |:balt| :balt like ":badd" but also set the alternate file |:bdelete| :bd[elete] remove a buffer from the buffer list -|:behave| :be[have] set mouse and selection behavior |:belowright| :bel[owright] make split window appear right or below |:bfirst| :bf[irst] go to first buffer in the buffer list |:blast| :bl[ast] go to last buffer in the buffer list diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 9309b45557..ba428679f0 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -18,6 +18,13 @@ The following changes may require adaptations in user config or plugins. • "#" followed by a digit no longer stands for a function key at the start of the lhs of a mapping. +• `:behave` was removed. if you used `:behave mswin`, the following is equivalent: >vim + + set selection=exclusive + set selectmode=mouse,key + set mousemodel=popup + set keymodel=startsel,stopsel + ============================================================================== ADDED FEATURES *news-added* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d22a78700f..b4cad51990 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3589,7 +3589,6 @@ A jump table for the options with a short description can be found at |Q_op|. stopsel Using a not-shifted special key stops selection. Special keys in this context are the cursor keys, , , and . - The 'keymodel' option is set by the |:behave| command. *'keywordprg'* *'kp'* 'keywordprg' 'kp' string (default ":Man", Windows: ":help") @@ -4168,21 +4167,6 @@ A jump table for the options with a short description can be found at |Q_op|. 'mousehide' hide mouse pointer while typing text 'selectmode' whether to start Select mode or Visual mode - The :behave command provides some "profiles" for mouse behavior. - *:behave* *:be* - :be[have] {model} Set behavior for mouse and selection. Valid - arguments are: - mswin MS-Windows behavior - xterm Xterm behavior - - Using ":behave" changes these options: - option mswin xterm ~ - 'selectmode' "mouse,key" "" - 'mousemodel' "popup" "extend" - 'keymodel' "startsel,stopsel" "" - 'selection' "exclusive" "inclusive" - - *'mousefocus'* *'mousef'* *'nomousefocus'* *'nomousef'* 'mousefocus' 'mousef' boolean (default off) global @@ -4250,8 +4234,6 @@ A jump table for the options with a short description can be found at |Q_op|. "g" is " (jump to tag under mouse click) "g" is " ("CTRL-T") - The 'mousemodel' option is set by the |:behave| command. - *'mousemoveevent'* *'mousemev'* *'nomousemoveevent'* *'nomousemev'* 'mousemoveevent' 'mousemev' boolean (default off) global @@ -5013,8 +4995,6 @@ A jump table for the options with a short description can be found at |Q_op|. backwards, you cannot include the last character of a line, when starting in Normal mode and 'virtualedit' empty. - The 'selection' option is set by the |:behave| command. - *'selectmode'* *'slm'* 'selectmode' 'slm' string (default "") global @@ -5025,7 +5005,6 @@ A jump table for the options with a short description can be found at |Q_op|. key when using shifted special keys cmd when using "v", "V" or CTRL-V See |Select-mode|. - The 'selectmode' option is set by the |:behave| command. *'sessionoptions'* *'ssop'* 'sessionoptions' 'ssop' string (default: "blank,buffers,curdir,folds, diff --git a/runtime/doc/usr_09.txt b/runtime/doc/usr_09.txt index 8084d13b5d..ea16010dc2 100644 --- a/runtime/doc/usr_09.txt +++ b/runtime/doc/usr_09.txt @@ -124,41 +124,13 @@ This adds the 'l' flag to 'guioptions'. Standards are wonderful. In Microsoft Windows, you can use the mouse to select text in a standard manner. The X Window system also has a standard system for using the mouse. Unfortunately, these two standards are not the -same. - Fortunately, you can customize Vim. You can make the behavior of the mouse -work like an X Window system mouse or a Microsoft Windows mouse. The following -command makes the mouse behave like an X Window mouse: > +same. Fortunately, you can customize Vim. - :behave xterm - -The following command makes the mouse work like a Microsoft Windows mouse: > - - :behave mswin - -The default behavior of the mouse on Unix systems is xterm. The default -behavior on Windows systems is selected during the installation process. For -details about what the two behaviors are, see |:behave|. Here follows a -summary. - - -XTERM MOUSE BEHAVIOR - -Left mouse click position the cursor -Left mouse drag select text in Visual mode -Middle mouse click paste text from the clipboard -Right mouse click extend the selected text until the mouse - pointer - - -MSWIN MOUSE BEHAVIOR - -Left mouse click position the cursor -Left mouse drag select text in Select mode (see |09.4|) -Left mouse click, with Shift extend the selected text until the mouse - pointer -Middle mouse click paste text from the clipboard -Right mouse click display a pop-up menu +The following commands makes the mouse work more like a Microsoft Windows mouse: > + set selection=exclusive + set selectmode=mouse,key + set keymodel=startsel,stopsel The mouse can be further tuned. Check out these options if you want to change the way how the mouse works: diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 783aa2f113..58f6d6f6f9 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -556,6 +556,7 @@ Aliases: vimdiff (alias for "nvim -d" |diff-mode|) Commands: + :behave :fixdel :hardcopy :helpfind diff --git a/runtime/mswin.vim b/runtime/mswin.vim index 2b04c1aea3..482b720c53 100644 --- a/runtime/mswin.vim +++ b/runtime/mswin.vim @@ -15,7 +15,10 @@ endif set cpo&vim " set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows -behave mswin +set selection=exclusive +set selectmode=mouse,key +set mousemodel=popup +set keymodel=startsel,stopsel " backspace and cursor keys wrap to previous/next line set backspace=indent,eol,start whichwrap+=<,>,[,] diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 774e16f73d..f2776191b7 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -2104,10 +2104,6 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa xp->xp_context = EXPAND_CHECKHEALTH; xp->xp_pattern = (char *)arg; break; - case CMD_behave: - xp->xp_context = EXPAND_BEHAVE; - xp->xp_pattern = (char *)arg; - break; case CMD_messages: xp->xp_context = EXPAND_MESSAGES; @@ -2478,19 +2474,6 @@ static int expand_files_and_dirs(expand_T *xp, char *pat, char ***matches, int * return ret; } -/// Function given to ExpandGeneric() to obtain the possible arguments of the -/// ":behave {mswin,xterm}" command. -static char *get_behave_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) -{ - if (idx == 0) { - return "mswin"; - } - if (idx == 1) { - return "xterm"; - } - return NULL; -} - /// Function given to ExpandGeneric() to obtain the possible arguments of the /// ":breakadd {expr, file, func, here}" command. /// ":breakdel {func, file, here}" command. @@ -2585,7 +2568,6 @@ static int ExpandOther(char *pat, expand_T *xp, regmatch_T *rmp, char ***matches int escaped; } tab[] = { { EXPAND_COMMANDS, get_command_name, false, true }, - { EXPAND_BEHAVE, get_behave_arg, true, true }, { EXPAND_MAPCLEAR, get_mapclear_arg, true, true }, { EXPAND_MESSAGES, get_messages_arg, true, true }, { EXPAND_HISTORY, get_history_arg, true, true }, diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 2fd50a18d3..bdc1174de3 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -196,12 +196,6 @@ module.cmds = { addr_type='ADDR_BUFFERS', func='ex_bunload', }, - { - command='behave', - flags=bit.bor(BANG, NEEDARG, WORD1, TRLBAR, CMDWIN, LOCK_OK), - addr_type='ADDR_NONE', - func='ex_behave', - }, { command='belowright', flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM), diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 699c1da3a7..fbdb1bc2d7 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7058,24 +7058,6 @@ void dialog_msg(char *buff, char *format, char *fname) vim_snprintf(buff, DIALOG_MSG_SIZE, format, fname); } -/// ":behave {mswin,xterm}" -static void ex_behave(exarg_T *eap) -{ - if (strcmp(eap->arg, "mswin") == 0) { - set_option_value_give_err("selection", 0L, "exclusive", 0); - set_option_value_give_err("selectmode", 0L, "mouse,key", 0); - set_option_value_give_err("mousemodel", 0L, "popup", 0); - set_option_value_give_err("keymodel", 0L, "startsel,stopsel", 0); - } else if (strcmp(eap->arg, "xterm") == 0) { - set_option_value_give_err("selection", 0L, "inclusive", 0); - set_option_value_give_err("selectmode", 0L, "", 0); - set_option_value_give_err("mousemodel", 0L, "extend", 0); - set_option_value_give_err("keymodel", 0L, "", 0); - } else { - semsg(_(e_invarg2), eap->arg); - } -} - static TriState filetype_detect = kNone; static TriState filetype_plugin = kNone; static TriState filetype_indent = kNone; diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 4cd58bb91b..e859a96552 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -56,7 +56,6 @@ static const char e_no_such_user_defined_command_in_current_buffer_str[] static const char *command_complete[] = { [EXPAND_ARGLIST] = "arglist", [EXPAND_AUGROUP] = "augroup", - [EXPAND_BEHAVE] = "behave", [EXPAND_BUFFERS] = "buffer", [EXPAND_CHECKHEALTH] = "checkhealth", [EXPAND_COLORS] = "color", diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 00e28e3e68..44e3e9d86a 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -140,7 +140,6 @@ enum { EXPAND_SHELLCMD, EXPAND_SIGN, EXPAND_PROFILE, - EXPAND_BEHAVE, EXPAND_FILETYPE, EXPAND_FILES_IN_PATH, EXPAND_OWNSYNTAX, diff --git a/test/old/testdir/test_alot.vim b/test/old/testdir/test_alot.vim index a3d240f27e..4a22315b9f 100644 --- a/test/old/testdir/test_alot.vim +++ b/test/old/testdir/test_alot.vim @@ -2,7 +2,6 @@ " This makes testing go faster, since Vim doesn't need to restart. source test_backup.vim -source test_behave.vim source test_compiler.vim source test_ex_equal.vim source test_ex_undo.vim diff --git a/test/old/testdir/test_behave.vim b/test/old/testdir/test_behave.vim deleted file mode 100644 index c26bfe7ce3..0000000000 --- a/test/old/testdir/test_behave.vim +++ /dev/null @@ -1,29 +0,0 @@ -" Test the :behave command - -func Test_behave() - behave mswin - call assert_equal('mouse,key', &selectmode) - call assert_equal('popup', &mousemodel) - call assert_equal('startsel,stopsel', &keymodel) - call assert_equal('exclusive', &selection) - - behave xterm - call assert_equal('', &selectmode) - call assert_equal('extend', &mousemodel) - call assert_equal('', &keymodel) - call assert_equal('inclusive', &selection) - - set selection& - set mousemodel& - set keymodel& - set selection& -endfunc - -func Test_behave_completion() - call feedkeys(":behave \\\"\", 'tx') - call assert_equal('"behave mswin xterm', @:) -endfunc - -func Test_behave_error() - call assert_fails('behave x', 'E475:') -endfunc diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 1dceb43e5d..f9ac7db5d2 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -453,11 +453,6 @@ func Test_getcompletion() let l = getcompletion('blahblah', 'augroup') call assert_equal([], l) - let l = getcompletion('', 'behave') - call assert_true(index(l, 'mswin') >= 0) - let l = getcompletion('not', 'behave') - call assert_equal([], l) - let l = getcompletion('', 'color') call assert_true(index(l, 'default') >= 0) let l = getcompletion('dirty', 'color') @@ -2768,25 +2763,6 @@ func Test_fuzzy_completion_bufname_fullpath() set wildoptions& endfunc -" :behave suboptions fuzzy completion -func Test_fuzzy_completion_behave() - set wildoptions& - call feedkeys(":behave xm\\\"\", 'tx') - call assert_equal('"behave xm', @:) - call feedkeys(":behave xt*m\\\"\", 'tx') - call assert_equal('"behave xterm', @:) - set wildoptions=fuzzy - call feedkeys(":behave xm\\\"\", 'tx') - call assert_equal('"behave xterm', @:) - call feedkeys(":behave xt*m\\\"\", 'tx') - call assert_equal('"behave xt*m', @:) - let g:Sline = '' - call feedkeys(":behave win\\\\"\", 'tx') - call assert_equal('mswin', g:Sline) - call assert_equal('"behave win', @:) - set wildoptions& -endfunc - " " colorscheme name fuzzy completion - NOT supported " func Test_fuzzy_completion_colorscheme() " endfunc diff --git a/test/old/testdir/test_usercommands.vim b/test/old/testdir/test_usercommands.vim index 898f7a59f1..ac37094b1b 100644 --- a/test/old/testdir/test_usercommands.vim +++ b/test/old/testdir/test_usercommands.vim @@ -303,7 +303,6 @@ func Test_CmdErrors() call assert_fails('com! -complete=xxx DoCmd :', 'E180:') call assert_fails('com! -complete=custom DoCmd :', 'E467:') call assert_fails('com! -complete=customlist DoCmd :', 'E467:') - call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:') call assert_fails('com! -complete=file DoCmd :', 'E1208:') call assert_fails('com! -nargs=0 -complete=file DoCmd :', 'E1208:') call assert_fails('com! -nargs=x DoCmd :', 'E176:') @@ -391,10 +390,6 @@ func Test_CmdCompletion() call feedkeys(":com DoC\\\"\", 'tx') call assert_equal('"com DoC', @:) - com! -nargs=1 -complete=behave DoCmd : - call feedkeys(":DoCmd \\\"\", 'tx') - call assert_equal('"DoCmd mswin xterm', @:) - " Test for file name completion com! -nargs=1 -complete=file DoCmd : call feedkeys(":DoCmd READM\\\"\", 'tx') diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim index 350c69fe4e..75487f8402 100644 --- a/test/old/testdir/test_visual.vim +++ b/test/old/testdir/test_visual.vim @@ -485,14 +485,14 @@ endfunc func Test_visual_block_put_invalid() enew! - behave mswin + set selection=exclusive norm yy norm v)Ps/^/ " this was causing the column to become negative silent norm ggv)P bwipe! - behave xterm + set selection& endfunc " Visual modes (v V CTRL-V) followed by an operator; count; repeating