[aquaskk-changes 83] CVS update: AquaSKK

Back to archive index

Tomotaka SUWA t-suw****@users*****
2005年 10月 8日 (土) 17:10:48 JST


Index: AquaSKK/BIM.cpp
diff -u AquaSKK/BIM.cpp:1.4 AquaSKK/BIM.cpp:1.5
--- AquaSKK/BIM.cpp:1.4	Sat Oct  8 00:08:36 2005
+++ AquaSKK/BIM.cpp	Sat Oct  8 17:10:48 2005
@@ -1,4 +1,4 @@
-/*  $Id: BIM.cpp,v 1.4 2005/10/07 15:08:36 t-suwa Exp $
+/*  $Id: BIM.cpp,v 1.5 2005/10/08 08:10:48 t-suwa Exp $
 	
     MacOS X implementation of the SKK input method.
     Copyright (C) 2002-2004 phonohawk
@@ -66,26 +66,89 @@
     kRegisterWordMenuCommand = 'RGWR'
 };
 
-static CFMutableArrayRef activeSessions = NULL;
 static MenuRef gPencilMenu;
 
 static pascal OSStatus BIMPencilMenuEventHandler( EventHandlerCallRef inEventHandlerCallRef,
                                                   EventRef inEventRef, void *inUserData );
 
-static const void *activeSessionRetain(CFAllocatorRef allocator, const void *value)
-{
-    return (const void *)CFRetain((CFTypeRef)value);
-}
+// ƒZƒbƒVƒ‡ƒ“ŠÇ——p‚̃†[ƒeƒBƒŠƒeƒBƒNƒ‰ƒX
+class ActiveSession {
+    CFMutableArrayRef sessions_;
 
-static void activeSessionRelease(CFAllocatorRef allocator, const void *value)
-{
-    CFRelease((CFTypeRef)value);
-}
+    ActiveSession() : sessions_(0) {
+	CFArrayCallBacks c;
+	c.version = 0;
+	c.retain = ActiveSession::retain;
+	c.release = ActiveSession::release;
+	c.copyDescription = NULL;
+	c.equal = ActiveSession::equal;
+	sessions_ = CFArrayCreateMutable(kCFAllocatorDefault, 0, &c);
+    }
 
-static Boolean activeSessionEqual(const void *value1, const void *value2)
-{
-    return CFEqual((CFTypeRef)value1, (CFTypeRef)value2);
-}
+    // ˆÈ‰º‚ÌŽO‚Â‚Í callback —p
+    static const void* retain(CFAllocatorRef allocator, const void* value) {
+	return (const void *)CFRetain((CFTypeRef)value);
+    }
+
+    static void release(CFAllocatorRef allocator, const void* value) {
+	return CFRelease((CFTypeRef)value);
+    }
+
+    static Boolean equal(const void* value1, const void* value2) {
+	return CFEqual((CFTypeRef)value1, (CFTypeRef)value2);
+    }
+
+public:
+    // ƒVƒ“ƒOƒ‹ƒgƒ“
+    static ActiveSession& theInstance() {
+	static ActiveSession self;
+	return self;
+    }
+
+    ~ActiveSession() {
+	CFRelease(sessions_);
+    }
+
+    void Add(CFIndex session) {
+	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault,
+				       kCFNumberCFIndexType, &session);
+	CFRange r = {0, 0};
+	CFIndex i = CFArrayGetFirstIndexOfValue(sessions_, r, h);
+	if(i != -1) {
+	    CFArrayRemoveValueAtIndex(sessions_, i);
+	}
+	// V‚µ‚¢ƒZƒbƒVƒ‡ƒ“‚ð”z—ñ‚Ì––”ö‚ɒljÁ‚·‚é
+	CFArrayAppendValue(sessions_, h);
+	CFRelease(h);
+    }
+
+    void Remove(CFIndex session) {
+	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault,
+				       kCFNumberCFIndexType, &session);
+	CFRange r = {0, 0};
+	CFIndex i = CFArrayGetFirstIndexOfValue(sessions_, r, h);
+	if(i != -1) {
+	    CFArrayRemoveValueAtIndex(sessions_, i);
+	}
+	CFRelease(h);
+    }
+
+    void* GetCurrent() const {
+	CFIndex i = Count();
+	if(i >= 0) {
+	    CFNumberRef n = (CFNumberRef)CFArrayGetValueAtIndex(sessions_, i - 1);
+	    CFIndex h = 0;
+	    if(CFNumberGetValue(n, kCFNumberCFIndexType, &h)) {
+		return (void*)h;
+	    }
+	}
+	return NULL;
+    }
+
+    int Count(void) const {
+	return CFArrayGetCount(sessions_);
+    }
+};
 
 // ƒOƒ[ƒoƒ‹‚È’l‚ð‰Šú‰»‚µA‰”•Mƒƒjƒ…[‚ð\’z‚·‚éB
 ComponentResult BIMInitialize( ComponentInstance inComponentInstance,
@@ -99,16 +162,6 @@
     
     gPencilMenu = NULL;
 
-    {
-	CFArrayCallBacks c;
-	c.version = 0;
-	c.retain = activeSessionRetain;
-	c.release = activeSessionRelease;
-	c.copyDescription = NULL;
-	c.equal = activeSessionEqual;
-	activeSessions = CFArrayCreateMutable(kCFAllocatorDefault, 0, &c);
-    }
-    
     //  ŽI‚ª‹N“®‚µ‚Ä‚¢‚È‚©‚Á‚½‚ç‹N“®‚·‚éB
     ServerConnectionFactory::theInstance().prepareServer();
     
@@ -149,7 +202,6 @@
 // ÅŒã‚̃Cƒ“ƒXƒ^ƒ“ƒX‚ª”jŠü‚³‚ê‚鎞‚ɌĂ΂ê‚éB
 void BIMTerminate( ComponentInstance inComponentInstance ) {
     CFRelease(gPencilMenu);
-    CFRelease(activeSessions);
     gPencilMenu = NULL;
 }
 
@@ -202,24 +254,8 @@
 
 // ƒZƒbƒVƒ‡ƒ“‚ªƒAƒNƒeƒBƒu‚É‚È‚éB
 ComponentResult BIMSessionActivate( BIMSessionHandle inSessionHandle ) {
-    {
-	CFIndex iSession = (CFIndex)inSessionHandle;
-	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &iSession);
-	CFRange r = {0, 0};
-	CFIndex i = CFArrayGetFirstIndexOfValue(activeSessions, r, h);
-	if (i >= 0)
-	    CFArrayRemoveValueAtIndex(activeSessions, i);
-	CFArrayAppendValue(activeSessions, h);
-	/* the last one is latest */
-    }
-    /*
-        AquaSKK‘I‘ð‘O‚̃L[“ü—̓XƒNƒŠƒvƒg‚ð—LŒø‚É‚·‚éB
-        ‚±‚̏ˆ—‚ð‚µ‚È‚¢‚ÆDvorak,Dvorak - Qwerty“™‚ª—LŒø‚É‚È‚ç‚È‚¢B
-        ‚ªAŽ‘—¿‚ªŒ©•t‚©‚ç‚È‚¢‚̂Ő³‚µ‚¢ˆ—‚©‚Í‚í‚©‚ç‚È‚¢B
-    */
-    long keyboardID = GetScriptVariable(GetScriptManagerVariable(smKeyCache), smScriptKeys);
-    SetScriptVariable (smJapanese, smScriptKeys, keyboardID);
-    
+    ActiveSession::theInstance().Add((CFIndex)inSessionHandle);
+
     // ƒAƒNƒeƒBƒu‚É‚È‚Á‚½Ž–‚ðŽI‚É“`‚¦‚éB
     ServerConnectionFactory::theInstance().newConnection().send(
 	kBasicMessageActivated);
