diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2023-08-23 09:18:17 +0100 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2023-08-25 11:05:18 +0100 |
commit | 92ef2b2bcd4f8082e1b05af0663ffef422461e6a (patch) | |
tree | 105b9555fbe71d763450bff3086ad90d8327a39c | |
parent | 8aad4b84250a6e4d667bd7d15622164cd95fa1af (diff) | |
download | rneovim-92ef2b2bcd4f8082e1b05af0663ffef422461e6a.tar.gz rneovim-92ef2b2bcd4f8082e1b05af0663ffef422461e6a.tar.bz2 rneovim-92ef2b2bcd4f8082e1b05af0663ffef422461e6a.zip |
vim-patch:2ae7ffe0bc3c
runtime(termdebug): add frame related commands (vim/vim#12511)
implementing `:Frame`, `:Up` and `:Down'
https://github.com/vim/vim/commit/2ae7ffe0bc3c3ed9fcae35ef23a2b78908580201
Use maparg() for saving K as it's since been ported (and supports Lua callbacks
and the other API fields).
Use the 3 argument variant of mapset(), as the single argument one isn't ported
yet (v8.2.4861).
Co-authored-by: Simon Sobisch <simonsobisch@web.de>
-rw-r--r-- | runtime/doc/nvim_terminal_emulator.txt | 23 | ||||
-rw-r--r-- | runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 94 |
2 files changed, 109 insertions, 8 deletions
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt index 482b608ef9..ff3a5791ca 100644 --- a/runtime/doc/nvim_terminal_emulator.txt +++ b/runtime/doc/nvim_terminal_emulator.txt @@ -317,6 +317,21 @@ This is similar to using "print" in the gdb window. You can usually shorten `:Evaluate` to `:Ev`. +Navigation in the Stack ~ + *termdebug-variables* *:Frame* + `:Frame` Select the given frame, using either the frame's + stack number, address, or function name. + `:Up` Select the frame that called the current one with an + optional argument to say how many frames to go up. + `+` same (see |termdebug_map_plus| to disable) + `:Down` Select the frame called by the current one with + an optional argument to say how many frames to go down. + `-` same (see |termdebug_map_minus| to disable) + +This is similar to using "print" in the gdb window. +You can usually shorten `:Evaluate` to `:Ev`. + + Other commands ~ *termdebug-commands* *:Gdb* jump to the gdb window @@ -393,6 +408,14 @@ The K key is normally mapped to :Evaluate. If you do not want this use: >vim If there is no g:termdebug_config you can use: >vim let g:termdebug_map_K = 0 < + *termdebug_map_minus* +The - key is normally mapped to :Down. If you do not want this use: >vim + let g:termdebug_config['map_minus'] = 0 +< + *termdebug_map_plus* +The + key is normally mapped to :Up. If you do not want this use: >vim + let g:termdebug_config['map_plus'] = 0 +< *termdebug_disasm_window* If you want the Asm window shown by default, set the "disasm_window" flag to 1. The "disasm_window_height" entry can be used to set the window height: >vim diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index ab569772f5..781c34396d 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1005,6 +1005,10 @@ func s:InstallCommands() command Continue call chansend(s:gdb_job_id, "continue\r") endif + command -nargs=* Frame call s:Frame(<q-args>) + command -nargs=* Up call s:Up(<q-args>) + command -nargs=* Down call s:Down(<q-args>) + command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>) command Gdb call win_gotoid(s:gdbwin) command Program call s:GotoProgram() @@ -1020,17 +1024,29 @@ func s:InstallCommands() let map = g:termdebug_map_K endif if map - " let s:k_map_saved = maparg('K', 'n', 0, 1) - let s:k_map_saved = {} - for map in nvim_get_keymap('n') - if map.lhs ==# 'K' - let s:k_map_saved = map - break - endif - endfor + let s:k_map_saved = maparg('K', 'n', 0, 1) nnoremap K :Evaluate<CR> endif + let map = 1 + if exists('g:termdebug_config') + let map = get(g:termdebug_config, 'map_plus', 1) + endif + if map + let s:plus_map_saved = maparg('+', 'n', 0, 1) + nnoremap + :Up<CR> + endif + + let map = 1 + if exists('g:termdebug_config') + let map = get(g:termdebug_config, 'map_minus', 1) + endif + if map + let s:minus_map_saved = maparg('-', 'n', 0, 1) + nnoremap - :Down<CR> + endif + + if has('menu') && &mouse != '' call s:InstallWinbar(0) @@ -1081,6 +1097,9 @@ func s:DeleteCommands() delcommand Arguments delcommand Stop delcommand Continue + delcommand Frame + delcommand Up + delcommand Down delcommand Evaluate delcommand Gdb delcommand Program @@ -1098,6 +1117,24 @@ func s:DeleteCommands() endif unlet s:k_map_saved endif + if exists('s:plus_map_saved') + if empty(s:plus_map_saved) + nunmap + + else + " call mapset(s:plus_map_saved) + call mapset('n', 0, s:plus_map_saved) + endif + unlet s:plus_map_saved + endif + if exists('s:minus_map_saved') + if empty(s:minus_map_saved) + nunmap - + else + " call mapset(s:minus_map_saved) + call mapset('n', 0, s:minus_map_saved) + endif + unlet s:minus_map_saved + endif if has('menu') " Remove the WinBar entries from all windows where it was added. @@ -1214,6 +1251,47 @@ func s:Run(args) call s:SendResumingCommand('-exec-run') endfunc +" :Frame - go to a specfic frame in the stack +func s:Frame(arg) + " Note: we explicit do not use mi's command + " call s:SendCommand('-stack-select-frame "' . a:arg .'"') + " as we only get a "done" mi response and would have to open the file + " 'manually' - using cli command "frame" provides us with the mi response + " already parsed and allows for more formats + if a:arg =~ '^\d\+$' || a:arg == '' + " specify frame by number + call s:SendCommand('-interpreter-exec mi "frame ' . a:arg .'"') + elseif a:arg =~ '^0x[0-9a-fA-F]\+$' + " specify frame by stack address + call s:SendCommand('-interpreter-exec mi "frame address ' . a:arg .'"') + else + " specify frame by function name + call s:SendCommand('-interpreter-exec mi "frame function ' . a:arg .'"') + endif +endfunc + +" :Up - go one frame in the stack "higher" +func s:Up(arg) + if a:arg != '' + let s:cmd = '"up ' . a:arg . '"' + else + let s:cmd = '"up"' + endif + " the 'correct' one would be -stack-select-frame N, but we don't know N + call s:SendCommand('-interpreter-exec console ' . s:cmd) +endfunc + +" :Down - go one frame in the stack "below" +func s:Down(arg) + if a:arg != '' + let s:cmd = '"down ' . a:arg . '"' + else + let s:cmd = '"down"' + endif + " the 'correct' one would be -stack-select-frame N, but we don't know N + call s:SendCommand('-interpreter-exec console ' . s:cmd) +endfunc + func s:SendEval(expr) " check for "likely" boolean expressions, in which case we take it as lhs if a:expr =~ "[=!<>]=" |