To: vim_dev@googlegroups.com Subject: Patch 8.0.1562 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1562 Problem: The terminal debugger can't set a breakpoint with the mouse. Solution: Add popup menu entries. Files: runtime/pack/dist/opt/termdebug/plugin/termdebug.vim, runtime/doc/terminal.txt *** ../vim-8.0.1561/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim 2017-11-19 19:56:21.617894971 +0100 --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim 2018-03-03 20:26:53.699421654 +0100 *************** *** 201,207 **** " Install commands in the current window to control the debugger. func s:InstallCommands() command Break call s:SetBreakpoint() ! command Delete call s:DeleteBreakpoint() command Step call s:SendCommand('-exec-step') command Over call s:SendCommand('-exec-next') command Finish call s:SendCommand('-exec-finish') --- 201,207 ---- " Install commands in the current window to control the debugger. func s:InstallCommands() command Break call s:SetBreakpoint() ! command Clear call s:ClearBreakpoint() command Step call s:SendCommand('-exec-step') command Over call s:SendCommand('-exec-next') command Finish call s:SendCommand('-exec-finish') *************** *** 212,235 **** command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) command Program call win_gotoid(s:ptywin) " TODO: can the K mapping be restored? nnoremap K :Evaluate ! if has('menu') ! nnoremenu WinBar.Step :Step ! nnoremenu WinBar.Next :Over ! nnoremenu WinBar.Finish :Finish ! nnoremenu WinBar.Cont :Continue ! nnoremenu WinBar.Stop :Stop ! nnoremenu WinBar.Eval :Evaluate endif endfunc " Delete installed debugger commands in the current window. func s:DeleteCommands() delcommand Break ! delcommand Delete delcommand Step delcommand Over delcommand Finish --- 212,253 ---- command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) command Program call win_gotoid(s:ptywin) + command Winbar call s:InstallWinbar() " TODO: can the K mapping be restored? nnoremap K :Evaluate ! if has('menu') && &mouse != '' ! call s:InstallWinbar() ! ! if !exists('g:termdebug_popup') || g:termdebug_popup != 0 ! let s:saved_mousemodel = &mousemodel ! let &mousemodel = 'popup_setpos' ! an 1.200 PopUp.-SEP3- ! an 1.210 PopUp.Set\ breakpoint :Break ! an 1.220 PopUp.Clear\ breakpoint :Clear ! an 1.230 PopUp.Evaluate :Evaluate ! endif endif endfunc + let s:winbar_winids = [] + + " Install the window toolbar in the current window. + func s:InstallWinbar() + nnoremenu WinBar.Step :Step + nnoremenu WinBar.Next :Over + nnoremenu WinBar.Finish :Finish + nnoremenu WinBar.Cont :Continue + nnoremenu WinBar.Stop :Stop + nnoremenu WinBar.Eval :Evaluate + call add(s:winbar_winids, win_getid(winnr())) + endfunc + " Delete installed debugger commands in the current window. func s:DeleteCommands() delcommand Break ! delcommand Clear delcommand Step delcommand Over delcommand Finish *************** *** 240,255 **** delcommand Evaluate delcommand Gdb delcommand Program nunmap K if has('menu') ! aunmenu WinBar.Step ! aunmenu WinBar.Next ! aunmenu WinBar.Finish ! aunmenu WinBar.Cont ! aunmenu WinBar.Stop ! aunmenu WinBar.Eval endif exe 'sign unplace ' . s:pc_id --- 258,291 ---- delcommand Evaluate delcommand Gdb delcommand Program + delcommand Winbar nunmap K if has('menu') ! " Remove the WinBar entries from all windows where it was added. ! let curwinid = win_getid(winnr()) ! for winid in s:winbar_winids ! if win_gotoid(winid) ! aunmenu WinBar.Step ! aunmenu WinBar.Next ! aunmenu WinBar.Finish ! aunmenu WinBar.Cont ! aunmenu WinBar.Stop ! aunmenu WinBar.Eval ! endif ! endfor ! call win_gotoid(curwinid) ! let s:winbar_winids = [] ! ! if exists('s:saved_mousemodel') ! let &mousemodel = s:saved_mousemodel ! unlet s:saved_mousemodel ! aunmenu PopUp.-SEP3- ! aunmenu PopUp.Set\ breakpoint ! aunmenu PopUp.Clear\ breakpoint ! aunmenu PopUp.Evaluate ! endif endif exe 'sign unplace ' . s:pc_id *************** *** 278,285 **** endif endfunc ! " :Delete - Delete a breakpoint at the cursor position. ! func s:DeleteBreakpoint() let fname = fnameescape(expand('%:p')) let lnum = line('.') for [key, val] in items(s:breakpoints) --- 314,321 ---- endif endfunc ! " :Clear - Delete a breakpoint at the cursor position. ! func s:ClearBreakpoint() let fname = fnameescape(expand('%:p')) let lnum = line('.') for [key, val] in items(s:breakpoints) *************** *** 325,333 **** --- 361,371 ---- else let expr = expand('') endif + let s:ignoreEvalError = 0 call s:SendEval(expr) endfunc + let s:ignoreEvalError = 0 let s:evalFromBalloonExpr = 0 " Handle the result of data-evaluate-expression *************** *** 347,352 **** --- 385,391 ---- if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$' " Looks like a pointer, also display what it points to. + let s:ignoreEvalError = 1 call s:SendEval('*' . s:evalexpr) else let s:evalFromBalloonExpr = 0 *************** *** 359,377 **** if v:beval_winid != s:startwin return endif - call s:SendEval(v:beval_text) let s:evalFromBalloonExpr = 1 let s:evalFromBalloonExprResult = '' return '' endfunc " Handle an error. func s:HandleError(msg) ! if a:msg =~ 'No symbol .* in current context' ! \ || a:msg =~ 'Cannot access memory at address ' ! \ || a:msg =~ 'Attempt to use a type name as an expression' ! \ || a:msg =~ 'A syntax error in expression,' " Result of s:SendEval() failed, ignore. return endif echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') --- 398,416 ---- if v:beval_winid != s:startwin return endif let s:evalFromBalloonExpr = 1 let s:evalFromBalloonExprResult = '' + let s:ignoreEvalError = 1 + call s:SendEval(v:beval_text) return '' endfunc " Handle an error. func s:HandleError(msg) ! if s:ignoreEvalError " Result of s:SendEval() failed, ignore. + let s:ignoreEvalError = 0 + let s:evalFromBalloonExpr = 0 return endif echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') *** ../vim-8.0.1561/runtime/doc/terminal.txt 2018-02-20 15:50:49.304325584 +0100 --- runtime/doc/terminal.txt 2018-03-03 20:43:44.160802765 +0100 *************** *** 7,14 **** Terminal window support *terminal* - WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE - The terminal feature is optional, use this to check if your Vim has it: > echo has('terminal') If the result is "1" you have it. --- 7,12 ---- *************** *** 40,46 **** {Vi does not have any of these commands} {only available when compiled with the |+terminal| feature} - The terminal feature requires the |+multi_byte|, |+job| and |+channel| features. ============================================================================== --- 38,43 ---- *************** *** 481,487 **** The current window is used to show the source code. When gdb pauses the source file location will be displayed, if possible. A sign is used to ! highlight the current position (using highlight group debugPC). If the buffer in the current window is modified, another window will be opened to display the current gdb position. --- 478,484 ---- The current window is used to show the source code. When gdb pauses the source file location will be displayed, if possible. A sign is used to ! highlight the current position, using highlight group debugPC. If the buffer in the current window is modified, another window will be opened to display the current gdb position. *************** *** 506,511 **** --- 503,509 ---- source - where you started, has a window toolbar with buttons gdb - you can type gdb commands here program - the executed program will use this window + You can use CTRL-W CTRL-W or the mouse to move focus between windows. Put focus on the gdb window and type: > break ex_help *************** *** 526,531 **** --- 524,531 ---- This way you can inspect the value of local variables. You can also focus the gdb window and use a "print" command, e.g.: > print *eap + If mouse pointer movements are working, Vim will also show a balloon when the + mouse rests on text that can be evaluated by gdb. Now go back to the source window and put the cursor on the first line after the for loop, then type: > *************** *** 561,598 **** - frame N go to the Nth stack frame - continue continue execution ! In the window showing the source code these commands can used to control gdb: ! :Run [args] run the program with [args] or the previous arguments ! :Arguments {args} set arguments for the next :Run ! ! :Break set a breakpoint at the current line; a sign will be displayed ! :Delete delete a breakpoint at the current line ! ! :Step execute the gdb "step" command ! :Over execute the gdb "next" command (:Next is a Vim command) ! :Finish execute the gdb "finish" command ! :Continue execute the gdb "continue" command ! :Stop interrupt the program If 'mouse' is set the plugin adds a window toolbar with these entries: ! Step :Step ! Next :Over ! Finish :Finish ! Cont :Continue ! Stop :Stop ! Eval :Evaluate This way you can use the mouse to perform the most common commands. You need to have the 'mouse' option set to enable mouse clicks. Inspecting variables ~ *termdebug-variables* ! :Evaluate evaluate the expression under the cursor ! K same ! :Evaluate {expr} evaluate {expr} ! :'<,'>Evaluate evaluate the Visually selected text This is similar to using "print" in the gdb window. Other commands ~ --- 561,602 ---- - frame N go to the Nth stack frame - continue continue execution ! In the window showing the source code these commands can be used to control gdb: ! `:Run` [args] run the program with [args] or the previous arguments ! `:Arguments` {args} set arguments for the next `:Run` ! ! `:Break` set a breakpoint at the current line; a sign will be displayed ! `:Clear` delete the breakpoint at the current line ! ! `:Step` execute the gdb "step" command ! `:Over` execute the gdb "next" command (`:Next` is a Vim command) ! `:Finish` execute the gdb "finish" command ! `:Continue` execute the gdb "continue" command ! `:Stop` interrupt the program If 'mouse' is set the plugin adds a window toolbar with these entries: ! Step `:Step` ! Next `:Over` ! Finish `:Finish` ! Cont `:Continue` ! Stop `:Stop` ! Eval `:Evaluate` This way you can use the mouse to perform the most common commands. You need to have the 'mouse' option set to enable mouse clicks. + You can add the window toolbar in other windows you open with: > + :Winbar + Inspecting variables ~ *termdebug-variables* ! `:Evaluate` evaluate the expression under the cursor ! `K` same ! `:Evaluate` {expr} evaluate {expr} ! `:'<,'>Evaluate` evaluate the Visually selected text This is similar to using "print" in the gdb window. + You can usually shorten `:Evaluate` to `:Ev`. Other commands ~ *************** *** 609,625 **** Customizing ~ ! *termdebug-customizing* To change the name of the gdb command, set the "termdebugger" variable before invoking `:Termdebug`: > let termdebugger = "mygdb" ! < *gdb-version* Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI interface. This probably requires gdb version 7.12. if you get this error: Undefined command: "new-ui". Try "help".~ Then your gdb is too old. ! *hl-debugPC* *hl-debugBreakpoint* The color of the signs can be adjusted with these highlight groups: - debugPC the current position - debugBreakpoint a breakpoint --- 613,633 ---- Customizing ~ ! ! GDB command *termdebug-customizing* ! To change the name of the gdb command, set the "termdebugger" variable before invoking `:Termdebug`: > let termdebugger = "mygdb" ! < *gdb-version* Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI interface. This probably requires gdb version 7.12. if you get this error: Undefined command: "new-ui". Try "help".~ Then your gdb is too old. ! ! Colors *hl-debugPC* *hl-debugBreakpoint* ! The color of the signs can be adjusted with these highlight groups: - debugPC the current position - debugBreakpoint a breakpoint *************** *** 632,637 **** --- 640,659 ---- hi debugPC term=reverse ctermbg=darkblue guibg=darkblue hi debugBreakpoint term=reverse ctermbg=red guibg=red + + Popup menu *termdebug_popup* + + By default the Termdebug plugin sets 'mousemodel' to "popup_setpos" and adds + these entries to the popup menu: + Set breakpoint `:Break` + Clear breakpoint `:Clear` + Evaluate `:Evaluate` + If you don't want this then disable it with: > + let g:termdebug_popup = 0 + + + Vim window width *termdebug_wide* + To change the width of the Vim window when debugging starts, and use a vertical split: > let g:termdebug_wide = 163 *** ../vim-8.0.1561/src/version.c 2018-03-03 20:02:13.704760116 +0100 --- src/version.c 2018-03-03 20:30:06.590168200 +0100 *************** *** 780,781 **** --- 780,783 ---- { /* Add new patch number below this line */ + /**/ + 1562, /**/ -- Mynd you, m00se bites Kan be pretty nasti ... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///