def _CreateBuffer(self, category, file_name=None, cmd=None, completion_handler=None, syntax=None): buf_to_delete = None if (not self._buffers and self._window is not None and self._window.valid and not self._window.buffer.name): # If there's an empty buffer in the current window that we're not using, # delete it. We could try and use it, but that complicates the call to # SetUpCommandBuffer buf_to_delete = self._window.buffer if file_name is not None: assert cmd is None if install.GetOS() == "windows": # FIXME: Can't display fiels in windows (yet?) return cmd = ['tail', '-F', '-n', '+1', '--', file_name] if cmd is not None: out = utils.SetUpCommandBuffer( cmd, category, self._api_prefix, completion_handler=completion_handler) self._buffers[category] = TabBuffer(out, len(self._buffers)) self._buffers[category].is_job = True self._RenderWinBar(category) else: if category == 'Console': name = 'vimspector.Console' else: name = 'vimspector.Output:{0}'.format(category) tab_buffer = TabBuffer(utils.NewEmptyBuffer(), len(self._buffers)) self._buffers[category] = tab_buffer if category == 'Console': utils.SetUpPromptBuffer(tab_buffer.buf, name, '> ', 'vimspector#EvaluateConsole', 'vimspector#OmniFuncConsole') else: utils.SetUpHiddenBuffer(tab_buffer.buf, name) self._RenderWinBar(category) self._buffers[category].syntax = utils.SetSyntax( self._buffers[category].syntax, syntax, self._buffers[category].buf) if buf_to_delete: with utils.RestoreCurrentWindow(): self._ShowOutput(category) utils.CleanUpHiddenBuffer(buf_to_delete)
def _CreateBuffer(self, category, file_name=None, cmd=None): with utils.LetCurrentWindow(self._window): with utils.RestoreCurrentBuffer(self._window): if file_name is not None: assert cmd is None cmd = ['tail', '-F', '-n', '+1', '--', file_name] if cmd is not None: out, err = utils.SetUpCommandBuffer(cmd, category) self._buffers[category + '-out'] = TabBuffer( out, len(self._buffers)) self._buffers[category + '-out'].is_job = True self._buffers[category + '-err'] = TabBuffer( err, len(self._buffers)) self._buffers[category + '-err'].is_job = False self._RenderWinBar(category + '-out') self._RenderWinBar(category + '-err') else: vim.command('enew') tab_buffer = TabBuffer(vim.current.buffer, len(self._buffers)) self._buffers[category] = tab_buffer if category == 'Console': utils.SetUpPromptBuffer(tab_buffer.buf, 'vimspector.Console', '> ', 'vimspector#EvaluateConsole', hidden=True) else: utils.SetUpHiddenBuffer( tab_buffer.buf, 'vimspector.Output:{0}'.format(category)) self._RenderWinBar(category)
def __init__(self, variables_win, watches_win): self._logger = logging.getLogger(__name__) utils.SetUpLogging(self._logger) self._connection = None self._current_syntax = '' # Set up the "Variables" buffer in the variables_win self._scopes: typing.List[Scope] = [] self._vars = View(variables_win, {}, self._DrawScopes) utils.SetUpHiddenBuffer(self._vars.buf, 'vimspector.Variables') with utils.LetCurrentWindow(variables_win): vim.command( 'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>') # Set up the "Watches" buffer in the watches_win (and create a WinBar in # there) self._watches: typing.List[Watch] = [] self._watch = View(watches_win, {}, self._DrawWatches) utils.SetUpPromptBuffer(self._watch.buf, 'vimspector.Watches', 'Expression: ', 'vimspector#AddWatchPrompt', 'vimspector#OmniFuncWatch') with utils.LetCurrentWindow(watches_win): vim.command( 'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>') vim.command( 'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>') vim.command('nnoremenu 1.1 WinBar.New ' ':call vimspector#AddWatch()<CR>') vim.command('nnoremenu 1.2 WinBar.Expand/Collapse ' ':call vimspector#ExpandVariable()<CR>') vim.command('nnoremenu 1.3 WinBar.Delete ' ':call vimspector#DeleteWatch()<CR>') # Set the (global!) balloon expr if supported has_balloon = int(vim.eval("has( 'balloon_eval' )")) has_balloon_term = int(vim.eval("has( 'balloon_eval_term' )")) self._oldoptions = {} if has_balloon or has_balloon_term: self._oldoptions = { 'balloonexpr': vim.options['balloonexpr'], 'balloondelay': vim.options['balloondelay'], } vim.options[ 'balloonexpr'] = 'vimspector#internal#balloon#BalloonExpr()' vim.options['balloondelay'] = 250 if has_balloon: self._oldoptions['ballooneval'] = vim.options['ballooneval'] vim.options['ballooneval'] = True if has_balloon_term: self._oldoptions['balloonevalterm'] = vim.options[ 'balloonevalterm'] vim.options['balloonevalterm'] = True self._is_term = not bool(int(vim.eval("has( 'gui_running' )")))
def __init__( self, connection, variables_win, watches_win ): self._logger = logging.getLogger( __name__ ) utils.SetUpLogging( self._logger ) self._vars = View( variables_win, {}, self._DrawScopes ) self._watch = View( watches_win, {}, self._DrawWatches ) self._connection = connection # Allows us to hit <CR> to expand/collapse variables vim.current.window = self._vars.win vim.command( 'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' ) # This is actually the tree (scopes are alwyas the root) # it's just a list of DAP scope dicts, with one magic key (_variables) # _variables is a list of DAP variable with the same magic key # # If _variables is present, then we have requested and should display the # children. Otherwise, we haven't or shouldn't. self._scopes = [] # This is similar to scopes, but the top level is an "expression" (request) # containing a special '_result' key which is the response. The response # structure con contain _variables and is handled identically to the scopes # above. It also has a special _line key which is where we printed it (last) self._watches = [] # Allows us to hit <CR> to expand/collapse variables vim.current.window = self._watch.win vim.command( 'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' ) vim.command( 'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>' ) utils.SetUpScratchBuffer( self._vars.win.buffer, 'vimspector.Variables' ) utils.SetUpPromptBuffer( self._watch.win.buffer, 'vimspector.Watches', 'Expression: ', 'vimspector#AddWatchPrompt' ) has_balloon = int( vim.eval( "has( 'balloon_eval' )" ) ) has_balloon_term = int( vim.eval( "has( 'balloon_eval_term' )" ) ) self._oldoptions = {} if has_balloon or has_balloon_term: self._oldoptions = { 'balloonexpr': vim.options[ 'balloonexpr' ], 'balloondelay': vim.options[ 'balloondelay' ], } vim.options[ 'balloonexpr' ] = 'vimspector#internal#balloon#BalloonExpr()' vim.options[ 'balloondelay' ] = 250 if has_balloon: self._oldoptions[ 'ballooneval' ] = vim.options[ 'ballooneval' ] vim.options[ 'ballooneval' ] = True if has_balloon_term: self._oldoptions[ 'balloonevalterm' ] = vim.options[ 'balloonevalterm' ] vim.options[ 'balloonevalterm' ] = True
def _CreateBuffer( self, category, file_name = None, cmd = None, completion_handler = None, syntax = None ): if file_name is not None: assert cmd is None if install.GetOS() == "windows": # FIXME: Can't display fiels in windows (yet?) return cmd = [ 'tail', '-F', '-n', '+1', '--', file_name ] if cmd is not None: out = utils.SetUpCommandBuffer( cmd, category, self._api_prefix, completion_handler = completion_handler ) self._buffers[ category ] = TabBuffer( out, len( self._buffers ) ) self._buffers[ category ].is_job = True self._RenderWinBar( category ) else: if category == 'Console': name = 'vimspector.Console' else: name = 'vimspector.Output:{0}'.format( category ) tab_buffer = TabBuffer( utils.NewEmptyBuffer(), len( self._buffers ) ) self._buffers[ category ] = tab_buffer if category == 'Console': utils.SetUpPromptBuffer( tab_buffer.buf, name, '> ', 'vimspector#EvaluateConsole' ) else: utils.SetUpHiddenBuffer( tab_buffer.buf, name ) self._RenderWinBar( category ) self._buffers[ category ].syntax = utils.SetSyntax( self._buffers[ category ].syntax, syntax, self._buffers[ category ].buf )
def _CreateBuffer(self, category, file_name=None, cmd=None): win = self._window if not win.valid: # We need to borrow the current window win = vim.current.window with utils.LetCurrentWindow(win): with utils.RestoreCurrentBuffer(win): if file_name is not None: assert cmd is None if install.GetOS() == "windows": # FIXME: Can't display fiels in windows (yet?) return cmd = ['tail', '-F', '-n', '+1', '--', file_name] if cmd is not None: out, err = utils.SetUpCommandBuffer( cmd, category, self._api_prefix) self._buffers[category + '-out'] = TabBuffer( out, len(self._buffers)) self._buffers[category + '-out'].is_job = True self._buffers[category + '-out'].job_category = category self._buffers[category + '-err'] = TabBuffer( err, len(self._buffers)) self._buffers[category + '-err'].is_job = False self._RenderWinBar(category + '-out') self._RenderWinBar(category + '-err') else: vim.command('enew') tab_buffer = TabBuffer(vim.current.buffer, len(self._buffers)) self._buffers[category] = tab_buffer if category == 'Console': utils.SetUpPromptBuffer(tab_buffer.buf, 'vimspector.Console', '> ', 'vimspector#EvaluateConsole') else: utils.SetUpHiddenBuffer( tab_buffer.buf, 'vimspector.Output:{0}'.format(category)) self._RenderWinBar(category)
def _CreateBuffer(self, category): with utils.RestoreCurrentWindow(): vim.current.window = self._window with utils.RestoreCurrentBuffer(self._window): vim.command('enew') self._buffers[category] = vim.current.buffer if category == 'Console': utils.SetUpPromptBuffer(self._buffers[category], 'vimspector.Console', '> ', 'vimspector#EvaluateConsole', hidden=True) else: utils.SetUpHiddenBuffer( self._buffers[category], 'vimspector.Output:{0}'.format(category)) vim.command("nnoremenu WinBar.{0} " ":call vimspector#ShowOutput( '{0}' )<CR>".format( utils.Escape(category)))
def __init__(self, variables_win, watches_win): self._logger = logging.getLogger(__name__) utils.SetUpLogging(self._logger) self._connection = None self._current_syntax = '' self._server_capabilities = None self._variable_eval: Scope = None self._variable_eval_view: View = None mappings = settings.Dict('mappings')['variables'] # Set up the "Variables" buffer in the variables_win self._scopes: typing.List[Scope] = [] self._vars = View(variables_win, {}, self._DrawScopes) utils.SetUpHiddenBuffer(self._vars.buf, 'vimspector.Variables') with utils.LetCurrentWindow(variables_win): if utils.UseWinBar(): vim.command('nnoremenu <silent> 1.1 WinBar.Set ' ':call vimspector#SetVariableValue()<CR>') AddExpandMappings(mappings) # Set up the "Watches" buffer in the watches_win (and create a WinBar in # there) self._watches: typing.List[Watch] = [] self._watch = View(watches_win, {}, self._DrawWatches) utils.SetUpPromptBuffer(self._watch.buf, 'vimspector.Watches', 'Expression: ', 'vimspector#AddWatchPrompt', 'vimspector#OmniFuncWatch') with utils.LetCurrentWindow(watches_win): AddExpandMappings(mappings) for mapping in utils.GetVimList(mappings, 'delete'): vim.command( f'nnoremap <buffer> { mapping } :call vimspector#DeleteWatch()<CR>' ) if utils.UseWinBar(): vim.command('nnoremenu <silent> 1.1 WinBar.New ' ':call vimspector#AddWatch()<CR>') vim.command('nnoremenu <silent> 1.2 WinBar.Expand/Collapse ' ':call vimspector#ExpandVariable()<CR>') vim.command('nnoremenu <silent> 1.3 WinBar.Delete ' ':call vimspector#DeleteWatch()<CR>') vim.command('nnoremenu <silent> 1.1 WinBar.Set ' ':call vimspector#SetVariableValue()<CR>') # Set the (global!) balloon expr if supported has_balloon = int(vim.eval("has( 'balloon_eval' )")) has_balloon_term = int(vim.eval("has( 'balloon_eval_term' )")) self._oldoptions = {} if has_balloon or has_balloon_term: self._oldoptions = { 'balloonexpr': vim.options['balloonexpr'], 'balloondelay': vim.options['balloondelay'], } vim.options['balloonexpr'] = ("vimspector#internal#" "balloon#HoverTooltip()") vim.options['balloondelay'] = 250 if has_balloon: self._oldoptions['ballooneval'] = vim.options['ballooneval'] vim.options['ballooneval'] = True if has_balloon_term: self._oldoptions['balloonevalterm'] = vim.options[ 'balloonevalterm'] vim.options['balloonevalterm'] = True self._is_term = not bool(int(vim.eval("has( 'gui_running' )")))