@@ -232,19 +268,13 @@
 
 // ƒZƒbƒVƒ‡ƒ“‚ªƒAƒNƒeƒBƒu‚Å‚È‚­‚È‚éB
 ComponentResult BIMSessionDeactivate( BIMSessionHandle inSessionHandle ) {
-    {
-	CFIndex iSession = (CFIndex)inSessionHandle;
-	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &iSession);
-	CFRange r = {0, 0};
-	CFIndex i = CFArrayGetFirstIndexOfValue(activeSessions, r, h);
-	if (i >= 0)
-	    CFArrayRemoveValueAtIndex(activeSessions, i);
-    }
+    ActiveSession::theInstance().Remove((CFIndex)inSessionHandle);
 
     // ƒAƒNƒeƒBƒu‚Å‚È‚­‚È‚Á‚½Ž–‚ðŽI‚É“`‚¦‚éB
-    if (CFArrayGetCount(activeSessions) == 0)
+    if(ActiveSession::theInstance().Count() == 0) {
 	ServerConnectionFactory::theInstance().newConnection().send(
 	    kBasicMessageDeactivated);
+    }
 
     return 0;
 }
@@ -335,18 +365,8 @@
 #pragma mark -
 
 // ƒAƒNƒeƒBƒu‚ȃZƒbƒVƒ‡ƒ“‚ð•Ô‚·B
