summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-09-17 23:03:31 +0200
committerBram Moolenaar <Bram@vim.org>2017-09-17 23:03:31 +0200
commit1b9645de3c05f37b5c30e78f999351b0cf486ade (patch)
tree4041a73d7fd4ab444372919e99962587a689388a /runtime
parentdde403c2d8f3dabe6fefa7b526958b49a8f2e6e9 (diff)
patch 8.0.1123: cannot define a toolbar for a windowv8.0.1123
Problem: Cannot define a toolbar for a window. Solution: Add a window-local toolbar.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/gui.txt23
-rw-r--r--runtime/doc/terminal.txt14
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim85
3 files changed, 108 insertions, 14 deletions
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index a66fbb31e9..7fb6a59719 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -1,4 +1,4 @@
-*gui.txt* For Vim version 8.0. Last change: 2017 Aug 27
+*gui.txt* For Vim version 8.0. Last change: 2017 Sep 16
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -784,10 +784,31 @@ In the Win32 and GTK+ GUI, starting a menu name with ']' excludes that menu
from the main menu bar. You must then use the |:popup| or |:tearoff| command
to display it.
+ *window-toolbar*
+Each window can have a local toolbar. This uses the first line of the window,
+thus reduces the space for the text by one line.
+
+Only text can be used. When using Unicode special characters can be used to
+make the items look like icons.
+
+If the items do not fit then the last ones cannot be used. The toolbar does
+not wrap.
+
+Example for debugger tools: >
+ amenu 1.10 WinBar.Step :Step<CR>
+ amenu 1.20 WinBar.Next :Next<CR>
+ amenu 1.30 WinBar.Finish :Finish<CR>
+ amenu 1.40 WinBar.Cont :Continue<CR>
+<
+The window toolbar uses the ToolbarLine and ToolbarButton highlight groups.
+
*popup-menu*
In the Win32, GTK+, Motif, Athena and Photon GUI, you can define the
special menu "PopUp". This is the menu that is displayed when the right mouse
button is pressed, if 'mousemodel' is set to popup or popup_setpos.
+Example: >
+ nnoremenu 1.40 PopUp.&Paste "+gP
+ menu PopUp
5.3 Showing What Menus Are Mapped To *showing-menus*
diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt
index aad8e4a5f6..bce1d6fb00 100644
--- a/runtime/doc/terminal.txt
+++ b/runtime/doc/terminal.txt
@@ -1,4 +1,4 @@
-*terminal.txt* For Vim version 8.0. Last change: 2017 Sep 14
+*terminal.txt* For Vim version 8.0. Last change: 2017 Sep 17
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -226,7 +226,7 @@ Use CTRL-W N (or 'termkey' N) to switch to Terminal-Normal mode. Now the
contents of the terminal window is under control of Vim, the job output is
suspended. CTRL-\ CTRL-N does the same.
-Terminal-Job mode is where |tmap| mappings are applied. Keys sent by
+Terminal-Job mode is where |:tmap| mappings are applied. Keys sent by
|term_sendkeys()| are not subject to tmap, but keys from |feedkeys()| are.
*E946*
@@ -234,7 +234,7 @@ In Terminal-Normal mode you can move the cursor around with the usual Vim
commands, Visually mark text, yank text, etc. But you cannot change the
contents of the buffer. The commands that would start insert mode, such as
'i' and 'a', return to Terminal-Job mode. The window will be updated to show
-the contents of the terminal.
+the contents of the terminal. |:startinsert| is ineffective.
In Terminal-Normal mode the statusline and window title show "(Terminal)". If
the job ends while in Terminal-Normal mode this changes to
@@ -372,6 +372,14 @@ In the window showing the source code some commands can used to control gdb:
:Finish execute the gdb "finish" command
:Continue execute the gdb "continue" command
+The plugin adds a window toolbar with these entries:
+ Step :Step
+ Next :Over
+ Finish :Finish
+ Cont :Continue
+ Eval :Evaluate
+This way you can use the mouse to perform the most common commands.
+
Inspecting variables ~
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index ffd53fa578..d23a883e7f 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -104,6 +104,11 @@ func s:StartDebug(cmd)
call win_gotoid(s:gdbwin)
let s:breakpoints = {}
+
+ augroup TermDebug
+ au BufRead * call s:BufRead()
+ au BufUnload * call s:BufUnloaded()
+ augroup END
endfunc
func s:EndDebug(job, status)
@@ -120,6 +125,8 @@ func s:EndDebug(job, status)
if s:save_columns > 0
let &columns = s:save_columns
endif
+
+ au! TermDebug
endfunc
" Handle a message received from gdb on the GDB/MI interface.
@@ -132,7 +139,7 @@ func s:CommOutput(chan, msg)
let msg = msg[1:]
endif
if msg != ''
- if msg =~ '^\*\(stopped\|running\)'
+ if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)'
call s:HandleCursor(msg)
elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,'
call s:HandleNewBreakpoint(msg)
@@ -161,6 +168,14 @@ func s:InstallCommands()
" TODO: can the K mapping be restored?
nnoremap K :Evaluate<CR>
+
+ if has('menu')
+ amenu WinBar.Step :Step<CR>
+ amenu WinBar.Next :Over<CR>
+ amenu WinBar.Finish :Finish<CR>
+ amenu WinBar.Cont :Continue<CR>
+ amenu WinBar.Eval :Evaluate<CR>
+ endif
endfunc
" Delete installed debugger commands in the current window.
@@ -176,6 +191,15 @@ func s:DeleteCommands()
delcommand Program
nunmap K
+
+ if has('menu')
+ aunmenu WinBar.Step
+ aunmenu WinBar.Next
+ aunmenu WinBar.Finish
+ aunmenu WinBar.Cont
+ aunmenu WinBar.Eval
+ endif
+
exe 'sign unplace ' . s:pc_id
for key in keys(s:breakpoints)
exe 'sign unplace ' . (s:break_id + key)
@@ -232,7 +256,15 @@ endfunc
" Handle the result of data-evaluate-expression
func s:HandleEvaluate(msg)
- echomsg '"' . s:evalexpr . '": ' . substitute(a:msg, '.*value="\(.*\)"', '\1', '')
+ let value = substitute(a:msg, '.*value="\(.*\)"', '\1', '')
+ let value = substitute(value, '\\"', '"', 'g')
+ echomsg '"' . s:evalexpr . '": ' . value
+
+ if s:evalexpr[0] != '*' && value =~ '^0x' && value !~ '"$'
+ " Looks like a pointer, also display what it points to.
+ let s:evalexpr = '*' . s:evalexpr
+ call term_sendkeys(s:commbuf, '-data-evaluate-expression "' . s:evalexpr . "\"\r")
+ endif
endfunc
" Handle an error.
@@ -247,10 +279,10 @@ func s:HandleCursor(msg)
if win_gotoid(s:startwin)
let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '')
- if a:msg =~ '^\*stopped' && filereadable(fname)
+ if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname)
let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
if lnum =~ '^[0-9]*$'
- if expand('%:h') != fname
+ if expand('%:p') != fnamemodify(fname, ':p')
if &modified
" TODO: find existing window
exe 'split ' . fnameescape(fname)
@@ -260,7 +292,7 @@ func s:HandleCursor(msg)
endif
endif
exe lnum
- exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fnameescape(fname)
+ exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname
setlocal signcolumn=yes
endif
else
@@ -288,11 +320,17 @@ func s:HandleNewBreakpoint(msg)
let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '')
let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
-
- exe 'sign place ' . (s:break_id + nr) . ' line=' . lnum . ' name=debugBreakpoint file=' . fnameescape(fname)
-
let entry['fname'] = fname
let entry['lnum'] = lnum
+
+ if bufloaded(fname)
+ call s:PlaceSign(nr, entry)
+ endif
+endfunc
+
+func s:PlaceSign(nr, entry)
+ exe 'sign place ' . (s:break_id + a:nr) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint file=' . a:entry['fname']
+ let a:entry['placed'] = 1
endfunc
" Handle deleting a breakpoint
@@ -302,6 +340,33 @@ func s:HandleBreakpointDelete(msg)
if nr == 0
return
endif
- exe 'sign unplace ' . (s:break_id + nr)
- unlet s:breakpoints[nr]
+ if has_key(s:breakpoints, nr)
+ let entry = s:breakpoints[nr]
+ if has_key(entry, 'placed')
+ exe 'sign unplace ' . (s:break_id + nr)
+ unlet entry['placed']
+ endif
+ unlet s:breakpoints[nr]
+ endif
endfunc
+
+" Handle a BufRead autocommand event: place any signs.
+func s:BufRead()
+ let fname = expand('<afile>:p')
+ for [nr, entry] in items(s:breakpoints)
+ if entry['fname'] == fname
+ call s:PlaceSign(nr, entry)
+ endif
+ endfor
+endfunc
+
+" Handle a BufUnloaded autocommand event: unplace any signs.
+func s:BufUnloaded()
+ let fname = expand('<afile>:p')
+ for [nr, entry] in items(s:breakpoints)
+ if entry['fname'] == fname
+ let entry['placed'] = 0
+ endif
+ endfor
+endfunc
+