To: vim_dev@googlegroups.com Subject: Patch 8.1.04 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 --- 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 *************** *** 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 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\") - 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\") - 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"+y nnoremenu 20.360 &Edit.&Paste"+gP "+gP cnoremenu &Edit.&Paste"+gP + + if exists(':tlmenu') + tlnoremenu &Edit.&Paste"+gP "+ + endif exe 'vnoremenu