only diplaying relevant info like name and value for nested types and value only for simple types

This commit is contained in:
dsych 2021-01-02 12:29:18 -05:00 • committed by Ben Jackson
commit 2f1c93a2ac

View file

@ -274,9 +274,15 @@ class VariablesView( object ):
with utils.RestoreCursorPosition(): with utils.RestoreCursorPosition():
with utils.ModifiableScratchBuffer( self._variable_eval_view.buf ): with utils.ModifiableScratchBuffer( self._variable_eval_view.buf ):
utils.ClearBuffer( self._variable_eval_view.buf ) utils.ClearBuffer( self._variable_eval_view.buf )
icon = '+' if self._variable_eval.IsExpandable() and not self._variable_eval.IsExpanded() else '-' # if we only have a single non-expandable variable, it means we ran into a simple type
# hence, there is no need to draw additional fluff around the value
self._DrawVariables( self._variable_eval_view, self._variable_eval.variables, 2 , True) if(len(self._variable_eval.variables) == 1 and self._variable_eval.variables[0].IsExpandable() == False):
utils.AppendToBuffer(
self._variable_eval_view.buf,
self._variable_eval.variables[0].variable.get( 'value', '<unknown>' )
)
else:
self._DrawVariables( self._variable_eval_view, self._variable_eval.variables, 2 , True)
def _CleanUpTooltip(self): def _CleanUpTooltip(self):
# remove reference to old tooltip window # remove reference to old tooltip window
@ -442,26 +448,32 @@ class VariablesView( object ):
def _DrawVariables( self, view, variables, indent, is_short = False ): def _DrawVariables( self, view, variables, indent, is_short = False ):
assert indent > 0 assert indent > 0
for variable in variables: for variable in variables:
type_ = variable.variable.get( 'type', '' ) text = ''
value = variable.variable.get( 'value', '<unknown>' )
if is_short: if is_short:
if( len(type_) > 20): text = '{indent}{icon} {name}: {value}'.format(
type_ = type_[0:16] + " ..." # We borrow 1 space of indent to draw the change marker
if( len(value) > 100 ): indent = ' ' * ( indent - 1 ),
value = value[0:96] + " ..." icon = '+' if ( variable.IsExpandable()
and not variable.IsExpanded() ) else '-',
line = utils.AppendToBuffer( name = variable.variable.get( 'name', '' ),
view.buf, value = variable.variable.get( 'value', '<unknown>' )
'{indent}{marker}{icon} {name} ({type_}): {value}'.format( )
else:
text = '{indent}{marker}{icon} {name} ({type_}): {value}'.format(
# We borrow 1 space of indent to draw the change marker # We borrow 1 space of indent to draw the change marker
indent = ' ' * ( indent - 1 ), indent = ' ' * ( indent - 1 ),
marker = '*' if variable.changed else ' ', marker = '*' if variable.changed else ' ',
icon = '+' if ( variable.IsExpandable() icon = '+' if ( variable.IsExpandable()
and not variable.IsExpanded() ) else '-', and not variable.IsExpanded() ) else '-',
name = variable.variable.get( 'name', '' ), name = variable.variable.get( 'name', '' ),
type_ = type_, type_ = variable.variable.get( 'type', '' ),
value = value ).split( '\n' )) value = variable.variable.get( 'value', '<unknown>' )
)
line = utils.AppendToBuffer(
view.buf,
text.split( '\n' ))
view.lines[ line ] = variable view.lines[ line ] = variable
if variable.ShouldDrawDrillDown(): if variable.ShouldDrawDrillDown():