Mercurial > vim
comparison runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 12865:ebb4f6c93598 v8.0.1309
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
commit https://github.com/vim/vim/commit/51b0f3701ecb440aa72ab6017c1df6940c0e0f6f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 18 18:52:04 2017 +0100
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 18 Nov 2017 19:00:06 +0100 |
parents | db9ffed7e1fc |
children | 058e93aee621 |
comparison
equal
deleted
inserted
replaced
12864:e98532b79dba | 12865:ebb4f6c93598 |
---|---|
67 echoerr 'Failed to open the program terminal window' | 67 echoerr 'Failed to open the program terminal window' |
68 return | 68 return |
69 endif | 69 endif |
70 let pty = job_info(term_getjob(s:ptybuf))['tty_out'] | 70 let pty = job_info(term_getjob(s:ptybuf))['tty_out'] |
71 let s:ptywin = win_getid(winnr()) | 71 let s:ptywin = win_getid(winnr()) |
72 if vertical | |
73 " Assuming the source code window will get a signcolumn, use two more | |
74 " columns for that, thus one less for the terminal window. | |
75 exe (&columns / 2 - 1) . "wincmd |" | |
76 endif | |
72 | 77 |
73 " Create a hidden terminal window to communicate with gdb | 78 " Create a hidden terminal window to communicate with gdb |
74 let s:commbuf = term_start('NONE', { | 79 let s:commbuf = term_start('NONE', { |
75 \ 'term_name': 'gdb communication', | 80 \ 'term_name': 'gdb communication', |
76 \ 'out_cb': function('s:CommOutput'), | 81 \ 'out_cb': function('s:CommOutput'), |
119 " Install debugger commands in the text window. | 124 " Install debugger commands in the text window. |
120 call win_gotoid(s:startwin) | 125 call win_gotoid(s:startwin) |
121 call s:InstallCommands() | 126 call s:InstallCommands() |
122 call win_gotoid(s:gdbwin) | 127 call win_gotoid(s:gdbwin) |
123 | 128 |
129 " Enable showing a balloon with eval info | |
130 if has("balloon_eval") | |
131 set ballooneval | |
132 set balloonexpr=TermDebugBalloonExpr() | |
133 if has("balloon_eval_term") | |
134 set balloonevalterm | |
135 endif | |
136 endif | |
137 | |
124 let s:breakpoints = {} | 138 let s:breakpoints = {} |
125 | 139 |
126 augroup TermDebug | 140 augroup TermDebug |
127 au BufRead * call s:BufRead() | 141 au BufRead * call s:BufRead() |
128 au BufUnload * call s:BufUnloaded() | 142 au BufUnload * call s:BufUnloaded() |
140 call s:DeleteCommands() | 154 call s:DeleteCommands() |
141 | 155 |
142 call win_gotoid(curwinid) | 156 call win_gotoid(curwinid) |
143 if s:save_columns > 0 | 157 if s:save_columns > 0 |
144 let &columns = s:save_columns | 158 let &columns = s:save_columns |
159 endif | |
160 | |
161 if has("balloon_eval") | |
162 set noballooneval | |
163 set balloonexpr= | |
164 if has("balloon_eval_term") | |
165 set noballoonevalterm | |
166 endif | |
145 endif | 167 endif |
146 | 168 |
147 au! TermDebug | 169 au! TermDebug |
148 endfunc | 170 endfunc |
149 | 171 |
277 call s:SendCommand('-exec-arguments ' . a:args) | 299 call s:SendCommand('-exec-arguments ' . a:args) |
278 endif | 300 endif |
279 call s:SendCommand('-exec-run') | 301 call s:SendCommand('-exec-run') |
280 endfunc | 302 endfunc |
281 | 303 |
304 func s:SendEval(expr) | |
305 call s:SendCommand('-data-evaluate-expression "' . a:expr . '"') | |
306 let s:evalexpr = a:expr | |
307 endfunc | |
308 | |
282 " :Evaluate - evaluate what is under the cursor | 309 " :Evaluate - evaluate what is under the cursor |
283 func s:Evaluate(range, arg) | 310 func s:Evaluate(range, arg) |
284 if a:arg != '' | 311 if a:arg != '' |
285 let expr = a:arg | 312 let expr = a:arg |
286 elseif a:range == 2 | 313 elseif a:range == 2 |
292 call setpos('.', pos) | 319 call setpos('.', pos) |
293 call setreg('v', reg, regt) | 320 call setreg('v', reg, regt) |
294 else | 321 else |
295 let expr = expand('<cexpr>') | 322 let expr = expand('<cexpr>') |
296 endif | 323 endif |
297 call s:SendCommand('-data-evaluate-expression "' . expr . '"') | 324 call s:SendEval(expr) |
298 let s:evalexpr = expr | 325 endfunc |
299 endfunc | 326 |
327 let s:evalFromBalloonExpr = 0 | |
300 | 328 |
301 " Handle the result of data-evaluate-expression | 329 " Handle the result of data-evaluate-expression |
302 func s:HandleEvaluate(msg) | 330 func s:HandleEvaluate(msg) |
303 let value = substitute(a:msg, '.*value="\(.*\)"', '\1', '') | 331 let value = substitute(a:msg, '.*value="\(.*\)"', '\1', '') |
304 let value = substitute(value, '\\"', '"', 'g') | 332 let value = substitute(value, '\\"', '"', 'g') |
305 echomsg '"' . s:evalexpr . '": ' . value | 333 if s:evalFromBalloonExpr |
334 if s:evalFromBalloonExprResult == '' | |
335 let s:evalFromBalloonExprResult = s:evalexpr . ': ' . value | |
336 else | |
337 let s:evalFromBalloonExprResult .= ' = ' . value | |
338 endif | |
339 call balloon_show(s:evalFromBalloonExprResult) | |
340 else | |
341 echomsg '"' . s:evalexpr . '": ' . value | |
342 endif | |
306 | 343 |
307 if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$' | 344 if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$' |
308 " Looks like a pointer, also display what it points to. | 345 " Looks like a pointer, also display what it points to. |
309 let s:evalexpr = '*' . s:evalexpr | 346 call s:SendEval('*' . s:evalexpr) |
310 call term_sendkeys(s:commbuf, '-data-evaluate-expression "' . s:evalexpr . "\"\r") | 347 else |
311 endif | 348 let s:evalFromBalloonExpr = 0 |
349 endif | |
350 endfunc | |
351 | |
352 " Show a balloon with information of the variable under the mouse pointer, | |
353 " if there is any. | |
354 func TermDebugBalloonExpr() | |
355 if v:beval_winid != s:startwin | |
356 return | |
357 endif | |
358 call s:SendEval(v:beval_text) | |
359 let s:evalFromBalloonExpr = 1 | |
360 let s:evalFromBalloonExprResult = '' | |
361 return '' | |
312 endfunc | 362 endfunc |
313 | 363 |
314 " Handle an error. | 364 " Handle an error. |
315 func s:HandleError(msg) | 365 func s:HandleError(msg) |
366 if a:msg =~ 'No symbol .* in current context' | |
367 \ || a:msg =~ 'Cannot access memory at address ' | |
368 \ || a:msg =~ 'Attempt to use a type name as an expression' | |
369 " Result of s:SendEval() failed, ignore. | |
370 return | |
371 endif | |
316 echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') | 372 echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '') |
317 endfunc | 373 endfunc |
318 | 374 |
319 " Handle stopping and running message from gdb. | 375 " Handle stopping and running message from gdb. |
320 " Will update the sign that shows the current position. | 376 " Will update the sign that shows the current position. |