From 489c956cf18036144aafc952b93497984344495f Mon Sep 17 00:00:00 2001 From: Da Woon Jung Date: Tue, 19 Jun 2007 00:45:13 +0000 Subject: [PATCH] Multibyte console input --- macosx/CelestiaAppCore.h | 1 + macosx/CelestiaAppCore.mm | 42 ++++- macosx/CelestiaOpenGLView.h | 6 + macosx/CelestiaOpenGLView.m | 53 ++++-- macosx/CelestiaSettings.h | 2 +- macosx/CelestiaSettings.mm | 15 +- .../English.lproj/TextWindow.nib/classes.nib | 12 ++ macosx/English.lproj/TextWindow.nib/info.nib | 16 ++ .../TextWindow.nib/keyedobjects.nib | Bin 0 -> 3371 bytes macosx/MacInputWatcher.h | 25 +++ macosx/MacInputWatcher.mm | 177 ++++++++++++++++++ macosx/TextWindowController.h | 16 ++ macosx/TextWindowController.m | 25 +++ macosx/celestia.xcodeproj/project.pbxproj | 24 +++ 14 files changed, 382 insertions(+), 32 deletions(-) create mode 100644 macosx/English.lproj/TextWindow.nib/classes.nib create mode 100644 macosx/English.lproj/TextWindow.nib/info.nib create mode 100644 macosx/English.lproj/TextWindow.nib/keyedobjects.nib create mode 100644 macosx/MacInputWatcher.h create mode 100644 macosx/MacInputWatcher.mm create mode 100644 macosx/TextWindowController.h create mode 100644 macosx/TextWindowController.m diff --git a/macosx/CelestiaAppCore.h b/macosx/CelestiaAppCore.h index b53323af..ca3ef2f7 100644 --- a/macosx/CelestiaAppCore.h +++ b/macosx/CelestiaAppCore.h @@ -31,6 +31,7 @@ class CelestiaCore; -(BOOL)initRenderer; -(void)start:(NSDate *)date withTimeZone:(NSTimeZone *)timeZone; -(void)charEntered:(char)c withModifiers:(int)modifiers; +-(void)charEntered:(NSString *)string; -(void)keyDown:(int)c; -(void)keyUp:(int)c; -(void)mouseWheel:(float)motion modifiers:(int)modifiers; diff --git a/macosx/CelestiaAppCore.mm b/macosx/CelestiaAppCore.mm index 25bf2873..138ba3d3 100644 --- a/macosx/CelestiaAppCore.mm +++ b/macosx/CelestiaAppCore.mm @@ -23,6 +23,33 @@ #include "qtcapture.h" #import +class MacSettingsWatcher : public CelestiaWatcher +{ +private: + CelestiaSettings *settings; + +public: + MacSettingsWatcher(CelestiaAppCore *_appCore, + CelestiaSettings* _settings) : + CelestiaWatcher(*[_appCore appCore]), settings(_settings) + {}; + + void notifyChange(CelestiaCore *, int flags) + { + if ( 0 != (flags & ( + CelestiaCore::LabelFlagsChanged + | CelestiaCore::RenderFlagsChanged + | CelestiaCore::VerbosityLevelChanged + | CelestiaCore::TimeZoneChanged + | CelestiaCore::AmbientLightChanged + | CelestiaCore::FaintestChanged + )) ) + { + [settings validateItems]; + } + }; +}; + class MacOSXAlerter : public CelestiaCore::Alerter { public: @@ -259,14 +286,14 @@ void ContextMenuCallback(float x,float y, Selection selection) { return cModifiers; } -static NSMutableDictionary* tagDict; +//static NSMutableDictionary* tagDict; +(void)initialize { _sharedCelestiaAppCore = nil; contextMenuCallbackInvocation = nil; appCore = NULL; - tagDict = [[ NSMutableDictionary dictionaryWithCapacity: 100 ] retain]; +// tagDict = [[ NSMutableDictionary dictionaryWithCapacity: 100 ] retain]; } +(CelestiaAppCore *)sharedAppCore @@ -349,6 +376,12 @@ static NSMutableDictionary* tagDict; result = appCore->initSimulation(!confFile.empty() ? &confFile : nil, extrasDirsSetting ? &extrasDirs : nil, &progressNotifier); + if (result) + { + CelestiaSettings *settings = [CelestiaSettings shared]; + new MacSettingsWatcher(self, settings); // adds itself to the appCore + } + return result; } @@ -369,6 +402,11 @@ static NSMutableDictionary* tagDict; appCore->charEntered(c, modifiers); } +-(void)charEntered:(NSString *)string +{ + appCore->charEntered([string UTF8String]); +} + -(void)keyDown:(int)c { appCore->keyDown(c); diff --git a/macosx/CelestiaOpenGLView.h b/macosx/CelestiaOpenGLView.h index 59899a45..433fca5d 100644 --- a/macosx/CelestiaOpenGLView.h +++ b/macosx/CelestiaOpenGLView.h @@ -7,9 +7,15 @@ // #import "CelestiaController.h" + +@class MacInputWatcher; +@class TextWindowController; + @interface CelestiaOpenGLView : NSOpenGLView { IBOutlet CelestiaController *controller; + MacInputWatcher *inputWatcher; + TextWindowController *textWindow; } - (void)setAASamples: (unsigned int)aaSamples; @end diff --git a/macosx/CelestiaOpenGLView.m b/macosx/CelestiaOpenGLView.m index 1a25fee6..bd92463e 100644 --- a/macosx/CelestiaOpenGLView.m +++ b/macosx/CelestiaOpenGLView.m @@ -7,6 +7,8 @@ // #import "CelestiaOpenGLView.h" #import "CelestiaAppCore.h" +#import "MacInputWatcher.h" +#import "TextWindowController.h" #import #import #import @@ -19,8 +21,6 @@ #define CEL_MIDDLE_BUTTON 2 #define CEL_RIGHT_BUTTON 4 -//static CelestiaAppCore* appCore = nil; -//static NSPoint lastLoc = NSMakePoint(0.0, 0.0); @implementation CelestiaOpenGLView @@ -138,7 +138,7 @@ - (BOOL) isFlipped {return YES;} - (void) viewDidMoveToWindow -{ +{ [[self window] setAcceptsMouseMovedEvents: YES]; } @@ -171,9 +171,29 @@ return [self menu]; } +- (void) textEnterModeChanged +{ + CelestiaAppCore *appCore = [CelestiaAppCore sharedAppCore]; + if ([appCore textEnterMode] & 1) + { + if (textWindow == nil) + textWindow = [[TextWindowController alloc] init]; + + [textWindow makeActiveWithDelegate: inputWatcher]; + } + else if (0 == ([appCore textEnterMode] & 1)) + { + [[textWindow window] orderOut: nil]; + [[self window] makeFirstResponder: self]; + } +} + - (void) keyDown: (NSEvent*)theEvent { CelestiaAppCore *appCore = [CelestiaAppCore sharedAppCore]; + if (inputWatcher == nil) + inputWatcher = [[MacInputWatcher alloc] initWithWatched: self]; + NSString *eventChars = [theEvent characters]; if (!eventChars || [eventChars length] == 0) { @@ -184,16 +204,18 @@ unichar key = [eventChars characterAtIndex: 0]; int modifiers = [appCore toCelestiaModifiers: [theEvent modifierFlags] buttons: 0]; - if (key == 127) - key = 8; // delete = backspace + if ( key == NSDeleteCharacter ) + key = NSBackspaceCharacter; // delete = backspace else if ( key == NSDeleteFunctionKey || key == NSClearLineFunctionKey ) - key = 127; // del = delete - + key = NSDeleteCharacter; // del = delete + else if ( key == NSBackTabCharacter ) + key = 127; + if ( (key<128) && ((key < '0') || (key>'9') || !([theEvent modifierFlags] & NSNumericPadKeyMask)) ) [ appCore charEntered: key withModifiers: modifiers]; - [ appCore keyDown: [appCore toCelestiaKey: theEvent] + [ appCore keyDown: [appCore toCelestiaKey: theEvent] withModifiers: modifiers ]; } @@ -202,8 +224,8 @@ CelestiaAppCore *appCore = [CelestiaAppCore sharedAppCore]; // if ( [[theEvent characters] characterAtIndex: 0] >= 128 ) // [ appCore keyUp: [appCore toCelestiaKey: theEvent] ]; - [ appCore keyUp: [appCore toCelestiaKey: theEvent] - withModifiers: [appCore toCelestiaModifiers: [theEvent modifierFlags] buttons: 0] ]; + [ appCore keyUp: [appCore toCelestiaKey: theEvent] + withModifiers: [appCore toCelestiaModifiers: [theEvent modifierFlags] buttons: 0] ]; // NSLog(@"keyUp: %@",theEvent); } @@ -299,19 +321,16 @@ - (BOOL) acceptsFirstResponder: (NSEvent*)theEvent { -// NSLog(@"CelestiaOpenGLView acceptsFirstResponder" ); return YES; } - (BOOL) becomeFirstResponder { -// NSLog(@"CelestiaOpenGLView becomeFirstResponder" ); return YES; } - (BOOL) resignFirstResponder { -// NSLog(@"CelestiaOpenGLView resignFirstResponder" ); return YES; } @@ -352,15 +371,12 @@ NSString *value = nil; NSString *type = [pb availableTypeFromArray: [NSArray arrayWithObjects: NSURLPboardType, NSFilenamesPboardType, NSStringPboardType, nil ]]; -//NSLog(@"read paste"); if ( type != nil ) { CelestiaAppCore *appCore = [CelestiaAppCore sharedAppCore]; -// value = [ pb stringForType: NSURLPboardType ]; - value = [ pb stringForType: NSStringPboardType ]; + value = [ pb stringForType: NSStringPboardType ]; if (value != nil ) { - NSLog(value); if ( [value rangeOfString:@"cel:" options: (NSCaseInsensitiveSearch|NSAnchoredSearch) ].location == 0 ) [appCore goToUrl: value ]; else @@ -369,7 +385,6 @@ else { value = [[NSURL URLWithString: (NSString*) [((NSArray*)[ pb propertyListForType: type ]) objectAtIndex: 0 ]] path]; - NSLog(value); [controller runScript: value ]; return NO; @@ -378,7 +393,6 @@ value = [ pb stringForType: NSFilenamesPboardType ]; if (value != nil ) { - NSLog(value); [controller runScript: value ]; } } @@ -392,7 +406,6 @@ NSPasteboard *pb = [sender draggingPasteboard]; NSString *type = [pb availableTypeFromArray: [NSArray arrayWithObjects: NSStringPboardType, NSFilenamesPboardType, nil ]]; -// NSLog(@"dragentered"); if ( type != nil ) { return NSDragOperationCopy; diff --git a/macosx/CelestiaSettings.h b/macosx/CelestiaSettings.h index 0c4f460d..5ebb7f8f 100644 --- a/macosx/CelestiaSettings.h +++ b/macosx/CelestiaSettings.h @@ -204,7 +204,7 @@ // GUI Methods -- (void) addSurfaceMenu: (id) contextMenu; +- (void) addSurfaceMenu: (NSMenu*) contextMenu; - (void) actionForItem: (id) item; - (BOOL) validateItem: (id) item; - (void) validateItems; diff --git a/macosx/CelestiaSettings.mm b/macosx/CelestiaSettings.mm index 33448ac9..813bf60d 100644 --- a/macosx/CelestiaSettings.mm +++ b/macosx/CelestiaSettings.mm @@ -74,15 +74,12 @@ static NSMutableDictionary* tagMap; [[super init] release]; return sharedInstance; } - - self = [super init]; - - tagMap = [[ NSMutableDictionary dictionaryWithCapacity: 100 ] retain]; - - appCore = (CelestiaCore*) [[CelestiaAppCore sharedAppCore] appCore]; - MacOSXWatcher* theWatcher = new MacOSXWatcher(appCore,self); - appCore->addWatcher(theWatcher); + self = [super init]; + + tagMap = [[ NSMutableDictionary dictionaryWithCapacity: 100 ] retain]; + + appCore = (CelestiaCore*) [[CelestiaAppCore sharedAppCore] appCore]; tagDict = [[NSDictionary dictionaryWithObjectsAndKeys: // TAGDEF(101,@"time") @@ -182,7 +179,7 @@ static NSMutableDictionary* tagMap; return self; } --(void) setControl: (CelestiaController*) _control +-(void) setControl: (id) _control { control = _control; } diff --git a/macosx/English.lproj/TextWindow.nib/classes.nib b/macosx/English.lproj/TextWindow.nib/classes.nib new file mode 100644 index 00000000..4488bbe6 --- /dev/null +++ b/macosx/English.lproj/TextWindow.nib/classes.nib @@ -0,0 +1,12 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + CLASS = TextWindowController; + LANGUAGE = ObjC; + OUTLETS = {textView = NSTextField; }; + SUPERCLASS = NSWindowController; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/macosx/English.lproj/TextWindow.nib/info.nib b/macosx/English.lproj/TextWindow.nib/info.nib new file mode 100644 index 00000000..48eac37a --- /dev/null +++ b/macosx/English.lproj/TextWindow.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 69 48 356 240 0 0 1280 832 + IBFramework Version + 446.1 + IBOpenObjects + + 5 + + IBSystem Version + 8P135 + + diff --git a/macosx/English.lproj/TextWindow.nib/keyedobjects.nib b/macosx/English.lproj/TextWindow.nib/keyedobjects.nib new file mode 100644 index 0000000000000000000000000000000000000000..ed04e97baedfec82a08a3b29c91446c0dffd372a GIT binary patch literal 3371 zcmZWrYjjlA75>hBpDU0{c!rlT1_C66$wLSPF)xDQ5ik=%z(~BAxg;Z#nJ|xp5Thsc zSr;OuihZ~=Cf0XRYt>p?Yt^+{mtqS-5wt$gT5D^UE?w4YmvrBI6N2shn0wB-dw+ZH zZ=b#QZR?6glBq!8C>SKjP@qDC4s%Pcod|VAx}8LGF8w7V@mOPSD&Ezc8*jV938j*) zRz`hrt<&p-D@Oz~!LA=X3da1O?y2p3=pR^UQZVine*5m9s^ zhB%Vw!PU41`|v#s;~_kZNANU$iD&Q}p2zR-d%TQ4;7>S-H}Ge?g}3nz-oyL&5Fg{8 z_za)p-}s7wNz7mq*km>ZhuKt?#b&WQR?JFRDZ2nqvL$ROD`U&p3U(2z+LRkhN270B znHY}=$bf~3$iyT}#uQA&G)zYpW?&{}VK(OATx8=sN+8o@7&Q$hGGJ`fgBC z-JNI3*P`7>1irCp|KtBz4%Q~f!=89z2kF$tW2yCa%x-rQTL{nDl_J5W`d~vmo)RTu zl~^vyMX6XOR*Mxv6Bi3ZTp)@>txyH52|_wTj2EK>r4+aqtm~3cgxqRPZX`560P;GO zh)1JN;s}**$>G{ZuJ*2(i_5Zly4)TbTSq1^uuW$jjPqN>Z+>ap}2j<|07sQ z<}X48C1B**CI^M?+o(eIFsf05a$~$QO&m zVv%zc>rqd*8xX)HXh4u?s&SI3NX$+V@0;s`>+CisN{$8N=|sp8l2{-X3iC~DLK8Nl z8C$Rwm!buiVH@GJ;&Rw%LkM9w*p7B|Ac8Bfqt%*NAM^Qqi%UM?1ynziXgNN}FIP;W#mOUdLO%bPujyE^f zM(uX@%DM+0j5W!U#5^%hj2GvKxgt+klTOp`lU;zAFDA5FQ~LS>1=&l>O8X14`-)3x zT~gfNzmZ7UXvduB5p+?+JK9%gd@r%#BrVUQAD;^6w2{P?n2r*GWoG)_y)C#P<8v`O!?~@8ee7h6A{r4E+E<#Ev1)6~HLWD>!ry4&hb0 zJN~V8(^VUBqG6Y43ZydR_62w2+x;UB-;2XIg4c-UV<;cVu&2^8*H5>%p>&UQMxxJ6 zE=iub*FM&9ygrQAal-41Bjr+=NZ7qZs`n&v`ud6rvX_0UAbsUGadg;sVYF}qu2fNR z8P#o>Tew^LiUPDQE$eT!X7rU5mIjK;ikMluH5)sF6xvM{NoA_LG8E36$cASZKj2L$lO~l# zb4nVsH=ktL0=AIlvjVn=6|%)FATAUu#YLh*REjE5EowxuWmw}Z)zYo;7PHRrtuM#g zL6PIHFFeb7#mJh5HLGSdLyX2K<*csCAIddUt@OE=MITiK^liADz6dX&*%zki_BCT{ z9oxosvpwu~Hq0JlhuBH>G5cJSBuknjl}R;HgVZ90Bu8qOBGL}2Q;JJFrKFUWdZb>d zPwJPhmIkD2r0b*`q|m3p=M9rarEdUc=rg!+H{f24nEz%YzCMxIe<)EXO&PNUoCGxi#{8-vDu#i;=B2k{3?C}-^=&${rpyb zfZxUM<@fUk`NRAme}+HLU*@mySNU=NIzP$Z + +@class _MacInputWatcher; + + +@interface MacInputWatcher : NSObject +{ + _MacInputWatcher *watcher; + id watched; +} +- (id)initWithWatched: (id)aWatched; + +- (BOOL) control: (NSControl *)aControl textShouldBeginEditing: (NSText *)aTextObject; +- (void) controlTextDidChange: (NSNotification *)aNotification; +- (BOOL) control: (NSControl *)aControl textView: (NSTextView *)aTextView doCommandBySelector: (SEL)aCommand; +- (void) stringEntered: (NSString *)aString; +@end diff --git a/macosx/MacInputWatcher.mm b/macosx/MacInputWatcher.mm new file mode 100644 index 00000000..ab880eff --- /dev/null +++ b/macosx/MacInputWatcher.mm @@ -0,0 +1,177 @@ +// +// MacInputWatcher.mm +// celestia +// +// Created by Da Woon Jung on 2007-06-15. +// Copyright 2007 Da Woon Jung. All rights reserved. +// + +#import "MacInputWatcher.h" +#import "CelestiaAppCore.h" +#import "CelestiaController.h" +#import "celestiacore.h" + +@interface MacInputWatcher(Private) +- (id) watched; +@end + + +class _MacInputWatcher : public CelestiaWatcher +{ +private: + MacInputWatcher *watcherWrapper; + +public: + _MacInputWatcher(CelestiaAppCore *_appCore, MacInputWatcher *_watcherWrapper) : + CelestiaWatcher(*[_appCore appCore]), watcherWrapper(_watcherWrapper) + {}; + + void notifyChange(CelestiaCore *, int flags) + { + if ( 0 != (flags & CelestiaCore::TextEnterModeChanged) ) + { + id watched = [watcherWrapper watched]; + if ([watched respondsToSelector: @selector(textEnterModeChanged)]) + [watched performSelector: @selector(textEnterModeChanged)]; + } + }; +}; + + +@implementation MacInputWatcher + +- (id)initWithWatched: (id)aWatched; +{ + self = [super init]; + if (self) + { + watcher = new _MacInputWatcher([CelestiaAppCore sharedAppCore], self); + watched = aWatched; + } + return self; +} + +- (void)dealloc +{ + if (watcher) delete watcher; + [super dealloc]; +} + +- (id) watched +{ + return watched; +} + + +- (BOOL) control: (NSControl *)aControl textShouldBeginEditing: (NSText *)aTextObject +{ + BOOL hasMarkedText = NO; + if ([aTextObject respondsToSelector: @selector(hasMarkedText)]) + { + hasMarkedText = [aTextObject performSelector: @selector(hasMarkedText)]; + } + + [[aTextObject window] makeKeyAndOrderFront: nil]; + + if (hasMarkedText) + { + [[aTextObject window] setAlphaValue: 1.0f]; + } + else + { + [[aTextObject window] setAlphaValue: 0.0f]; + } + return YES; +} + +-(void) stringEntered: (NSString *)aString +{ + [[CelestiaAppCore sharedAppCore] charEntered: aString]; +} + +- (void) controlTextDidChange: (NSNotification *)aNotification +{ + id fieldEditor = [[aNotification userInfo] objectForKey: @"NSFieldEditor"]; + NSString *changedText = [fieldEditor string]; + [[[aNotification object] window] setAlphaValue: 0.0f]; + [self stringEntered: changedText]; + if ([fieldEditor shouldChangeTextInRange: NSMakeRange(NSNotFound, 0) + replacementString: nil]) + { + [fieldEditor setString: @""]; + // Make sure textShouldBeginEditing gets reinvoked + [[[aNotification object] window] makeFirstResponder: [aNotification object]]; + } +} + +- (BOOL) control: (NSControl *)aControl textView: (NSTextView *)aTextView doCommandBySelector: (SEL)aCommand +{ + CelestiaAppCore *appCore = [CelestiaAppCore sharedAppCore]; + unichar key = 0; + int modifiers = 0; + + if (@selector(insertNewline:) == aCommand) + key = NSNewlineCharacter; + else if (@selector(deleteBackward:) == aCommand) + key = NSBackspaceCharacter; + else if (@selector(insertTab:) == aCommand) + key = NSTabCharacter; + else if (@selector(insertBacktab:) == aCommand) + key = 127; + else if (@selector(cancelOperation:) == aCommand) + key = '\033'; + else + { + // Allow zoom/pan etc during console input + if (@selector(scrollToBeginningOfDocument:) == aCommand) + key = CelestiaCore::Key_Home; + else if (@selector(scrollToEndOfDocument:) == aCommand) + key = CelestiaCore::Key_End; + else if (@selector(scrollPageUp:) == aCommand) + key = CelestiaCore::Key_PageUp; + else if (@selector(scrollPageDown:) == aCommand) + key = CelestiaCore::Key_PageDown; + else if (@selector(moveLeft:) == aCommand) + key = CelestiaCore::Key_Left; + else if (@selector(moveLeftAndModifySelection:) == aCommand) + { key = CelestiaCore::Key_Left; + modifiers = [appCore toCelestiaModifiers: NSShiftKeyMask buttons: 0]; } + else if (@selector(moveRight:) == aCommand) + key = CelestiaCore::Key_Right; + else if (@selector(moveRightAndModifySelection:) == aCommand) + { key = CelestiaCore::Key_Right; + modifiers = [appCore toCelestiaModifiers: NSShiftKeyMask buttons: 0]; } + else if (@selector(moveUp:) == aCommand) + key = CelestiaCore::Key_Up; + else if (@selector(moveUpAndModifySelection:) == aCommand) + { key = CelestiaCore::Key_Up; + modifiers = [appCore toCelestiaModifiers: NSShiftKeyMask buttons: 0]; } + else if (@selector(moveDown:) == aCommand) + key = CelestiaCore::Key_Down; + else if (@selector(moveDownAndModifySelection:) == aCommand) + { key = CelestiaCore::Key_Down; + modifiers = [appCore toCelestiaModifiers: NSShiftKeyMask buttons: 0]; } + else + { + NSEvent *currEvent = [[aTextView window] currentEvent]; + if (currEvent && [currEvent type] == NSKeyDown) + { + NSString *eventChars = [currEvent charactersIgnoringModifiers]; + if (eventChars && [eventChars length]) + { + key = [eventChars characterAtIndex: 0]; + modifiers = [appCore toCelestiaModifiers: [currEvent modifierFlags] buttons: 0]; + } + } + else + return NO; + } + + [appCore keyDown: key withModifiers: modifiers]; + return YES; + } + + [appCore charEntered: key withModifiers: modifiers]; + return YES; +} +@end diff --git a/macosx/TextWindowController.h b/macosx/TextWindowController.h new file mode 100644 index 00000000..578f35e9 --- /dev/null +++ b/macosx/TextWindowController.h @@ -0,0 +1,16 @@ +// +// TextWindowController.h +// celestia +// +// Created by Da Woon Jung on 2006-10-01. +// Copyright 2006 Da Woon Jung. All rights reserved. +// + +#import + +@interface TextWindowController : NSWindowController +{ + IBOutlet NSTextField *textView; +} +- (void)makeActiveWithDelegate: (id)aDelegate; +@end diff --git a/macosx/TextWindowController.m b/macosx/TextWindowController.m new file mode 100644 index 00000000..362bac90 --- /dev/null +++ b/macosx/TextWindowController.m @@ -0,0 +1,25 @@ +// +// TextWindowController.h +// celestia +// +// Created by Da Woon Jung on 2006-10-01. +// Copyright 2006 Da Woon Jung. All rights reserved. +// + +#import "TextWindowController.h" + +@implementation TextWindowController +- (id)init +{ + self = [super initWithWindowNibName: @"TextWindow"]; + return self; +} + +- (void)makeActiveWithDelegate: (id)aDelegate +{ + [[self window] makeKeyAndOrderFront: nil]; + [[self window] setAlphaValue: 0.0f]; + [[self window] makeFirstResponder: textView]; + [textView setDelegate: aDelegate]; +} +@end diff --git a/macosx/celestia.xcodeproj/project.pbxproj b/macosx/celestia.xcodeproj/project.pbxproj index 3250c424..0fbf0c6b 100644 --- a/macosx/celestia.xcodeproj/project.pbxproj +++ b/macosx/celestia.xcodeproj/project.pbxproj @@ -203,6 +203,7 @@ E59AD8160AAB361400E2841D /* hubble.cmod in Copy Models */ = {isa = PBXBuildFile; fileRef = E59AD8150AAB361400E2841D /* hubble.cmod */; }; E5A994750B1482FE009F40FA /* scriptrotation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E5A994710B1482FE009F40FA /* scriptrotation.cpp */; }; E5A994770B1482FE009F40FA /* scriptobject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E5A994730B1482FE009F40FA /* scriptobject.cpp */; }; + E5B48EBA0C22065E00C6FBD7 /* MacInputWatcher.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5B48EB80C22065E00C6FBD7 /* MacInputWatcher.mm */; }; E5B615070777307F001BB2BF /* celestia.icns in Resources */ = {isa = PBXBuildFile; fileRef = E5B615060777307F001BB2BF /* celestia.icns */; }; E5C9ADE10848FFEF0071B1EE /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5040B0602A47B91014901DC /* Carbon.framework */; }; E5C9B478084909E40071B1EE /* README for Mac OS X.rtf in Copy App */ = {isa = PBXBuildFile; fileRef = E5C9B46B084909B90071B1EE /* README for Mac OS X.rtf */; }; @@ -266,6 +267,8 @@ E5D969B20ABCC7CC00F43225 /* SBc.png in Copy Models */ = {isa = PBXBuildFile; fileRef = E5D969AA0ABCC76C00F43225 /* SBc.png */; }; E5D969B30ABCC7CC00F43225 /* Sc.png in Copy Models */ = {isa = PBXBuildFile; fileRef = E5D969AB0ABCC76C00F43225 /* Sc.png */; }; E5E198B00C1D9C2E0094D8BB /* scripts in Copy Misc */ = {isa = PBXBuildFile; fileRef = E5E198960C1D9BB90094D8BB /* scripts */; }; + E5E2BDD20C24F7B6000D6E83 /* TextWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = E5E2BDD00C24F7B6000D6E83 /* TextWindow.nib */; }; + E5E2BDD70C24F7E6000D6E83 /* TextWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = E5E2BDD50C24F7E6000D6E83 /* TextWindowController.m */; }; E5E365AD095C11B500B14224 /* SplashScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = E5E365AB095C11B500B14224 /* SplashScreen.m */; }; E5E365AF095C123E00B14224 /* splash.png in Resources */ = {isa = PBXBuildFile; fileRef = E5E365AE095C123E00B14224 /* splash.png */; }; E5F8C9690795232900D1DAF2 /* libpng.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E5D471260778E33C007731C3 /* libpng.dylib */; }; @@ -603,6 +606,8 @@ E5A994710B1482FE009F40FA /* scriptrotation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = scriptrotation.cpp; path = ../src/celengine/scriptrotation.cpp; sourceTree = SOURCE_ROOT; }; E5A994720B1482FE009F40FA /* scriptobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scriptobject.h; path = ../src/celengine/scriptobject.h; sourceTree = SOURCE_ROOT; }; E5A994730B1482FE009F40FA /* scriptobject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = scriptobject.cpp; path = ../src/celengine/scriptobject.cpp; sourceTree = SOURCE_ROOT; }; + E5B48EB70C22065E00C6FBD7 /* MacInputWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacInputWatcher.h; sourceTree = ""; }; + E5B48EB80C22065E00C6FBD7 /* MacInputWatcher.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MacInputWatcher.mm; sourceTree = ""; }; E5B615060777307F001BB2BF /* celestia.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = celestia.icns; sourceTree = ""; }; E5B61B2C077737A6001BB2BF /* lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua.h; sourceTree = ""; }; E5B61B2D077737A6001BB2BF /* lualib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lualib.h; sourceTree = ""; }; @@ -677,6 +682,9 @@ E5D969AA0ABCC76C00F43225 /* SBc.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SBc.png; sourceTree = ""; }; E5D969AB0ABCC76C00F43225 /* Sc.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Sc.png; sourceTree = ""; }; E5E198960C1D9BB90094D8BB /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = scripts; path = ../scripts; sourceTree = SOURCE_ROOT; }; + E5E2BDD10C24F7B6000D6E83 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/TextWindow.nib; sourceTree = ""; }; + E5E2BDD40C24F7E6000D6E83 /* TextWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextWindowController.h; sourceTree = ""; }; + E5E2BDD50C24F7E6000D6E83 /* TextWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextWindowController.m; sourceTree = ""; }; E5E365AA095C11B500B14224 /* SplashScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplashScreen.h; sourceTree = ""; }; E5E365AB095C11B500B14224 /* SplashScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SplashScreen.m; sourceTree = ""; }; E5E365AE095C123E00B14224 /* splash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = splash.png; path = ../splash.png; sourceTree = ""; }; @@ -977,6 +985,7 @@ F5EDC6BA0456666601000002 /* SetTimeWindowController.m */, E5E365AB095C11B500B14224 /* SplashScreen.m */, E5D956DF096651DF00CB02B2 /* SplashWindowController.m */, + E5E2BDD50C24F7E6000D6E83 /* TextWindowController.m */, F5040B0E02A484DA014901DC /* CelestiaController.h */, F5231C7202C2997601000006 /* CelestiaFavorites.h */, F5274ED202AE88260100020A /* CelestiaOpenGLView.h */, @@ -992,6 +1001,7 @@ F5EDC6B90456666601000002 /* SetTimeWindowController.h */, E5E365AA095C11B500B14224 /* SplashScreen.h */, E5D956DE096651DF00CB02B2 /* SplashWindowController.h */, + E5E2BDD40C24F7E6000D6E83 /* TextWindowController.h */, F578B79D02B3E2AD0100020A /* Cocoa Extensions */, F55A246702B2D4FF0100020A /* Wrappers */, E5CC203109AA832000CFFF2C /* POConverter */, @@ -1077,6 +1087,7 @@ E54343100783C3F200053094 /* BrowserWindow.nib */, E50CCA530C065F0100E9C76A /* EclipseFinder.nib */, E5D7660E0982B1860099DBBD /* HelpWindow.nib */, + E5E2BDD00C24F7B6000D6E83 /* TextWindow.nib */, 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, E5CC204509AA843300CFFF2C /* Localizable.strings */, ); @@ -1509,6 +1520,8 @@ F55A246702B2D4FF0100020A /* Wrappers */ = { isa = PBXGroup; children = ( + E5B48EB80C22065E00C6FBD7 /* MacInputWatcher.mm */, + E5B48EB70C22065E00C6FBD7 /* MacInputWatcher.h */, F55F041202B1105D0100020A /* Astro.mm */, F51FB0E102AF0C820100020A /* CelestiaAppCore.mm */, F55A246202B2AE6E0100020A /* CelestiaBody.mm */, @@ -1695,6 +1708,7 @@ E5D766140982B1860099DBBD /* HelpWindow.nib in Resources */, E5CC204709AA843300CFFF2C /* Localizable.strings in Resources */, E50CCA590C065F0100E9C76A /* EclipseFinder.nib in Resources */, + E5E2BDD20C24F7B6000D6E83 /* TextWindow.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1875,6 +1889,8 @@ E50CCA6A0C06632A00E9C76A /* EclipseFinderController.mm in Sources */, E53E619B0C0CA105003CD767 /* scriptmenu.cpp in Sources */, E53E61AD0C0CA444003CD767 /* ScriptsController.mm in Sources */, + E5B48EBA0C22065E00C6FBD7 /* MacInputWatcher.mm in Sources */, + E5E2BDD70C24F7E6000D6E83 /* TextWindowController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1972,6 +1988,14 @@ name = HelpWindow.nib; sourceTree = ""; }; + E5E2BDD00C24F7B6000D6E83 /* TextWindow.nib */ = { + isa = PBXVariantGroup; + children = ( + E5E2BDD10C24F7B6000D6E83 /* English */, + ); + name = TextWindow.nib; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */