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
This commit is contained in:
bfredl 2023-04-12 22:22:37 +02:00
parent f5231d61a5
commit e4a136f713
17 changed files with 19 additions and 162 deletions

View File

@ -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

View File

@ -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

View File

@ -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*

View File

@ -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, <End>, <Home>,
<PageUp> and <PageDown>.
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<LeftMouse>" is "<C-LeftMouse> (jump to tag under mouse click)
"g<RightMouse>" is "<C-RightMouse> ("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,

View File

@ -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:

View File

@ -556,6 +556,7 @@ Aliases:
vimdiff (alias for "nvim -d" |diff-mode|)
Commands:
:behave
:fixdel
:hardcopy
:helpfind

View File

@ -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+=<,>,[,]

View File

@ -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 },

View File

@ -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),

View File

@ -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;

View File

@ -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",

View File

@ -140,7 +140,6 @@ enum {
EXPAND_SHELLCMD,
EXPAND_SIGN,
EXPAND_PROFILE,
EXPAND_BEHAVE,
EXPAND_FILETYPE,
EXPAND_FILES_IN_PATH,
EXPAND_OWNSYNTAX,

View File

@ -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

View File

@ -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 \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"behave mswin xterm', @:)
endfunc
func Test_behave_error()
call assert_fails('behave x', 'E475:')
endfunc

View File

@ -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\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal('"behave xm', @:)
call feedkeys(":behave xt*m\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal('"behave xterm', @:)
set wildoptions=fuzzy
call feedkeys(":behave xm\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal('"behave xterm', @:)
call feedkeys(":behave xt*m\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal('"behave xt*m', @:)
let g:Sline = ''
call feedkeys(":behave win\<C-D>\<F4>\<C-B>\"\<CR>", '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

View File

@ -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\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoC', @:)
com! -nargs=1 -complete=behave DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd mswin xterm', @:)
" Test for file name completion
com! -nargs=1 -complete=file DoCmd :
call feedkeys(":DoCmd READM\<Tab>\<C-B>\"\<CR>", 'tx')

View File

@ -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