Tomotaka SUWA
t-suw****@users*****
2006年 2月 19日 (日) 13:50:55 JST
Index: AquaSKK/AquaSKKServer.h diff -u AquaSKK/AquaSKKServer.h:1.1.2.1 AquaSKK/AquaSKKServer.h:1.1.2.2 --- AquaSKK/AquaSKKServer.h:1.1.2.1 Sat Feb 18 02:20:38 2006 +++ AquaSKK/AquaSKKServer.h Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* - $Id: AquaSKKServer.h,v 1.1.2.1 2006/02/17 17:20:38 t-suwa Exp $ + $Id: AquaSKKServer.h,v 1.1.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -26,6 +26,7 @@ @interface AquaSKKServer: NSObject { } ++ (void)initialize; - (void)applicationDidFinishLaunching:(NSNotification*)aNotification; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender; @end Index: AquaSKK/AquaSKKServer.mm diff -u AquaSKK/AquaSKKServer.mm:1.1.2.1 AquaSKK/AquaSKKServer.mm:1.1.2.2 --- AquaSKK/AquaSKKServer.mm:1.1.2.1 Sat Feb 18 02:20:38 2006 +++ AquaSKK/AquaSKKServer.mm Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: AquaSKKServer.mm,v 1.1.2.1 2006/02/17 17:20:38 t-suwa Exp $ + $Id: AquaSKKServer.mm,v 1.1.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -22,18 +22,37 @@ */ #include <AppKit/AppKit.h> +#include "BIMClientServer.h" #include "AquaSKKServer.h" -#include "PreferencesController.h" +#include "PreferenceKeys.h" #include "DictionarySet.h" -#include "BIMClientServer.h" #include "ServerMessageReceiver.h" #include "skkserv.h" @implementation AquaSKKServer +// ú» ++ (void)initialize { + NSString* defaultsPlist; + NSDictionary* userDefaults; + + // UserDefaults.plist Ìàeð[h·é + defaultsPlist = [[NSBundle mainBundle] pathForResource:@"UserDefaults" ofType:@"plist"]; + userDefaults =[NSDictionary dictionaryWithContentsOfFile:defaultsPlist]; + + // úÝèƵÄo^ + [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaults]; + + // [U[ftHgRg[[Éào^ + [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:userDefaults]; + + // ~/Library/AquaSKK/ ð쬷é + [[NSFileManager defaultManager] + createDirectoryAtPath:[@"~/Library/AquaSKK" stringByExpandingTildeInPath] attributes:nil]; +} + - (void)applicationDidFinishLaunching:(NSNotification*)aNotification { - // vt@Xðæ¾ - PreferencesController* pref = [PreferencesController sharedController]; + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; // «T[o[ðN®·é DictionarySet::theInstance().initialize(); @@ -42,8 +61,9 @@ ServerMessageReceiver::start(kAquaSKKServerRunLoopMode); // skkserv G~ [VÌN® - if([pref isSkkservEnabled]) { - skkserv::theInstance().start([pref skkservPort], [pref isSkkservLocalOnly]); + if([defaults boolForKey:KEY_skkserv_enabled]) { + skkserv::theInstance().start([defaults integerForKey:KEY_skkserv_port], + [defaults boolForKey:KEY_skkserv_localonly]); } } Index: AquaSKK/BIM.cpp diff -u AquaSKK/BIM.cpp:1.11.2.2 AquaSKK/BIM.cpp:1.11.2.3 --- AquaSKK/BIM.cpp:1.11.2.2 Sun Jan 8 16:15:30 2006 +++ AquaSKK/BIM.cpp Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* - $Id: BIM.cpp,v 1.11.2.2 2006/01/08 07:15:30 t-suwa Exp $ + $Id: BIM.cpp,v 1.11.2.3 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -164,9 +164,6 @@ refNum = -1; gPencilMenu = NULL; - - // IªN®µÄ¢È©Á½çN®·éB - ServerConnectionFactory::theInstance().prepareServer(); CFBundleRef bundleRef; IBNibRef nibRef; @@ -195,6 +192,9 @@ // bZ[WóM@\ðú» ClientMessageReceiver::start(kAquaSKKClientRunLoopMode); + // AquaSKKServer ÌN® + ServerConnectionFactory::theInstance().prepareServer(); + Finish: return result; Index: AquaSKK/BIM.r diff -u AquaSKK/BIM.r:1.3.4.2 AquaSKK/BIM.r:1.3.4.3 --- AquaSKK/BIM.r:1.3.4.2 Mon Jan 9 11:11:05 2006 +++ AquaSKK/BIM.r Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* - $Id: BIM.r,v 1.3.4.2 2006/01/09 02:11:05 t-suwa Exp $ + $Id: BIM.r,v 1.3.4.3 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -60,11 +60,11 @@ #define kAquaSKKBaseResouceID 16384 #define kAquaSKKComponentFlags 0x8000 + smJapanese * 0x100 + langJapanese -// "org.ccm-software.AquaSKKInputMethod" Ì pascal ¶ñ +// "jp.sourceforge.AquaSKKInputMethod" Ì pascal ¶ñ data 'cbnm' (0) { - $"236f 7267 2e63 636d 2d73 6f66 7477 6172" - $"652e 4171 7561 534b 4b49 6e70 7574 4d65" - $"7468 6f64" + $"216a 702e 736f 7572 6365 666f 7267 652e" + $"4171 7561 534b 4b49 6e70 7574 4d65 7468" + $"6f64" }; resource 'thng' (kAquaSKKBaseResouceID) { Index: AquaSKK/BIMClientServer.h diff -u AquaSKK/BIMClientServer.h:1.3.2.1 AquaSKK/BIMClientServer.h:1.3.2.2 --- AquaSKK/BIMClientServer.h:1.3.2.1 Sat Jan 7 16:22:28 2006 +++ AquaSKK/BIMClientServer.h Sun Feb 19 13:50:54 2006 @@ -1,10 +1,10 @@ /* - $Id: BIMClientServer.h,v 1.3.2.1 2006/01/07 07:22:28 t-suwa Exp $ + $Id: BIMClientServer.h,v 1.3.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. Copyright (C) 2002 phonohawk - Copyright (C) 2005 Tomotaka SUWA <t.suw****@mac*****> + Copyright (C) 2005-2006 Tomotaka SUWA <t.suw****@mac*****> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,14 +24,14 @@ #pragma once // IMÌoh¼ -#define kIMBundleIdentifier "org.ccm-software.AquaSKKInputMethod" +#define kIMBundleIdentifier "jp.sourceforge.AquaSKKInputMethod" // IÌAv¼ #define kBasicServerName "\pAquaSKKServer.app" #define kCSTR_SKKServerName "AquaSKKServer.app" // IÌ|[g¼ -#define kBasicServerPortName "org.ccm-software.AquaSKKServer" +#define kBasicServerPortName "jp.sourceforge.AquaSKKServer" // T[o[Ì RunLoopMode #define kAquaSKKServerRunLoopMode CFSTR("AquaSKK::ServerRunLoopMode") @@ -102,11 +102,14 @@ kSKKFetchCompletions = 400, // â®ÌóâðõBNGÌ`®ÍUniCharÌzñÅA // á¦ÎuÙvBX|XÍuÙ© Ù©ñvÌæ¤É¼pXy[XÅæØç꽩oµêÌXgB -}; -enum { kBasicMessageIsSkkEggLikeNewline = 500, // kBasicMessageIsNumericKeypad_HalfWidth = 501, kBasicMessageIsAsciiModeStartup = 502, kBasicMessageKbdLayoutId = 503, }; + +// T[o[©çNCAgÖÌÊmbZ[W +enum { + kSKKClientConfigurationModified = 100, +}; Index: AquaSKK/CandidatesFrame.h diff -u AquaSKK/CandidatesFrame.h:1.2.2.1 AquaSKK/CandidatesFrame.h:1.2.2.2 --- AquaSKK/CandidatesFrame.h:1.2.2.1 Sat Jan 14 20:01:58 2006 +++ AquaSKK/CandidatesFrame.h Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ -/* - $Id: CandidatesFrame.h,v 1.2.2.1 2006/01/14 11:01:58 t-suwa Exp $ +/* -*- objc -*- + $Id: CandidatesFrame.h,v 1.2.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -23,29 +23,51 @@ #pragma once -// -// Ï·óât[C^tF[X -// - @ interface CandidatesFrame : NSObject { - NSImage* view_; // t[ - NSString* caption_; // [cè nnn] - NSMutableArray* candidates_; // óâ - NSDictionary* attributes_; // tHg®« +// t[®« + @ interface FrameAttribute : NSObject { NSString* labels_; // ANZX¶ + NSString* entry_; // PêÌóâ + NSString* caption_; // [cè nnn] + NSDictionary* attributes_; // tHg®« NSSize viewSize_; // r [é` NSSize marginSize_; // }[W - NSSize itemAreaSize_; // Ï·óâÌGA NSSize itemSize_; // PêÏ·óâTCY + NSSize itemAreaSize_; // Ï·óâÌGA float spaceWidth_; // Ô +} + ++ (id)sharedFrameAttribute; + +- (void)refresh; + +- (NSString*)labels; +- (NSString*)caption; +- (NSDictionary*)fontAttributes; +- (NSSize)viewSize; +- (NSSize)marginSize; +- (NSSize)itemSize; +- (NSSize)itemAreaSize; +- (float)spaceWidth; +- (NSRect)drawArea; +- (NSRect)viewRect; + + @ end + +// Ï·óât[C^tF[X + @ interface CandidatesFrame : NSObject { + NSImage* view_; // t[ + NSMutableArray* candidates_; // óâ + float restWidth_; // cè unsigned remainCandidates_; // cèóâ bool useLineBreak_; // Ȫ·é©H } + - (bool)addCandidate:(NSString*)str; - (void)setRemain:(int)remains; - (unsigned)count; - (void)drawRect:(NSRect)rect; -- (NSSize)size; + @end Index: AquaSKK/CandidatesFrame.m diff -u AquaSKK/CandidatesFrame.m:1.4.2.1 AquaSKK/CandidatesFrame.m:1.4.2.2 --- AquaSKK/CandidatesFrame.m:1.4.2.1 Sat Jan 14 20:01:58 2006 +++ AquaSKK/CandidatesFrame.m Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* - $Id: CandidatesFrame.m,v 1.4.2.1 2006/01/14 11:01:58 t-suwa Exp $ + $Id: CandidatesFrame.m,v 1.4.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -21,70 +21,144 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#import <AppKit/AppKit.h> -#import "CandidatesFrame.h" +#include <AppKit/AppKit.h> +#include "CandidatesFrame.h" +#include "PreferenceKeys.h" + + @ implementation FrameAttribute - @ implementation CandidatesFrame - (id)init { if((self = [super init])) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSFont *font = [NSFont fontWithName:[defaults objectForKey:@"dic.FontName.Window"] - size:[[defaults objectForKey:@"dic.FontSize.Window"] floatValue]]; + // x labels_ = @"ASDFJKL"; - attributes_ = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; - candidates_ = [[NSMutableArray alloc] init]; - // ÚÌTCYðæ¾ + // PêÌGg char* data = " A ¿"; NSData* sjis = [[NSData alloc] initWithBytes:data length:strlen(data)]; - NSString* str = [[NSString alloc] initWithData:sjis encoding:NSShiftJISStringEncoding]; + entry_ = [[NSString alloc] initWithData:sjis encoding:NSShiftJISStringEncoding]; [sjis release]; - NSMutableAttributedString* tmp = [[NSMutableAttributedString alloc] initWithString:str attributes:attributes_]; - itemSize_ = [tmp size]; - [tmp release]; - // [cè n] ÌTCYðæ¾ + // [cè n] data = "cè"; sjis = [[NSData alloc] initWithBytes:data length:strlen(data)]; caption_ = [[NSString alloc] initWithData:sjis encoding:NSShiftJISStringEncoding]; [sjis release]; - tmp = [[NSMutableAttributedString alloc] - initWithString:[NSString stringWithFormat:@"[%@ 000]", caption_] attributes:attributes_]; - NSSize remainSize = [tmp size]; - [tmp release]; - // ]ðßé marginSize_ = NSMakeSize(8, 8); spaceWidth_ = marginSize_.width * 2; - // Ï·óâð`æ·éGAÌTCY - itemAreaSize_ = NSMakeSize([labels_ length] * (itemSize_.width + spaceWidth_), itemSize_.height); + [self refresh]; + } + + return self; +} + ++ (id)sharedFrameAttribute { + static FrameAttribute* obj = NULL; + + if(!obj) { + obj = [[FrameAttribute alloc] init]; + } + + return obj; +} + +- (void)refresh { + // [U[ftHgðæ¾µ¼· + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + NSFont* font = [NSFont fontWithName:[defaults stringForKey:KEY_candidates_font_name] + size:[defaults floatForKey:KEY_candidates_font_size]]; + attributes_ = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; + + // ÚÌTCYðæ¾ + NSMutableAttributedString* tmp = [[NSMutableAttributedString alloc] initWithString:entry_ attributes:attributes_]; + itemSize_ = [tmp size]; + [tmp release]; + + // [cè n] ÌTCYðæ¾ + NSString* formatedStr = [NSString stringWithFormat:@"[%@ 000]", caption_]; + tmp = [[NSMutableAttributedString alloc] initWithString:formatedStr attributes:attributes_]; + NSSize remainSize = [tmp size]; + [tmp release]; + + // Ï·óâð`æ·éGAÌTCY + itemAreaSize_ = NSMakeSize([labels_ length] * (itemSize_.width + spaceWidth_), itemSize_.height); + + // r [SÌÌTCY + viewSize_ = NSMakeSize(marginSize_.width * 2 + itemAreaSize_.width + remainSize.width, + marginSize_.height * 2 + itemAreaSize_.height); +} + +- (NSString*)labels { + return labels_; +} + +- (NSString*)caption { + return caption_; +} + +- (NSDictionary*)fontAttributes { + return attributes_; +} - // r [SÌÌTCY - viewSize_ = NSMakeSize(marginSize_.width * 2 + itemAreaSize_.width + remainSize.width, - marginSize_.height * 2 + itemAreaSize_.height); +- (NSSize)viewSize { + return viewSize_; +} +- (NSSize)marginSize { + return marginSize_; +} + +- (NSSize)itemSize { + return itemSize_; +} + +- (NSSize)itemAreaSize { + return itemAreaSize_; +} + +- (float)spaceWidth { + return spaceWidth_; +} + +- (NSRect)drawArea { + return NSMakeRect(marginSize_.width, marginSize_.height, itemAreaSize_.width - spaceWidth_, itemAreaSize_.height); +} + +- (NSRect)viewRect { + return NSMakeRect(0, 0, viewSize_.width, viewSize_.height); +} + + @ end + + @ implementation CandidatesFrame +- (id)init { + if((self = [super init])) { + FrameAttribute* attr = [FrameAttribute sharedFrameAttribute]; + candidates_ = [[NSMutableArray alloc] init]; useLineBreak_ = false; - remainCandidates_ = 0; - restWidth_ = itemAreaSize_.width - marginSize_.width; + restWidth_ = [attr itemAreaSize].width - [attr marginSize].width; } return self; } - (bool)addCandidate:(NSString*)str { + FrameAttribute* attr = [FrameAttribute sharedFrameAttribute]; + // ±êÈãͳH - if(restWidth_ < 1 || [self count] == [labels_ length]) { + if(restWidth_ < 1 || [self count] == [[attr labels] length]) { return false; } // Ï·óâ̶ñ𶬷é - NSString* tmpstr - = [NSString stringWithFormat:@" %@ %@", [labels_ substringWithRange:NSMakeRange([self count], 1)], str]; + NSString* tmpstr = [NSString stringWithFormat:@" %@ %@", + [[attr labels] substringWithRange:NSMakeRange([self count], 1)], str]; // ®«t«¶ñðìé - NSMutableAttributedString* entry = [[NSMutableAttributedString alloc] initWithString:tmpstr attributes:attributes_]; + NSMutableAttributedString* entry = [[NSMutableAttributedString alloc] initWithString:tmpstr + attributes:[attr fontAttributes]]; // x̶FÆwiFðÝè [entry addAttribute:NSBackgroundColorAttributeName @@ -92,22 +166,10 @@ [entry addAttribute:NSForegroundColorAttributeName value:[NSColor selectedMenuItemTextColor] range:NSMakeRange(0, 3)]; - // xÌhbvVhEðÝè -#if 0 - NSShadow* shadow = [[NSShadow alloc] init]; - //[shadow setShadowColor:[[NSColor shadowColor] shadowWithLevel:1.0]]; - [shadow setShadowColor:[[NSColor shadowColor] colorWithAlphaComponent:1.0]]; - [shadow setShadowBlurRadius:2]; - [shadow setShadowOffset:NSMakeSize(0, -1)]; - [entry addAttribute:NSShadowAttributeName - value:shadow range:NSMakeRange(0, 3)]; - [shadow release]; -#endif - // `æTCYðæ¾ NSSize box = [entry size]; - if(box.width < itemSize_.width) { - box.width = itemSize_.width; + if(box.width < [attr itemSize].width) { + box.width = [attr itemSize].width; } // `浫êÈ¢H @@ -131,7 +193,7 @@ // zñɶñðÇÁ·é [candidates_ addObject:entry]; [entry release]; - restWidth_ -= (box.width + spaceWidth_); + restWidth_ -= (box.width + [attr spaceWidth]); return true; } [entry release]; @@ -148,54 +210,48 @@ } - (void)drawRect:(NSRect)rect { + FrameAttribute* attr = [FrameAttribute sharedFrameAttribute]; + // ú»³êĢȢH if(!view_) { - view_ = [[NSImage alloc] initWithSize:viewSize_]; + view_ = [[NSImage alloc] initWithSize:[attr viewSize]]; [view_ lockFocus]; // Ȫ\¦©H if(useLineBreak_) { NSAttributedString* tmp = [candidates_ objectAtIndex:0]; - [tmp drawInRect:NSMakeRect(marginSize_.width, marginSize_.height, - itemAreaSize_.width - spaceWidth_, itemAreaSize_.height)]; + [tmp drawInRect:[attr drawArea]]; } else { - NSPoint pt = NSMakePoint(marginSize_.width, marginSize_.height); + NSPoint pt = NSMakePoint([attr marginSize].width, [attr marginSize].height); unsigned i; for(i = 0; i < [self count]; ++ i) { NSAttributedString* tmp = [candidates_ objectAtIndex:i]; [tmp drawAtPoint:pt]; - if([tmp size].width < itemSize_.width) { - pt.x += (itemSize_.width + spaceWidth_); + if([tmp size].width < [attr itemSize].width) { + pt.x += ([attr itemSize].width + [attr spaceWidth]); } else { - pt.x += ([tmp size].width + spaceWidth_); + pt.x += ([tmp size].width + [attr spaceWidth]); } } } // [cè n] ð`æ - NSAttributedString* remain - = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"[%@ %d]", - caption_, remainCandidates_] - attributes:attributes_]; - [remain drawAtPoint:NSMakePoint(marginSize_.width + itemAreaSize_.width, marginSize_.height)]; + NSAttributedString* remain = [[NSAttributedString alloc] + initWithString:[NSString stringWithFormat:@"[%@ %d]", + [attr caption], remainCandidates_] + attributes:[attr fontAttributes]]; + [remain drawAtPoint:NSMakePoint([attr marginSize].width + [attr itemAreaSize].width, [attr marginSize].height)]; [remain release]; [view_ unlockFocus]; } // r [Ì`æ - [view_ drawInRect:NSMakeRect(0, 0, viewSize_.width, viewSize_.height) - fromRect:NSMakeRect(0, 0, viewSize_.width, viewSize_.height) - operation:NSCompositeSourceOver fraction:1.0]; -} - -- (NSSize)size { - return viewSize_; + [view_ drawInRect:[attr viewRect] fromRect:[attr viewRect] operation:NSCompositeSourceOver fraction:1.0]; } - (void)dealloc { [view_ release]; - [caption_ release]; [candidates_ release]; [super dealloc]; } Index: AquaSKK/CandidatesView.h diff -u AquaSKK/CandidatesView.h:1.2 AquaSKK/CandidatesView.h:1.2.2.1 --- AquaSKK/CandidatesView.h:1.2 Sat Oct 8 00:08:36 2005 +++ AquaSKK/CandidatesView.h Sun Feb 19 13:50:54 2006 @@ -1,31 +1,32 @@ -/* - $Id: CandidatesView.h,v 1.2 2005/10/07 15:08:36 t-suwa Exp $ - --------- - - MacOS X implementation of the SKK input method. - Copyright (C) 2002 phonohawk - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* -*- objc -*- + $Id: CandidatesView.h,v 1.2.2.1 2006/02/19 04:50:54 t-suwa Exp $ + + MacOS X implementation of the SKK input method. + + Copyright (C) 2002 phonohawk + Copyright (C) 2006 Tomotaka SUWA <t.suw****@mac*****> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once @interface CandidatesView : NSView { - NSMutableArray* frames; - unsigned current_frame; + NSMutableArray* frames; + unsigned current_frame; } - (id)initWithCandidates:(NSArray*)cands; @@ -34,4 +35,5 @@ - (unsigned)getCandidatesPerFrame; - (unsigned)getNumOfFrames; - (void)setCurrentFrame:(unsigned)frame; + @end Index: AquaSKK/CandidatesView.mm diff -u AquaSKK/CandidatesView.mm:1.2 AquaSKK/CandidatesView.mm:1.2.2.1 --- AquaSKK/CandidatesView.mm:1.2 Sat Oct 8 00:08:36 2005 +++ AquaSKK/CandidatesView.mm Sun Feb 19 13:50:54 2006 @@ -1,23 +1,24 @@ -/* -*- objc -*- - $Id: CandidatesView.mm,v 1.2 2005/10/07 15:08:36 t-suwa Exp $ - --------- - - MacOS X implementation of the SKK input method. - Copyright (C) 2002 phonohawk - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* -*- objc -*- + $Id: CandidatesView.mm,v 1.2.2.1 2006/02/19 04:50:54 t-suwa Exp $ + + MacOS X implementation of the SKK input method. + + Copyright (C) 2002 phonohawk + Copyright (C) 2006 Tomotaka SUWA <t.suw****@mac*****> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #import <AppKit/AppKit.h> @@ -28,78 +29,81 @@ - (id)initWithCandidates:(NSArray*)cands { - // ¼ÌTCYÅú» - self = [super initWithFrame:NSMakeRect(0,0,100,100)]; + // t[®«ðtbV ·é + [[FrameAttribute sharedFrameAttribute] refresh]; - frames = [[NSMutableArray alloc] init]; - CandidatesFrame* tmpFrame = [[CandidatesFrame alloc] init]; - unsigned i; - - // SÄÌÏ·óâ©çAKvÈt[IuWFNg𶬷é - for(i = 0; i < [cands count]; ++ i) { - // ±Ìt[ɱêÈãÍÇÁÅ«È¢H - if(![tmpFrame addCandidate:[cands objectAtIndex:i]]) { - // ucèvÌðZbgµÄAzñÉÇÁ - [tmpFrame setRemain:[cands count] - i]; - [frames addObject:tmpFrame]; - [tmpFrame release]; - - // ìê½Ï·óâðVKÌt[ÉÇÁ - tmpFrame = [[CandidatesFrame alloc] init]; - [tmpFrame addCandidate:[cands objectAtIndex:i]]; - } - } + // ¼ÌTCYÅú» + self = [super initWithFrame:NSMakeRect(0,0,100,100)]; + + frames = [[NSMutableArray alloc] init]; - // LøÈt[ª êÎAzñÉÇÁ - if([tmpFrame count] > 0) { - [frames addObject:tmpFrame]; + CandidatesFrame* tmpFrame = [[CandidatesFrame alloc] init]; + unsigned i; + + // SÄÌÏ·óâ©çAKvÈt[IuWFNg𶬷é + for(i = 0; i < [cands count]; ++ i) { + // ±Ìt[ɱêÈãÍÇÁÅ«È¢H + if(![tmpFrame addCandidate:[cands objectAtIndex:i]]) { + // ucèvÌðZbgµÄAzñÉÇÁ + [tmpFrame setRemain:[cands count] - i]; + [frames addObject:tmpFrame]; + [tmpFrame release]; + + // ìê½Ï·óâðVKÌt[ÉÇÁ + tmpFrame = [[CandidatesFrame alloc] init]; + [tmpFrame addCandidate:[cands objectAtIndex:i]]; } - NSSize frame_size = [tmpFrame size]; - [tmpFrame release]; + } - // ÅIIÈTCYðè·é - [self setFrame:NSMakeRect(0, 0, frame_size.width, frame_size.height)]; - current_frame = 0; + // LøÈt[ª êÎAzñÉÇÁ + if([tmpFrame count] > 0) { + [frames addObject:tmpFrame]; + } + [tmpFrame release]; + + // ÅIIÈTCYðè·é + [self setFrame:[[FrameAttribute sharedFrameAttribute] viewRect]]; + current_frame = 0; - return self; + return self; } -- (void)drawRect:(NSRect)rect +- (void)dealloc { - [[frames objectAtIndex:current_frame] drawRect:rect]; + [frames release]; + [super dealloc]; } -- (void)dealloc +- (void)drawRect:(NSRect)rect { - [frames release]; - [super dealloc]; + [[frames objectAtIndex:current_frame] drawRect:rect]; } - (void)showNextFrame { - current_frame++; - [self display]; + ++ current_frame; + [self display]; } - (void)showPrevFrame { - current_frame--; - [self display]; + -- current_frame; + [self display]; } - (unsigned)getCandidatesPerFrame { - return [[frames objectAtIndex:current_frame] count]; + return [[frames objectAtIndex:current_frame] count]; } - (unsigned)getNumOfFrames { - return [frames count]; + return [frames count]; } - (void)setCurrentFrame:(unsigned)frame { - current_frame = frame; + current_frame = frame; } @end Index: AquaSKK/CandidatesWindowController.h diff -u AquaSKK/CandidatesWindowController.h:1.2 AquaSKK/CandidatesWindowController.h:1.2.2.1 --- AquaSKK/CandidatesWindowController.h:1.2 Sat Oct 8 00:08:36 2005 +++ AquaSKK/CandidatesWindowController.h Sun Feb 19 13:50:54 2006 @@ -1,32 +1,34 @@ -/* - $Id: CandidatesWindowController.h,v 1.2 2005/10/07 15:08:36 t-suwa Exp $ - --------- - - MacOS X implementation of the SKK input method. - Copyright (C) 2002 phonohawk - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* -*- objc -*- + $Id: CandidatesWindowController.h,v 1.2.2.1 2006/02/19 04:50:54 t-suwa Exp $ + + MacOS X implementation of the SKK input method. + + Copyright (C) 2002 phonohawk + Copyright (C) 2006 Tomotaka SUWA <t.suw****@mac*****> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once @interface CandidatesWindowController : NSWindowController { - NSArray *candidates; - CandidatesView *candidates_view; + NSArray *candidates; + CandidatesView *candidates_view; } + - initWithCandidates:(NSArray*)cands; // <NSString>óâ - (NSArray*)getCandidates; @@ -35,4 +37,5 @@ - (unsigned)getCandidatesPerFrame; - (unsigned)getNumOfFrames; - (void)setCurrentFrame:(unsigned)frame; + @end Index: AquaSKK/CandidatesWindowController.mm diff -u AquaSKK/CandidatesWindowController.mm:1.2.2.1 AquaSKK/CandidatesWindowController.mm:1.2.2.2 --- AquaSKK/CandidatesWindowController.mm:1.2.2.1 Sun Jan 8 16:15:30 2006 +++ AquaSKK/CandidatesWindowController.mm Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: CandidatesWindowController.mm,v 1.2.2.1 2006/01/08 07:15:30 t-suwa Exp $ + $Id: CandidatesWindowController.mm,v 1.2.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -21,26 +21,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#import <AppKit/AppKit.h> -#import "CandidatesView.h" -#import "CandidatesWindowController.h" -#import "PreferencesController.h" +#include <AppKit/AppKit.h> +#include "CandidatesView.h" +#include "CandidatesWindowController.h" +#include "PreferenceKeys.h" @implementation CandidatesWindowController - initWithCandidates:(NSArray*)cands { + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; self = [super initWithWindowNibName:@"Candidates"]; [self window]; // load now - self->candidates = [[NSArray alloc] initWithArray:cands]; + candidates = [[NSArray alloc] initWithArray:cands]; // wiF - [[self window] setBackgroundColor: [[PreferencesController sharedController] windowColor]]; + NSColor* color = [NSUnarchiver unarchiveObjectWithData:[defaults objectForKey:KEY_candidates_window_color]]; + [[self window] setBackgroundColor:color]; // s§¾x - [[self window] setAlphaValue: [[PreferencesController sharedController] windowAlpha]]; + [[self window] setAlphaValue:[defaults floatForKey:KEY_candidates_window_alpha]]; - self->candidates_view = [[CandidatesView alloc] initWithCandidates:cands]; + candidates_view = [[CandidatesView alloc] initWithCandidates:cands]; [[self window] setContentSize:[candidates_view bounds].size]; [[[self window] contentView] addSubview:candidates_view]; Index: AquaSKK/ChangeLog diff -u AquaSKK/ChangeLog:1.20.2.5 AquaSKK/ChangeLog:1.20.2.6 --- AquaSKK/ChangeLog:1.20.2.5 Sat Feb 18 02:20:38 2006 +++ AquaSKK/ChangeLog Sun Feb 19 13:50:54 2006 @@ -1,3 +1,28 @@ +2006-02-19 Tomotaka SUWA <t.suw****@mac*****> + + * DictArrayController.*: NSTableView Ìf[^\[X\bhðÀB + + * ServerConnectionFactory.cpp: T[o[ÌN®^CAEgð 40 b© + ç 10 bÉZkB»Ì©íèAsleep Í 0.3 ¨ 2 bɵÄSÌIÈp + tH[}Xðã°éB + + * CandidatesFrame.*: FrameAttribute NXðÇÁBóâEBhEÌ + ®«ðVOgŵ¤æ¤É·éB + + * BIM.r: cbnm ð jp.sourceforge.AquaSKKInputMethod ÉÏXB + + * PreferencesController.*: Cocoa Bindings ðg¤æ¤ÉC³B + + * PreferenceKeys.h: VKÇÁB[U[ftHgpÌL[ðè`B + + * Info-AquaSKKServer.plist, Info-AquaSKKInputMethod.plist: oh + ID ðÏXB + + * DictionarySet.cpp: «ÌpXÉ "~/" ªÜÜêÄ¢éêAz[fB + NgÉWJ·éæ¤ÉC³B + + * AquaSKKServer.*: initialize \bhðÇÁB + 2006-02-18 Tomotaka SUWA <t.suw****@mac*****> * skkserv.*: socketstream ðg¤æ¤ÉC³B Index: AquaSKK/ClientMessageReceiver.cpp diff -u AquaSKK/ClientMessageReceiver.cpp:1.3.2.2 AquaSKK/ClientMessageReceiver.cpp:1.3.2.3 --- AquaSKK/ClientMessageReceiver.cpp:1.3.2.2 Sat Jan 14 20:01:58 2006 +++ AquaSKK/ClientMessageReceiver.cpp Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* - $Id: ClientMessageReceiver.cpp,v 1.3.2.2 2006/01/14 11:01:58 t-suwa Exp $ + $Id: ClientMessageReceiver.cpp,v 1.3.2.3 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -58,10 +58,7 @@ CppCFData ClientMessageReceiver::messageReceived(SInt32 msgid, const CppCFData& data) { switch(msgid) { - case kBasicMessageIsSkkEggLikeNewline: - case kBasicMessageIsNumericKeypad_HalfWidth: - case kBasicMessageIsAsciiModeStartup: - case kBasicMessageKbdLayoutId: + case kSKKClientConfigurationModified: ClientConfiguration::theInstance().reloadConfiguration(); break; default: Index: AquaSKK/DictArrayController.m diff -u AquaSKK/DictArrayController.m:1.1.2.1 AquaSKK/DictArrayController.m:1.1.2.2 --- AquaSKK/DictArrayController.m:1.1.2.1 Wed Feb 15 00:12:44 2006 +++ AquaSKK/DictArrayController.m Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: DictArrayController.m,v 1.1.2.1 2006/02/14 15:12:44 t-suwa Exp $ + $Id: DictArrayController.m,v 1.1.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -167,4 +167,13 @@ return YES; } +- (int)numberOfRowsInTableView:(NSTableView*)tv { + return [[self arrangedObjects] count]; +} + +- (id)tableView:(NSTableView*)tv objectValueForTableColumn:(NSTableColumn*)column row:(int)row { + id obj = [[self arrangedObjects] objectAtIndex:row]; + return [obj valueForKey:[column identifier]]; +} + @end Index: AquaSKK/DictionarySet.cpp diff -u AquaSKK/DictionarySet.cpp:1.1.2.1 AquaSKK/DictionarySet.cpp:1.1.2.2 --- AquaSKK/DictionarySet.cpp:1.1.2.1 Sat Feb 18 02:20:38 2006 +++ AquaSKK/DictionarySet.cpp Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* - $Id: DictionarySet.cpp,v 1.1.2.1 2006/02/17 17:20:38 t-suwa Exp $ + $Id: DictionarySet.cpp,v 1.1.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -23,6 +23,7 @@ #include <iostream> #include <sstream> +#include <set> #include "CppCFString.h" #include "OkuriganaEntry.h" #include "Dictionary.h" @@ -72,6 +73,12 @@ // t@Ng\bh Dictionary* DictionarySet::createDictionary(const DictionaryPref& pref) const { Dictionary* dict; + std::string path = pref.location; + + // pXðWJ·é + if(path.size() > 2 && path.find("~/") == 0) { + path = SkkConfig::home() + path.substr(1); + } // «Ì¶¬ switch(pref.type) { @@ -97,7 +104,7 @@ } // ú» - dict->load(pref.location); + dict->load(path); return dict; } @@ -113,7 +120,7 @@ } void DictionarySet::load() { - CFArrayRef arrayRef = (CFArrayRef)CFPreferencesCopyAppValue(CFSTR("DictionaryInfo"), + CFArrayRef arrayRef = (CFArrayRef)CFPreferencesCopyAppValue(CFSTR("dictionary_info_array"), kCFPreferencesCurrentApplication); if(arrayRef == NULL) { return; @@ -478,23 +485,14 @@ } static void removeRedundantItems(std::vector<CppCFString>& candidates) { - // ±ÌÍcandidates̪¦éÙÇÔª©©èÜ·B - // dûȢ̾뤯ÇB - int size = candidates.size(); - for(int i = 0; i < size; ++ i) { - CppCFString& cand_i = candidates[i]; - bool is_redundant = false; - for(int j = 0; j < i; ++ j) { - if(cand_i == candidates[j]) { - is_redundant = true; - break; - } - } - - if(is_redundant) { - candidates.erase(candidates.begin() + i); - -- i; // êÂÁµ½ÌÅA»Ìãɱڪê¸êéB - -- size; // êÂÁµ½ÌÅB + std::set<CppCFString> check; + std::vector<CppCFString> result; + + for(std::vector<CppCFString>::iterator iter = candidates.begin(); iter != candidates.end(); ++ iter) { + if(check.find(*iter) == check.end()) { + check.insert(check.lower_bound(*iter), *iter); + result.push_back(*iter); } } + result.swap(candidates); } Index: AquaSKK/Info-AquaSKKInputMethod.plist diff -u AquaSKK/Info-AquaSKKInputMethod.plist:1.4.2.1 AquaSKK/Info-AquaSKKInputMethod.plist:1.4.2.2 --- AquaSKK/Info-AquaSKKInputMethod.plist:1.4.2.1 Sun Jan 8 16:15:30 2006 +++ AquaSKK/Info-AquaSKKInputMethod.plist Sun Feb 19 13:50:54 2006 @@ -11,7 +11,7 @@ <key>CFBundleIconFile</key> <string></string> <key>CFBundleIdentifier</key> - <string>org.ccm-software.AquaSKKInputMethod</string> + <string>jp.sourceforge.AquaSKKInputMethod</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> Index: AquaSKK/Info-AquaSKKServer.plist diff -u AquaSKK/Info-AquaSKKServer.plist:1.4 AquaSKK/Info-AquaSKKServer.plist:1.4.2.1 --- AquaSKK/Info-AquaSKKServer.plist:1.4 Mon Dec 19 23:46:44 2005 +++ AquaSKK/Info-AquaSKKServer.plist Sun Feb 19 13:50:54 2006 @@ -11,7 +11,7 @@ <key>CFBundleIconFile</key> <string></string> <key>CFBundleIdentifier</key> - <string>org.ccm-software.AquaSKKServer</string> + <string>jp.sourceforge.AquaSKKServer</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> Index: AquaSKK/PreferenceKeys.h diff -u /dev/null AquaSKK/PreferenceKeys.h:1.1.2.1 --- /dev/null Sun Feb 19 13:50:55 2006 +++ AquaSKK/PreferenceKeys.h Sun Feb 19 13:50:54 2006 @@ -0,0 +1,45 @@ +/* -*- objc -*- + $Id: PreferenceKeys.h,v 1.1.2.1 2006/02/19 04:50:54 t-suwa Exp $ + + MacOS X implementation of the SKK input method. + + Copyright (C) 2002 phonohawk + Copyright (C) 2005-2006 Tomotaka SUWA <t.suw****@mac*****> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef INC__PreferenceKeys__ +#define INC__PreferenceKeys__ + +// [U[ftHgpÌL[ +extern NSString* KEY_egg_like_newline; +extern NSString* KEY_numkeypad_must_halfwidth; +extern NSString* KEY_force_ascii_mode_startup; +extern NSString* KEY_keyboard_layout_id; + +extern NSString* KEY_candidates_font_name; +extern NSString* KEY_candidates_font_size; +extern NSString* KEY_candidates_window_color; +extern NSString* KEY_candidates_window_alpha; +extern NSString* KEY_candidates_window_show_after_nth_cand; + +extern NSString* KEY_dictionary_info_array; + +extern NSString* KEY_skkserv_enabled; +extern NSString* KEY_skkserv_port; +extern NSString* KEY_skkserv_localonly; + +#endif Index: AquaSKK/PreferencesController.h diff -u AquaSKK/PreferencesController.h:1.6.2.4 AquaSKK/PreferencesController.h:1.6.2.5 --- AquaSKK/PreferencesController.h:1.6.2.4 Sat Feb 18 02:20:38 2006 +++ AquaSKK/PreferencesController.h Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: PreferencesController.h,v 1.6.2.4 2006/02/17 17:20:38 t-suwa Exp $ + $Id: PreferencesController.h,v 1.6.2.5 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -21,57 +21,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#pragma once - -/* - ±ÌNXÍSingletonÅ·B -*/ - @interface PreferencesController : NSWindowController { - // üÍì IBOutlet NSPopUpButton* kbdLayoutPopUp; - IBOutlet NSButton* skkEggLikeNewlineBtn; - IBOutlet NSButton* NumericKeypad_HalfWidthBtn; - IBOutlet NSButton* AsciiModeStartupButton; - - // óâEBhE - IBOutlet id fontBtn; - IBOutlet id winColor; - IBOutlet id winTransparent; - - // skkserv - IBOutlet NSButton *skkserv_enabled; - IBOutlet NSTextField *skkserv_port; - IBOutlet NSButton *skkserv_local_only; + IBOutlet NSButton* fontButton; - NSFont *font; + NSFont* font; NSFontPanel* fontPanel; NSMenu* kbdLayoutMenu; } -+ (PreferencesController*)sharedController; -- init; ++ (PreferencesController*)sharedController; - (IBAction)showFontPanel:(id)sender; -- (void)changeFont:(id)fontManager; -- (void)setFontButtonTitle:(NSFont *)aFont; - -- (NSColor *)windowColor; -- (float)windowAlpha; - -- (int)kbdLayoutId; -- (IBAction)changeKbdLayoutId:(id)sender; -- (BOOL)isSkkEggLikeNewline; -- (IBAction)skkEggLikeNewline:(id)sender; -- (BOOL)isNumericKeypad_HalfWidth; -- (IBAction)numericKeypad_HalfWidth:(id)sender; -- (BOOL)isAsciiModeStartup; -- (IBAction)asciiModeStartup:(id)sender; - -- (IBAction)saveUserDefault:(id)sender; - -- (BOOL)isSkkservEnabled; -- (unsigned short)skkservPort; -- (BOOL)isSkkservLocalOnly; +- (void)changeFont:(id)sender; +- (void)setFontButtonTitle:(NSFont*)aFont; @end Index: AquaSKK/PreferencesController.mm diff -u AquaSKK/PreferencesController.mm:1.6.2.6 AquaSKK/PreferencesController.mm:1.6.2.7 --- AquaSKK/PreferencesController.mm:1.6.2.6 Sat Feb 18 02:20:38 2006 +++ AquaSKK/PreferencesController.mm Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: PreferencesController.mm,v 1.6.2.6 2006/02/17 17:20:38 t-suwa Exp $ + $Id: PreferencesController.mm,v 1.6.2.7 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -25,32 +25,34 @@ #include "PreferencesController.h" #include "BIMClientServer.h" -#include "CppCFString.h" #include "CppCFData.h" +#include "CppCFString.h" #include "DictionarySet.h" -#include "skkserv.h" #include "ClientConnectionFactory.h" +#include "skkserv.h" // [U[ftHgp -static NSString* KbdLayoutKey = @"KeyboardLayoutIdentifier"; -static NSString* EggLikeNewLineKey = @"dic.skk-egg-like-newline.kotoeri"; -static NSString* KeypadHalfWidthKey = @"dic.NumericKeypad_HalfWidth.kotoeri"; -static NSString* AsciiStartupKey = @"ForceASCIImodeStartup"; - -static NSString* FontNameKey = @"dic.FontName.Window"; -static NSString* FontSizeKey = @"dic.FontSize.Window"; -static NSString* WindowColorKey = @"dic.WindowColor.kotoeri"; -static NSString* WindowAlphaKey = @"dic.WindowAlpha.kotoeri"; -static NSString* ShowCandsLimitKey = @"dic.showCandsWindowAfterNthCand"; - -static NSString* SKKServEnabledKey = @"pref.skkserv.enabled"; -static NSString* SKKServPortKey = @"pref.skkserv.port"; -static NSString* SKKServLocalOnlyKey = @"pref.skkserv.local-only"; +NSString* KEY_keyboard_layout_id = @"keyboard_layout_id"; +NSString* KEY_egg_like_newline = @"egg_like_newline"; +NSString* KEY_numkeypad_must_halfwidth = @"numkeypad_must_halfwidth"; +NSString* KEY_force_ascii_mode_startup = @"force_ascii_mode_startup"; + +NSString* KEY_candidates_font_name = @"candidates_font_name"; +NSString* KEY_candidates_font_size = @"candidates_font_size"; +NSString* KEY_candidates_window_color = @"candidates_window_color"; +NSString* KEY_candidates_window_alpha = @"candidates_window_alpha"; +NSString* KEY_candidates_window_show_after_nth_cand = @"candidates_window_show_after_nth_cand"; + +NSString* KEY_dictionary_info_array = @"dictionary_info_array"; + +NSString* KEY_skkserv_enabled = @"skkserv_enabled"; +NSString* KEY_skkserv_port = @"skkserv_port"; +NSString* KEY_skkserv_localonly = @"skkserv_localonly"; // L[{[hCAEgp -static NSString* KbdIdKey = @"Identifier"; -static NSString* KbdNameKey = @"LocalizedName"; -static NSString* KbdIconKey = @"Icon"; +const NSString* KbdIdKey = @"Identifier"; +const NSString* KbdNameKey = @"LocalizedName"; +const NSString* KbdIconKey = @"Icon"; @implementation PreferencesController @@ -120,16 +122,6 @@ [kbdLayoutPopUp setMenu:kbdLayoutMenu]; } -- (void)setState:(SInt32)msgID state:(int)state { - bool boolState = state ? true : false; - - CppCFData data(&boolState, sizeof(bool)); - - ClientConnectionFactory::theInstance().newConnection().send(msgID, data); - - [self saveUserDefault:self]; -} - + (PreferencesController*)sharedController { static PreferencesController* _shared_instance = nil; if(_shared_instance == nil) { @@ -138,150 +130,24 @@ return _shared_instance; } -- init { +- (id)init { self = [super initWithWindowNibName:@"Preferences"]; [self window]; - // xÏXFt[eBO - //[[self window] setLevel:NSPopUpMenuWindowLevel]; - - // o×ÝèÌú» - NSMutableDictionary* templateDefaults = [NSMutableDictionary dictionary]; - - NSColor* color = [NSColor controlColor]; - [templateDefaults setObject:@"NO" forKey:EggLikeNewLineKey]; - [templateDefaults setObject:@"NO" forKey:KeypadHalfWidthKey]; - [templateDefaults setObject:@"NO" forKey:AsciiStartupKey]; - [templateDefaults setObject:@"0" forKey:KbdLayoutKey]; - [templateDefaults setObject:[[NSFont systemFontOfSize:0] fontName] forKey:FontNameKey]; - [templateDefaults setObject:[NSNumber numberWithInt:0] forKey:FontSizeKey]; - [templateDefaults setObject:[NSArchiver archivedDataWithRootObject:color] forKey:WindowColorKey]; - [templateDefaults setObject:@"1.0" forKey:WindowAlphaKey]; - [templateDefaults setObject:@"5" forKey:ShowCandsLimitKey]; - [templateDefaults setObject:@"NO" forKey:SKKServEnabledKey]; - [templateDefaults setObject:@"1178" forKey:SKKServPortKey]; - [templateDefaults setObject:@"YES" forKey:SKKServLocalOnlyKey]; - - // ~/Library/AquaSKK/ª³¯êÎìéB - [[NSFileManager defaultManager] - createDirectoryAtPath:[@"~/Library/AquaSKK" stringByExpandingTildeInPath] attributes:nil]; - - // defaultsðÇÞ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - [defaults registerDefaults:templateDefaults]; - // üÍì - [skkEggLikeNewlineBtn setState:[defaults boolForKey:EggLikeNewLineKey]]; - [NumericKeypad_HalfWidthBtn setState:[defaults boolForKey:KeypadHalfWidthKey]]; - [AsciiModeStartupButton setState:[defaults boolForKey:AsciiStartupKey]]; + // ú» [self initKbdLayoutPopUp]; - [kbdLayoutPopUp selectItemAtIndex:[kbdLayoutPopUp indexOfItemWithTag:[defaults integerForKey:KbdLayoutKey]]]; + int index = [kbdLayoutPopUp indexOfItemWithTag:[defaults integerForKey:KEY_keyboard_layout_id]]; + [kbdLayoutPopUp selectItemAtIndex:index]; - // óâEBhE - font = [[NSFont fontWithName:[defaults objectForKey:FontNameKey] size:[defaults floatForKey:FontSizeKey]] retain]; + font = [[NSFont fontWithName:[defaults objectForKey:KEY_candidates_font_name] + size:[defaults floatForKey:KEY_candidates_font_size]] retain]; [self setFontButtonTitle:font]; - [winColor setColor:[NSUnarchiver unarchiveObjectWithData:[defaults objectForKey:WindowColorKey]]]; - [winTransparent setDoubleValue:[defaults floatForKey:WindowAlphaKey]]; - - // « - - // skkserv - [skkserv_enabled setState:[defaults boolForKey:SKKServEnabledKey]]; - [skkserv_port setIntValue:[defaults integerForKey:SKKServPortKey]]; - [skkserv_local_only setState:[defaults boolForKey:SKKServLocalOnlyKey]]; return self; } -- (IBAction)saveUserDefault:(id)sender { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - // üÍì - [defaults setBool:[skkEggLikeNewlineBtn state] forKey:EggLikeNewLineKey]; - [defaults setBool:[NumericKeypad_HalfWidthBtn state] forKey:KeypadHalfWidthKey]; - [defaults setBool:[AsciiModeStartupButton state] forKey:AsciiStartupKey]; - [defaults setInteger:[[kbdLayoutPopUp selectedItem] tag] forKey:KbdLayoutKey]; - - // óâEBhE - [defaults setObject:[font fontName] forKey:FontNameKey]; - [defaults setObject:[NSNumber numberWithFloat:[font pointSize]] forKey:FontSizeKey]; - [defaults setObject:[NSArchiver archivedDataWithRootObject:[winColor color]] forKey:WindowColorKey]; - [defaults setFloat:[winTransparent doubleValue] forKey:WindowAlphaKey]; - - // « - - // skkserv - [defaults setBool:[skkserv_enabled state] forKey:SKKServEnabledKey]; - [defaults setInteger:[skkserv_port intValue] forKey:SKKServPortKey]; - [defaults setBool:[skkserv_local_only state] forKey:SKKServLocalOnlyKey]; - - [defaults synchronize]; -} - -- (IBAction)showFontPanel:(id)sender { - [fontPanel release]; - fontPanel = [[[NSFontManager sharedFontManager] fontPanel:YES] retain]; - [fontPanel setPanelFont:font isMultiple:NO]; - [fontPanel makeKeyAndOrderFront:self]; -} - -- (void)changeFont:(id)fontManager { - [font release]; - font = [[fontManager convertFont:[NSFont systemFontOfSize:14]] retain]; - [self setFontButtonTitle:font]; - [self saveUserDefault:self]; -} - -- (void)setFontButtonTitle:(NSFont *)aFont { - [[fontBtn cell] setFont:[NSFont fontWithName:[aFont fontName] size:[aFont pointSize]]]; - [fontBtn setTitle:[NSString stringWithFormat:@"%@ - %2.1f", [aFont displayName], [aFont pointSize]]]; -} - -- (NSColor *)windowColor { - return [winColor color]; -} - -- (float)windowAlpha { - return [winTransparent doubleValue]; -} - -- (int)kbdLayoutId { - return [[kbdLayoutPopUp selectedItem] tag]; -} - -- (IBAction)changeKbdLayoutId:(id)sender { - SInt32 kbdId = [self kbdLayoutId]; - CppCFData data(&kbdId, sizeof(SInt32)); - - ClientConnectionFactory::theInstance().newConnection().send(kBasicMessageKbdLayoutId, data); - - [self saveUserDefault:self]; -} - -- (BOOL)isSkkEggLikeNewline { - return [skkEggLikeNewlineBtn state]; -} - -- (IBAction)skkEggLikeNewline:(id)sender { - [self setState:kBasicMessageIsSkkEggLikeNewline state:[sender state]]; -} - -- (BOOL)isNumericKeypad_HalfWidth { - return [NumericKeypad_HalfWidthBtn state]; -} - -- (IBAction)numericKeypad_HalfWidth:(id)sender { - [self setState:kBasicMessageIsNumericKeypad_HalfWidth state:[sender state]]; -} - -- (BOOL)isAsciiModeStartup { - return [AsciiModeStartupButton state]; -} - -- (IBAction)asciiModeStartup:(id)sender { - [self setState:kBasicMessageIsAsciiModeStartup state:[sender state]]; -} - - (IBAction)showWindow:(id)sender { [NSApp activateIgnoringOtherApps:YES]; [[self window] makeKeyAndOrderFront:nil]; @@ -290,33 +156,49 @@ } - (BOOL)windowShouldClose:(NSNotification *)aNotification { + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + + // [U[ftHgÌÛ¶ + [defaults synchronize]; + [fontPanel close]; + + // NCgÉÏXðÊm·é + ClientConnectionFactory::theInstance().newConnection().send(kSKKClientConfigurationModified, CppCFData()); + // ÄxA«T[o[ðú»·é DictionarySet::theInstance().initialize(); // skkserv G~ [VÌÄN® skkserv& skkserv = skkserv::theInstance(); skkserv.stop(); - if([self isSkkservEnabled]) { - skkserv.start([self skkservPort], [self isSkkservLocalOnly]); + if([defaults boolForKey:KEY_skkserv_enabled]) { + skkserv.start([defaults integerForKey:KEY_skkserv_port], [defaults boolForKey:KEY_skkserv_localonly]); } - [fontPanel close]; - - [self saveUserDefault:self]; return TRUE; } -// skkserv -- (BOOL)isSkkservEnabled { - return [skkserv_enabled state]; +- (IBAction)showFontPanel:(id)sender { + fontPanel = [NSFontPanel sharedFontPanel]; + [fontPanel setPanelFont:font isMultiple:NO]; + [fontPanel makeKeyAndOrderFront:self]; } -- (unsigned short)skkservPort { - return [skkserv_port intValue]; +- (void)changeFont:(id)sender { + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + + [font release]; + font = [[sender convertFont:[NSFont systemFontOfSize:14]] retain]; + + // Cocoa Bindings ÉæèA{^ÌtHg®«àA®µÄÏX³êé + [defaults setObject:[font fontName] forKey:KEY_candidates_font_name]; + [defaults setObject:[NSNumber numberWithFloat:[font pointSize]] forKey:KEY_candidates_font_size]; + + [self setFontButtonTitle:font]; } -- (BOOL)isSkkservLocalOnly { - return [skkserv_local_only state]; +- (void)setFontButtonTitle:(NSFont *)aFont { + [fontButton setTitle:[NSString stringWithFormat:@"%@ - %2.1f", [aFont displayName], [aFont pointSize]]]; } @end Index: AquaSKK/ServerConnectionFactory.cpp diff -u AquaSKK/ServerConnectionFactory.cpp:1.2.2.1 AquaSKK/ServerConnectionFactory.cpp:1.2.2.2 --- AquaSKK/ServerConnectionFactory.cpp:1.2.2.1 Sat Jan 14 20:01:58 2006 +++ AquaSKK/ServerConnectionFactory.cpp Sun Feb 19 13:50:54 2006 @@ -1,23 +1,24 @@ /* - $Id: ServerConnectionFactory.cpp,v 1.2.2.1 2006/01/14 11:01:58 t-suwa Exp $ - --------- - - MacOS X implementation of the SKK input method. - Copyright (C) 2002 phonohawk + $Id: ServerConnectionFactory.cpp,v 1.2.2.2 2006/02/19 04:50:54 t-suwa Exp $ + + MacOS X implementation of the SKK input method. + + Copyright (C) 2002 phonohawk + Copyright (C) 2006 Tomotaka SUWA <t.suw****@mac*****> - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <Carbon/Carbon.h> @@ -30,8 +31,7 @@ static ServerConnectionFactory* _shared_instance = NULL; -ServerConnectionFactory& ServerConnectionFactory::theInstance() -{ +ServerConnectionFactory& ServerConnectionFactory::theInstance() { if(_shared_instance == NULL) { _shared_instance = new ServerConnectionFactory(); } @@ -39,22 +39,17 @@ return *_shared_instance; } -ServerConnectionFactory::ServerConnectionFactory() - :serverIsRunning(false) -{ +ServerConnectionFactory::ServerConnectionFactory() :serverIsRunning(false) { // empty } -void ServerConnectionFactory::waitUntilServerStarts() -{ +void ServerConnectionFactory::waitUntilServerStarts() { prepareServer(); if(!serverIsRunning) { - // IªÚ±Â\ÉÈéÜÅÒÂB40bÒÁÄàÚ±Â\ÉÈçȯê - // Î^CAEgB + // 10 bÒÁÄàÚ±Â\ÉÈçȯêÎ^CAEg CppCFString server_port_name(kBasicServerPortName); - - unsigned long timeout = TickCount() + (40 * 60); + unsigned long timeout = TickCount() + (10 * 60); while(true) { try { ServerConnection connection(server_port_name); @@ -62,25 +57,21 @@ break; } catch (std::exception& e) { if(TickCount() > timeout) { - fprintf(stderr, - "*** Timed out. AquaSKKServer.app didn\'t get online.\n"); + fprintf(stderr, "*** Timed out. AquaSKKServer.app didn\'t get online.\n"); break; // ^CAEg } else { - // 0.3bÒÁÄÄÚ± - usleep(300000); // 0.3 * 1000 * 1000 + sleep(2); // 2 bÒÁÄÄÚ± } } } } } -ServerConnectionFactory& ServerConnectionFactory::prepareServer() -{ +ServerConnectionFactory& ServerConnectionFactory::prepareServer() { serverIsRunning = false; - // IÌ|[gðJ¢ÄÝÄAJ¯éÈçùÉN®µÄ¢éÌÅßéB - CFMessagePortRef port - = CFMessagePortCreateRemote(NULL, CFSTR(kBasicServerPortName)); + // T[o[Ì|[gÉڱūé©H + CFMessagePortRef port = CFMessagePortCreateRemote(NULL, CFSTR(kBasicServerPortName)); if(port) { serverIsRunning = true; CFRelease(port); @@ -94,11 +85,10 @@ CFURLRef sharedSupportURL = CFBundleCopySharedSupportURL(myComponentBundle); // IÖÌpXðURLƵÄì¬ - CFURLRef serverURL - = CFURLCreateCopyAppendingPathComponent(NULL, - sharedSupportURL, - CFSTR(kCSTR_SKKServerName), - FALSE); + CFURLRef serverURL = CFURLCreateCopyAppendingPathComponent(NULL, + sharedSupportURL, + CFSTR(kCSTR_SKKServerName), + FALSE); // URLðFSRefÉÏ·µA»êðFSSpecÉÏ··éB FSRef serverFSRef; @@ -107,15 +97,18 @@ FSSpec serverFileSpec; FSGetCatalogInfo(&serverFSRef, kFSCatInfoNone, NULL,NULL, &serverFileSpec, NULL); - // E` - LaunchParamBlockRec launchParams; + // N® + LaunchParamBlockRec launchParams; launchParams.launchBlockID = extendedBlock; launchParams.launchEPBLength = extendedBlockLen; launchParams.launchFileFlags = 0; launchParams.launchControlFlags = launchNoFileFlags + launchContinue + launchDontSwitch; launchParams.launchAppSpec = &serverFileSpec; launchParams.launchAppParameters = NULL; - LaunchApplication(&launchParams); + OSErr result = LaunchApplication(&launchParams); + if(result != noErr) { + fprintf(stderr, "*** ERR ***: loading AquaSKKServer failed: %d\n", result); + } if(serverURL) CFRelease(serverURL); if(sharedSupportURL) CFRelease(sharedSupportURL); @@ -123,8 +116,7 @@ return *this; } -ServerConnection ServerConnectionFactory::newConnection() -{ +ServerConnection ServerConnectionFactory::newConnection() { try { return ServerConnection(kBasicServerPortName); } catch (std::exception& e) { Index: AquaSKK/ServerMessageReceiver.h diff -u AquaSKK/ServerMessageReceiver.h:1.4.2.1 AquaSKK/ServerMessageReceiver.h:1.4.2.2 --- AquaSKK/ServerMessageReceiver.h:1.4.2.1 Sat Jan 7 16:22:29 2006 +++ AquaSKK/ServerMessageReceiver.h Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* - $Id: ServerMessageReceiver.h,v 1.4.2.1 2006/01/07 07:22:29 t-suwa Exp $ + $Id: ServerMessageReceiver.h,v 1.4.2.2 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -48,10 +48,7 @@ void showAboutBox(); void showPreferencesBox(); CppCFData fetchCompletions(const CppCFData& attachment); - CppCFData eggLikeNewline(); - CppCFData numericKeypad_HalfWidth(); - CppCFData asciiModeStartup(); - CppCFData kbdLayoutId(); + CppCFData valueForKey(NSString* key); public: static void start(const CFStringRef loopMode); Index: AquaSKK/ServerMessageReceiver.mm diff -u AquaSKK/ServerMessageReceiver.mm:1.4.2.2 AquaSKK/ServerMessageReceiver.mm:1.4.2.3 --- AquaSKK/ServerMessageReceiver.mm:1.4.2.2 Sat Feb 18 02:20:38 2006 +++ AquaSKK/ServerMessageReceiver.mm Sun Feb 19 13:50:54 2006 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: ServerMessageReceiver.mm,v 1.4.2.2 2006/02/17 17:20:38 t-suwa Exp $ + $Id: ServerMessageReceiver.mm,v 1.4.2.3 2006/02/19 04:50:54 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -24,6 +24,7 @@ #include <AppKit/AppKit.h> #include "CandidatesView.h" #include "CandidatesWindowController.h" +#include "PreferenceKeys.h" #include "PreferencesController.h" #include "AboutBoxController.h" #include "BIMClientServer.h" @@ -108,16 +109,16 @@ reply = fetchCompletions(body); break; case kBasicMessageIsSkkEggLikeNewline: - reply = eggLikeNewline(); + reply = valueForKey(KEY_egg_like_newline); break; case kBasicMessageIsNumericKeypad_HalfWidth: - reply = numericKeypad_HalfWidth(); + reply = valueForKey(KEY_numkeypad_must_halfwidth); break; case kBasicMessageIsAsciiModeStartup: - reply = asciiModeStartup(); + reply = valueForKey(KEY_force_ascii_mode_startup); break; case kBasicMessageKbdLayoutId: - reply = kbdLayoutId(); + reply = valueForKey(KEY_keyboard_layout_id); break; default: break; @@ -215,26 +216,8 @@ return CppCFData().own(reply.toCFData()); } -CppCFData ServerMessageReceiver::eggLikeNewline() { - int isSkkEggLikeNewline = [[PreferencesController sharedController] isSkkEggLikeNewline]; +CppCFData ServerMessageReceiver::valueForKey(NSString* key) { + int result = [[NSUserDefaults standardUserDefaults] integerForKey:key]; - return CppCFData(&isSkkEggLikeNewline, sizeof(isSkkEggLikeNewline)); -} - -CppCFData ServerMessageReceiver::numericKeypad_HalfWidth() { - int isNumericKeypad_HalfWidth = [[PreferencesController sharedController] isNumericKeypad_HalfWidth]; - - return CppCFData(&isNumericKeypad_HalfWidth, sizeof(isNumericKeypad_HalfWidth)); -} - -CppCFData ServerMessageReceiver::asciiModeStartup() { - int isAsciiModeStartup = [[PreferencesController sharedController] isAsciiModeStartup]; - - return CppCFData(&isAsciiModeStartup, sizeof(isAsciiModeStartup)); -} - -CppCFData ServerMessageReceiver::kbdLayoutId() { - int kbdId = [[PreferencesController sharedController] kbdLayoutId]; - - return CppCFData(&kbdId, sizeof(kbdId)); + return CppCFData(&result, sizeof(result)); } Index: AquaSKK/UserDefaults.plist diff -u /dev/null AquaSKK/UserDefaults.plist:1.1.2.1 --- /dev/null Sun Feb 19 13:50:55 2006 +++ AquaSKK/UserDefaults.plist Sun Feb 19 13:50:54 2006 @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>candidates_font_name</key> + <string>LucidaGrande</string> + <key>candidates_font_size</key> + <integer>14</integer> + <key>candidates_window_alpha</key> + <real>1</real> + <key>candidates_window_color</key> + <data> + BAt0eXBlZHN0cmVhbYED6IQBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMGhANA + QECEhIQITlNTdHJpbmcBlIQBKwZTeXN0ZW2GhJaYDGNvbnRyb2xDb2xvcoaEk5UDhAJm + ZoM/KqqrAYaG + </data> + <key>candidates_window_show_after_nth_cand</key> + <integer>5</integer> + <key>dictionary_info_array</key> + <array> + <dict> + <key>active</key> + <true/> + <key>location</key> + <string>~/.skk-jisyo</string> + <key>type</key> + <integer>10</integer> + </dict> + <dict> + <key>active</key> + <true/> + <key>location</key> + <string>~/Library/AquaSKK/SKK-JISYO.L</string> + <key>type</key> + <integer>10</integer> + </dict> + </array> + <key>egg_like_new_line</key> + <false/> + <key>force_ascii_mode_startup</key> + <false/> + <key>keyboard_layout_Id</key> + <integer>0</integer> + <key>numkeypad_must_halfwidth</key> + <false/> + <key>skkserv_enabled</key> + <false/> + <key>skkserv_localonly</key> + <true/> + <key>skkserv_port</key> + <integer>1178</integer> +</dict> +</plist>