// The following routine is cut & pasted verbatim from dbgwvar.c // (which we really don't want to drag in here) var_node *VarGetDisplayPiece( var_info *i, int row, int piece, int *pdepth, int *pinherit ) { var_node *row_v; var_node *v; if( piece >= VAR_PIECE_LAST ) return( NULL ); if( VarFirstNode( i ) == NULL ) return( NULL ); if( row >= VarRowTotal( i ) ) return( NULL ); row_v = VarFindRowNode( i, row ); if( !row_v->value_valid ) { VarSetValue( row_v, LIT_ENG( Quest_Marks ) ); row_v->value_valid = false; } if( !row_v->gadget_valid ) { VarSetGadget( row_v, VARGADGET_NONE ); row_v->gadget_valid = false; } v = row_v; if( piece == VAR_PIECE_NAME || ( piece == VAR_PIECE_GADGET && row_v->gadget_valid ) || ( piece == VAR_PIECE_VALUE && row_v->value_valid ) ) { VarError = false; } else if( _IsOff( SW_TASK_RUNNING ) ) { if( row == i->exprsp_cacherow && i->exprsp_cache != NULL ) { VarError = false; v = i->exprsp_cache; } else if( row == i->exprsp_cacherow && i->exprsp_cache_is_error ) { VarError = true; v = NULL; } else { VarErrState(); v = VarFindRow( i, row ); VarOldErrState(); i->exprsp_cacherow = row; i->exprsp_cache = v; i->exprsp_cache_is_error = VarError; } if( v == NULL ) { if( !VarError ) return( NULL ); v = row_v; } VarNodeInvalid( v ); VarErrState(); ExprValue( ExprSP ); VarSetGadget( v, VarGetGadget( v ) ); VarSetOnTop( v, VarGetOnTop( v ) ); VarSetValue( v, VarGetValue( i, v ) ); VarOldErrState(); VarDoneRow( i ); } VarGetDepths( i, v, pdepth, pinherit ); return( v ); }
static void VarModify( a_window *wnd, int row, int piece ) { var_node *v; type_kind class; var_window *var = WndVar( wnd ); bool ok; bool followable; unsigned old; if( row < 0 ) { if( var->vtype == VAR_WATCH || var->vtype == VAR_VARIABLE ) { VarMenuItem( wnd, MENU_VAR_NEW_EXPRESSION, row, piece ); } return; } VarErrState(); VarKillExprSPCache( &var->i ); v = VarFindRow( &var->i, row ); if( v == NULL ) { v = VarFindRowNode( &var->i, row ); if( v == NULL ) return; if( piece != VAR_PIECE_GADGET && piece != VAR_PIECE_NAME ) return; if( v->expand != NULL || v->node_type == NODE_INHERIT ) { VarExpandRow( &var->i, v, row ); WndNewCurrent( wnd, row, VAR_PIECE_NAME ); VarRepaint( wnd ); } return; } followable = VarGetStackClass( &class ); switch( piece ) { case VAR_PIECE_GADGET: case VAR_PIECE_NAME: if( VarExpandable( class ) || followable || v->expand != NULL ) { VarExpandRow( &var->i, v, row ); WndNewCurrent( wnd, row, VAR_PIECE_NAME ); VarRepaint( wnd ); } break; case VAR_PIECE_VALUE: if( !VarExpandable( class ) ) { char *value = DbgAlloc( TXT_LEN ); char *name = DbgAlloc( TXT_LEN ); old = VarNewCurrRadix( v ); ExprValue( ExprSP ); VarBuildName( &var->i, v, FALSE ); StrCopy( TxtBuff, name ); VarPrintText( &var->i, value, PrintValue, TXT_LEN ); VarKillExprSPCache( &var->i ); v = VarFindRow( &var->i, row ); FreezeStack(); ok = DlgAnyExpr( name, value, TXT_LEN ); UnFreezeStack( FALSE ); if( ok ) VarDoAssign( &var->i, v, value ); NewCurrRadix( old ); WndRowDirty( wnd, row ); DbgFree( value ); DbgFree( name ); } break; } VarDoneRow( &var->i ); VarOldErrState(); }