Skip to content

Commit 4c5d815

Browse files
committed
patch 8.1.0487: no menus specifically for the terminal window
Problem: No menus specifically for the terminal window. Solution: Add :tlmenu. (Yee Cheng Chin, closes #3439) Add a menu test.
1 parent 42a4ea1 commit 4c5d815

19 files changed

Lines changed: 269 additions & 120 deletions

runtime/delmenu.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
" Last Change: 2001 May 27
66

77
aunmenu *
8+
tlunmenu *
89

910
silent! unlet did_install_default_menus
1011
silent! unlet did_install_syntax_menu

runtime/doc/autocmd.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,13 +835,14 @@ MenuPopup Just before showing the popup menu (under the
835835
right mouse button). Useful for adjusting the
836836
menu for what is under the cursor or mouse
837837
pointer.
838-
The pattern is matched against a single
839-
character representing the mode:
838+
The pattern is matched against one or two
839+
characters representing the mode:
840840
n Normal
841841
v Visual
842842
o Operator-pending
843843
i Insert
844844
c Command line
845+
tl Terminal
845846
*OptionSet*
846847
OptionSet After setting an option. The pattern is
847848
matched against the long option name.

runtime/doc/gui.txt

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,16 @@ floating menus that do not appear on the main menu bar.
547547

548548
5.2 Creating New Menus *creating-menus*
549549

550-
*:me* *:menu* *:noreme* *:noremenu*
551-
*:am* *:amenu* *:an* *:anoremenu*
552-
*:nme* *:nmenu* *:nnoreme* *:nnoremenu*
553-
*:ome* *:omenu* *:onoreme* *:onoremenu*
554-
*:vme* *:vmenu* *:vnoreme* *:vnoremenu*
555-
*:xme* *:xmenu* *:xnoreme* *:xnoremenu*
556-
*:sme* *:smenu* *:snoreme* *:snoremenu*
557-
*:ime* *:imenu* *:inoreme* *:inoremenu*
558-
*:cme* *:cmenu* *:cnoreme* *:cnoremenu*
550+
*:me* *:menu* *:noreme* *:noremenu*
551+
*:am* *:amenu* *:an* *:anoremenu*
552+
*:nme* *:nmenu* *:nnoreme* *:nnoremenu*
553+
*:ome* *:omenu* *:onoreme* *:onoremenu*
554+
*:vme* *:vmenu* *:vnoreme* *:vnoremenu*
555+
*:xme* *:xmenu* *:xnoreme* *:xnoremenu*
556+
*:sme* *:smenu* *:snoreme* *:snoremenu*
557+
*:ime* *:imenu* *:inoreme* *:inoremenu*
558+
*:cme* *:cmenu* *:cnoreme* *:cnoremenu*
559+
*:tlm* *:tlmenu* *:tln* *:tlnoremenu*
559560
*E330* *E327* *E331* *E336* *E333*
560561
*E328* *E329* *E337* *E792*
561562
To create a new menu item, use the ":menu" commands. They are mostly like
@@ -571,6 +572,10 @@ the mouse button down on this will pop up a menu containing the item
571572
"Big Changes", which is a sub-menu containing the item "Delete All Spaces",
572573
which when selected, performs the operation.
573574

575+
To create a menu for terminal mode, use |:tlmenu| instead of |:tmenu| unlike
576+
key mapping (|:tmap|). This is because |:tmenu| is already used for defining
577+
tooltips for menus. See |terminal-typing|.
578+
574579
Special characters in a menu name:
575580

576581
& The next character is the shortcut key. Make sure each
@@ -589,9 +594,9 @@ With the shortcut "F" (while keeping the <Alt> key pressed), and then "O",
589594
this menu can be used. The second part is shown as "Open :e". The ":e"
590595
is right aligned, and the "O" is underlined, to indicate it is the shortcut.
591596

592-
The ":amenu" command can be used to define menu entries for all modes at once.
593-
To make the command work correctly, a character is automatically inserted for
594-
some modes:
597+
The ":amenu" command can be used to define menu entries for all modes at once,
598+
except for Terminal mode. To make the command work correctly, a character is
599+
automatically inserted for some modes:
595600
mode inserted appended ~
596601
Normal nothing nothing
597602
Visual <C-C> <C-\><C-G>
@@ -865,6 +870,16 @@ be used to complete the name of the menu item.
865870
insert-mode menu Eg: >
866871
:emenu File.Exit
867872
873+
:[range]em[enu] {mode} {menu} Like above, but execute the menu for {mode}:
874+
'n': |:nmenu| Normal mode
875+
'v': |:vmenu| Visual mode
876+
's': |:smenu| Select mode
877+
'o': |:omenu| Operator-pending mode
878+
't': |:tlmenu| Terminal mode
879+
'i': |:imenu| Insert mode
880+
'c': |:cmenu| Cmdline mode
881+
882+
868883
If the console-mode vim has been compiled with WANT_MENU defined, you can
869884
use :emenu to access useful menu items you may have got used to from GUI
870885
mode. See 'wildmenu' for an option that works well with this. See
@@ -885,6 +900,7 @@ using the last visual selection.
885900
*:sunme* *:sunmenu*
886901
*:iunme* *:iunmenu*
887902
*:cunme* *:cunmenu*
903+
*:tlu* *:tlunmenu*
888904
To delete a menu item or a whole submenu, use the unmenu commands, which are
889905
analogous to the unmap commands. Eg: >
890906
:unmenu! Edit.Paste
@@ -951,6 +967,8 @@ See section |42.4| in the user manual.
951967
:tu[nmenu] {menupath} Remove a tip for a menu or tool.
952968
{only in X11 and Win32 GUI}
953969

970+
Note: To create menus for terminal mode, use |:tlmenu| instead.
971+
954972
When a tip is defined for a menu item, it appears in the command-line area
955973
when the mouse is over that item, much like a standard Windows menu hint in
956974
the status bar. (Except when Vim is in Command-line mode, when of course

runtime/doc/index.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,9 @@ tag command action ~
15831583
|:tjump| :tj[ump] like ":tselect", but jump directly when there
15841584
is only one match
15851585
|:tlast| :tl[ast] jump to last matching tag
1586+
|:tlmenu| :tlm[enu] add menu for Terminal-Job mode
1587+
|:tlnoremenu| :tln[oremenu] like ":noremenu" but for Terminal-Job mode
1588+
|:tlunmenu| :tlu[nmenu] remove menu for Terminal-Job mode
15861589
|:tmapclear| :tmapc[lear] remove all mappings for Terminal-Job mode
15871590
|:tmap| :tma[p] like ":map" but for Terminal-Job mode
15881591
|:tmenu| :tm[enu] define menu tooltip

runtime/doc/tags

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,6 +3185,12 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
31853185
:tjump tagsrch.txt /*:tjump*
31863186
:tl tagsrch.txt /*:tl*
31873187
:tlast tagsrch.txt /*:tlast*
3188+
:tlm gui.txt /*:tlm*
3189+
:tlmenu gui.txt /*:tlmenu*
3190+
:tln gui.txt /*:tln*
3191+
:tlnoremenu gui.txt /*:tlnoremenu*
3192+
:tlu gui.txt /*:tlu*
3193+
:tlunmenu gui.txt /*:tlunmenu*
31883194
:tm gui.txt /*:tm*
31893195
:tma map.txt /*:tma*
31903196
:tmap map.txt /*:tmap*

runtime/doc/terminal.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ break: >
114114
tnoremap <Esc> <C-W>N
115115
set notimeout ttimeout timeoutlen=100
116116
117+
You can also create menus similar to terminal mode mappings, but you have to
118+
use |:tlmenu| instead of |:tmenu|.
119+
117120
< *options-in-terminal*
118121
After opening the terminal window and setting 'buftype' to "terminal" the
119122
TerminalOpen autocommand event is triggered. This makes it possible to set

runtime/doc/todo.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ Terminal emulator window:
9595
Key mapping times out when using a timer in Gvim. (Michael Henry, 2018 Sep 9,
9696
#3417)
9797

98-
Patch to check for directory access in term_start(). (Jason Franklin, 2018 Oct
99-
15)
100-
10198
Does not build with MinGW out of the box:
10299
- _stat64 is not defined, need to use "struct stat" in vim.h
103100
- WINVER conflict, should use 0x0600 by default?
@@ -189,17 +186,13 @@ Memory leak in test_terminal:
189186

190187
gethostbyname() is old, use getaddrinfo() if available. (#3227)
191188

192-
Delete the src/main.aap file?
193-
194189
matchaddpos() gets slow with many matches. Proposal by Rick Howe, 2018 Jul
195190
19.
196191

197192
Patch to support ":tag <tagkind> <tagname>". (emmrk, 2018 May 7, #2871)
198193
Use something like ":tag {kind}/{tagname}".
199194
Not ready to include.
200195

201-
Patch to support menus in terminal: ":tlmenu". (Yee Cheng Chin, #3439)
202-
203196
:pedit resets the 'buflisted' option unexpectedly. (Wang Shidong, 2018 Oct 12,
204197
#3536)
205198

@@ -2223,8 +2216,6 @@ still delete them. Also convert all buffer file names?
22232216
"gqip" in Insert mode has an off-by-one error, causing it to reflow text.
22242217
(Raul Coronado, 2009 Nov 2)
22252218

2226-
Update src/testdir/main.aap.
2227-
22282219
Something wrong with session that has "cd" commands and "badd", in such a way
22292220
that Vim doesn't find the edited file in the buffer list, causing the
22302221
ATTENTION message? (Tony Mechelynck, 2008 Dec 1)

runtime/doc/usr_42.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ like the variations on the ":map" command:
150150
:menu! Insert and Command-line mode
151151
:imenu Insert mode
152152
:cmenu Command-line mode
153-
:amenu All modes
153+
:tlmenu Terminal mode
154+
:amenu All modes (except for Terminal mode)
154155

155156
To avoid that the commands of a menu item are being mapped, use the command
156157
":noremenu", ":nnoremenu", ":anoremenu", etc.

runtime/menu.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ vnoremenu 20.350 &Edit.&Copy<Tab>"+y "+y
160160
cnoremenu 20.350 &Edit.&Copy<Tab>"+y <C-Y>
161161
nnoremenu 20.360 &Edit.&Paste<Tab>"+gP "+gP
162162
cnoremenu &Edit.&Paste<Tab>"+gP <C-R>+
163+
if exists(':tlmenu')
164+
tlnoremenu &Edit.&Paste<Tab>"+gP <C-W>"+
165+
endif
163166
exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP ' . paste#paste_cmd['v']
164167
exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP ' . paste#paste_cmd['i']
165168
nnoremenu 20.370 &Edit.Put\ &Before<Tab>[p [p

runtime/syntax/vim.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ syn case match
407407
" Menus {{{2
408408
" =====
409409
syn cluster vimMenuList contains=vimMenuBang,vimMenuPriority,vimMenuName,vimMenuMod
410-
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
410+
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
411411
syn match vimMenuName "[^ \t\\<]\+" contained nextgroup=vimMenuNameMore,vimMenuMap
412412
syn match vimMenuPriority "\d\+\(\.\d\+\)*" contained skipwhite nextgroup=vimMenuName
413413
syn match vimMenuNameMore "\c\\\s\|<tab>\|\\\." contained nextgroup=vimMenuName,vimMenuNameMore contains=vimNotation

0 commit comments

Comments
 (0)