git-svn-id: svn://qnap.local/TwoTerm/trunk@1792 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
9c9741dcc8
commit
7d5ddda36d
|
@ -28,17 +28,17 @@ static NSMutableArray *array = nil;
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
+(void)load
|
|
||||||
{
|
|
||||||
array = [NSMutableArray new];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// can be called before +load.
|
||||||
+(void)registerClass: (Class)klass
|
+(void)registerClass: (Class)klass
|
||||||
{
|
{
|
||||||
if (klass && [klass conformsToProtocol: @protocol(Emulator)])
|
if (klass && [klass conformsToProtocol: @protocol(Emulator)])
|
||||||
{
|
{
|
||||||
@synchronized (self)
|
@synchronized (self)
|
||||||
{
|
{
|
||||||
|
if (!array)
|
||||||
|
array = [NSMutableArray new];
|
||||||
|
|
||||||
[array addObject: klass];
|
[array addObject: klass];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ static NSMutableArray *array = nil;
|
||||||
{
|
{
|
||||||
@synchronized(self)
|
@synchronized(self)
|
||||||
{
|
{
|
||||||
if (tag && tag < [array count])
|
if (tag && tag <= [array count])
|
||||||
{
|
{
|
||||||
return [array objectAtIndex: tag - 1];
|
return [array objectAtIndex: tag - 1];
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<object class="NSWindowTemplate" id="1005">
|
<object class="NSWindowTemplate" id="1005">
|
||||||
<int key="NSWindowStyleMask">263</int>
|
<int key="NSWindowStyleMask">263</int>
|
||||||
<int key="NSWindowBacking">2</int>
|
<int key="NSWindowBacking">2</int>
|
||||||
<string key="NSWindowRect">{{196, 240}, {300, 175}}</string>
|
<string key="NSWindowRect">{{196, 240}, {400, 175}}</string>
|
||||||
<int key="NSWTFlags">544736256</int>
|
<int key="NSWTFlags">544736256</int>
|
||||||
<string key="NSWindowTitle">New Terminal</string>
|
<string key="NSWindowTitle">New Terminal</string>
|
||||||
<string key="NSWindowClass">NSWindow</string>
|
<string key="NSWindowClass">NSWindow</string>
|
||||||
|
@ -59,14 +59,13 @@
|
||||||
<object class="NSPopUpButton" id="988010808">
|
<object class="NSPopUpButton" id="988010808">
|
||||||
<reference key="NSNextResponder" ref="1006"/>
|
<reference key="NSNextResponder" ref="1006"/>
|
||||||
<int key="NSvFlags">266</int>
|
<int key="NSvFlags">266</int>
|
||||||
<string key="NSFrame">{{121, 130}, {159, 26}}</string>
|
<string key="NSFrame">{{121, 130}, {259, 26}}</string>
|
||||||
<reference key="NSSuperview" ref="1006"/>
|
<reference key="NSSuperview" ref="1006"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="391841165"/>
|
<reference key="NSNextKeyView" ref="391841165"/>
|
||||||
<bool key="NSEnabled">YES</bool>
|
<bool key="NSEnabled">YES</bool>
|
||||||
<object class="NSPopUpButtonCell" key="NSCell" id="49383316">
|
<object class="NSPopUpButtonCell" key="NSCell" id="49383316">
|
||||||
<int key="NSCellFlags">-2080244160</int>
|
<int key="NSCellFlags">-2080244160</int>
|
||||||
<int key="NSCellFlags2">134219776</int>
|
<int key="NSCellFlags2">2048</int>
|
||||||
<object class="NSFont" key="NSSupport" id="1027415380">
|
<object class="NSFont" key="NSSupport" id="1027415380">
|
||||||
<string key="NSName">LucidaGrande</string>
|
<string key="NSName">LucidaGrande</string>
|
||||||
<double key="NSSize">13</double>
|
<double key="NSSize">13</double>
|
||||||
|
@ -85,6 +84,7 @@
|
||||||
<string key="NSKeyEquiv"/>
|
<string key="NSKeyEquiv"/>
|
||||||
<int key="NSKeyEquivModMask">1048576</int>
|
<int key="NSKeyEquivModMask">1048576</int>
|
||||||
<int key="NSMnemonicLoc">2147483647</int>
|
<int key="NSMnemonicLoc">2147483647</int>
|
||||||
|
<int key="NSState">1</int>
|
||||||
<object class="NSCustomResource" key="NSOnImage" id="1036081624">
|
<object class="NSCustomResource" key="NSOnImage" id="1036081624">
|
||||||
<string key="NSClassName">NSImage</string>
|
<string key="NSClassName">NSImage</string>
|
||||||
<string key="NSResourceName">NSMenuCheckmark</string>
|
<string key="NSResourceName">NSMenuCheckmark</string>
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
</object>
|
</object>
|
||||||
<reference key="NSMenuFont" ref="1027415380"/>
|
<reference key="NSMenuFont" ref="1027415380"/>
|
||||||
</object>
|
</object>
|
||||||
<int key="NSPreferredEdge">1</int>
|
<int key="NSPreferredEdge">2</int>
|
||||||
<bool key="NSUsesItemFromMenu">YES</bool>
|
<bool key="NSUsesItemFromMenu">YES</bool>
|
||||||
<bool key="NSAltersState">YES</bool>
|
<bool key="NSAltersState">YES</bool>
|
||||||
<int key="NSArrowPosition">2</int>
|
<int key="NSArrowPosition">2</int>
|
||||||
|
@ -129,7 +129,6 @@
|
||||||
<int key="NSvFlags">268</int>
|
<int key="NSvFlags">268</int>
|
||||||
<string key="NSFrame">{{17, 135}, {99, 17}}</string>
|
<string key="NSFrame">{{17, 135}, {99, 17}}</string>
|
||||||
<reference key="NSSuperview" ref="1006"/>
|
<reference key="NSSuperview" ref="1006"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="988010808"/>
|
<reference key="NSNextKeyView" ref="988010808"/>
|
||||||
<bool key="NSEnabled">YES</bool>
|
<bool key="NSEnabled">YES</bool>
|
||||||
<object class="NSTextFieldCell" key="NSCell" id="1072357374">
|
<object class="NSTextFieldCell" key="NSCell" id="1072357374">
|
||||||
|
@ -161,10 +160,8 @@
|
||||||
<object class="NSButton" id="839562449">
|
<object class="NSButton" id="839562449">
|
||||||
<reference key="NSNextResponder" ref="1006"/>
|
<reference key="NSNextResponder" ref="1006"/>
|
||||||
<int key="NSvFlags">289</int>
|
<int key="NSvFlags">289</int>
|
||||||
<string key="NSFrame">{{162, 18}, {118, 25}}</string>
|
<string key="NSFrame">{{262, 18}, {118, 25}}</string>
|
||||||
<reference key="NSSuperview" ref="1006"/>
|
<reference key="NSSuperview" ref="1006"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView"/>
|
|
||||||
<bool key="NSEnabled">YES</bool>
|
<bool key="NSEnabled">YES</bool>
|
||||||
<object class="NSButtonCell" key="NSCell" id="1046436309">
|
<object class="NSButtonCell" key="NSCell" id="1046436309">
|
||||||
<int key="NSCellFlags">-2080244224</int>
|
<int key="NSCellFlags">-2080244224</int>
|
||||||
|
@ -185,7 +182,6 @@
|
||||||
<int key="NSvFlags">292</int>
|
<int key="NSvFlags">292</int>
|
||||||
<string key="NSFrame">{{20, 18}, {118, 25}}</string>
|
<string key="NSFrame">{{20, 18}, {118, 25}}</string>
|
||||||
<reference key="NSSuperview" ref="1006"/>
|
<reference key="NSSuperview" ref="1006"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="839562449"/>
|
<reference key="NSNextKeyView" ref="839562449"/>
|
||||||
<bool key="NSEnabled">YES</bool>
|
<bool key="NSEnabled">YES</bool>
|
||||||
<object class="NSButtonCell" key="NSCell" id="779500661">
|
<object class="NSButtonCell" key="NSCell" id="779500661">
|
||||||
|
@ -203,9 +199,8 @@
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrame">{{7, 11}, {300, 175}}</string>
|
<string key="NSFrame">{{7, 11}, {400, 175}}</string>
|
||||||
<reference key="NSSuperview"/>
|
<reference key="NSSuperview"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="497952356"/>
|
<reference key="NSNextKeyView" ref="497952356"/>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
|
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
|
||||||
|
@ -447,36 +442,7 @@
|
||||||
<nil key="sourceID"/>
|
<nil key="sourceID"/>
|
||||||
<int key="maxID">48</int>
|
<int key="maxID">48</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
|
||||||
<object class="IBPartialClassDescription">
|
|
||||||
<string key="className">NewTerminalWindowController</string>
|
|
||||||
<string key="superclassName">NSWindowController</string>
|
|
||||||
<object class="NSMutableDictionary" key="actions">
|
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
|
||||||
<object class="NSArray" key="dict.sortedKeys">
|
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
|
||||||
<string>cancelButton:</string>
|
|
||||||
<string>connectButton:</string>
|
|
||||||
</object>
|
|
||||||
<object class="NSMutableArray" key="dict.values">
|
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
|
||||||
<string>id</string>
|
|
||||||
<string>id</string>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
<object class="NSMutableDictionary" key="outlets">
|
|
||||||
<string key="NS.key.0">_terminalTypeButton</string>
|
|
||||||
<string key="NS.object.0">NSPopUpButton</string>
|
|
||||||
</object>
|
|
||||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
|
||||||
<string key="majorKey">IBProjectSource</string>
|
|
||||||
<string key="minorKey">./classes-xjh84/NewTerminalWindowController.h</string>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
</object>
|
|
||||||
<int key="IBDocument.localizationMode">0</int>
|
<int key="IBDocument.localizationMode">0</int>
|
||||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||||
<object class="NSDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
<object class="NSDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#import "NewTerminalWindowController.h"
|
#import "NewTerminalWindowController.h"
|
||||||
#import "Emulator.h"
|
#import "Emulator.h"
|
||||||
|
#import "Defaults.h"
|
||||||
|
|
||||||
@implementation NewTerminalWindowController
|
@implementation NewTerminalWindowController
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
// Clean-up code here.
|
// Clean-up code here.
|
||||||
|
|
||||||
[_terminalTypeButton release];
|
//[_terminalTypeButton release];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -53,6 +54,13 @@
|
||||||
|
|
||||||
if (klass)
|
if (klass)
|
||||||
{
|
{
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
klass, @"Class",
|
||||||
|
nil];
|
||||||
|
|
||||||
|
[nc postNotificationName: kNotificationNewTerminal object: self userInfo: userInfo];
|
||||||
|
|
||||||
// post notificiation...
|
// post notificiation...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
PTSE.mm
11
PTSE.mm
|
@ -33,10 +33,9 @@ enum {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
+(void)load
|
||||||
-(const char *)termName
|
|
||||||
{
|
{
|
||||||
return "proterm-special";
|
[EmulatorManager registerClass: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
+(NSString *)name
|
+(NSString *)name
|
||||||
|
@ -49,6 +48,12 @@ enum {
|
||||||
return @"Proterm Special Emulation";
|
return @"Proterm Special Emulation";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(const char *)termName
|
||||||
|
{
|
||||||
|
return "proterm-special";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void)reset
|
-(void)reset
|
||||||
{
|
{
|
||||||
_state = StateText;
|
_state = StateText;
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
-(void)dealloc
|
-(void)dealloc
|
||||||
{
|
{
|
||||||
[_emulator release];
|
[_emulator release];
|
||||||
[_emulatorView release];
|
//[_emulatorView release];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
int pid;
|
int pid;
|
||||||
int fd;
|
int fd;
|
||||||
struct termios term;
|
struct termios term;
|
||||||
struct winsize ws = { 24, 80, 0, 0 };
|
struct winsize ws = [_emulator defaultSize];
|
||||||
//int flags;
|
//int flags;
|
||||||
|
|
||||||
memset(&term, 0, sizeof(term));
|
memset(&term, 0, sizeof(term));
|
||||||
|
@ -75,7 +75,9 @@
|
||||||
|
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
{
|
{
|
||||||
//error
|
fprintf(stderr, "forkpty failed\n");
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
|
@ -83,7 +85,7 @@
|
||||||
|
|
||||||
std::vector<const char *> environ;
|
std::vector<const char *> environ;
|
||||||
std::string s;
|
std::string s;
|
||||||
;
|
|
||||||
|
|
||||||
s.append("TERM_PROGRAM=2Term");
|
s.append("TERM_PROGRAM=2Term");
|
||||||
s.append(1, (char)0);
|
s.append(1, (char)0);
|
||||||
|
@ -118,6 +120,7 @@
|
||||||
|
|
||||||
// TODO -- option for localhost, telnet, ssh, etc.
|
// TODO -- option for localhost, telnet, ssh, etc.
|
||||||
execle("/usr/bin/login", "login", "-pf", getlogin(), NULL, &environ[0]);
|
execle("/usr/bin/login", "login", "-pf", getlogin(), NULL, &environ[0]);
|
||||||
|
|
||||||
fprintf(stderr, "execle failed\n");
|
fprintf(stderr, "execle failed\n");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
|
@ -130,6 +133,18 @@
|
||||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
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;
|
_child = pid;
|
||||||
|
|
||||||
[_emulatorView setFd: fd];
|
[_emulatorView setFd: fd];
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
@property (assign) IBOutlet NSImageView *imageView;
|
@property (assign) IBOutlet NSImageView *imageView;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-(void)newTerminal: (NSNotification *)notification;
|
-(void)newTerminal: (NSNotification *)notification;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#import "TwoTermAppDelegate.h"
|
#import "TwoTermAppDelegate.h"
|
||||||
|
|
||||||
#import "TermWindowController.h"
|
#import "TermWindowController.h"
|
||||||
|
#import "NewTerminalWindowController.h"
|
||||||
#import "Defaults.h"
|
#import "Defaults.h"
|
||||||
#import "VT52.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
|
-(void)newTerminal: (NSNotification *)notification
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -50,7 +63,7 @@
|
||||||
|
|
||||||
|
|
||||||
Class klass = [userInfo objectForKey: @"Class"];
|
Class klass = [userInfo objectForKey: @"Class"];
|
||||||
if ([klass conformsToProtocol: @protocol(Emulator)])
|
if (![klass conformsToProtocol: @protocol(Emulator)])
|
||||||
klass = [VT52 class];
|
klass = [VT52 class];
|
||||||
|
|
||||||
|
|
||||||
|
|
8
VT05.mm
8
VT05.mm
|
@ -40,15 +40,19 @@ enum {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
+(void)load
|
||||||
|
{
|
||||||
|
[EmulatorManager registerClass: self];
|
||||||
|
}
|
||||||
|
|
||||||
+(NSString *)name
|
+(NSString *)name
|
||||||
{
|
{
|
||||||
return @"vt05";
|
return @"VT05";
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSString *)name
|
-(NSString *)name
|
||||||
{
|
{
|
||||||
return @"vt05";
|
return @"VT05";
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *)termName
|
-(const char *)termName
|
||||||
|
|
5
VT100.mm
5
VT100.mm
|
@ -30,6 +30,11 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
+(void)load
|
||||||
|
{
|
||||||
|
[EmulatorManager registerClass: self];
|
||||||
|
}
|
||||||
|
|
||||||
-(id)init
|
-(id)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
Loading…
Reference in New Issue