aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-01 10:49:14 +0800
committerGitHub <noreply@github.com>2022-07-01 10:49:14 +0800
commit2268a4147ec1e9f0236fd5eb56c1cc2b751eca05 (patch)
treee85448107d27109df805e865053468e199956dbe /runtime
parent5a490d838ed3288abcf45e16e6ab79c326a67c17 (diff)
parent5a62ad605e4945562d5defb5eb6a2e8a88107ebf (diff)
downloadrneovim-2268a4147ec1e9f0236fd5eb56c1cc2b751eca05.tar.gz
rneovim-2268a4147ec1e9f0236fd5eb56c1cc2b751eca05.tar.bz2
rneovim-2268a4147ec1e9f0236fd5eb56c1cc2b751eca05.zip
Merge pull request #19170 from zeertzjq/vim-8.0.1558
vim-patch:8.0.{1558,1570,1574,1588},8.1.{0487,0695,1274}: menu features
Diffstat (limited to 'runtime')
-rw-r--r--runtime/delmenu.vim1
-rw-r--r--runtime/doc/autocmd.txt5
-rw-r--r--runtime/doc/gui.txt31
-rw-r--r--runtime/doc/index.txt11
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt3
-rw-r--r--runtime/doc/usr_42.txt3
-rw-r--r--runtime/menu.vim3
-rw-r--r--runtime/syntax/vim.vim2
8 files changed, 44 insertions, 15 deletions
diff --git a/runtime/delmenu.vim b/runtime/delmenu.vim
index 5c20290152..040cc09aa9 100644
--- a/runtime/delmenu.vim
+++ b/runtime/delmenu.vim
@@ -5,6 +5,7 @@
" Last Change: 2019 Dec 10
aunmenu *
+tlunmenu *
unlet! g:did_install_default_menus
unlet! g:did_install_syntax_menu
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index bf231044a0..59e5c078a3 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -727,13 +727,14 @@ MenuPopup Just before showing the popup menu (under the
right mouse button). Useful for adjusting the
menu for what is under the cursor or mouse
pointer.
- The pattern is matched against a single
- character representing the mode:
+ The pattern is matched against one or two
+ characters representing the mode:
n Normal
v Visual
o Operator-pending
i Insert
c Command line
+ tl Terminal
*ModeChanged*
ModeChanged After changing the mode. The pattern is
matched against `'old_mode:new_mode'`, for
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index e296141c39..5badd954d9 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -195,6 +195,10 @@ the mouse button down on this will pop up a menu containing the item
"Big Changes", which is a sub-menu containing the item "Delete All Spaces",
which when selected, performs the operation.
+To create a menu for terminal mode, use |:tlmenu| instead of |:tmenu| unlike
+key mapping (|:tmap|). This is because |:tmenu| is already used for defining
+tooltips for menus. See |terminal-input|.
+
Special characters in a menu name:
& The next character is the shortcut key. Make sure each
@@ -214,9 +218,9 @@ this menu can be used. The second part is shown as "Open :e". The ":e"
is right aligned, and the "O" is underlined, to indicate it is the shortcut.
*:am* *:amenu* *:an* *:anoremenu*
-The ":amenu" command can be used to define menu entries for all modes at once.
-To make the command work correctly, a character is automatically inserted for
-some modes:
+The ":amenu" command can be used to define menu entries for all modes at once,
+expect for Terminal mode. To make the command work correctly, a character is
+automatically inserted for some modes:
mode inserted appended ~
Normal nothing nothing
Visual <C-C> <C-\><C-G>
@@ -469,6 +473,16 @@ Executing Menus *execute-menus*
insert-mode menu Eg: >
:emenu File.Exit
+:[range]em[enu] {mode} {menu} Like above, but execute the menu for {mode}:
+ 'n': |:nmenu| Normal mode
+ 'v': |:vmenu| Visual mode
+ 's': |:smenu| Select mode
+ 'o': |:omenu| Operator-pending mode
+ 't': |:tlmenu| Terminal mode
+ 'i': |:imenu| Insert mode
+ 'c': |:cmenu| Cmdline mode
+
+
You can use :emenu to access useful menu items you may have got used to from
GUI mode. See 'wildmenu' for an option that works well with this. See
|console-menus| for an example.
@@ -494,7 +508,9 @@ may be used to complete the name of the menu item for the appropriate mode.
To remove all menus use: *:unmenu-all* >
:unmenu * " remove all menus in Normal and visual mode
:unmenu! * " remove all menus in Insert and Command-line mode
- :aunmenu * " remove all menus in all modes
+ :aunmenu * " remove all menus in all modes, except for Terminal
+ " mode
+ :tlunmenu * " remove all menus in Terminal mode
If you want to get rid of the menu bar: >
:set guioptions-=m
@@ -547,6 +563,8 @@ See section |42.4| in the user manual.
:tu[nmenu] {menupath} Remove a tip for a menu or tool.
{only in X11 and Win32 GUI}
+Note: To create menus for terminal mode, use |:tlmenu| instead.
+
When a tip is defined for a menu item, it appears in the command-line area
when the mouse is over that item, much like a standard Windows menu hint in
the status bar. (Except when Vim is in Command-line mode, when of course
@@ -577,8 +595,8 @@ a menu item - you don't need to do a :tunmenu as well.
5.9 Popup Menus
-In the Win32 GUI, you can cause a menu to popup at the cursor. This behaves
-similarly to the PopUp menus except that any menu tree can be popped up.
+You can cause a menu to popup at the cursor. This behaves similarly to the
+PopUp menus except that any menu tree can be popped up.
This command is for backwards compatibility, using it is discouraged, because
it behaves in a strange way.
@@ -587,7 +605,6 @@ it behaves in a strange way.
:popu[p] {name} Popup the menu {name}. The menu named must
have at least one subentry, but need not
appear on the menu-bar (see |hidden-menus|).
- {only available for Win32 GUI}
:popu[p]! {name} Like above, but use the position of the mouse
pointer instead of the cursor.
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index 279645009b..25b98ae4ab 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -1622,17 +1622,20 @@ tag command action ~
|:tjump| :tj[ump] like ":tselect", but jump directly when there
is only one match
|:tlast| :tl[ast] jump to last matching tag
-|:tmapclear| :tmapc[lear] remove all mappings for Terminal-Job mode
-|:tmap| :tma[p] like ":map" but for Terminal-Job mode
+|:tlmenu| :tlm[enu] add menu for |Terminal-mode|
+|:tlnoremenu| :tln[oremenu] like ":noremenu" but for |Terminal-mode|
+|:tlunmenu| :tlu[nmenu] remove menu for |Terminal-mode|
+|:tmapclear| :tmapc[lear] remove all mappings for |Terminal-mode|
+|:tmap| :tma[p] like ":map" but for |Terminal-mode|
|:tmenu| :tm[enu] define menu tooltip
|:tnext| :tn[ext] jump to next matching tag
-|:tnoremap| :tno[remap] like ":noremap" but for Terminal-Job mode
+|:tnoremap| :tno[remap] like ":noremap" but for |Terminal-mode|
|:topleft| :to[pleft] make split window appear at top or far left
|:tprevious| :tp[revious] jump to previous matching tag
|:trewind| :tr[ewind] jump to first matching tag
|:try| :try execute commands, abort on error or exception
|:tselect| :ts[elect] list matching tags and select one
-|:tunmap| :tunma[p] like ":unmap" but for Terminal-Job mode
+|:tunmap| :tunma[p] like ":unmap" but for |Terminal-mode|
|:tunmenu| :tu[nmenu] remove menu tooltip
|:undo| :u[ndo] undo last change(s)
|:undojoin| :undoj[oin] join next change with previous undo block
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index a4c25009a9..487ccdb0c5 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -80,6 +80,9 @@ To use `ALT+{h,j,k,l}` to navigate windows from any mode: >
:nnoremap <A-k> <C-w>k
:nnoremap <A-l> <C-w>l
+You can also create menus similar to terminal mode mappings, but you have to
+use |:tlmenu| instead of |:tmenu|.
+
Mouse input has the following behavior:
- If the program has enabled mouse events, the corresponding events will be
diff --git a/runtime/doc/usr_42.txt b/runtime/doc/usr_42.txt
index ff3ae7057a..470f4e0fe5 100644
--- a/runtime/doc/usr_42.txt
+++ b/runtime/doc/usr_42.txt
@@ -150,7 +150,8 @@ like the variations on the ":map" command:
:menu! Insert and Command-line mode
:imenu Insert mode
:cmenu Command-line mode
- :amenu All modes
+ :tlmenu Terminal mode
+ :amenu All modes (except for Terminal mode)
To avoid that the commands of a menu item are being mapped, use the command
":noremenu", ":nnoremenu", ":anoremenu", etc.
diff --git a/runtime/menu.vim b/runtime/menu.vim
index 956b941971..e20720dbd2 100644
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -164,6 +164,9 @@ if exists(':tlmenu')
endif
nnoremenu 20.360 &Edit.&Paste<Tab>"+gP "+gP
cnoremenu &Edit.&Paste<Tab>"+gP <C-R>+
+if exists(':tlmenu')
+ tlnoremenu &Edit.&Paste<Tab>"+gP <C-W>"+
+endif
exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP ' . paste#paste_cmd['v']
exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP ' . paste#paste_cmd['i']
nnoremenu 20.370 &Edit.Put\ &Before<Tab>[p [p
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index 3a5b6b6418..6353a40d6a 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -411,7 +411,7 @@ syn case match
" Menus: {{{2
" =====
syn cluster vimMenuList contains=vimMenuBang,vimMenuPriority,vimMenuName,vimMenuMod
-syn keyword vimCommand am[enu] an[oremenu] aun[menu] cme[nu] cnoreme[nu] cunme[nu] ime[nu] inoreme[nu] iunme[nu] me[nu] nme[nu] nnoreme[nu] noreme[nu] nunme[nu] ome[nu] onoreme[nu] ounme[nu] unme[nu] vme[nu] vnoreme[nu] vunme[nu] skipwhite nextgroup=@vimMenuList
+syn keyword vimCommand am[enu] an[oremenu] aun[menu] cme[nu] cnoreme[nu] cunme[nu] ime[nu] inoreme[nu] iunme[nu] me[nu] nme[nu] nnoreme[nu] noreme[nu] nunme[nu] ome[nu] onoreme[nu] ounme[nu] tlm[enu] tln[oremenu] tlu[nmenu] unme[nu] vme[nu] vnoreme[nu] vunme[nu] skipwhite nextgroup=@vimMenuList
syn match vimMenuName "[^ \t\\<]\+" contained nextgroup=vimMenuNameMore,vimMenuMap
syn match vimMenuPriority "\d\+\(\.\d\+\)*" contained skipwhite nextgroup=vimMenuName
syn match vimMenuNameMore "\c\\\s\|<tab>\|\\\." contained nextgroup=vimMenuName,vimMenuNameMore contains=vimNotation