From 020b0955423bcd8e45910de13721e304453afbac Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 28 Feb 2018 21:06:06 -0500 Subject: [PATCH] reset / hard reset menus. --- Emulators/Apple80.mm.ragel | 19 +++++++++++-------- Emulators/Emulator.h | 2 +- Emulators/GNOConsole.mm.ragel | 14 +++++++------- Emulators/GSOSConsole.mm.ragel | 15 +++++++++------ Emulators/PTSE.mm.ragel | 19 +++++++------------ Emulators/VT52.mm | 19 +++++++++++-------- English.lproj/MainMenu.xib | 17 +++++++++++++++-- TermWindowController.h | 3 +++ TermWindowController.mm | 10 ++++++++-- Views/EmulatorView.h | 2 ++ Views/EmulatorView.mm | 7 ++++++- 11 files changed, 80 insertions(+), 47 deletions(-) diff --git a/Emulators/Apple80.mm.ragel b/Emulators/Apple80.mm.ragel index 530432f..3e8e7a2 100644 --- a/Emulators/Apple80.mm.ragel +++ b/Emulators/Apple80.mm.ragel @@ -268,13 +268,16 @@ } --(void)reset +-(void)reset: (BOOL)hard { %%write init; - _context.window = iRect(0, 0, _columns, 24); - _context.cursor = iPoint(0,0); _context.flags = 0; + + if (hard) { + _context.window = iRect(0, 0, _columns, 24); + _context.cursor = iPoint(0,0); + } } -(BOOL)resizable @@ -299,7 +302,7 @@ { if ((self = [super init])) { - [self reset]; + [self reset: YES]; } return self; @@ -414,9 +417,9 @@ return "appleIIe"; } --(void) reset { +-(void) reset: (BOOL)hard { _columns = 40; - [super reset]; + [super reset: hard]; } -(CharacterGenerator *)characterGenerator { @@ -448,9 +451,9 @@ return "appleIIe"; } --(void) reset { +-(void) reset: (BOOL)hard { _columns = 80; - [super reset]; + [super reset: hard]; } @end diff --git a/Emulators/Emulator.h b/Emulators/Emulator.h index bd92923..40e813f 100644 --- a/Emulators/Emulator.h +++ b/Emulators/Emulator.h @@ -50,7 +50,7 @@ extern "C" unsigned EventCharacters(NSEvent *event, std::u32string &rv); -(void)keyDown: (NSEvent *)event screen: (Screen *)screen output: (OutputChannel *)output; --(void)reset; +-(void)reset: (BOOL)hard; +(NSString *)name; -(NSString *)name; diff --git a/Emulators/GNOConsole.mm.ragel b/Emulators/GNOConsole.mm.ragel index a4d37a6..6a49353 100644 --- a/Emulators/GNOConsole.mm.ragel +++ b/Emulators/GNOConsole.mm.ragel @@ -411,19 +411,19 @@ } --(void)reset +-(void)reset: (BOOL)hard { %%write init; _context.flags = 0; - _context.window = iRect(0, 0, 80, 24); - _context.cursor = iPoint(0,0); - - _cursorType = Screen::CursorTypeUnderscore; - // set flags to plain text. + if (hard) { + _context.window = iRect(0, 0, 80, 24); + _context.cursor = iPoint(0,0); + } + } -(BOOL)resizable @@ -448,7 +448,7 @@ { if ((self = [super init])) { - [self reset]; + [self reset: YES]; } return self; diff --git a/Emulators/GSOSConsole.mm.ragel b/Emulators/GSOSConsole.mm.ragel index a25ff19..7a462d4 100644 --- a/Emulators/GSOSConsole.mm.ragel +++ b/Emulators/GSOSConsole.mm.ragel @@ -496,20 +496,23 @@ static void advance(Screen *screen, gsos_context &ctx) { { if ((self = [super init])) { - [self reset]; + [self reset: YES]; } return self; } --(void)reset +-(void)reset: (BOOL)hard { %%write init; - - _context.window = iRect(0, 0, 80, 24); - _context.cursor = iPoint(0,0); - + + if (hard) { + _context_stack.clear(); + + _context.window = iRect(0, 0, 80, 24); + _context.cursor = iPoint(0,0); + } _context.consWrap = true; _context.consAdvance = true; diff --git a/Emulators/PTSE.mm.ragel b/Emulators/PTSE.mm.ragel index c45b172..3146f03 100644 --- a/Emulators/PTSE.mm.ragel +++ b/Emulators/PTSE.mm.ragel @@ -306,20 +306,15 @@ return "proterm-special"; } --(void)reset: (Screen *)screen -{ - [self reset]; - - if (screen) screen->eraseScreen(); -} - --(void)reset +-(void)reset: (BOOL)hard { %%write init; - - _context.cursor = iPoint(0,0); - _context.window = iRect(0,0,80,24); _context.flags = 0; + + if (hard) { + _context.cursor = iPoint(0,0); + _context.window = iRect(0,0,80,24); + } } -(BOOL)resizable @@ -336,7 +331,7 @@ -(id)init { - [self reset]; + [self reset: YES]; return self; } diff --git a/Emulators/VT52.mm b/Emulators/VT52.mm index e8b31a9..d70f653 100644 --- a/Emulators/VT52.mm +++ b/Emulators/VT52.mm @@ -72,7 +72,7 @@ enum { -(id)init { if ((self = [super init])) { _model = ModelVT50; - [self reset]; + [self reset: YES]; } return self; @@ -104,7 +104,7 @@ enum { -(id)init { if ((self = [super init])) { _model = ModelVT50H; - [self reset]; + [self reset: YES]; } return self; @@ -141,7 +141,7 @@ enum { -(id)init { if ((self = [super init])) { _model = ModelVT52; - [self reset]; + [self reset: YES]; } return self; } @@ -168,7 +168,7 @@ enum { -(id)init { if ((self = [super init])) { _model = ModelVT55; - [self reset]; + [self reset: YES]; } return self; @@ -319,15 +319,18 @@ enum { } } --(void)reset +-(void)reset: (BOOL)hard { cs = StateText; _escape = false; _altKeyPad = false; _graphics = false; - _context.cursor = iPoint(0,0); - _context.window = iRect(0, 0, 80, 24); - if (_model <= ModelVT50H) _context.window = iRect(0, 0, 80, 12); + + if (hard) { + _context.cursor = iPoint(0,0); + _context.window = iRect(0, 0, 80, 24); + if (_model <= ModelVT50H) _context.window = iRect(0, 0, 80, 12); + } _context.flags = 0; } diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index ba149c7..0ab5523 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -63,8 +63,8 @@ - - + + @@ -112,6 +112,19 @@ + + + + + + + + + + + + + diff --git a/TermWindowController.h b/TermWindowController.h index ca05225..a1db637 100644 --- a/TermWindowController.h +++ b/TermWindowController.h @@ -57,6 +57,9 @@ -(void)setParameters: (NSDictionary *)parameters; +-(IBAction)resetTerminal: (id)sender; +-(IBAction)hardResetTerminal: (id)sender; + @end diff --git a/TermWindowController.mm b/TermWindowController.mm index 27b7292..3a30380 100644 --- a/TermWindowController.mm +++ b/TermWindowController.mm @@ -248,8 +248,14 @@ [_emulatorView processData: (uint8_t *)buffer size: size]; } +-(IBAction)resetTerminal: (id)sender { + [_emulator reset: NO]; +} - +-(IBAction)hardResetTerminal: (id)sender { + [_emulator reset: YES]; + [_emulatorView reset]; +} #pragma mark - #pragma mark NSWindowDelegate @@ -413,6 +419,7 @@ } } + - (IBAction)foregroundColor:(id)sender { [self updateForegroundColor]; } @@ -463,7 +470,6 @@ [_emulatorView setBackgroundColor: color]; } - @end diff --git a/Views/EmulatorView.h b/Views/EmulatorView.h index cf3dcad..3ce1056 100644 --- a/Views/EmulatorView.h +++ b/Views/EmulatorView.h @@ -111,6 +111,8 @@ private: -(void)processData: (uint8_t *)data size: (size_t)size; -(void)childFinished: (int)status; -(void)childBegan; + +-(void)reset; @end diff --git a/Views/EmulatorView.mm b/Views/EmulatorView.mm index 31f0ff9..42d33a8 100644 --- a/Views/EmulatorView.mm +++ b/Views/EmulatorView.mm @@ -888,7 +888,12 @@ } - +-(void)reset { + _screen.eraseScreen(); + _screen.setCursor(iPoint(0,0)); + _cursorOn = YES; + [self setNeedsDisplay: YES]; +} @end