mirror of https://github.com/bsnes-emu/bsnes.git
Terminal-style command history in the Cocoa debugger
This commit is contained in:
parent
44b414d45f
commit
6b2a302393
|
@ -112,7 +112,7 @@
|
|||
<textField focusRingType="none" verticalHuggingPriority="750" mirrorLayoutDirectionWhenInternationalizing="never" allowsCharacterPickerTouchBarItem="NO" id="l22-S8-uji">
|
||||
<rect key="frame" x="0.0" y="0.0" width="921" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" focusRingType="none" id="p3j-nS-44f">
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" focusRingType="none" id="p3j-nS-44f" customClass="GBTerminalTextFieldCell">
|
||||
<font key="font" metaFont="fixedUser" size="11"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" red="0.16470588235294117" green="0.16470588235294117" blue="0.16470588235294117" alpha="1" colorSpace="calibratedRGB"/>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface GBTerminalTextFieldCell : NSTextFieldCell
|
||||
|
||||
@end
|
|
@ -0,0 +1,73 @@
|
|||
#import <Carbon/Carbon.h>
|
||||
#import "GBTerminalTextFieldCell.h"
|
||||
|
||||
@interface GBTerminalTextView : NSTextView
|
||||
@end
|
||||
|
||||
@implementation GBTerminalTextFieldCell
|
||||
{
|
||||
GBTerminalTextView *field_editor;
|
||||
}
|
||||
|
||||
- (NSTextView *)fieldEditorForView:(NSView *)controlView
|
||||
{
|
||||
if (field_editor) {
|
||||
return field_editor;
|
||||
}
|
||||
field_editor = [[GBTerminalTextView alloc] init];
|
||||
[field_editor setFieldEditor:YES];
|
||||
return field_editor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GBTerminalTextView
|
||||
{
|
||||
NSMutableOrderedSet *lines;
|
||||
NSUInteger current_line;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return NULL;
|
||||
}
|
||||
lines = [[NSMutableOrderedSet alloc] init];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)moveUp:(id)sender
|
||||
{
|
||||
if (current_line != 0) {
|
||||
current_line--;
|
||||
[self setString:[lines objectAtIndex:current_line]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)moveDown:(id)sender
|
||||
{
|
||||
if (current_line == [lines count]) {
|
||||
return;
|
||||
}
|
||||
current_line++;
|
||||
if (current_line == [lines count]) {
|
||||
[self setString:@""];
|
||||
}
|
||||
else {
|
||||
[self setString:[lines objectAtIndex:current_line]];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) insertNewline:(id)sender
|
||||
{
|
||||
if ([self.string length]) {
|
||||
NSString *string = [self.string copy];
|
||||
[lines removeObject:string];
|
||||
[lines addObject:string];
|
||||
}
|
||||
[super insertNewline:sender];
|
||||
current_line = [lines count];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue