Use CursorLine highlihgt to highlight current PC line
This commit is contained in:
parent
b2456b587f
commit
dffd65f241
5 changed files with 97 additions and 6 deletions
|
|
@ -1370,7 +1370,7 @@ define them in your `vimrc`.
|
||||||
| `vimspectorBP` | Line breakpoint | 9 |
|
| `vimspectorBP` | Line breakpoint | 9 |
|
||||||
| `vimspectorBPCond` | Conditional line breakpiont | 9 |
|
| `vimspectorBPCond` | Conditional line breakpiont | 9 |
|
||||||
| `vimspectorBPDisabled` | Disabled breakpoint | 9 |
|
| `vimspectorBPDisabled` | Disabled breakpoint | 9 |
|
||||||
| `vimspectorPC` | Program counter (i.e. current line) | 20 |
|
| `vimspectorPC` | Program counter (i.e. current line) | 200 |
|
||||||
|
|
||||||
The default symbols are the equivalent of something like the following:
|
The default symbols are the equivalent of something like the following:
|
||||||
|
|
||||||
|
|
@ -1378,7 +1378,7 @@ The default symbols are the equivalent of something like the following:
|
||||||
sign define vimspectorBP text=\ ● texthl=WarningMsg
|
sign define vimspectorBP text=\ ● texthl=WarningMsg
|
||||||
sign define vimspectorBPCond text=\ ◆ texthl=WarningMsg
|
sign define vimspectorBPCond text=\ ◆ texthl=WarningMsg
|
||||||
sign define vimspectorBPDisabled text=\ ● texthl=LineNr
|
sign define vimspectorBPDisabled text=\ ● texthl=LineNr
|
||||||
sign define vimspectorPC text=\ ▶ texthl=MatchParen
|
sign define vimspectorPC text=\ ▶ texthl=MatchParen linehl=CursorLine
|
||||||
```
|
```
|
||||||
|
|
||||||
If the signs don't display properly, your font probably doesn't contain these
|
If the signs don't display properly, your font probably doesn't contain these
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ class CodeView( object ):
|
||||||
if not signs.SignDefined( 'vimspectorPC' ):
|
if not signs.SignDefined( 'vimspectorPC' ):
|
||||||
signs.DefineSign( 'vimspectorPC',
|
signs.DefineSign( 'vimspectorPC',
|
||||||
text = '▶',
|
text = '▶',
|
||||||
texthl = 'MatchParen' )
|
texthl = 'MatchParen',
|
||||||
|
linehl = 'CursorLine' )
|
||||||
|
|
||||||
|
|
||||||
def SetCurrentFrame( self, frame ):
|
def SetCurrentFrame( self, frame ):
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ DEFAULTS = {
|
||||||
|
|
||||||
# Signs
|
# Signs
|
||||||
'sign_priority': {
|
'sign_priority': {
|
||||||
'vimspectorPC': 20,
|
'vimspectorPC': 200,
|
||||||
'vimspectorBP': 9,
|
'vimspectorBP': 9,
|
||||||
'vimspectorBPCond': 9,
|
'vimspectorBPCond': 9,
|
||||||
'vimspectorBPDisabled': 9,
|
'vimspectorBPDisabled': 9,
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,18 @@ def SignDefined( name ):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def DefineSign( name, text, texthl, col = 'right' ):
|
def DefineSign( name, text, texthl, col = 'right', **kwargs ):
|
||||||
if col == 'right':
|
if col == 'right':
|
||||||
if int( utils.Call( 'strdisplaywidth', text ) ) < 2:
|
if int( utils.Call( 'strdisplaywidth', text ) ) < 2:
|
||||||
text = ' ' + text
|
text = ' ' + text
|
||||||
|
|
||||||
text = text.replace( ' ', r'\ ' )
|
text = text.replace( ' ', r'\ ' )
|
||||||
|
|
||||||
vim.command( f'sign define { name } text={ text } texthl={ texthl }' )
|
cmd = f'sign define { name } text={ text } texthl={ texthl }'
|
||||||
|
for key, value in kwargs.items():
|
||||||
|
cmd += f' { key }={ value }'
|
||||||
|
|
||||||
|
vim.command( cmd )
|
||||||
|
|
||||||
|
|
||||||
def PlaceSign( sign_id, group, name, file, line ):
|
def PlaceSign( sign_id, group, name, file, line ):
|
||||||
|
|
|
||||||
|
|
@ -633,6 +633,92 @@ function! Test_Custom_Breakpoint_Priority()
|
||||||
%bwipeout!
|
%bwipeout!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! Test_Custom_Breakpoint_Priority_Partial()
|
||||||
|
let g:vimspector_sign_priority = {
|
||||||
|
\ 'vimspectorBP': 2,
|
||||||
|
\ 'vimspectorBPCond': 3,
|
||||||
|
\ 'vimspectorBPDisabled': 4
|
||||||
|
\ }
|
||||||
|
|
||||||
|
" While not debugging
|
||||||
|
lcd testdata/cpp/simple
|
||||||
|
edit simple.cpp
|
||||||
|
|
||||||
|
call setpos( '.', [ 0, 15, 1 ] )
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call setpos( '.', [ 0, 16, 1 ] )
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
|
||||||
|
\ 'VimspectorBP',
|
||||||
|
\ 16,
|
||||||
|
\ 'vimspectorBPDisabled',
|
||||||
|
\ 4 )
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 )
|
||||||
|
|
||||||
|
call setpos( '.', [ 0, 17, 1 ] )
|
||||||
|
call vimspector#ToggleBreakpoint( { 'condition': '1' } )
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
|
||||||
|
\ 'VimspectorBP',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorBPCond',
|
||||||
|
\ 3 )
|
||||||
|
|
||||||
|
" While debugging
|
||||||
|
call vimspector#Launch()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 )
|
||||||
|
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 15 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorPC',
|
||||||
|
\ 200 )
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorCode',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
|
||||||
|
call vimspector#StepOver()
|
||||||
|
" No sign as disabled
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 16, 1 )
|
||||||
|
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 16 )
|
||||||
|
|
||||||
|
call vimspector#StepOver()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 17, 1 )
|
||||||
|
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 17 )
|
||||||
|
|
||||||
|
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 15,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorBP',
|
||||||
|
\ 2 )
|
||||||
|
call vimspector#test#signs#AssertSignAtLine(
|
||||||
|
\ 'VimspectorCode',
|
||||||
|
\ 17,
|
||||||
|
\ 'vimspectorPC',
|
||||||
|
\ 200 )
|
||||||
|
|
||||||
|
|
||||||
|
call vimspector#test#setup#Reset()
|
||||||
|
lcd -
|
||||||
|
%bwipeout!
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! TearDown_Test_Custom_Breakpoint_Priority()
|
function! TearDown_Test_Custom_Breakpoint_Priority()
|
||||||
unlet! g:vimspector_sign_priority
|
unlet! g:vimspector_sign_priority
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue