moving stuff around

This commit is contained in:
dsych 2021-02-20 00:15:31 -05:00 committed by Ben Jackson
commit 44711899cb
2 changed files with 45 additions and 64 deletions

View file

@ -21,9 +21,8 @@ set cpoptions&vim
scriptencoding utf-8
" Returns: py.ShowBalloon( winnr, expresssion )
function! vimspector#internal#balloon#HoverTooltip() abort
return py3eval('_vimspector_session.ShowTooltip(int( vim.eval( "v:beval_winnr" ) ) + 1 ,vim.eval( "v:beval_text"), 1)')
return py3eval('_vimspector_session.ShowEvalBalloon(int( vim.eval( "v:beval_winnr" ) ) + 1 ,vim.eval( "v:beval_text"), 1)')
endfunction
let s:float_win = 0
@ -35,6 +34,47 @@ let s:min_height = 1
let s:max_width = 80
let s:max_height = 20
function! vimspector#internal#balloon#MouseFilter(winid, key) abort
if index(["\<leftmouse>", "\<2-leftmouse>"], a:key) < 0
return 0
endif
let handled = 0
let mouse_coords = getmousepos()
" close the popup if mouse is clicked outside the window
if mouse_coords['winid'] != a:winid
call vimspector#internal#balloon#Close()
return 0
endif
" place the cursor according to the click
call win_execute(a:winid, ':call cursor('.mouse_coords['line'].', '.mouse_coords['column'].')')
" expand the variable if we got double click
if a:key ==? "\<2-leftmouse>"
" forward line number to python, since vim does not allow us to focus
" the correct window
call py3eval('_vimspector_session.ExpandVariable('.line('.', a:winid).')')
let handled = 1
endif
return handled
endfunction
function! vimspector#internal#balloon#CursorFilter(winid, key) abort
if a:key ==? "\<CR>"
" forward line number to python, since vim does not allow us to focus
" the correct window
call py3eval('_vimspector_session.ExpandVariable('.line('.', a:winid).')')
return 1
elseif index( [ "\<LeftMouse>", "\<2-LeftMouse>" ], a:key ) >= 0
return vimspector#internal#balloon#MouseFilter( a:winid, a:key )
endif
return popup_filter_menu( a:winid, a:key )
endfunction
function! vimspector#internal#balloon#Close() abort
if has('nvim')
call nvim_win_close(s:float_win, v:true)
@ -152,50 +192,10 @@ function! vimspector#internal#balloon#CreateTooltip(is_hover, ...) abort
" make sure we clean up the float after it loses focus
augroup vimspector#internal#balloon#nvim_float
autocmd!
autocmd WinLeave * :call vimspector#internal#balloon#Close() | autocmd! vimspector#internal#balloon#nvim_float
autocmd BufLeave * :call vimspector#internal#balloon#Close() | autocmd! vimspector#internal#balloon#nvim_float
augroup END
else
func! MouseFilter(winid, key) abort
if index(["\<leftmouse>", "\<2-leftmouse>"], a:key) < 0
return 0
endif
let handled = 0
let mouse_coords = getmousepos()
" close the popup if mouse is clicked outside the window
if mouse_coords['winid'] != a:winid
call vimspector#internal#balloon#Close()
return 0
endif
" place the cursor according to the click
call win_execute(a:winid, ':call cursor('.mouse_coords['line'].', '.mouse_coords['column'].')')
" expand the variable if we got double click
if a:key ==? "\<2-leftmouse>"
" forward line number to python, since vim does not allow us to focus
" the correct window
call py3eval('_vimspector_session.ExpandVariable('.line('.', a:winid).')')
let handled = 1
endif
return handled
endfunc
func! CursorFilter(winid, key) abort
if a:key ==? "\<CR>"
" forward line number to python, since vim does not allow us to focus
" the correct window
call py3eval('_vimspector_session.ExpandVariable('.line('.', a:winid).')')
return 1
elseif index( [ "\<LeftMouse>", "\<2-LeftMouse>" ], a:key ) >= 0
return MouseFilter( a:winid, a:key )
endif
return popup_filter_menu( a:winid, a:key )
endfunc
if s:float_win != 0
call vimspector#internal#balloon#Close()
@ -222,11 +222,11 @@ function! vimspector#internal#balloon#CreateTooltip(is_hover, ...) abort
endif
if a:is_hover
let config['filter'] = 'MouseFilter'
let config['filter'] = 'vimspector#internal#balloon#MouseFilter'
let config['mousemoved'] = [0, 0, 0]
let s:float_win = popup_beval(body, config)
else
let config['filter'] = 'CursorFilter'
let config['filter'] = 'vimspector#internal#balloon#CursorFilter'
let config['moved'] = 'any'
let config['cursorline'] = 1
let s:float_win = popup_atcursor(body, config)

View file

@ -558,25 +558,6 @@ class DebugSession( object ):
return self._variablesView.VariableEval( frame, expression, is_hover )
@IfConnected()
def ShowTooltip( self, winnr, expression, is_hover ):
"""Proxy: ballonexpr -> variables.ShowTooltip"""
frame = self._stackTraceView.GetCurrentFrame()
# Check if RIP is in a frame
if frame is None:
self._logger.debug( 'Tooltip: Not in a stack frame' )
return ''
# Check if cursor in code window
if winnr != int( self._codeView._window.number ):
self._logger.debug( 'Winnr %s is not the code window %s',
winnr,
self._codeView._window.number )
return ''
# Return variable aware function
return self._variablesView.VariableEval( frame, expression, is_hover )
def _CleanUpTooltip( self ):
return self._variablesView._CleanUpTooltip()