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);
-}
+// ZbVÇpÌ[eBeBNX
+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:
+ // VOg
+ 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µ¢ZbVðzñÌöÉÇÁ·é
+ 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ðú»µAMj
[ð\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 @@
// ÅãÌCX^Xªjü³êéÉÄÎêéB
void BIMTerminate( ComponentInstance inComponentInstance ) {
CFRelease(gPencilMenu);
- CFRelease(activeSessions);
gPencilMenu = NULL;
}
@@ -202,24 +254,8 @@
// ZbVªANeBuÉÈé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 */
- }
- /*
- AquaSKKIðOÌL[üÍXNvgð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);
+
// ANeBuÉÈÁ½ðIÉ`¦éB
ServerConnectionFactory::theInstance().newConnection().send(
kBasicMessageActivated);
@@ -232,19 +268,13 @@
// ZbVªANeBuÅÈÈé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);
// ANeBuÅÈÈÁ½ðIÉ`¦éB
- if (CFArrayGetCount(activeSessions) == 0)
+ if(ActiveSession::theInstance().Count() == 0) {
ServerConnectionFactory::theInstance().newConnection().send(
kBasicMessageDeactivated);
+ }
return 0;
}
@@ -335,18 +365,8 @@
#pragma mark -
// ANeBuÈZbVðÔ·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) // AXL[pLÌÍÍ
|| 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: \bhÌé¾ðÇÁB
+
+ * WordRegisterMode.*: ParentInputMode::handleInput ðI[o[ChB
+ «o^Í ASCII [hðLøÉµÈ¯êÎÈçÈ¢½ßB
+
+ * BIM.cpp (BIMHandleInput): PanrentInputMode::handleInput ÌÔèl
+ ðg¤æ¤ÉC³BܽAZbVÇpÌ[eBeBƵÄ
+ ActiveSession NXðÇÁ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.*: tHgÝèÌÇÁ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 ª³µ½CxgÍ 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);