-BIMSessionHandle BIMGetActiveSession( void ) {
-    BIMSessionHandle handle = NULL;
- 	
-    CFIndex i = CFArrayGetCount(activeSessions);
-    if (i >= 0) {
-	CFNumberRef n = (CFNumberRef)CFArrayGetValueAtIndex(activeSessions, i - 1);
-	CFIndex h = 0;
-	if (CFNumberGetValue(n, kCFNumberCFIndexType, &h))
-	    handle = (BIMSessionHandle)h;
-    }
- 	
-    return handle;
+BIMSessionHandle BIMGetActiveSession() {
+    return (BIMSessionHandle)ActiveSession::theInstance().GetCurrent();
 }
 
 // •¶Žš‚Ì“ü—͂ɑ΂µ‚Ă̏ˆ—B
@@ -389,8 +409,7 @@
 	}
 	else if ((inCharCode >= 0x20 && inCharCode <= 0x7e) // ƒAƒXƒL[‰p”Žš‹L†‚͈̔Í
 		 || SkkConfig::config().isMappedKey(inCharCode)) {
-	    (*inSessionHandle)->imsession_input_mode->handleInput(inCharCode);
-	    handled = TRUE;
+	    handled = (*inSessionHandle)->imsession_input_mode->handleInput(inCharCode);
 	}
 	break;
     }
