Patch 8.1.0487
Problem: No menus specifically for the terminal window.
Solution: Add :tlmenu. (Yee Cheng Chin, closes #3439) Add a menu test.
Files: runtime/delmenu.vim, runtime/doc/autocmd.txt, runtime/doc/gui.txt,
runtime/doc/index.txt, runtime/doc/terminal.txt,
runtime/doc/usr_42.txt, runtime/menu.vim, src/ex_cmdidxs.h,
src/ex_cmds.h, src/ex_docmd.c, src/menu.c, src/proto/menu.pro,
src/popupmnu.c, src/structs.h, src/testdir/test_menu.vim
*** ../vim-8.1.0486/runtime/delmenu.vim 2010-05-15 13:03:31.000000000 +0200
--- runtime/delmenu.vim 2018-10-19 18:35:52.654453150 +0200
***************
*** 5,10 ****
--- 5,11 ----
" Last Change: 2001 May 27
aunmenu *
+ tlunmenu *
silent! unlet did_install_default_menus
silent! unlet did_install_syntax_menu
*** ../vim-8.1.0486/runtime/doc/autocmd.txt 2018-09-16 15:47:45.629425398
+0200
--- runtime/doc/autocmd.txt 2018-10-19 18:35:52.654453150 +0200
***************
*** 831,843 ****
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:
n Normal
v Visual
o Operator-pending
i Insert
c Command line
*OptionSet*
OptionSet After setting an option. The pattern is
matched against the long option name.
--- 835,848 ----
right mouse button). Useful for adjusting the
menu for what is under the cursor or mouse
pointer.
! 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
*OptionSet*
OptionSet After setting an option. The pattern is
matched against the long option name.
*** ../vim-8.1.0486/runtime/doc/gui.txt 2018-05-17 13:41:40.000000000 +0200
--- runtime/doc/gui.txt 2018-10-19 19:21:48.080078320 +0200
***************
*** 547,561 ****
5.2 Creating New Menus *creating-menus*
! *:me* *:menu* *:noreme* *:noremenu*
! *:am* *:amenu* *:an* *:anoremenu*
! *:nme* *:nmenu* *:nnoreme* *:nnoremenu*
! *:ome* *:omenu* *:onoreme* *:onoremenu*
! *:vme* *:vmenu* *:vnoreme* *:vnoremenu*
! *:xme* *:xmenu* *:xnoreme* *:xnoremenu*
! *:sme* *:smenu* *:snoreme* *:snoremenu*
! *:ime* *:imenu* *:inoreme* *:inoremenu*
! *:cme* *:cmenu* *:cnoreme* *:cnoremenu*
*E330* *E327* *E331* *E336* *E333*
*E328* *E329* *E337* *E792*
To create a new menu item, use the ":menu" commands. They are mostly like
--- 547,562 ----
5.2 Creating New Menus *creating-menus*
! *:me* *:menu* *:noreme* *:noremenu*
! *:am* *:amenu* *:an* *:anoremenu*
! *:nme* *:nmenu* *:nnoreme* *:nnoremenu*
! *:ome* *:omenu* *:onoreme* *:onoremenu*
! *:vme* *:vmenu* *:vnoreme* *:vnoremenu*
! *:xme* *:xmenu* *:xnoreme* *:xnoremenu*
! *:sme* *:smenu* *:snoreme* *:snoremenu*
! *:ime* *:imenu* *:inoreme* *:inoremenu*
! *:cme* *:cmenu* *:cnoreme* *:cnoremenu*
! *:tlm* *:tlmenu* *:tln* *:tlnoremenu*
*E330* *E327* *E331* *E336* *E333*
*E328* *E329* *E337* *E792*
To create a new menu item, use the ":menu" commands. They are mostly like
***************
*** 571,576 ****
--- 572,581 ----
"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-typing|.
+
Special characters in a menu name:
& The next character is the shortcut key. Make sure each
***************
*** 589,597 ****
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.
! 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:
mode inserted appended ~
Normal nothing nothing
Visual <C-C> <C-\><C-G>
--- 594,602 ----
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.
! The ":amenu" command can be used to define menu entries for all modes at once,
! except 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>
***************
*** 865,870 ****
--- 870,885 ----
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
+
+
If the console-mode vim has been compiled with WANT_MENU defined, 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
***************
*** 885,890 ****
--- 900,906 ----
*:sunme* *:sunmenu*
*:iunme* *:iunmenu*
*:cunme* *:cunmenu*
+ *:tlu* *:tlunmenu*
To delete a menu item or a whole submenu, use the unmenu commands, which are
analogous to the unmap commands. Eg: >
:unmenu! Edit.Paste
***************
*** 951,956 ****
--- 967,974 ----
: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
***************
*** 999,1005 ****
pointer instead of the cursor.
In the terminal this is the last known
position, which is usually at the last click
! or release (mouse movement is irrelevalt).
Example: >
:popup File
--- 1017,1023 ----
pointer instead of the cursor.
In the terminal this is the last known
position, which is usually at the last click
! or release (mouse movement is irrelevant).
Example: >
:popup File
***************
*** 1075,1078 ****
For the Win32 GUI the external commands are executed in a separate window.
See |gui-shell-win32|.
! vim:tw=78:sw=4:ts=8:ft=help:norl:
--- 1093,1096 ----
For the Win32 GUI the external commands are executed in a separate window.
See |gui-shell-win32|.
! vim:tw=78:sw=4:ts=8:noet:ft=help:norl:
*** ../vim-8.1.0486/runtime/doc/index.txt 2018-05-17 13:41:41.000000000
+0200
--- runtime/doc/index.txt 2018-10-19 18:35:52.654453150 +0200
***************
*** 1583,1588 ****
--- 1583,1591 ----
|:tjump| :tj[ump] like ":tselect", but jump directly when there
is only one match
|:tlast| :tl[ast] jump to last matching tag
+ |:tlmenu| :tlm[enu] add menu for Terminal-Job mode
+ |:tlnoremenu| :tln[oremenu] like ":noremenu" but for Terminal-Job mode
+ |:tlunmenu| :tlu[nmenu] remove menu for Terminal-Job mode
|:tmapclear| :tmapc[lear] remove all mappings for Terminal-Job mode
|:tmap| :tma[p] like ":map" but for Terminal-Job mode
|:tmenu| :tm[enu] define menu tooltip
***************
*** 1657,1660 ****
|:~| :~ repeat last ":substitute"
! vim:tw=78:ts=8:ft=help:norl:
--- 1660,1663 ----
|:~| :~ repeat last ":substitute"
! vim:tw=78:ts=8:noet:ft=help:norl:
*** ../vim-8.1.0486/runtime/doc/terminal.txt 2018-06-19 16:59:31.333713053
+0200
--- runtime/doc/terminal.txt 2018-10-19 18:35:52.658453120 +0200
***************
*** 114,119 ****
--- 114,122 ----
tnoremap <Esc> <C-W>N
set notimeout ttimeout timeoutlen=100
+ You can also create menus similar to terminal mode mappings, but you have to
+ use |:tlmenu| instead of |:tmenu|.
+
< *options-in-terminal*
After opening the terminal window and setting 'buftype' to "terminal" the
TerminalOpen autocommand event is triggered. This makes it possible to set
***************
*** 228,233 ****
--- 231,240 ----
If you want to use more options use the |term_start()|
function.
+ If you want to split the window vertically, use: >
+ :vertical terminal
+ < Or short: >
+ :vert ter
When the buffer associated with the terminal is forcibly unloaded or wiped out
the job is killed, similar to calling `job_stop(job, "kill")` .
***************
*** 523,531 ****
Functions ~
! term_sendkeys() send keystrokes to a terminal (not subject to
tmap)
! term_wait() wait for screen to be updated
! term_scrape() inspect terminal screen
==============================================================================
--- 530,538 ----
Functions ~
! |term_sendkeys()| send keystrokes to a terminal (not subject to tmap)
! |term_wait()| wait for screen to be updated
! |term_scrape()| inspect terminal screen
==============================================================================
***************
*** 552,558 ****
characters. This makes sure the dump is always this size. The function
RunVimInTerminal() takes care of this. Pass it the arguments for the Vim
command.
! - Send any commands to Vim using term_sendkeys(). For example: >
call term_sendkeys(buf, ":echo &lines &columns\<CR>")
- Check that the screen is now in the expected state, using
VerifyScreenDump(). This expects the reference screen dump to be in the
--- 559,565 ----
characters. This makes sure the dump is always this size. The function
RunVimInTerminal() takes care of this. Pass it the arguments for the Vim
command.
! - Send any commands to Vim using |term_sendkeys()|. For example: >
call term_sendkeys(buf, ":echo &lines &columns\<CR>")
- Check that the screen is now in the expected state, using
VerifyScreenDump(). This expects the reference screen dump to be in the
***************
*** 580,592 ****
*terminal-screendump*
To create the screen dump, run Vim (or any other program) in a terminal and
! make it show the desired state. Then use the term_dumpwrite() function to
create a screen dump file. For example: >
:call term_dumpwrite(77, "mysyntax.dump")
Here "77" is the buffer number of the terminal. Use `:ls!` to see it.
! You can view the screen dump with term_dumpload(): >
:call term_dumpload("mysyntax.dump")
To verify that Vim still shows exactly the same screen, run Vim again with
--- 587,599 ----
*terminal-screendump*
To create the screen dump, run Vim (or any other program) in a terminal and
! make it show the desired state. Then use the |term_dumpwrite()| function to
create a screen dump file. For example: >
:call term_dumpwrite(77, "mysyntax.dump")
Here "77" is the buffer number of the terminal. Use `:ls!` to see it.
! You can view the screen dump with |term_dumpload()|: >
:call term_dumpload("mysyntax.dump")
To verify that Vim still shows exactly the same screen, run Vim again with
***************
*** 594,600 ****
again, using a different file name: >
:call term_dumpwrite(88, "test.dump")
! To assert that the files are exactly the same use assert_equalfile(): >
call assert_equalfile("mysyntax.dump", "test.dump")
If there are differences then v:errors will contain the error message.
--- 601,607 ----
again, using a different file name: >
:call term_dumpwrite(88, "test.dump")
! To assert that the files are exactly the same use |assert_equalfile()|: >
call assert_equalfile("mysyntax.dump", "test.dump")
If there are differences then v:errors will contain the error message.
***************
*** 603,610 ****
Comparing screen dumps ~
*terminal-diffscreendump*
! assert_equalfile() does not make it easy to see what is different.
! To spot the problem use term_dumpdiff(): >
call term_dumpdiff("mysyntax.dump", "test.dump")
This will open a window consisting of three parts:
--- 610,617 ----
Comparing screen dumps ~
*terminal-diffscreendump*
! |assert_equalfile()| does not make it easy to see what is different.
! To spot the problem use |term_dumpdiff()|: >
call term_dumpdiff("mysyntax.dump", "test.dump")
This will open a window consisting of three parts:
***************
*** 613,619 ****
3. The contents of the second dump
You can usually see what differs in the second part. Use the 'ruler' to
! relate it to the position in the first or second dump.
Alternatively, press "s" to swap the first and second dump. Do this several
times so that you can spot the difference in the context of the text.
--- 620,637 ----
3. The contents of the second dump
You can usually see what differs in the second part. Use the 'ruler' to
! relate it to the position in the first or second dump. Letters indicate the
! kind of difference:
! X different character
! > cursor in first but not in second
! < cursor in second but not in first
! w character width differs (single vs double width)
! f foreground color differs
! b background color differs
! a attribute differs (bold, underline, reverse, etc.)
! ? character missing in both
! + character missing in first
! - character missing in second
Alternatively, press "s" to swap the first and second dump. Do this several
times so that you can spot the difference in the context of the text.
***************
*** 635,641 ****
Load the plugin with this command: >
packadd termdebug
< *:Termdebug*
! To start debugging use `:Termdebug` or `:TermdebugCommand`` followed by the
command name, for example: >
:Termdebug vim
--- 653,659 ----
Load the plugin with this command: >
packadd termdebug
< *:Termdebug*
! To start debugging use `:Termdebug` or `:TermdebugCommand` followed by the
command name, for example: >
:Termdebug vim
***************
*** 900,906 ****
To change the width of the Vim window when debugging starts, and use a
vertical split: >
let g:termdebug_wide = 163
! This will set &columns to 163 when :Termdebug is used. The value is restored
when quitting the debugger.
If g:termdebug_wide is set and &columns is already larger than
g:termdebug_wide then a vertical split will be used without changing &columns.
--- 918,924 ----
To change the width of the Vim window when debugging starts, and use a
vertical split: >
let g:termdebug_wide = 163
! This will set &columns to 163 when `:Termdebug` is used. The value is
restored
when quitting the debugger.
If g:termdebug_wide is set and &columns is already larger than
g:termdebug_wide then a vertical split will be used without changing &columns.
***************
*** 909,912 ****
! vim:tw=78:ts=8:ft=help:norl:
--- 927,930 ----
! vim:tw=78:ts=8:noet:ft=help:norl:
*** ../vim-8.1.0486/runtime/doc/usr_42.txt 2018-05-17 13:42:03.000000000
+0200
--- runtime/doc/usr_42.txt 2018-10-19 18:35:52.658453120 +0200
***************
*** 150,156 ****
:menu! Insert and Command-line mode
:imenu Insert mode
:cmenu Command-line mode
! :amenu All modes
To avoid that the commands of a menu item are being mapped, use the command
":noremenu", ":nnoremenu", ":anoremenu", etc.
--- 150,157 ----
:menu! Insert and Command-line mode
:imenu Insert mode
:cmenu Command-line mode
! :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.
***************
*** 362,365 ****
Next chapter: |usr_43.txt| Using filetypes
! Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl:
--- 363,366 ----
Next chapter: |usr_43.txt| Using filetypes
! Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl:
*** ../vim-8.1.0486/runtime/menu.vim 2018-07-23 05:09:05.593235641 +0200
--- runtime/menu.vim 2018-10-19 22:31:52.955188961 +0200
***************
*** 160,165 ****
--- 160,168 ----
cnoremenu 20.350 &Edit.&Copy<Tab>"+y <C-Y>
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
***************
*** 356,361 ****
--- 359,366 ----
let s:did_setup_color_schemes = 1
let n = globpath(&runtimepath, "colors/*.vim", 1, 1)
+ let n += globpath(&runtimepath, "pack/*/start/*/colors/*.vim", 1, 1)
+ let n += globpath(&runtimepath, "pack/*/opt/*/colors/*.vim", 1, 1)
" Ignore case for VMS and windows, sort on name
let names = sort(map(n, 'substitute(v:val,
"\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1)
*** ../vim-8.1.0486/src/ex_cmdidxs.h 2017-09-18 22:06:03.000000000 +0200
--- src/ex_cmdidxs.h 2018-10-19 18:35:52.658453120 +0200
***************
*** 25,36 ****
/* r */ 351,
/* s */ 370,
/* t */ 437,
! /* u */ 477,
! /* v */ 488,
! /* w */ 506,
! /* x */ 521,
! /* y */ 530,
! /* z */ 531
};
/*
--- 25,36 ----
/* r */ 351,
/* s */ 370,
/* t */ 437,
! /* u */ 480,
! /* v */ 491,
! /* w */ 509,
! /* x */ 524,
! /* y */ 533,
! /* z */ 534
};
/*
***************
*** 60,66 ****
/* q */ { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* r */ { 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 13, 18, 0, 0, 0, 0 },
/* s */ { 2, 6, 15, 0, 18, 22, 0, 24, 25, 0, 0, 28, 30, 34, 38, 40,
0, 48, 0, 49, 0, 61, 62, 0, 63, 0 },
! /* t */ { 2, 0, 19, 0, 22, 24, 0, 25, 0, 26, 0, 27, 28, 31, 33, 34,
0, 35, 37, 0, 38, 0, 0, 0, 0, 0 },
/* u */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* v */ { 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0, 9, 12, 0, 0,
0, 0, 15, 0, 16, 0, 0, 0, 0, 0 },
/* w */ { 2, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 8, 0, 9,
10, 0, 12, 0, 13, 14, 0, 0, 0, 0 },
--- 60,66 ----
/* q */ { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* r */ { 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 13, 18, 0, 0, 0, 0 },
/* s */ { 2, 6, 15, 0, 18, 22, 0, 24, 25, 0, 0, 28, 30, 34, 38, 40,
0, 48, 0, 49, 0, 61, 62, 0, 63, 0 },
! /* t */ { 2, 0, 19, 0, 22, 24, 0, 25, 0, 26, 0, 27, 31, 34, 36, 37,
0, 38, 40, 0, 41, 0, 0, 0, 0, 0 },
/* u */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* v */ { 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0, 9, 12, 0, 0,
0, 0, 15, 0, 16, 0, 0, 0, 0, 0 },
/* w */ { 2, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 8, 0, 9,
10, 0, 12, 0, 13, 14, 0, 0, 0, 0 },
***************
*** 69,72 ****
/* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
! static const int command_count = 544;
--- 69,72 ----
/* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
! static const int command_count = 547;
*** ../vim-8.1.0486/src/ex_cmds.h 2018-08-14 13:38:12.744559267 +0200
--- src/ex_cmds.h 2018-10-19 18:35:52.658453120 +0200
***************
*** 20,28 ****
* 1. Add an entry in the table below. Keep it sorted on the shortest
* version of the command name that works. If it doesn't start with a
* lower case letter, add it at the end.
! * 2. Add a "case: CMD_xxx" in the big switch in ex_docmd.c.
! * 3. Add an entry in the index for Ex commands at ":help ex-cmd-index".
! * 4. Add documentation in ../doc/xxx.txt. Add a tag for both the short and
* long name of the command.
*/
--- 20,29 ----
* 1. Add an entry in the table below. Keep it sorted on the shortest
* version of the command name that works. If it doesn't start with a
* lower case letter, add it at the end.
! * 2. Run "make cmdidxs" to re-generate ex_cmdidxs.h.
! * 3. Add a "case: CMD_xxx" in the big switch in ex_docmd.c.
! * 4. Add an entry in the index for Ex commands at ":help ex-cmd-index".
! * 5. Add documentation in ../doc/xxx.txt. Add a tag for both the short and
* long name of the command.
*/
***************
*** 176,182 ****
BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR,
ADDR_BUFFERS),
EX(CMD_behave, "behave", ex_behave,
! NEEDARG|WORD1|TRLBAR|CMDWIN,
ADDR_LINES),
EX(CMD_belowright, "belowright", ex_wrongmodifier,
NEEDARG|EXTRA|NOTRLCOM,
--- 177,183 ----
BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR,
ADDR_BUFFERS),
EX(CMD_behave, "behave", ex_behave,
! BANG|NEEDARG|WORD1|TRLBAR|CMDWIN,
ADDR_LINES),
EX(CMD_belowright, "belowright", ex_wrongmodifier,
NEEDARG|EXTRA|NOTRLCOM,
***************
*** 1498,1503 ****
--- 1499,1513 ----
EX(CMD_tlast, "tlast", ex_tag,
BANG|TRLBAR,
ADDR_LINES),
+ EX(CMD_tlmenu, "tlmenu", ex_menu,
+
RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN,
+ ADDR_LINES),
+ EX(CMD_tlnoremenu, "tlnoremenu", ex_menu,
+
RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN,
+ ADDR_LINES),
+ EX(CMD_tlunmenu, "tlunmenu", ex_menu,
+
RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN,
+ ADDR_LINES),
EX(CMD_tmenu, "tmenu", ex_menu,
RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN,
ADDR_LINES),
*** ../vim-8.1.0486/src/ex_docmd.c 2018-10-02 16:23:55.323037143 +0200
--- src/ex_docmd.c 2018-10-19 18:35:52.658453120 +0200
***************
*** 4283,4288 ****
--- 4283,4289 ----
case CMD_omenu: case CMD_onoremenu: case CMD_ounmenu:
case CMD_imenu: case CMD_inoremenu: case CMD_iunmenu:
case CMD_cmenu: case CMD_cnoremenu: case CMD_cunmenu:
+ case CMD_tlmenu: case CMD_tlnoremenu: case CMD_tlunmenu:
case CMD_tmenu: case CMD_tunmenu:
case CMD_popup: case CMD_tearoff: case CMD_emenu:
return set_context_in_menu_cmd(xp, cmd, arg, forceit);
*** ../vim-8.1.0486/src/menu.c 2018-09-10 21:04:09.872392623 +0200
--- src/menu.c 2018-10-19 19:18:38.677792759 +0200
***************
*** 58,64 ****
static char_u *menu_translate_tab_and_shift(char_u *arg_start);
/* The character for each menu mode */
! static char_u menu_mode_chars[] = {'n', 'v', 's', 'o', 'i', 'c', 't'};
static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not
sub-menu");
static char_u e_othermode[] = N_("E328: Menu only exists in another mode");
--- 58,64 ----
static char_u *menu_translate_tab_and_shift(char_u *arg_start);
/* The character for each menu mode */
! static char *menu_mode_chars[] = {"n", "v", "s", "o", "i", "c", "tl", "t"};
static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not
sub-menu");
static char_u e_othermode[] = N_("E328: Menu only exists in another mode");
***************
*** 1196,1202 ****
return;
for (i = 0; i < depth + 2; i++)
MSG_PUTS(" ");
! msg_putchar(menu_mode_chars[bit]);
if (menu->noremap[bit] == REMAP_NONE)
msg_putchar('*');
else if (menu->noremap[bit] == REMAP_SCRIPT)
--- 1196,1202 ----
return;
for (i = 0; i < depth + 2; i++)
MSG_PUTS(" ");
! msg_puts((char_u*)menu_mode_chars[bit]);
if (menu->noremap[bit] == REMAP_NONE)
msg_putchar('*');
else if (menu->noremap[bit] == REMAP_SCRIPT)
***************
*** 1645,1650 ****
--- 1645,1656 ----
modes = MENU_INSERT_MODE;
break;
case 't':
+ if (*cmd == 'l') /* tlmenu, tlunmenu, tlnoremenu */
+ {
+ modes = MENU_TERMINAL_MODE;
+ ++cmd;
+ break;
+ }
modes = MENU_TIP_MODE; /* tmenu */
break;
case 'c': /* cmenu */
***************
*** 1687,1698 ****
{
char_u *p;
int len = (int)STRLEN(name);
! p = vim_strnsave(name, len + 1);
if (p != NULL)
{
! mch_memmove(p + 6, p + 5, (size_t)(len - 4));
! p[5] = menu_mode_chars[idx];
}
return p;
}
--- 1693,1710 ----
{
char_u *p;
int len = (int)STRLEN(name);
+ char *mode_chars = menu_mode_chars[idx];
+ int mode_chars_len = (int)strlen(mode_chars);
+ int i;
! p = vim_strnsave(name, len + mode_chars_len);
if (p != NULL)
{
! mch_memmove(p + 5 + mode_chars_len, p + 5, (size_t)(len - 4));
! for (i = 0; i < mode_chars_len; ++i)
! {
! p[5 + i] = menu_mode_chars[idx][i];
! }
}
return p;
}
***************
*** 1712,1717 ****
--- 1724,1733 ----
idx = MENU_INDEX_INSERT;
else if (state & CMDLINE)
idx = MENU_INDEX_CMDLINE;
+ #ifdef FEAT_TERMINAL
+ else if (term_use_loop())
+ idx = MENU_INDEX_TERMINAL;
+ #endif
else if (VIsual_active)
{
if (VIsual_select)
***************
*** 1872,1877 ****
--- 1888,1899 ----
static int
get_menu_mode(void)
{
+ #ifdef FEAT_TERMINAL
+ if (term_use_loop())
+ {
+ return MENU_INDEX_TERMINAL;
+ }
+ #endif
if (VIsual_active)
{
if (VIsual_select)
***************
*** 1910,1932 ****
show_popupmenu(void)
{
vimmenu_T *menu;
! int mode;
! mode = get_menu_mode();
! if (mode == MENU_INDEX_INVALID)
return;
! mode = menu_mode_chars[mode];
! {
! char_u ename[2];
!
! ename[0] = mode;
! ename[1] = NUL;
! apply_autocmds(EVENT_MENUPOPUP, ename, NULL, FALSE, curbuf);
! }
for (menu = root_menu; menu != NULL; menu = menu->next)
! if (STRNCMP("PopUp", menu->name, 5) == 0 && menu->name[5] == mode)
break;
/* Only show a popup when it is defined and has entries */
--- 1932,1951 ----
show_popupmenu(void)
{
vimmenu_T *menu;
! int menu_mode;
! char* mode;
! int mode_len;
! menu_mode = get_menu_mode();
! if (menu_mode == MENU_INDEX_INVALID)
return;
! mode = menu_mode_chars[menu_mode];
! mode_len = (int)strlen(mode);
! apply_autocmds(EVENT_MENUPOPUP, (char_u*)mode, NULL, FALSE, curbuf);
for (menu = root_menu; menu != NULL; menu = menu->next)
! if (STRNCMP("PopUp", menu->name, 5) == 0 && STRNCMP(menu->name + 5,
mode, mode_len) == 0)
break;
/* Only show a popup when it is defined and has entries */
***************
*** 2249,2330 ****
/*
* Execute "menu". Use by ":emenu" and the window toolbar.
* "eap" is NULL for the window toolbar.
*/
void
! execute_menu(exarg_T *eap, vimmenu_T *menu)
{
! char_u *mode;
! int idx = -1;
! /* Use the Insert mode entry when returning to Insert mode. */
! if (restart_edit
#ifdef FEAT_EVAL
! && !current_sctx.sc_sid
#endif
! )
! {
! mode = (char_u *)"Insert";
! idx = MENU_INDEX_INSERT;
! }
! else if (VIsual_active)
! {
! mode = (char_u *)"Visual";
! idx = MENU_INDEX_VISUAL;
! }
! else if (eap != NULL && eap->addr_count)
! {
! pos_T tpos;
!
! mode = (char_u *)"Visual";
! idx = MENU_INDEX_VISUAL;
!
! /* GEDDES: This is not perfect - but it is a
! * quick way of detecting whether we are doing this from a
! * selection - see if the range matches up with the visual
! * select start and end. */
! if ((curbuf->b_visual.vi_start.lnum == eap->line1)
! && (curbuf->b_visual.vi_end.lnum) == eap->line2)
! {
! /* Set it up for visual mode - equivalent to gv. */
! VIsual_mode = curbuf->b_visual.vi_mode;
! tpos = curbuf->b_visual.vi_end;
! curwin->w_cursor = curbuf->b_visual.vi_start;
! curwin->w_curswant = curbuf->b_visual.vi_curswant;
}
! else
{
! /* Set it up for line-wise visual mode */
! VIsual_mode = 'V';
! curwin->w_cursor.lnum = eap->line1;
! curwin->w_cursor.col = 1;
! tpos.lnum = eap->line2;
! tpos.col = MAXCOL;
! #ifdef FEAT_VIRTUALEDIT
! tpos.coladd = 0;
#endif
}
! /* Activate visual mode */
! VIsual_active = TRUE;
! VIsual_reselect = TRUE;
! check_cursor();
! VIsual = curwin->w_cursor;
! curwin->w_cursor = tpos;
! check_cursor();
! /* Adjust the cursor to make sure it is in the correct pos
! * for exclusive mode */
! if (*p_sel == 'e' && gchar_cursor() != NUL)
! ++curwin->w_cursor.col;
}
/* For the WinBar menu always use the Normal mode menu. */
if (idx == -1 || eap == NULL)
- {
- mode = (char_u *)"Normal";
idx = MENU_INDEX_NORMAL;
- }
if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL)
{
--- 2268,2353 ----
/*
* Execute "menu". Use by ":emenu" and the window toolbar.
* "eap" is NULL for the window toolbar.
+ * "mode_idx" specifies a MENU_INDEX_ value, use -1 to depend on the current
+ * state.
*/
void
! execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
{
! int idx = mode_idx;
! if (idx < 0)
! {
! /* Use the Insert mode entry when returning to Insert mode. */
! if (restart_edit
#ifdef FEAT_EVAL
! && !current_sctx.sc_sid
#endif
! )
! {
! idx = MENU_INDEX_INSERT;
}
! #ifdef FEAT_TERMINAL
! else if (term_use_loop())
{
! idx = MENU_INDEX_TERMINAL;
! }
#endif
+ else if (VIsual_active)
+ {
+ idx = MENU_INDEX_VISUAL;
}
+ else if (eap != NULL && eap->addr_count)
+ {
+ pos_T tpos;
! idx = MENU_INDEX_VISUAL;
! /* GEDDES: This is not perfect - but it is a
! * quick way of detecting whether we are doing this from a
! * selection - see if the range matches up with the visual
! * select start and end. */
! if ((curbuf->b_visual.vi_start.lnum == eap->line1)
! && (curbuf->b_visual.vi_end.lnum) == eap->line2)
! {
! /* Set it up for visual mode - equivalent to gv. */
! VIsual_mode = curbuf->b_visual.vi_mode;
! tpos = curbuf->b_visual.vi_end;
! curwin->w_cursor = curbuf->b_visual.vi_start;
! curwin->w_curswant = curbuf->b_visual.vi_curswant;
! }
! else
! {
! /* Set it up for line-wise visual mode */
! VIsual_mode = 'V';
! curwin->w_cursor.lnum = eap->line1;
! curwin->w_cursor.col = 1;
! tpos.lnum = eap->line2;
! tpos.col = MAXCOL;
! #ifdef FEAT_VIRTUALEDIT
! tpos.coladd = 0;
! #endif
! }
! /* Activate visual mode */
! VIsual_active = TRUE;
! VIsual_reselect = TRUE;
! check_cursor();
! VIsual = curwin->w_cursor;
! curwin->w_cursor = tpos;
!
! check_cursor();
!
! /* Adjust the cursor to make sure it is in the correct pos
! * for exclusive mode */
! if (*p_sel == 'e' && gchar_cursor() != NUL)
! ++curwin->w_cursor.col;
! }
}
/* For the WinBar menu always use the Normal mode menu. */
if (idx == -1 || eap == NULL)
idx = MENU_INDEX_NORMAL;
if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL)
{
***************
*** 2351,2357 ****
--- 2374,2408 ----
TRUE, menu->silent[idx]);
}
else if (eap != NULL)
+ {
+ char_u *mode;
+
+ switch (idx)
+ {
+ case MENU_INDEX_VISUAL:
+ mode = (char_u *)"Visual";
+ break;
+ case MENU_INDEX_SELECT:
+ mode = (char_u *)"Select";
+ break;
+ case MENU_INDEX_OP_PENDING:
+ mode = (char_u *)"Op-pending";
+ break;
+ case MENU_INDEX_TERMINAL:
+ mode = (char_u *)"Terminal";
+ break;
+ case MENU_INDEX_INSERT:
+ mode = (char_u *)"Insert";
+ break;
+ case MENU_INDEX_CMDLINE:
+ mode = (char_u *)"Cmdline";
+ break;
+ // case MENU_INDEX_TIP: cannot happen
+ default:
+ mode = (char_u *)"Normal";
+ }
EMSG2(_("E335: Menu not defined for %s mode"), mode);
+ }
}
/*
***************
*** 2364,2372 ****
vimmenu_T *menu;
char_u *name;
char_u *saved_name;
char_u *p;
! saved_name = vim_strsave(eap->arg);
if (saved_name == NULL)
return;
--- 2415,2443 ----
vimmenu_T *menu;
char_u *name;
char_u *saved_name;
+ char_u *arg = eap->arg;
char_u *p;
+ int gave_emsg = FALSE;
+ int mode_idx = -1;
+
+ if (arg[0] && VIM_ISWHITE(arg[1]))
+ {
+ switch (arg[0])
+ {
+ case 'n': mode_idx = MENU_INDEX_NORMAL; break;
+ case 'v': mode_idx = MENU_INDEX_VISUAL; break;
+ case 's': mode_idx = MENU_INDEX_SELECT; break;
+ case 'o': mode_idx = MENU_INDEX_OP_PENDING; break;
+ case 't': mode_idx = MENU_INDEX_TERMINAL; break;
+ case 'i': mode_idx = MENU_INDEX_INSERT; break;
+ case 'c': mode_idx = MENU_INDEX_CMDLINE; break;
+ default: EMSG2(_(e_invarg2), arg);
+ return;
+ }
+ arg = skipwhite(arg + 2);
+ }
! saved_name = vim_strsave(arg);
if (saved_name == NULL)
return;
***************
*** 2384,2389 ****
--- 2455,2461 ----
if (*p == NUL && menu->children != NULL)
{
EMSG(_("E333: Menu path must lead to a menu item"));
+ gave_emsg = TRUE;
menu = NULL;
}
else if (*p != NUL && menu->children == NULL)
***************
*** 2403,2414 ****
vim_free(saved_name);
if (menu == NULL)
{
! EMSG2(_("E334: Menu not found: %s"), eap->arg);
return;
}
! /* Found the menu, so execute. */
! execute_menu(eap, menu);
}
/*
--- 2475,2487 ----
vim_free(saved_name);
if (menu == NULL)
{
! if (!gave_emsg)
! EMSG2(_("E334: Menu not found: %s"), arg);
return;
}
! // Found the menu, so execute.
! execute_menu(eap, menu, mode_idx);
}
/*
***************
*** 2445,2451 ****
check_cursor();
}
! execute_menu(NULL, item->wb_menu);
if (save_curwin != NULL)
{
--- 2518,2524 ----
check_cursor();
}
! execute_menu(NULL, item->wb_menu, -1);
if (save_curwin != NULL)
{
*** ../vim-8.1.0486/src/proto/menu.pro 2018-05-17 13:52:44.000000000 +0200
--- src/proto/menu.pro 2018-10-19 19:18:21.773946949 +0200
***************
*** 19,25 ****
void gui_update_menus(int modes);
int gui_is_menu_shortcut(int key);
void gui_mch_toggle_tearoffs(int enable);
! void execute_menu(exarg_T *eap, vimmenu_T *menu);
void ex_emenu(exarg_T *eap);
void winbar_click(win_T *wp, int col);
vimmenu_T *gui_find_menu(char_u *path_name);
--- 19,25 ----
void gui_update_menus(int modes);
int gui_is_menu_shortcut(int key);
void gui_mch_toggle_tearoffs(int enable);
! void execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx);
void ex_emenu(exarg_T *eap);
void winbar_click(win_T *wp, int col);
vimmenu_T *gui_find_menu(char_u *path_name);
*** ../vim-8.1.0486/src/popupmnu.c 2018-09-09 15:27:54.808344790 +0200
--- src/popupmnu.c 2018-10-19 19:06:36.212711840 +0200
***************
*** 1176,1182 ****
if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected)
{
vim_memset(&ea, 0, sizeof(ea));
! execute_menu(&ea, mp);
break;
}
}
--- 1176,1182 ----
if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected)
{
vim_memset(&ea, 0, sizeof(ea));
! execute_menu(&ea, mp, -1);
break;
}
}
*** ../vim-8.1.0486/src/structs.h 2018-10-14 22:38:06.161665231 +0200
--- src/structs.h 2018-10-19 18:35:52.662453090 +0200
***************
*** 3101,3108 ****
#define MENU_INDEX_OP_PENDING 3
#define MENU_INDEX_INSERT 4
#define MENU_INDEX_CMDLINE 5
! #define MENU_INDEX_TIP 6
! #define MENU_MODES 7
/* Menu modes */
#define MENU_NORMAL_MODE (1 << MENU_INDEX_NORMAL)
--- 3101,3109 ----
#define MENU_INDEX_OP_PENDING 3
#define MENU_INDEX_INSERT 4
#define MENU_INDEX_CMDLINE 5
! #define MENU_INDEX_TERMINAL 6
! #define MENU_INDEX_TIP 7
! #define MENU_MODES 8
/* Menu modes */
#define MENU_NORMAL_MODE (1 << MENU_INDEX_NORMAL)
***************
*** 3111,3116 ****
--- 3112,3118 ----
#define MENU_OP_PENDING_MODE (1 << MENU_INDEX_OP_PENDING)
#define MENU_INSERT_MODE (1 << MENU_INDEX_INSERT)
#define MENU_CMDLINE_MODE (1 << MENU_INDEX_CMDLINE)
+ #define MENU_TERMINAL_MODE (1 << MENU_INDEX_TERMINAL)
#define MENU_TIP_MODE (1 << MENU_INDEX_TIP)
#define MENU_ALL_MODES ((1 << MENU_INDEX_TIP) - 1)
/*note MENU_INDEX_TIP is not a 'real' mode*/
*** ../vim-8.1.0486/src/testdir/test_menu.vim 2017-03-18 20:09:29.000000000
+0100
--- src/testdir/test_menu.vim 2018-10-19 22:19:19.563500587 +0200
***************
*** 30,32 ****
--- 30,66 ----
source $VIMRUNTIME/delmenu.vim
endfunc
+
+ func Test_menu_commands()
+ nmenu 2 Test.FooBar :let g:did_menu = 'normal'<CR>
+ vmenu 2 Test.FooBar :let g:did_menu = 'visual'<CR>
+ smenu 2 Test.FooBar :let g:did_menu = 'select'<CR>
+ omenu 2 Test.FooBar :let g:did_menu = 'op-pending'<CR>
+ tlmenu 2 Test.FooBar :let g:did_menu = 'terminal'<CR>
+ imenu 2 Test.FooBar :let g:did_menu = 'insert'<CR>
+ cmenu 2 Test.FooBar :let g:did_menu = 'cmdline'<CR>
+ emenu n Test.FooBar
+ call assert_equal('normal', g:did_menu)
+ emenu v Test.FooBar
+ call assert_equal('visual', g:did_menu)
+ emenu s Test.FooBar
+ call assert_equal('select', g:did_menu)
+ emenu o Test.FooBar
+ call assert_equal('op-pending', g:did_menu)
+ emenu t Test.FooBar
+ call assert_equal('terminal', g:did_menu)
+ emenu i Test.FooBar
+ call assert_equal('insert', g:did_menu)
+ emenu c Test.FooBar
+ call assert_equal('cmdline', g:did_menu)
+
+ aunmenu Test.FooBar
+ tlunmenu Test.FooBar
+ call assert_fails('emenu n Test.FooBar', 'E334:')
+
+ nmenu 2 Test.FooBar.Child :let g:did_menu = 'foobar'<CR>
+ call assert_fails('emenu n Test.FooBar', 'E333:')
+ nunmenu Test.FooBar.Child
+
+ unlet g:did_menu
+ endfun
*** ../vim-8.1.0486/src/version.c 2018-10-19 17:35:58.081200733 +0200
--- src/version.c 2018-10-19 18:36:44.394062760 +0200
***************
*** 794,795 ****
--- 794,797 ----
{ /* Add new patch number below this line */
+ /**/
+ 487,
/**/
--
"Women marry men hoping they will change. Men marry women hoping
they will not. So each is inevitably disappointed."
- Einstein
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.