3 * Copyright (c) 2002 - 2007, Blue Static <http://www.bluestatic.org>
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 #import "DebuggerWindowController.h"
18 #import "DebuggerConnection.h"
20 @interface DebuggerWindowController (Private
)
22 - (void)updateSourceViewer
;
26 @implementation DebuggerWindowController
29 * Initializes the window controller and sets the connection
31 - (id)initWithConnection
: (DebuggerConnection
*)cnx
33 if (self = [super initWithWindowNibName
: @
"Debugger"])
35 _connection
= [cnx retain
];
41 * Before the display get's comfortable, set up the NSTextView to scroll horizontally
45 // set up the scroller for the source viewer
46 [_sourceViewer setMaxSize
: NSMakeSize(FLT_MAX
, FLT_MAX
)];
47 [[_sourceViewer textContainer
] setContainerSize
: NSMakeSize(FLT_MAX
, FLT_MAX
)];
48 [[_sourceViewer textContainer
] setWidthTracksTextView
: NO
];
49 [_sourceViewer setHorizontallyResizable
: YES
];
50 [_sourceViewerScroller setHasHorizontalScroller
: YES
];
51 [_sourceViewerScroller display
];
55 * Release object members
59 [_connection release
];
65 * Sets the status and clears any error message
67 - (void)setStatus
: (NSString
*)status
69 [_error setHidden
: YES
];
70 [_status setStringValue
: status
];
71 [[self window
] setTitle
: [NSString stringWithFormat
: @
"GDBp @ %@:%d/%@", [_connection remoteHost
], [_connection port
], [_connection session
]]];
75 * Sets the status to be "Error" and then displays the error message
77 - (void)setError
: (NSString
*)error
79 [_error setStringValue
: error
];
80 [self setStatus
: @
"Error"];
81 [_error setHidden
: NO
];
85 * Sets the root node element of the stacktrace
87 - (void)setStack
: (NSArray
*)stack
96 [self updateSourceViewer
];
100 * Forwards the message to run script execution to the connection
102 - (IBAction
)run
: (id)sender
108 * Forwards the message to "step in" to the connection
110 - (IBAction
)stepIn
: (id)sender
112 [_connection stepIn
];
116 * Forwards the message to "step out" to the connection
118 - (IBAction
)stepOut
: (id)sender
120 [_connection stepOut
];
124 * Forwards the message to "step over" to the connection
126 - (IBAction
)stepOver
: (id)sender
128 [_connection stepOver
];
132 * NSTableView delegate method that informs the controller that the stack selection did change and that
133 * we should update the source viewer
135 - (void)tableViewSelectionDidChange
: (NSNotification
*)notif
137 [self updateSourceViewer
];
140 * Does the actual updating of the source viewer by reading in the file
142 - (void)updateSourceViewer
144 NSString
*filename
= [[_stackController selection
] valueForKey
: @
"filename"];
145 if (filename
== NSNoSelectionMarker
)
148 [_sourceViewer setString
: @
""];
152 filename
= [[NSURL URLWithString
: filename
] path
];
153 if (filename
== _currentFile
)
158 _currentFile
= filename
;
159 [_sourceViewer setString
: [NSString stringWithContentsOfFile
: _currentFile
]];
160 [_sourceViewer setFont
: [NSFont fontWithName
: @
"Monaco" size
: 10.0]];