From 3650cf924246c3cd3756e7c74c1a984e107ee058 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 3 Apr 2009 23:31:24 -0400 Subject: [PATCH] Retain the selection in the variable list when stepping through code * Source/DebuggerController.h: Add the selectedVariable ivar * Source/DebuggerController.m: (stepIn:): Save selected variable (stepOut:): ditto (stepOver:): ditto (expandVariables): When looping over variables to expand, also reset the selection --- CHANGES | 2 ++ Source/DebuggerController.h | 1 + Source/DebuggerController.m | 23 ++++++++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 9a1c047..c1060db 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,8 @@ MacGDBp CHANGE LOG - New: #155 Add a variable inspector to display the full, untruncated value - Change: The Window->Breakpoints (Cmd+Shift+B) will now toggle the visibility - Fix: All breakpoint markers will now be displayed in the active code debugger +- New: When stepping through code, the selection in the variable list will be +retained 1.2.1 diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h index 9f7c149..f322dac 100644 --- a/Source/DebuggerController.h +++ b/Source/DebuggerController.h @@ -30,6 +30,7 @@ IBOutlet NSTreeController *variablesTreeController; IBOutlet NSOutlineView *variablesOutlineView; NSMutableSet *expandedVariables; + NSXMLElement *selectedVariable; IBOutlet NSWindow *inspector; diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 25f5e29..effd641 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -170,6 +170,8 @@ */ - (IBAction)stepIn:(id)sender { + selectedVariable = [[variablesTreeController selectedObjects] objectAtIndex:0]; + StackFrame *frame = [connection stepIn]; if ([frame isShiftedFrame:[stackController peek]]) [stackController pop]; @@ -178,10 +180,12 @@ } /** -* Forwards the message to "step out" to the connection + * Forwards the message to "step out" to the connection */ - (IBAction)stepOut:(id)sender { + selectedVariable = [[variablesTreeController selectedObjects] objectAtIndex:0]; + StackFrame *frame = [connection stepOut]; [stackController pop]; // frame we were out of [stackController pop]; // frame we are returning to @@ -190,10 +194,12 @@ } /** -* Forwards the message to "step over" to the connection + * Forwards the message to "step over" to the connection */ - (IBAction)stepOver:(id)sender { + selectedVariable = [[variablesTreeController selectedObjects] objectAtIndex:0]; + StackFrame *frame = [connection stepOver]; [stackController pop]; [stackController push:frame]; @@ -276,13 +282,20 @@ */ - (void)expandVariables { + NSString *selection = [selectedVariable fullname]; + for (int i = 0; i < [variablesOutlineView numberOfRows]; i++) { NSTreeNode *node = [variablesOutlineView itemAtRow:i]; - if ([expandedVariables containsObject:[[node representedObject] fullname]]) - { + NSString *fullname = [[node representedObject] fullname]; + + // see if it needs expanding + if ([expandedVariables containsObject:fullname]) [variablesOutlineView expandItem:node]; - } + + // select it if we had it selected before + if ([fullname isEqualToString:selection]) + [variablesTreeController setSelectionIndexPath:[node indexPath]]; } } -- 2.22.5