diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-11-18 18:52:04 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-11-18 18:52:04 +0100 |
commit | 51b0f3701ecb440aa72ab6017c1df6940c0e0f6f (patch) | |
tree | 9cfd3546d8e52be2b1425dcc65095f8e650eadde /runtime/pack | |
parent | 234d16286a2733adedef56784c17415ae169b9ad (diff) | |
download | vim-git-51b0f3701ecb440aa72ab6017c1df6940c0e0f6f.tar.gz |
patch 8.0.1309: cannot use 'balloonexpr' in a terminalv8.0.1309
Problem: Cannot use 'balloonexpr' in a terminal.
Solution: Add 'balloonevalterm' and add code to handle mouse movements in a
terminal. Initial implementation for Unix with GUI.
Diffstat (limited to 'runtime/pack')
-rw-r--r-- | runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 635bf93f2..1c3c9df9a 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -69,6 +69,11 @@ func s:StartDebug(cmd) endif let pty = job_info(term_getjob(s:ptybuf))['tty_out'] let s:ptywin = win_getid(winnr()) + if vertical + " Assuming the source code window will get a signcolumn, use two more + " columns for that, thus one less for the terminal window. + exe (&columns / 2 - 1) . "wincmd |" + endif " Create a hidden terminal window to communicate with gdb let s:commbuf = term_start('NONE', { @@ -121,6 +126,15 @@ func s:StartDebug(cmd) call s:InstallCommands() call win_gotoid(s:gdbwin) + " Enable showing a balloon with eval info + if has("balloon_eval") + set ballooneval + set balloonexpr=TermDebugBalloonExpr() + if has("balloon_eval_term") + set balloonevalterm + endif + endif + let s:breakpoints = {} augroup TermDebug @@ -144,6 +158,14 @@ func s:EndDebug(job, status) let &columns = s:save_columns endif + if has("balloon_eval") + set noballooneval + set balloonexpr= + if has("balloon_eval_term") + set noballoonevalterm + endif + endif + au! TermDebug endfunc @@ -279,6 +301,11 @@ func s:Run(args) call s:SendCommand('-exec-run') endfunc +func s:SendEval(expr) + call s:SendCommand('-data-evaluate-expression "' . a:expr . '"') + let s:evalexpr = a:expr +endfunc + " :Evaluate - evaluate what is under the cursor func s:Evaluate(range, arg) if a:arg != '' @@ -294,25 +321,54 @@ func s:Evaluate(range, arg) else let expr = expand('<cexpr>') endif - call s:SendCommand('-data-evaluate-expression "' . expr . '"') - let s:evalexpr = expr + call s:SendEval(expr) endfunc +let s:evalFromBalloonExpr = 0 + " Handle the result of data-evaluate-expression func s:HandleEvaluate(msg) let value = substitute(a:msg, '.*value="\(.*\)"', '\1', '') let value = substitute(value, '\\"', '"', 'g') - echomsg '"' . s:evalexpr . '": ' . value + if s:evalFromBalloonExpr + if s:evalFromBalloonExprResult == '' + let s:evalFromBalloonExprResult = s:evalexpr . ': ' . value + else + let s:evalFromBalloonExprResult .= ' = ' . value + endif + call balloon_show(s:evalFromBalloonExprResult) + else + echomsg '"' . s:evalexpr . '": ' . value + endif if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && 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") + call s:SendEval('*' . s:evalexpr) + else + let s:evalFromBalloonExpr = 0 + endif +endfunc + +" Show a balloon with information of the variable under the mouse pointer, +" if there is any. +func TermDebugBalloonExpr() + 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' + " Result of s:SendEval() failed, ignore. + return + endif echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') endfunc |