More intuitive command/expression history

This commit is contained in:
Vas Crabb 2015-02-14 10:06:55 +11:00
parent 146653f9d7
commit 6ec9472c84
8 changed files with 69 additions and 43 deletions

View File

@ -42,32 +42,34 @@
class debugger_osx : public osd_module, public debug_module class debugger_osx : public osd_module, public debug_module
{ {
public: public:
debugger_osx() debugger_osx()
: osd_module(OSD_DEBUG_PROVIDER, "osx"), debug_module(), : osd_module(OSD_DEBUG_PROVIDER, "osx"), debug_module(),
m_machine(NULL), m_machine(NULL),
m_console(nil) m_console(nil)
{ {
} }
virtual ~debugger_osx() virtual ~debugger_osx()
{ {
} if (m_console != nil)
[m_console release];
}
virtual int init() virtual int init()
{ {
return 0; return 0;
} }
virtual void exit() virtual void exit()
{ {
} }
virtual void init_debugger(running_machine &machine); virtual void init_debugger(running_machine &machine);
virtual void wait_for_debugger(device_t &device, bool firststop); virtual void wait_for_debugger(device_t &device, bool firststop);
virtual void debugger_update(); virtual void debugger_update();
private: private:
running_machine *m_machine; running_machine *m_machine;
MAMEDebugConsole *m_console; MAMEDebugConsole *m_console;
}; };

View File

@ -31,6 +31,7 @@
- (void)add:(NSString *)entry; - (void)add:(NSString *)entry;
- (NSString *)previous:(NSString *)cur; - (NSString *)previous:(NSString *)cur;
- (NSString *)next:(NSString *)cur; - (NSString *)next:(NSString *)cur;
- (void)edit;
- (void)reset; - (void)reset;
- (void)clear; - (void)clear;

View File

@ -50,8 +50,8 @@
- (void)setLength:(NSInteger)l { - (void)setLength:(NSInteger)l {
length = l; length = l;
while ([history count] > length) if ([history count] > length)
[history removeLastObject]; [history removeObjectsInRange:NSMakeRange(length, [history count] - length)];
} }
@ -61,7 +61,7 @@
while ([history count] > length) while ([history count] > length)
[history removeLastObject]; [history removeLastObject];
} }
position = -1; position = 0;
} }
@ -81,7 +81,7 @@
- (NSString *)next:(NSString *)cur { - (NSString *)next:(NSString *)cur {
if (position > 0) { if (position > 0) {
return [history objectAtIndex:--position]; return [history objectAtIndex:--position];
} else if (position == 0) { } else if ((position == 0) && (current != nil) && ![current isEqualToString:[history objectAtIndex:0]]) {
position--; position--;
return [[current retain] autorelease]; return [[current retain] autorelease];
} else { } else {
@ -90,6 +90,11 @@
} }
- (void)edit {
if (position == 0)
position--;
}
- (void)reset { - (void)reset {
position = -1; position = -1;
if (current != nil) { if (current != nil) {

View File

@ -12,7 +12,6 @@
#import "debugosx.h" #import "debugosx.h"
#import "debugosxdebugwindowhandler.h" #import "debugosxdebugwindowhandler.h"
#include "device.h"
#include "emu.h" #include "emu.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@ -44,6 +43,7 @@
- (void)showDebugger:(NSNotification *)notification; - (void)showDebugger:(NSNotification *)notification;
- (void)auxiliaryWindowWillClose:(NSNotification *)notification; - (void)auxiliaryWindowWillClose:(NSNotification *)notification;
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor;
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command; - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command;
- (void)windowWillClose:(NSNotification *)notification; - (void)windowWillClose:(NSNotification *)notification;

View File

@ -218,9 +218,11 @@
NSString *command = [sender stringValue]; NSString *command = [sender stringValue];
if ([command length] == 0) { if ([command length] == 0) {
debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); debug_cpu_get_visible_cpu(*machine)->debug()->single_step();
[history reset];
} else { } else {
debug_console_execute_command(*machine, [command UTF8String], 1); debug_console_execute_command(*machine, [command UTF8String], 1);
[history add:command]; [history add:command];
[history edit];
} }
[sender setStringValue:@""]; [sender setStringValue:@""];
} }
@ -264,6 +266,14 @@
} }
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor {
if (control == commandField)
[history edit];
return YES;
}
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command {
if (control == commandField) { if (control == commandField) {
if (command == @selector(cancelOperation:)) { if (command == @selector(cancelOperation:)) {

View File

@ -17,24 +17,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@protocol MAMEDebugViewSubviewSupport <NSObject>
- (NSString *)selectedSubviewName;
- (int)selectedSubviewIndex;
- (void)selectSubviewAtIndex:(int)index;
- (void)selectSubviewForCPU:(device_t *)device;
@end
@protocol MAMEDebugViewExpressionSupport <NSObject>
- (NSString *)expression;
- (void)setExpression:(NSString *)exp;
@end
@interface MAMEDebugView : NSView @interface MAMEDebugView : NSView
{ {
int type; int type;
@ -66,3 +48,21 @@
- (void)windowDidResignKey:(NSNotification *)notification; - (void)windowDidResignKey:(NSNotification *)notification;
@end @end
@protocol MAMEDebugViewSubviewSupport <NSObject>
- (NSString *)selectedSubviewName;
- (int)selectedSubviewIndex;
- (void)selectSubviewAtIndex:(int)index;
- (void)selectSubviewForCPU:(device_t *)device;
@end
@protocol MAMEDebugViewExpressionSupport <NSObject>
- (NSString *)expression;
- (void)setExpression:(NSString *)exp;
@end

View File

@ -91,6 +91,7 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification;
- (IBAction)doExpression:(id)sender; - (IBAction)doExpression:(id)sender;
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor;
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command; - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command;
@end @end

View File

@ -357,6 +357,13 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
} }
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor
{
[history edit];
return YES;
}
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command {
if (control == expressionField) { if (control == expressionField) {
if (command == @selector(cancelOperation:)) { if (command == @selector(cancelOperation:)) {