Add options to control window sizes

This adds the following options, allowing the default sizes to be
overridden:

- g:vimspector_sidebar_width: Controls the width of the left utility
  windows (variables, watches, stack trace)
- g:vimspector_bottombar_height: Controls the height of the output
  window below the code window

The terminal is typically created as a vertical split of the code
window.  The following control the sizing of the terminal window used
for debuggee input/output when using Vim's built-in terminal.

- g:vimspector_code_minwidth: Minimum number of columns to try and
  maintain for the code window.
- g:vimspector_terminal_maxwidth: Maximum number of columns to use for
  th terminal, when vertically splitting the code window.
- g:vimspector_terminal_minwidth: Minimum number of columns to use when
  it is not possible to fit g:vimspector_terminal_maxwidth columns next
  to the code window with g:vimspector_code_minwidth columns.
This commit is contained in:
Ben Jackson 2020-07-17 16:52:41 +01:00
commit f8cbb7c5b6
3 changed files with 42 additions and 12 deletions

View file

@ -18,7 +18,7 @@ import logging
import json
from collections import defaultdict
from vimspector import utils
from vimspector import utils, settings
class CodeView( object ):
@ -218,7 +218,7 @@ class CodeView( object ):
args = params[ 'args' ]
env = params.get( 'env', {} )
options = {
term_options = {
'vertical': 1,
'norestore': 1,
'cwd': cwd,
@ -238,9 +238,9 @@ class CodeView( object ):
and int( utils.Call( 'vimspector#internal#{}term#IsFinished'.format(
self._api_prefix ),
self._terminal_buffer_number ) ) ):
options[ 'curwin' ] = 1
term_options[ 'curwin' ] = 1
else:
options[ 'vertical' ] = 0
term_options[ 'vertical' ] = 0
buffer_number = None
terminal_window = None
@ -248,17 +248,19 @@ class CodeView( object ):
# If we're making a vertical split from the code window, make it no more
# than 80 columns and no fewer than 10. Also try and keep the code window
# at least 82 columns
if options[ 'vertical' ] and not options.get( 'curwin', 0 ):
options[ 'term_cols' ] = max(
min ( int( vim.eval( 'winwidth( 0 ) - 82' ) ), 80 ),
10
if term_options[ 'vertical' ] and not term_options.get( 'curwin', 0 ):
term_options[ 'term_cols' ] = max(
min ( int( vim.eval( 'winwidth( 0 )' ) )
- settings.Int( 'code_minwidth', 82 ),
settings.Int( 'terminal_maxwidth', 80 ) ),
settings.Int( 'terminal_minwidth' , 10 )
)
buffer_number = int(
utils.Call(
'vimspector#internal#{}term#Start'.format( self._api_prefix ),
args,
options ) )
term_options ) )
terminal_window = vim.current.window
if buffer_number is None or buffer_number <= 0:

View file

@ -29,7 +29,8 @@ from vimspector import ( breakpoints,
output,
stack_trace,
utils,
variables )
variables,
settings )
from vimspector.vendor.json_minify import minify
# We cache this once, and don't allow it to change (FIXME?)
@ -487,7 +488,8 @@ class DebugSession( object ):
self._codeView = code.CodeView( code_window, self._api_prefix )
# Call stack
vim.command( 'topleft vertical 50new' )
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,
@ -515,7 +517,7 @@ class DebugSession( object ):
# Output/logging
vim.current.window = code_window
vim.command( 'rightbelow 10new' )
vim.command( f'rightbelow { settings.Int( "bottombar_height", 10 ) }new' )
output_window = vim.current.window
self._outputView = output.OutputView( self._connection,
output_window,

View file

@ -0,0 +1,26 @@
# vimspector - A multi-language debugging system for Vim
# Copyright 2020 Ben Jackson
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vim
import builtins
def Get( option: str, default=None, cls=str ):
return cls( vim.vars.get( f'vimspector_{ option }', default ) )
def Int( option: str, default=0 ):
return Get( option, default=default, cls=builtins.int )