Index: AquaSKK/ChangeLog
diff -u AquaSKK/ChangeLog:1.7 AquaSKK/ChangeLog:1.8
--- AquaSKK/ChangeLog:1.7	Sat Oct  8 00:08:36 2005
+++ AquaSKK/ChangeLog	Sat Oct  8 17:10:48 2005
@@ -1,3 +1,17 @@
+2005-10-08  Tomotaka SUWA  <t.suw****@mac*****>
+
+	* PreferencesController.h: ƒƒ\ƒbƒh‚̐錾‚ð’ljÁB
+
+	* WordRegisterMode.*: ParentInputMode::handleInput ‚ðƒI[ƒo[ƒ‰ƒCƒhB
+	Ž«‘“o˜^’†‚Í ASCII ƒ‚[ƒh‚ð—LŒø‚É‚µ‚È‚¯‚ê‚΂Ȃç‚È‚¢‚½‚߁B
+
+	* BIM.cpp (BIMHandleInput): PanrentInputMode::handleInput ‚Ì•Ô‚è’l
+	‚ðŽg‚¤‚悤‚ɏC³B‚Ü‚½AƒZƒbƒVƒ‡ƒ“ŠÇ——p‚̃†[ƒeƒBƒŠƒeƒB‚Æ‚µ‚Ä
+	ActiveSession ƒNƒ‰ƒX‚ð’ljÁBSetScriptVariable ‚̌ďo‚ðíœB
+	
+	* ParentInputMode.cpp (handleInput): ƒˆ‚È ASCII ƒ‚[ƒh‚ÌŽž‚É‚Í
+	Ctrl-J ‚¾‚¯ˆ—‚·‚é‚悤‚ɏC³B‚»‚êˆÈŠO‚̃L[‚Í TSM ‚ɏˆ—‚ð”C‚¹‚éB
+
 2005-09-24  Shin_ichi Abe  <xdd****@mac*****>
 
 	* PreferencesController.*: ƒtƒHƒ“ƒgÝ’è‚̒ljÁB
Index: AquaSKK/ParentInputMode.cpp
diff -u AquaSKK/ParentInputMode.cpp:1.2 AquaSKK/ParentInputMode.cpp:1.3
--- AquaSKK/ParentInputMode.cpp:1.2	Sat Oct  8 00:08:36 2005
+++ AquaSKK/ParentInputMode.cpp	Sat Oct  8 17:10:48 2005
@@ -1,5 +1,5 @@
 /*
-	$Id: ParentInputMode.cpp,v 1.2 2005/10/07 15:08:36 t-suwa Exp $
+	$Id: ParentInputMode.cpp,v 1.3 2005/10/08 08:10:48 t-suwa Exp $
 	---------
 	
     MacOS X implementation of the SKK input method.
@@ -23,6 +23,7 @@
 #include <Carbon/Carbon.h>
 #include <string>
 #include <vector>
+#include <map>
 #include <cassert>
 #include "BIM.h"
 #include "CppCFString.h"
@@ -39,6 +40,7 @@
 #include "KanjiConversionMode.h"
 #include "AsciiConversionMode.h"
 #include "ParentInputMode.h"
+#include "SkkConfig.h"
 
 ParentInputMode::ParentInputMode()
 	:hiragana_input_mode(*this),
@@ -85,7 +87,15 @@
 		}
 	}
 	assert(input_mode != NULL);
-	
+
+	// ASCII ƒ‚[ƒh‚ÌŽž‚É‚Í Ctrl-J ‚¾‚¯ˆ—‚·‚é‚悤‚É‚·‚é
+	if(isHanAscInputMode() && !is_kanji_mode && !is_ascii_conv_mode &&
+	   !SkkConfig::config().isKakuteiKey(inputChar)) {
+	    // Input Method ‚ª–³Ž‹‚µ‚½ƒCƒxƒ“ƒg‚Í TSM ‚ª“KØ‚ɏˆ—‚µ‚Ä‚­
+	    // ‚ê‚邽‚߁AU.S. ‚Ƃ̌݊·«‚ª‚‚Ü‚é
+	    return false;
+	}
+
 	bool do_fix = input_mode->handleInput(inputChar);
 	if (do_fix)
 	{
@@ -93,7 +103,7 @@
 	}
 	displayUnlessIgnore(input_mode->getStringToDisplay());
 	
-	return false; // í‚Éfalse‚ð•Ô‚·BŒ‹‰Ê‚ɈӖ¡‚Í–³‚¢B
+	return true;
 }
 
 bool ParentInputMode::handleBackSpace()
Index: AquaSKK/PreferencesController.h
diff -u AquaSKK/PreferencesController.h:1.4 AquaSKK/PreferencesController.h:1.5
--- AquaSKK/PreferencesController.h:1.4	Sat Oct  8 00:08:36 2005
+++ AquaSKK/PreferencesController.h	Sat Oct  8 17:10:48 2005
@@ -1,5 +1,5 @@
 /*  -*- objc -*-
-    $Id: PreferencesController.h,v 1.4 2005/10/07 15:08:36 t-suwa Exp $
+    $Id: PreferencesController.h,v 1.5 2005/10/08 08:10:48 t-suwa Exp $
     ---------
 	
     MacOS X implementation of the SKK input method.
@@ -60,6 +60,8 @@
 - init;
 
 - (IBAction)showFontPanel:(id)sender;
+- (void)changeFont:(id)fontManager;
+- (void)setFontButtonTitle:(NSFont *)aFont;
 
 - (NSColor *)windowColor;
 - (float)windowAlpha;
Index: AquaSKK/WordRegisterMode.cpp
diff -u AquaSKK/WordRegisterMode.cpp:1.2 AquaSKK/WordRegisterMode.cpp:1.3
--- AquaSKK/WordRegisterMode.cpp:1.2	Sat Oct  8 00:08:36 2005
+++ AquaSKK/WordRegisterMode.cpp	Sat Oct  8 17:10:48 2005
@@ -1,5 +1,5 @@
 /*
-	$Id: WordRegisterMode.cpp,v 1.2 2005/10/07 15:08:36 t-suwa Exp $
+	$Id: WordRegisterMode.cpp,v 1.3 2005/10/08 08:10:48 t-suwa Exp $
 	---------
 	
     MacOS X implementation of the SKK input method.
@@ -167,6 +167,31 @@
 	return true; // í‚ɐH‚¤B
 }
 
+bool WordRegisterMode::handleInput(unsigned char inputChar) {
+    ChildInputMode* input_mode;
+    if(is_kanji_mode) {
+	input_mode = &kanji_conversion_mode;
+    } else if(is_ascii_conv_mode) {
+	input_mode = &ascii_conversion_mode;
+    } else {
+	if(inputChar >= 'A' && inputChar <= 'Z' && inputChar != 'L' &&	//XXX
+	   !isHanAscInputMode() && !isZenAscInputMode()) {
+	    is_kanji_mode = true;
+	    input_mode = &kanji_conversion_mode;
+	} else {
+	    input_mode = current_input_mode;
+	}
+    }
+
+    bool do_fix = input_mode->handleInput(inputChar);
+    if(do_fix) {
+	fixUnlessIgnore(input_mode->getStringToFix());
+    }
+    displayUnlessIgnore(input_mode->getStringToDisplay());
+	
+    return true;
+}
+
 CppCFString WordRegisterMode::getContent() const
 {
 	return buffer;
Index: AquaSKK/WordRegisterMode.h
diff -u AquaSKK/WordRegisterMode.h:1.2 AquaSKK/WordRegisterMode.h:1.3
--- AquaSKK/WordRegisterMode.h:1.2	Sat Oct  8 00:08:36 2005
+++ AquaSKK/WordRegisterMode.h	Sat Oct  8 17:10:48 2005
@@ -1,5 +1,5 @@
 /*
-	$Id: WordRegisterMode.h,v 1.2 2005/10/07 15:08:36 t-suwa Exp $
+	$Id: WordRegisterMode.h,v 1.3 2005/10/08 08:10:48 t-suwa Exp $
 	---------
 	
     MacOS X implementation of the SKK input method.
@@ -36,6 +36,7 @@
 		virtual bool handleCg();
 		virtual bool handleCy();
 		virtual bool handleTab();
+		virtual bool handleInput(unsigned char inputChar);
 		
 		virtual void fix(const CppCFString& str_to_fix);
 		virtual void display(const CppCFString& str_to_display);


aquaskk-changes メーリングリストの案内
Back to archive index