def _SetUpUI( self ): vim.command( 'tab split' ) self._uiTab = vim.current.tabpage # Code window code_window = vim.current.window self._codeView = code.CodeView( code_window, self._api_prefix ) # Call stack vim.command( f'topleft vertical { settings.Int( "sidebar_width", 50 ) }new' ) stack_trace_window = vim.current.window one_third = int( vim.eval( 'winheight( 0 )' ) ) / 3 self._stackTraceView = stack_trace.StackTraceView( self, self._connection, stack_trace_window ) # Watches vim.command( 'leftabove new' ) watch_window = vim.current.window # Variables vim.command( 'leftabove new' ) vars_window = vim.current.window with utils.LetCurrentWindow( vars_window ): vim.command( f'{ one_third }wincmd _' ) with utils.LetCurrentWindow( watch_window ): vim.command( f'{ one_third }wincmd _' ) with utils.LetCurrentWindow( stack_trace_window ): vim.command( f'{ one_third }wincmd _' ) self._variablesView = variables.VariablesView( self._connection, vars_window, watch_window ) # Output/logging vim.current.window = code_window vim.command( f'rightbelow { settings.Int( "bottombar_height", 10 ) }new' ) output_window = vim.current.window self._outputView = output.OutputView( self._connection, output_window, self._api_prefix ) # TODO: If/when we support multiple sessions, we'll need some way to # indicate which tab was created and store all the tabs vim.vars[ 'vimspector_session_windows' ] = { 'tabpage': self._uiTab.number, 'code': utils.WindowID( code_window, self._uiTab ), 'stack_trace': utils.WindowID( stack_trace_window, self._uiTab ), 'variables': utils.WindowID( vars_window, self._uiTab ), 'watches': utils.WindowID( watch_window, self._uiTab ), 'output': utils.WindowID( output_window, self._uiTab ), } with utils.RestoreCursorPosition(): with utils.RestoreCurrentWindow(): with utils.RestoreCurrentBuffer( vim.current.window ): vim.command( 'doautocmd User VimspectorUICreated' )
def RunInstaller( api_prefix, leave_open, *args, **kwargs ): from vimspector import utils, output, settings import vim if not args: args = settings.List( 'install_gadgets' ) if not args: return args = GadgetListToInstallerArgs( *args ) vimspector_home = utils.GetVimValue( vim.vars, 'vimspector_home' ) vimspector_base_dir = utils.GetVimspectorBase() global OUTPUT_VIEW _ResetInstaller() with utils.RestoreCurrentWindow(): vim.command( f'botright { settings.Int( "bottombar_height" ) }new' ) win = vim.current.window OUTPUT_VIEW = output.OutputView( win, api_prefix ) cmd = [ PathToAnyWorkingPython3(), '-u', os.path.join( vimspector_home, 'install_gadget.py' ), '--quiet', '--update-gadget-config', ] if not vimspector_base_dir == vimspector_home: cmd.extend( [ '--basedir', vimspector_base_dir ] ) cmd.extend( args ) def handler( exit_code ): if exit_code == 0: if not leave_open: _ResetInstaller() utils.UserMessage( "Vimspector gadget installation complete!" ) vim.command( 'silent doautocmd User VimspectorInstallSuccess' ) if 'then' in kwargs: kwargs[ 'then' ]() else: utils.UserMessage( 'Vimspector gadget installation reported errors', error = True ) vim.command( 'silent doautocmd User VimspectorInstallFailed' ) OUTPUT_VIEW.RunJobWithOutput( 'Installer', cmd, completion_handler = handler, syntax = 'vimspector-installer' ) OUTPUT_VIEW.ShowOutput( 'Installer' )
def _SetUpUI(self): original_window = vim.current.window vim.command('tabnew') self._uiTab = vim.current.tabpage # Code window self._codeView = code.CodeView(vim.current.window, original_window, self._api_prefix) # Call stack with utils.TemporaryVimOptions({ 'splitright': False, 'equalalways': False, }): vim.command('topleft 50vspl') vim.command('enew') self._stackTraceView = stack_trace.StackTraceView( self, self._connection, vim.current.buffer) with utils.TemporaryVimOptions({ 'splitbelow': False, 'eadirection': 'ver', 'equalalways': True }): # Watches vim.command('spl') vim.command('enew') watch_win = vim.current.window # Variables vim.command('spl') vim.command('enew') vars_win = vim.current.window self._variablesView = variables.VariablesView( self._connection, vars_win, watch_win) with utils.TemporaryVimOption('splitbelow', True): vim.current.window = self._codeView._window # Output/logging vim.command('10spl') vim.command('enew') self._outputView = output.OutputView(self._connection, vim.current.window, self._api_prefix)
def ToggleLog(self): if self._HasUI(): return self.ShowOutput('Vimspector') if self._logView and self._logView.WindowIsValid(): self._logView.Reset() self._logView = None return if self._logView: self._logView.Reset() # TODO: The UI code is too scattered. Re-organise into a UI class that # just deals with these thigns like window layout and custmisattion. vim.command(f'botright { settings.Int( "bottombar_height" ) }new') win = vim.current.window self._logView = output.OutputView(win, self._api_prefix) self._logView.AddLogFileView() self._logView.ShowOutput('Vimspector')