summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-03-03 20:47:21 +0100
committerBram Moolenaar <Bram@vim.org>2018-03-03 20:47:21 +0100
commit71137fed4d77e985d49ca32c79f030512767b8ce (patch)
tree0b81e0745769bd0b5428baa8d03080ab026d74c7
parent069dafc1ded60d9ee0fee4bcecce78ac8a235d87 (diff)
downloadvim-71137fed4d77e985d49ca32c79f030512767b8ce.zip
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.
-rw-r--r--runtime/doc/terminal.txt76
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim68
-rw-r--r--src/version.c2
3 files changed, 103 insertions, 43 deletions
diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt
index 9a35341f7..4bd0373be 100644
--- a/runtime/doc/terminal.txt
+++ b/runtime/doc/terminal.txt
@@ -7,8 +7,6 @@
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.
@@ -40,7 +38,6 @@ If the result is "1" you have it.
{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.
==============================================================================
@@ -481,7 +478,7 @@ program window A terminal window for the executed program. When "run" is
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).
+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,6 +503,7 @@ You should now have three windows:
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,6 +524,8 @@ displayed:
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,38 +561,42 @@ Put focus on the gdb window to type commands there. Some common ones are:
- 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
+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
- :Delete delete a breakpoint at the current line
+ `: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
+ `: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
+ 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
+ `: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,17 +613,21 @@ will break the debugger.
Customizing ~
- *termdebug-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*
+< *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*
+
+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,6 +640,20 @@ When 'background' is "dark":
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
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index 84ac0de42..add0de981 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(<range>, <q-args>)
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<CR>
if has('menu') && &mouse != ''
- nnoremenu WinBar.Step :Step<CR>
- nnoremenu WinBar.Next :Over<CR>
- nnoremenu WinBar.Finish :Finish<CR>
- nnoremenu WinBar.Cont :Continue<CR>
- nnoremenu WinBar.Stop :Stop<CR>
- nnoremenu WinBar.Eval :Evaluate<CR>
+ 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- <Nop>
+ an 1.210 PopUp.Set\ breakpoint :Break<CR>
+ an 1.220 PopUp.Clear\ breakpoint :Clear<CR>
+ an 1.230 PopUp.Evaluate :Evaluate<CR>
+ endif
endif
endfunc
+let s:winbar_winids = []
+
+" Install the window toolbar in the current window.
+func s:InstallWinbar()
+ nnoremenu WinBar.Step :Step<CR>
+ nnoremenu WinBar.Next :Over<CR>
+ nnoremenu WinBar.Finish :Finish<CR>
+ nnoremenu WinBar.Cont :Continue<CR>
+ nnoremenu WinBar.Stop :Stop<CR>
+ nnoremenu WinBar.Eval :Evaluate<CR>
+ 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)
diff --git a/src/version.c b/src/version.c
index ae51d723e..200ed6f2f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -779,6 +779,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1562,
+/**/
1561,
/**/
1560,