From 71137fed4d77e985d49ca32c79f030512767b8ce Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 3 Mar 2018 20:47:21 +0100 Subject: patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse Problem: The terminal debugger can't set a breakpoint with the mouse. Solution: Add popup menu entries. --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 68 +++++++++++++++++----- 1 file changed, 52 insertions(+), 16 deletions(-) (limited to 'runtime/pack/dist/opt/termdebug/plugin/termdebug.vim') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 84ac0de424..add0de9817 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -201,7 +201,7 @@ endfunc " Install commands in the current window to control the debugger. func s:InstallCommands() command Break call s:SetBreakpoint() - command Delete call s:DeleteBreakpoint() + 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,24 +212,42 @@ func s:InstallCommands() 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 != '' - 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 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 Delete + delcommand Clear delcommand Step delcommand Over delcommand Finish @@ -240,16 +258,34 @@ func s:DeleteCommands() delcommand Evaluate delcommand Gdb delcommand Program + delcommand Winbar nunmap K if has('menu') - aunmenu WinBar.Step - aunmenu WinBar.Next - aunmenu WinBar.Finish - aunmenu WinBar.Cont - aunmenu WinBar.Stop - aunmenu WinBar.Eval + " 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,8 +314,8 @@ func s:SetBreakpoint() endif endfunc -" :Delete - Delete a breakpoint at the cursor position. -func s:DeleteBreakpoint() +" :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) -- cgit v1.2.3