From 41c311fb8ade4f4a131125a82ada47cda1707397 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Fri, 9 Feb 2018 22:47:20 -0500 Subject: [PATCH] Squashed commit of the following: commit b9723cf13690c3a6ecefeee81b1d95a23bde0422 Author: Kelvin Sherlock Date: Fri Feb 9 22:41:59 2018 -0500 remove most gui config stuff from new window. commit c690c5ebd99d6268f605094f429114a39ab3c180 Author: Kelvin Sherlock Date: Thu Feb 8 11:48:29 2018 -0500 crosshatch cursor, push/pop cursor state when no longer key window. commit ebaa0e535ee52a85a514efbaa872f891f7e817f1 Author: Kelvin Sherlock Date: Thu Feb 8 11:47:20 2018 -0500 child monitor - removeAll commit e591630339f3cd22ca461f2006f4c360fa43d026 Author: Kelvin Sherlock Date: Thu Feb 8 11:46:19 2018 -0500 add config popup for the term window. --- ChildMonitor.h | 1 + ChildMonitor.mm | 16 ++ English.lproj/MainMenu.xib | 271 +-------------------------- English.lproj/NewTerminal.xib | 181 +++--------------- English.lproj/TermConfig.xib | 244 ++++++++++++++++++++++++ English.lproj/TermWindow.xib | 13 +- NewTerminalWindowController.h | 24 --- NewTerminalWindowController.mm | 64 +------ TermWindowController.h | 55 +++++- TermWindowController.mm | 296 ++++++++++++++++++++++++------ TwoTerm.xcodeproj/project.pbxproj | 12 ++ TwoTermAppDelegate.mm | 14 +- Views/EmulatorView.h | 5 +- Views/EmulatorView.mm | 93 ++-------- cpp/Screen.h | 3 +- 15 files changed, 640 insertions(+), 652 deletions(-) create mode 100644 English.lproj/TermConfig.xib diff --git a/ChildMonitor.h b/ChildMonitor.h index fa4192c..9c4ecba 100644 --- a/ChildMonitor.h +++ b/ChildMonitor.h @@ -17,4 +17,5 @@ -(void)removeController: (TermWindowController *)controller; -(void)addController: (TermWindowController *)controller pid: (pid_t)pid fd: (int)fd; +-(void)removeAll; @end diff --git a/ChildMonitor.mm b/ChildMonitor.mm index f18b3b9..700579f 100644 --- a/ChildMonitor.mm +++ b/ChildMonitor.mm @@ -107,6 +107,22 @@ namespace { [super dealloc]; } + +-(void)removeAll { + Locker l(_lock); + + for (auto &e : _table) { + if (e.controller) { + [e.controller release]; + e.controller = nil; + } + if (e.pid > 0) { + kill(e.pid, SIGHUP); + e.pid = -1; + } + } +} + -(void)removeController: (TermWindowController *)controller { if (!controller) return; diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 6db1784..ba149c7 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -342,268 +342,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -618,6 +356,11 @@ + + + + + diff --git a/English.lproj/NewTerminal.xib b/English.lproj/NewTerminal.xib index b3f61c5..446ad2a 100644 --- a/English.lproj/NewTerminal.xib +++ b/English.lproj/NewTerminal.xib @@ -1,7 +1,8 @@ - + - + + @@ -9,16 +10,9 @@ - - - - - - - @@ -27,14 +21,14 @@ - + - + - - + + @@ -42,9 +36,9 @@ - - - + @@ -86,13 +66,13 @@ Gw - + - + @@ -101,7 +81,7 @@ Gw - + @@ -110,7 +90,7 @@ Gw - + @@ -124,7 +104,7 @@ Gw - + @@ -132,7 +112,7 @@ Gw - + @@ -156,128 +136,27 @@ Gw - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +Gw + + + + + + - + diff --git a/English.lproj/TermConfig.xib b/English.lproj/TermConfig.xib new file mode 100644 index 0000000..01474fc --- /dev/null +++ b/English.lproj/TermConfig.xib @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/English.lproj/TermWindow.xib b/English.lproj/TermWindow.xib index 7166af7..5facc52 100644 --- a/English.lproj/TermWindow.xib +++ b/English.lproj/TermWindow.xib @@ -1,13 +1,15 @@ - - + + - + + + - - + + @@ -44,5 +46,6 @@ + diff --git a/NewTerminalWindowController.h b/NewTerminalWindowController.h index df60617..f6188d4 100644 --- a/NewTerminalWindowController.h +++ b/NewTerminalWindowController.h @@ -19,18 +19,6 @@ NSColorWell *_foregroundColorControl; NSColorWell *_backgroundColorControl; - - - NSButton *_effectsButton; - NSSlider *_blurSlider; - NSSlider *_lightenSlider; - NSSlider *_darkenSlider; - - - ExampleView *_exampleView; - - BOOL _effectsEnabled; - } @property (nonatomic, assign) IBOutlet ExampleView *exampleView; @@ -42,15 +30,6 @@ @property (nonatomic, assign) IBOutlet NSColorWell *foregroundColorControl; @property (nonatomic, assign) IBOutlet NSColorWell *backgroundColorControl; -@property (nonatomic, assign) IBOutlet NSButton *effectsButton; -@property (nonatomic, assign) IBOutlet NSSlider *blurSlider; -@property (nonatomic, assign) IBOutlet NSSlider *lightenSlider; -@property (nonatomic, assign) IBOutlet NSSlider *darkenSlider; -@property (nonatomic, assign) IBOutlet NSSlider *bloomSlider; -@property (nonatomic, assign) IBOutlet NSSlider *vignetteSlider; - -@property (nonatomic, assign) BOOL effectsEnabled; - -(IBAction)cancelButton: (id)sender; @@ -59,10 +38,7 @@ -(IBAction)colorChanged: (id)sender; -(IBAction)setColorScheme: (id)sender; --(IBAction)filterParameterChanged: (id)sender; -(NSMenu *)colorMenu; --(NSColor *)recalcBackground; - @end diff --git a/NewTerminalWindowController.mm b/NewTerminalWindowController.mm index 306a1ba..087819e 100644 --- a/NewTerminalWindowController.mm +++ b/NewTerminalWindowController.mm @@ -18,16 +18,9 @@ @synthesize terminalTypeButton = _terminalTypeButton; @synthesize colorSchemeButton = _colorSchemeButton; -@synthesize effectsButton = _effectsButton; @synthesize foregroundColorControl = _foregroundColorControl; @synthesize backgroundColorControl = _backgroundColorControl; -@synthesize blurSlider = _blurSlider; -@synthesize lightenSlider = _lightenSlider; -@synthesize darkenSlider = _darkenSlider; - - -@synthesize effectsEnabled = _effectsEnabled; // colors enum { kCustom = 0, @@ -59,12 +52,11 @@ enum { [super windowDidLoad]; window = [self window]; + //[[window contentView] setWantsLayer: YES]; //[window setAutorecalculatesContentBorderThickness: NO forEdge: NSMinYEdge]; //[window setAutorecalculatesContentBorderThickness: NO forEdge: NSMaxYEdge]; - [self setEffectsEnabled: YES]; - [_terminalTypeButton setMenu: [EmulatorManager emulatorMenu]]; @@ -143,16 +135,11 @@ enum { [userInfo setObject: klass forKey: kClass]; [userInfo setObject: [_foregroundColorControl color] forKey: kForegroundColor]; - [userInfo setObject: [self recalcBackground] forKey: kBackgroundColor]; - - if (_effectsEnabled) - { - [userInfo setObject: [_exampleView contentFilters] forKey: kContentFilters]; - } + [userInfo setObject: [_backgroundColorControl color] forKey: kBackgroundColor]; + [nc postNotificationName: kNotificationNewTerminal object: self userInfo: userInfo]; - // post notificiation... } @@ -205,43 +192,9 @@ enum { } - [self filterParameterChanged: nil]; } --(IBAction)filterParameterChanged: (id)sender -{ - - [_exampleView setForegroundColor: [_foregroundColorControl color]]; - [_exampleView setColor: [self recalcBackground]]; - - if (_effectsEnabled) - { - [_exampleView setBlur: [_blurSlider floatValue]]; - //[_exampleView setLighten: [_lightenSlider floatValue]]; - [_exampleView setDarken: [_darkenSlider floatValue]]; - [_exampleView setBloom: [_bloomSlider floatValue]]; - [_exampleView setVignette: [_vignetteSlider floatValue]]; - - } - else - { - [_exampleView setBlur: 0.0]; - //[_exampleView setLighten: 0.0]; - [_exampleView setDarken: 0.0]; - [_exampleView setBloom: 0.0]; - [_exampleView setVignette: 0.0]; - } - - [_exampleView updateEffects]; - [_exampleView setNeedsDisplay: YES]; -} - --(void)setEffectsEnabled:(BOOL)effectsEnabled -{ - _effectsEnabled = effectsEnabled; - [self filterParameterChanged: nil]; -} #pragma mark - #pragma mark NSWindowDelegate @@ -254,17 +207,6 @@ enum { [self autorelease]; } --(NSColor *)recalcBackground { - - NSColor *bg = [_backgroundColorControl color]; - NSColor *fg = [_foregroundColorControl color]; - CGFloat value = [_lightenSlider doubleValue]; - - if (_effectsEnabled) { - bg = [bg blendedColorWithFraction: value ofColor: fg]; - } - return bg; -} @end diff --git a/TermWindowController.h b/TermWindowController.h index c2990e0..ca05225 100644 --- a/TermWindowController.h +++ b/TermWindowController.h @@ -14,28 +14,65 @@ @protocol Emulator; -@interface TermWindowController : NSWindowController { - - NSDictionary *_parameters; - - EmulatorView *_emulatorView; - ColorView *_colorView; +@interface TermWindowController : NSWindowController { + IBOutlet EmulatorView *_emulatorView; + IBOutlet ColorView *_colorView; NSObject *_emulator; + /* popover configuration options */ + IBOutlet NSColorWell *_fg; + IBOutlet NSColorWell *_bg; + + IBOutlet NSButton *_effectsButton; + IBOutlet NSSlider *_blurSlider; + IBOutlet NSSlider *_lightenSlider; + IBOutlet NSSlider *_darkenSlider; + IBOutlet NSSlider *_bloomSlider; + IBOutlet NSSlider *_vignetteSlider; } -@property (nonatomic, retain) NSDictionary *parameters; +@property (nonatomic, retain) IBOutlet NSViewController *popoverViewController; +@property (nonatomic, retain) IBOutlet NSPopover *popover; -@property (nonatomic, retain) IBOutlet EmulatorView *emulatorView; -@property (nonatomic, retain) IBOutlet ColorView *colorView; @property (nonatomic, retain) NSObject *emulator; +@property (nonatomic, assign) BOOL effectsEnabled; +@property (nonatomic, assign) double blurValue; +@property (nonatomic, assign) double bloomValue; +@property (nonatomic, assign) double backlightValue; +@property (nonatomic, assign) double scanlineValue; +@property (nonatomic, assign) double vignetteValue; + +@property (nonatomic, retain) NSColor *foregroundColor; +@property (nonatomic, retain) NSColor *backgroundColor; + + -(void)initPTY; -(void)childFinished: (int)status; -(void)processData: (const void *)buffer size: (size_t)size; +-(void)setParameters: (NSDictionary *)parameters; + +@end + + +@interface TermWindowController (Config) + +- (IBAction)configure: (id)sender; + +- (IBAction)foregroundColor:(id)sender; +- (IBAction)backgroundColor:(id)sender; +- (IBAction)swapColors:(id)sender; + +- (IBAction)filterParameterChanged: (id)sender; + +-(void) updateBackgroundColor; +-(void) updateForegroundColor; + +-(NSArray *)effectsFilter; + @end diff --git a/TermWindowController.mm b/TermWindowController.mm index 0e3c7e2..2bf28ae 100644 --- a/TermWindowController.mm +++ b/TermWindowController.mm @@ -6,6 +6,9 @@ // Copyright 2010 __MyCompanyName__. All rights reserved. // +#import +#import "ScanLineFilter.h" + #import "TermWindowController.h" #import "EmulatorView.h" #import "CurveView.h" @@ -15,7 +18,7 @@ #include #include #include - +#include #import "Defaults.h" @@ -32,14 +35,11 @@ #include #include "ChildMonitor.h" +#include "ColorView.h" @implementation TermWindowController @synthesize emulator = _emulator; -@synthesize emulatorView = _emulatorView; -@synthesize colorView = _colorView; - -@synthesize parameters = _parameters; +(id)new { @@ -51,20 +51,63 @@ [[ChildMonitor monitor] removeController: self]; [_emulator release]; - [_emulatorView release]; - [_colorView release]; - - [_parameters release]; + [_popover release]; + [_popoverViewController release]; + + [_foregroundColor release]; + [_backgroundColor release]; + [super dealloc]; } -/* --(void)awakeFromNib -{ - [self initPTY]; +-(id)initWithWindow:(NSWindow *)window { + if ((self = [super initWithWindow: window])) { + _foregroundColor = [[NSColor greenColor] retain]; + _backgroundColor = [[NSColor blackColor] retain]; + + _bloomValue = 0.75; + _blurValue = 0.0; + _backlightValue = 0.25; + _scanlineValue = 0.5; + _vignetteValue = 0.5; + _effectsEnabled = YES; + + } + return self; } -*/ + +-(void)setParameters: (NSDictionary *)parameters { + + NSColor *o; + Class klass; + + o = [parameters objectForKey: kForegroundColor]; + o = o ? (NSColor *)o : [NSColor greenColor]; + [self setForegroundColor: o]; + + o = [parameters objectForKey: kBackgroundColor]; + o = o ? (NSColor *)o : [NSColor blackColor]; + [self setBackgroundColor: o]; + + klass = [parameters objectForKey: kClass]; + if (!klass || ![klass conformsToProtocol: @protocol(Emulator)]) + { + klass = Nil; + //klass = [VT52 class]; + } + + [self willChangeValueForKey: @"emulator"]; + _emulator = [klass new]; + [self didChangeValueForKey: @"emulator"]; + + +#if 0 + [self updateBackgroundColor]; + [self updateForegroundColor]; +#endif +} + -(void)initPTY { @@ -205,68 +248,35 @@ [_emulatorView processData: (uint8_t *)buffer size: size]; } + + #pragma mark - #pragma mark NSWindowDelegate - (void)windowDidLoad { - - NSColor *foregroundColor; - NSColor *backgroundColor; - Class klass; - id o; - + NSWindow *window; [super windowDidLoad]; - window = [self window]; - - //[(CurveView *)[window contentView] setColor: [NSColor clearColor]]; - - //[window setContentView: _curveView]; // resize in 2.0 height increments to prevent jittering the scan lines. //[window setResizeIncrements: NSMakeSize(1.0, 2.0)]; - - klass = [_parameters objectForKey: kClass]; - if (!klass || ![klass conformsToProtocol: @protocol(Emulator)]) - { - klass = Nil; - //klass = [VT52 class]; - } - - o = [_parameters objectForKey: kForegroundColor]; - foregroundColor = o ? (NSColor *)o : [NSColor greenColor]; - - o = [_parameters objectForKey: kBackgroundColor]; - backgroundColor = o ? (NSColor *)o : [NSColor blackColor]; - - - [self willChangeValueForKey: @"emulator"]; - _emulator = [klass new]; - [self didChangeValueForKey: @"emulator"]; - [window setBackgroundColor: backgroundColor]; - [(EmulatorWindow *)window setTitleTextColor: foregroundColor]; + window = [self window]; + [_emulatorView setEmulator: _emulator]; - [_emulatorView setForegroundColor: foregroundColor]; - [_emulatorView setBackgroundColor: backgroundColor]; - //[_emulatorView setScanLines: scanLines]; + + [self updateBackgroundColor]; + [self updateForegroundColor]; - [_colorView setColor: backgroundColor]; - - o = [_parameters objectForKey: kContentFilters]; - if (o) - { - [_colorView setWantsLayer: YES]; - [_colorView setContentFilters: (NSArray *)o]; - } + [_colorView setWantsLayer: YES]; + [_colorView setContentFilters: [self effectsFilter]]; [self initPTY]; - } -(void)windowWillClose:(NSNotification *)notification @@ -275,6 +285,178 @@ [self autorelease]; } +-(void)windowDidBecomeKey:(NSNotification *)notification { + [_emulatorView popCursor]; +} + +-(void)windowDidResignKey:(NSNotification *)notification { + [_emulatorView pushCursor: Screen::CursorTypeBlock]; +} + +-(void)popoverWillClose:(NSNotification *)notification { + [_fg deactivate]; + [_bg deactivate]; + [[NSColorPanel sharedColorPanel] orderOut: self]; +} +@end + +@implementation TermWindowController (Config) + +-(NSColor *)recalcBackgroundColor { + + if (_effectsEnabled) { + return [_backgroundColor blendedColorWithFraction: _backlightValue ofColor: _foregroundColor]; + } + return _backgroundColor; +} + +-(IBAction)filterParameterChanged:(id)sender { + if (sender == _effectsButton) sender = nil; + + if (sender == nil || sender == _fg) { + [self updateForegroundColor]; + } + if (sender == nil || sender == _fg || sender == _bg || sender == _lightenSlider) { + [self updateBackgroundColor]; + } + + if (sender == nil || sender == _vignetteSlider || sender == _darkenSlider || sender == _bloomSlider) { + + [_colorView setContentFilters: [self effectsFilter]]; + } + +#if 0 + CIFilter *filter = [_contentFilters objectAtIndex: 0]; + [filter setValue: @(_vignetteValue) forKey: @"inputIntensity"]; + } + + if (sender == _darkenSlider) { + CIFilter *filter = [_contentFilters objectAtIndex: 1]; + [filter setValue: @(_scanlineValue) forKey: @"inputDarken"]; + } + + if (sender == _bloomSlider) { + CIFilter *filter = [_contentFilters objectAtIndex: 2]; + [filter setValue: @(_bloomValue) forKey: @"inputIntensity"]; + } +#endif + + +} + +-(NSArray *)effectsFilter { + + if (!_effectsEnabled) return @[]; + + CIFilter *filter; + NSMutableArray *filters = [NSMutableArray arrayWithCapacity: 5]; + + // 1. vignette effect + filter = [CIFilter filterWithName: @"CIVignette"]; + [filter setDefaults]; + [filter setValue: @(_vignetteValue) forKey: @"inputIntensity"]; + [filter setValue: @(2.0) forKey: @"inputRadius"]; + + [filters addObject: filter]; + + + // 2. add the scanlines + filter = [[ScanLineFilter new] autorelease]; + [filter setValue: @(_scanlineValue) forKey: @"inputDarken"]; + [filter setValue: @(0.0) forKey: @"inputLighten"]; + [filters addObject: filter]; + + + // 3. bloom it... + filter = [CIFilter filterWithName: @"CIBloom"]; + [filter setDefaults]; + [filter setValue: @2.0 forKey: @"inputRadius"]; + [filter setValue: @(_bloomValue) forKey: @"inputIntensity"]; + + [filters addObject: filter]; + +#if 0 + //4. blur it a bit... + filter = [CIFilter filterWithName: @"CIGaussianBlur"]; + [filter setDefaults]; + [filter setValue: @(_blurValue) forKey: @"inputRadius"]; + + [filters addObject: filter]; +#endif + + return filters; +} + + + +#pragma mark - IBActions + +-(IBAction)configure: (id)sender { + + if (!_popover) { + NSNib *nib = [[NSNib alloc] initWithNibNamed: @"TermConfig" bundle: nil]; + // n.b. - instantiateWithOwner (10.8+) does not +1 refcount top level objects. + [nib instantiateWithOwner: self topLevelObjects: nil]; + [nib release]; + } + if ([_popover isShown]) { + [_popover close]; + } else { + [_popover showRelativeToRect: NSZeroRect ofView: _emulatorView preferredEdge: NSRectEdgeMaxX]; + } +} + +- (IBAction)foregroundColor:(id)sender { + [self updateForegroundColor]; +} + +- (IBAction)backgroundColor:(id)sender { + + [self updateBackgroundColor]; +} + +- (IBAction)swapColors:(id)sender { + + + [self willChangeValueForKey: @"foregroundColor"]; + [self willChangeValueForKey: @"backgroundColor"]; + + std::swap(_foregroundColor, _backgroundColor); + + [self didChangeValueForKey: @"foregroundColor"]; + [self didChangeValueForKey: @"backgroundColor"]; + + [self updateBackgroundColor]; + [self updateForegroundColor]; + + if ([_fg isActive]) { + [_bg activate: YES]; + } else if ([_bg isActive]) { + [_fg activate: YES]; + } +} + + +-(void)updateForegroundColor { + NSColor *color = _foregroundColor; + + NSWindow *window = [self window]; + + [(EmulatorWindow *)window setTitleTextColor: color]; + + [_emulatorView setForegroundColor: color]; +} + +-(void)updateBackgroundColor { + NSColor *color = [self recalcBackgroundColor]; + NSWindow *window = [self window]; + + [window setBackgroundColor: color]; + [_colorView setColor: color]; + [_emulatorView setBackgroundColor: color]; +} + + @end diff --git a/TwoTerm.xcodeproj/project.pbxproj b/TwoTerm.xcodeproj/project.pbxproj index fcdb261..7989885 100644 --- a/TwoTerm.xcodeproj/project.pbxproj +++ b/TwoTerm.xcodeproj/project.pbxproj @@ -44,6 +44,7 @@ B67B3CE612B6FA040033AE07 /* a2-charset-80.png in Resources */ = {isa = PBXBuildFile; fileRef = B67B3CE412B6FA040033AE07 /* a2-charset-80.png */; }; B6801BD912EB549300B22E9E /* vt100-charset.png in Resources */ = {isa = PBXBuildFile; fileRef = B6801BD812EB549300B22E9E /* vt100-charset.png */; }; B68E632A12FF909D00EAFF5F /* ExampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = B68E632912FF909C00EAFF5F /* ExampleView.m */; }; + B69D0FBA202799B10073CCB7 /* TermConfig.xib in Resources */ = {isa = PBXBuildFile; fileRef = B69D0FB8202799B10073CCB7 /* TermConfig.xib */; }; B69E32A920221C9E0086D7B1 /* ChildMonitor.mm in Sources */ = {isa = PBXBuildFile; fileRef = B69E32A820221C9E0086D7B1 /* ChildMonitor.mm */; }; B6ACA2AD1E614E38000E774B /* VT52.mm in Sources */ = {isa = PBXBuildFile; fileRef = B612F46312DD5DF1005D1B77 /* VT52.mm */; }; B6ACA2AF1E635CEC000E774B /* vt52-charset.png in Resources */ = {isa = PBXBuildFile; fileRef = B6ACA2AE1E635CEC000E774B /* vt52-charset.png */; }; @@ -164,6 +165,7 @@ B6801BD812EB549300B22E9E /* vt100-charset.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "vt100-charset.png"; sourceTree = ""; }; B68E632812FF909C00EAFF5F /* ExampleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleView.h; sourceTree = ""; }; B68E632912FF909C00EAFF5F /* ExampleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleView.m; sourceTree = ""; }; + B69D0FB9202799B10073CCB7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/TermConfig.xib; sourceTree = ""; }; B69E32A820221C9E0086D7B1 /* ChildMonitor.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ChildMonitor.mm; sourceTree = ""; }; B69E32AA20221CCA0086D7B1 /* ChildMonitor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChildMonitor.h; sourceTree = ""; }; B6ACA2AB1E5C8BEC000E774B /* GNOConsole.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GNOConsole.mm; sourceTree = ""; }; @@ -277,6 +279,7 @@ 1DDD58140DA1D0A300B32029 /* MainMenu.xib */, B676065011DEBAE900D6B66C /* TermWindow.xib */, B61EF7C714815AF8008C1891 /* NewTerminal.xib */, + B69D0FB8202799B10073CCB7 /* TermConfig.xib */, B61EF7CD148163E7008C1891 /* TitleBarView.xib */, ); name = Resources; @@ -442,6 +445,7 @@ files = ( B60EBE2B11E918D500C1974F /* ScanLineFilter.cikernel in Resources */, 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, + B69D0FBA202799B10073CCB7 /* TermConfig.xib in Resources */, 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */, B676065111DEBAE900D6B66C /* TermWindow.xib in Resources */, B67B3CE512B6FA040033AE07 /* a2-charset-40.png in Resources */, @@ -556,6 +560,14 @@ name = TermWindow.xib; sourceTree = ""; }; + B69D0FB8202799B10073CCB7 /* TermConfig.xib */ = { + isa = PBXVariantGroup; + children = ( + B69D0FB9202799B10073CCB7 /* English */, + ); + name = TermConfig.xib; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/TwoTermAppDelegate.mm b/TwoTermAppDelegate.mm index 181afc7..c6f35e6 100644 --- a/TwoTermAppDelegate.mm +++ b/TwoTermAppDelegate.mm @@ -13,7 +13,7 @@ #import "Defaults.h" //#import "VT52.h" #import "GNOConsole.h" - +#import "ChildMonitor.h" #import "ScanLineFilter.h" @implementation TwoTermAppDelegate @@ -27,9 +27,7 @@ TermWindowController *controller; - NSMutableArray *filters; NSDictionary *parameters; - CIFilter *filter; #if 0 struct sigaction sa = {}; @@ -42,7 +40,7 @@ [nc addObserver: self selector: @selector(newTerminal:) name: kNotificationNewTerminal object: nil]; - +#if 0 filters = [NSMutableArray arrayWithCapacity: 5]; @@ -76,12 +74,12 @@ [filter setValue: @2.0 forKey: @"inputRadius"]; [filter setValue: @(0.75) forKey: @"inputIntensity"]; - +#endif parameters = @{ kClass: [GNOConsole class], - kContentFilters: filters, + //kContentFilters: filters, kForegroundColor: [NSColor colorWithRed: 0.0 green: 1.0 blue: 0.6 alpha: 1.0], kBackgroundColor: [NSColor colorWithRed: 0.0 green: .25 blue: .15 alpha: 1.0] }; @@ -92,6 +90,10 @@ // this leak is ok. } +-(void)applicationWillTerminate:(NSNotification *)notification { + [[ChildMonitor monitor] removeAll]; +} + -(void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver: self]; diff --git a/Views/EmulatorView.h b/Views/EmulatorView.h index e87c3a8..cf3dcad 100644 --- a/Views/EmulatorView.h +++ b/Views/EmulatorView.h @@ -73,13 +73,14 @@ private: unsigned _cursorType; - NSImage *_cursors[4]; + NSImage *_cursors[5]; #ifdef __cplusplus ring_buffer<1024> _debug_buffer; ViewScreen _screen; #endif + std::vector _cursorStack; } @property (nonatomic, assign) BOOL scanLines; @@ -121,5 +122,7 @@ private: -(void)cursorTimer: (NSTimer *)timer; -(void)startCursorTimer; +-(void)pushCursor: (unsigned)type; +-(void)popCursor; @end diff --git a/Views/EmulatorView.mm b/Views/EmulatorView.mm index b3517bd..c045799 100644 --- a/Views/EmulatorView.mm +++ b/Views/EmulatorView.mm @@ -58,6 +58,7 @@ [_cursorTimer release]; _cursorTimer = nil; + _cursorOn = YES; iRect r(_screen.cursor(), iSize(1,1)); [self invalidateIRect: r]; } @@ -95,30 +96,24 @@ { return _cursorType; } -#if 0 -dispatch_async(dispatch_get_main_queue(), ^(){ - if (_cursorType == cursorType) return; +-(void)pushCursor:(unsigned)type { + if (_fd < 0) return; - unsigned char c; - switch (cursorType) { - default: - case Screen::CursorTypeUnderscore: c = '_'; break; - case Screen::CursorTypePipe: c = '|'; break; - case Screen::CursorTypeBlock: c = 0x80; break; - } - [_cursorImg release]; - _cursorType = cursorType; - _cursorImg = [[_charGen imageForCharacter: c] retain]; - - iRect r(_screen.cursor(), iSize(1,1)); - - [self invalidateIRect: r]; - - }); -#endif + _cursorStack.push_back(_cursorType); + [self setCursorType: type]; + [self stopCursorTimer]; +} +-(void)popCursor { + if (_fd < 0) return; + if (!_cursorStack.empty()) { + [self setCursorType: _cursorStack.back()]; + _cursorStack.pop_back(); + if (_cursorStack.empty()) [self startCursorTimer]; + } +} @end @@ -160,7 +155,7 @@ dispatch_async(dispatch_get_main_queue(), ^(){ _paddingLeft = 8; _paddingTop = 8; _paddingBottom = 8; - + _fd = 1; //_foregroundColor = [[NSColor greenColor] retain]; //_backgroundColor = [[NSColor blackColor] retain]; @@ -181,6 +176,7 @@ dispatch_async(dispatch_get_main_queue(), ^(){ _cursors[Screen::CursorTypeUnderscore] = [[_charGen imageForCharacter: '_'] retain]; _cursors[Screen::CursorTypePipe] = [[_charGen imageForCharacter: '|'] retain]; _cursors[Screen::CursorTypeBlock] = [[_charGen imageForCharacter: 0x80] retain]; + _cursors[Screen::CursorTypeCrossHatch] = [[_charGen imageForCharacter: 0x7f] retain]; size = [_charGen characterSize]; @@ -214,49 +210,6 @@ dispatch_async(dispatch_get_main_queue(), ^(){ [self setNeedsDisplay: YES]; } --(void)setScanLines:(BOOL)scanLines -{ - if (_scanLines == scanLines) return; - - _scanLines = scanLines; - - if (_scanLines) - { - NSMutableArray *filters; - CIFilter *filter; - - [self setWantsLayer: YES]; - - filters = [NSMutableArray arrayWithCapacity: 3]; - - - - //add the scanlines - - filter = [[ScanLineFilter new] autorelease]; - [filter setValue: [NSNumber numberWithFloat: 1.0] forKey: @"inputDarken"]; - [filter setValue: [NSNumber numberWithFloat: 0.025] forKey: @"inputLighten"]; - [filters addObject: filter]; - - //blur it a bit... - - filter = [CIFilter filterWithName: @"CIGaussianBlur"]; - [filter setDefaults]; - [filter setValue: [NSNumber numberWithFloat: 0.33] forKey: @"inputRadius"]; - - [filters addObject: filter]; - - - - - [self setContentFilters: filters]; - } - else - { - [self setContentFilters: @[]]; - } -} - -(BOOL)isFlipped { return YES; @@ -273,11 +226,6 @@ dispatch_async(dispatch_get_main_queue(), ^(){ [self startCursorTimer]; - /* - [[self window] display]; - [[self window] setHasShadow: NO]; - [[self window] setHasShadow: YES]; - */ } -(void)viewDidMoveToSuperview @@ -467,8 +415,6 @@ dispatch_async(dispatch_get_main_queue(), ^(){ -(void)dealloc { - close(_fd); - [_foregroundColor release]; [_backgroundColor release]; @@ -531,11 +477,12 @@ dispatch_async(dispatch_get_main_queue(), ^(){ //NSLog(@"[process complete]"); + _fd = -1; dispatch_async(dispatch_get_main_queue(), ^(){ iRect updateRect; - [self setCursorType: Screen::CursorTypeNone]; + [self setCursorType: Screen::CursorTypeCrossHatch]; [self stopCursorTimer]; //_screen.setCursorType(Screen::CursorTypeNone); @@ -802,7 +749,7 @@ dispatch_async(dispatch_get_main_queue(), ^(){ SEL cmd = [anItem action]; if (cmd == @selector(paste:)) { - return _fd >= 1; + return _fd >= 0; } if (cmd == @selector(copy:)) return NO; if (cmd == @selector(copyDebugData:)) return YES; diff --git a/cpp/Screen.h b/cpp/Screen.h index 6cb2f2b..563d6ee 100644 --- a/cpp/Screen.h +++ b/cpp/Screen.h @@ -69,7 +69,8 @@ public: CursorTypeNone, CursorTypeUnderscore, CursorTypePipe, - CursorTypeBlock + CursorTypeBlock, + CursorTypeCrossHatch, }; Screen(unsigned height = 24, unsigned width = 80);