diff --git a/EmulatorManager.m b/EmulatorManager.m index b1ae8db..2826c68 100644 --- a/EmulatorManager.m +++ b/EmulatorManager.m @@ -28,17 +28,17 @@ static NSMutableArray *array = nil; return nil; } -+(void)load -{ - array = [NSMutableArray new]; -} +// can be called before +load. +(void)registerClass: (Class)klass { if (klass && [klass conformsToProtocol: @protocol(Emulator)]) { @synchronized (self) { + if (!array) + array = [NSMutableArray new]; + [array addObject: klass]; } } @@ -69,7 +69,7 @@ static NSMutableArray *array = nil; { @synchronized(self) { - if (tag && tag < [array count]) + if (tag && tag <= [array count]) { return [array objectAtIndex: tag - 1]; } diff --git a/English.lproj/NewTerminal.xib b/English.lproj/NewTerminal.xib index 37936c5..e542f04 100644 --- a/English.lproj/NewTerminal.xib +++ b/English.lproj/NewTerminal.xib @@ -46,7 +46,7 @@ 263 2 - {{196, 240}, {300, 175}} + {{196, 240}, {400, 175}} 544736256 New Terminal NSWindow @@ -59,14 +59,13 @@ 266 - {{121, 130}, {159, 26}} + {{121, 130}, {259, 26}} - YES -2080244160 - 134219776 + 2048 LucidaGrande 13 @@ -85,6 +84,7 @@ 1048576 2147483647 + 1 NSImage NSMenuCheckmark @@ -118,7 +118,7 @@ - 1 + 2 YES YES 2 @@ -129,7 +129,6 @@ 268 {{17, 135}, {99, 17}} - YES @@ -161,10 +160,8 @@ 289 - {{162, 18}, {118, 25}} + {{262, 18}, {118, 25}} - - YES -2080244224 @@ -185,7 +182,6 @@ 292 {{20, 18}, {118, 25}} - YES @@ -203,9 +199,8 @@ - {{7, 11}, {300, 175}} + {{7, 11}, {400, 175}} - {{0, 0}, {1920, 1178}} @@ -447,36 +442,7 @@ 48 - - - YES - - NewTerminalWindowController - NSWindowController - - YES - - YES - cancelButton: - connectButton: - - - YES - id - id - - - - _terminalTypeButton - NSPopUpButton - - - IBProjectSource - ./classes-xjh84/NewTerminalWindowController.h - - - - + 0 IBCocoaFramework diff --git a/NewTerminalWindowController.m b/NewTerminalWindowController.m index 231dbdb..fee910c 100644 --- a/NewTerminalWindowController.m +++ b/NewTerminalWindowController.m @@ -8,6 +8,7 @@ #import "NewTerminalWindowController.h" #import "Emulator.h" +#import "Defaults.h" @implementation NewTerminalWindowController @@ -22,7 +23,7 @@ - (void)dealloc { // Clean-up code here. - [_terminalTypeButton release]; + //[_terminalTypeButton release]; [super dealloc]; } @@ -53,6 +54,13 @@ if (klass) { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys: + klass, @"Class", + nil]; + + [nc postNotificationName: kNotificationNewTerminal object: self userInfo: userInfo]; + // post notificiation... } diff --git a/PTSE.mm b/PTSE.mm index da37986..e1218bf 100644 --- a/PTSE.mm +++ b/PTSE.mm @@ -33,10 +33,9 @@ enum { }; - --(const char *)termName ++(void)load { - return "proterm-special"; + [EmulatorManager registerClass: self]; } +(NSString *)name @@ -49,6 +48,12 @@ enum { return @"Proterm Special Emulation"; } +-(const char *)termName +{ + return "proterm-special"; +} + + -(void)reset { _state = StateText; diff --git a/TermWindowController.mm b/TermWindowController.mm index 1079f76..0ef537b 100644 --- a/TermWindowController.mm +++ b/TermWindowController.mm @@ -34,7 +34,7 @@ -(void)dealloc { [_emulator release]; - [_emulatorView release]; + //[_emulatorView release]; [super dealloc]; } @@ -51,7 +51,7 @@ int pid; int fd; struct termios term; - struct winsize ws = { 24, 80, 0, 0 }; + struct winsize ws = [_emulator defaultSize]; //int flags; memset(&term, 0, sizeof(term)); @@ -75,7 +75,9 @@ if (pid < 0) { - //error + fprintf(stderr, "forkpty failed\n"); + fflush(stderr); + return; } if (pid == 0) @@ -83,7 +85,7 @@ std::vector environ; std::string s; - ; + s.append("TERM_PROGRAM=2Term"); s.append(1, (char)0); @@ -118,6 +120,7 @@ // TODO -- option for localhost, telnet, ssh, etc. execle("/usr/bin/login", "login", "-pf", getlogin(), NULL, &environ[0]); + fprintf(stderr, "execle failed\n"); fflush(stderr); @@ -130,6 +133,18 @@ fcntl(fd, F_SETFL, flags | O_NONBLOCK); */ + if (![_emulator resizable]) + { + + NSWindow *window = [self window]; + NSUInteger mask = [window styleMask]; + + + [window setShowsResizeIndicator: NO]; + + [window setStyleMask: mask & ~NSResizableWindowMask]; + } + _child = pid; [_emulatorView setFd: fd]; diff --git a/TwoTermAppDelegate.h b/TwoTermAppDelegate.h index 77786ba..d8b1caa 100644 --- a/TwoTermAppDelegate.h +++ b/TwoTermAppDelegate.h @@ -17,6 +17,7 @@ @property (assign) IBOutlet NSImageView *imageView; + -(void)newTerminal: (NSNotification *)notification; @end diff --git a/TwoTermAppDelegate.m b/TwoTermAppDelegate.m index c3a85b5..4b70b9a 100644 --- a/TwoTermAppDelegate.m +++ b/TwoTermAppDelegate.m @@ -9,6 +9,7 @@ #import "TwoTermAppDelegate.h" #import "TermWindowController.h" +#import "NewTerminalWindowController.h" #import "Defaults.h" #import "VT52.h" @@ -41,6 +42,18 @@ } +-(IBAction)newDocument: (id)sender +{ + NewTerminalWindowController *controller = [NewTerminalWindowController new]; + + + [controller showWindow: nil]; + // this leak is ok. +} + +#pragma mark - +#pragma mark Notificiations + -(void)newTerminal: (NSNotification *)notification { @@ -50,7 +63,7 @@ Class klass = [userInfo objectForKey: @"Class"]; - if ([klass conformsToProtocol: @protocol(Emulator)]) + if (![klass conformsToProtocol: @protocol(Emulator)]) klass = [VT52 class]; diff --git a/VT05.mm b/VT05.mm index 8a5ae0e..db4f11b 100644 --- a/VT05.mm +++ b/VT05.mm @@ -40,15 +40,19 @@ enum { }; ++(void)load +{ + [EmulatorManager registerClass: self]; +} +(NSString *)name { - return @"vt05"; + return @"VT05"; } -(NSString *)name { - return @"vt05"; + return @"VT05"; } -(const char *)termName diff --git a/VT100.mm b/VT100.mm index e46f11c..758db52 100644 --- a/VT100.mm +++ b/VT100.mm @@ -30,6 +30,11 @@ enum { }; ++(void)load +{ + [EmulatorManager registerClass: self]; +} + -(id)init { self = [super init]; diff --git a/VT52.mm b/VT52.mm index ce73759..2f3f696 100644 --- a/VT52.mm +++ b/VT52.mm @@ -41,6 +41,11 @@ enum { @implementation VT52 ++(void)load +{ + [EmulatorManager registerClass: self]; +} + +(NSString *)name { return @"VT52";