[aquaskk-changes 98] CVS update: AquaSKK

Back to archive index

Tomotaka SUWA t-suw****@users*****
2005年 12月 4日 (日) 12:42:24 JST


Index: AquaSKK/BIM.cpp
diff -u AquaSKK/BIM.cpp:1.7 AquaSKK/BIM.cpp:1.8
--- AquaSKK/BIM.cpp:1.7	Sun Nov  6 00:52:06 2005
+++ AquaSKK/BIM.cpp	Sun Dec  4 12:42:24 2005
@@ -1,22 +1,26 @@
-/*  $Id: BIM.cpp,v 1.7 2005/11/05 15:52:06 xdd Exp $
-	
-    MacOS X implementation of the SKK input method.
-    Copyright (C) 2002-2004 phonohawk
+/*
+  $Id: BIM.cpp,v 1.8 2005/12/04 03:42:24 t-suwa Exp $
+
+  MacOS X implementation of the SKK input method.
 
-    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
+  Copyright (C) 2002-2004 phonohawk
+  Copyright (C) 2005 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
 */
+
 #define TARGET_API_MAC_CARBON 1
 
 #define kMENU_Pencil (kBaseResourceID + 1)
@@ -68,8 +72,8 @@
 
 static MenuRef gPencilMenu;
 
-static pascal OSStatus BIMPencilMenuEventHandler( EventHandlerCallRef inEventHandlerCallRef,
-                                                  EventRef inEventRef, void *inUserData );
+static pascal OSStatus BIMPencilMenuEventHandler(EventHandlerCallRef inEventHandlerCallRef,
+						 EventRef inEventRef, void* inUserData);
 
 // ƒZƒbƒVƒ‡ƒ“ŠÇ——p‚̃†[ƒeƒBƒŠƒeƒBƒNƒ‰ƒX
 class ActiveSession {
@@ -110,8 +114,7 @@
     }
 
     void Add(CFIndex session) {
-	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault,
-				       kCFNumberCFIndexType, &session);
+	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &session);
 	CFRange r = {0, 0};
 	CFIndex i = CFArrayGetFirstIndexOfValue(sessions_, r, h);
 	if(i != -1) {
@@ -123,8 +126,7 @@
     }
 
     void Remove(CFIndex session) {
-	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault,
-				       kCFNumberCFIndexType, &session);
+	CFNumberRef h = CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &session);
 	CFRange r = {0, 0};
 	CFIndex i = CFArrayGetFirstIndexOfValue(sessions_, r, h);
 	if(i != -1) {
@@ -151,8 +153,7 @@
 };
 
 // ƒOƒ[ƒoƒ‹‚È’l‚ð‰Šú‰»‚µA‰”•Mƒƒjƒ…[‚ð\’z‚·‚éB
-ComponentResult BIMInitialize( ComponentInstance inComponentInstance,
-                               MenuRef *outTextServiceMenu ) {
+ComponentResult BIMInitialize(ComponentInstance inComponentInstance, MenuRef *outTextServiceMenu) {
     ComponentResult result;
     short refNum;
     EventTypeSpec menuEventSpec;
@@ -186,9 +187,8 @@
     //	‰”•Mƒƒjƒ…[‚̃Cƒxƒ“ƒgƒnƒ“ƒhƒ‰‚ðƒCƒ“ƒXƒg[ƒ‹‚·‚éB
     menuEventSpec.eventClass = kEventClassCommand;
     menuEventSpec.eventKind = kEventProcessCommand;
-    result = InstallMenuEventHandler( gPencilMenu,
-				      NewEventHandlerUPP( BIMPencilMenuEventHandler ), 1,
-				      &menuEventSpec, NULL, NULL);
+    result = InstallMenuEventHandler(gPencilMenu, NewEventHandlerUPP(BIMPencilMenuEventHandler),
+				     1, &menuEventSpec, NULL, NULL);
     
     //  ƒƒbƒZ[ƒWŽóM‹@\‚ð‰Šú‰»
     ClientMessageReceiver::start(kAquaSKKClientRunLoopMode);
@@ -200,7 +200,7 @@
 
 
 // ÅŒã‚̃Cƒ“ƒXƒ^ƒ“ƒX‚ª”jŠü‚³‚ê‚鎞‚ɌĂ΂ê‚éB
-void BIMTerminate( ComponentInstance inComponentInstance ) {
+void BIMTerminate(ComponentInstance inComponentInstance) {
     CFRelease(gPencilMenu);
     gPencilMenu = NULL;
 }
@@ -208,31 +208,33 @@
 #pragma mark -
 
 // V‚½‚ɃZƒbƒVƒ‡ƒ“‚ðŠJŽnB
-ComponentResult BIMSessionOpen( ComponentInstance inComponentInstance,
-                                BIMSessionHandle *outSessionHandle ) {
+ComponentResult BIMSessionOpen(ComponentInstance inComponentInstance, BIMSessionHandle *outSessionHandle) {
     ComponentResult result = noErr;
     
-    if( result == noErr ) {
-        if( *outSessionHandle == nil ) {
-            *outSessionHandle =( BIMSessionHandle ) NewHandle( sizeof( BIMSessionRecord ) );
-	}
-        if( *outSessionHandle ) {
-            ( **outSessionHandle )->fComponentInstance = inComponentInstance;
-            ( **outSessionHandle )->fLastUpdate = 0;
-	    ( **outSessionHandle )->fLastUpdateLength = 0;
-            ( **outSessionHandle )->fInputBufferCount = 0;
-            ( **outSessionHandle )->fInputBuffer = NULL;
-	    (**outSessionHandle)->terminate_disabled = false;
-	    (**outSessionHandle)->imsession_input_mode = new IMSessionInputMode(*outSessionHandle);
-        }
-        else {
-            result = memFullErr;
-	}
+    if(*outSessionHandle == nil) {
+	*outSessionHandle = (BIMSessionHandle)NewHandle(sizeof(BIMSessionRecord));
     }
-        
+
+    if(*outSessionHandle) {
+	(**outSessionHandle)->fComponentInstance = inComponentInstance;
+	(**outSessionHandle)->fLastUpdate = 0;
+	(**outSessionHandle)->fLastUpdateLength = 0;
+	(**outSessionHandle)->fInputBufferCount = 0;
+	(**outSessionHandle)->fInputBuffer = NULL;
+	(**outSessionHandle)->terminate_disabled = false;
+	(**outSessionHandle)->imsession_input_mode = new IMSessionInputMode(*outSessionHandle);
+
+	// “ú–{ŒêƒXƒNƒŠƒvƒg‚ð—LŒø‚É‚·‚é
+	long keyboardID = GetScriptVariable(smCurrentScript, smScriptKeys);
+	SetScriptVariable(smJapanese, smScriptKeys, keyboardID);
+	KeyScript(smJapanese);
+    } else {
+	result = memFullErr;
+    }
+
     //	ƒCƒ“ƒvƒbƒgƒoƒbƒtƒ@‚ð‰Šú‰»
-    if( result == noErr ) {
-        ( **outSessionHandle )->fInputBuffer = (UniCharPtr) NewPtr( 1024 );
+    if(result == noErr) {
+        (**outSessionHandle)->fInputBuffer = (UniCharPtr)NewPtr(1024);
         result = MemError();
     }
 
@@ -240,25 +242,24 @@
 }
 
 // ƒZƒbƒVƒ‡ƒ“‚ð”jŠü‚·‚éB
-void BIMSessionClose( BIMSessionHandle inSessionHandle ) {
-    if( inSessionHandle ) {
-        if( ( *inSessionHandle )->fInputBuffer ) {
-            DisposePtr( (Ptr) ( *inSessionHandle )->fInputBuffer );
+void BIMSessionClose(BIMSessionHandle inSessionHandle) {
+    if(inSessionHandle) {
+        if((*inSessionHandle)->fInputBuffer) {
+            DisposePtr((Ptr)(*inSessionHandle)->fInputBuffer);
 	}
-	
+
 	delete (*inSessionHandle)->imsession_input_mode;
-	
-        DisposeHandle( (Handle) inSessionHandle );
+
+        DisposeHandle((Handle)inSessionHandle );
     }
 }
 
 // ƒZƒbƒVƒ‡ƒ“‚ªƒAƒNƒeƒBƒu‚É‚È‚éB
-ComponentResult BIMSessionActivate( BIMSessionHandle inSessionHandle ) {
+ComponentResult BIMSessionActivate(BIMSessionHandle inSessionHandle) {
     ActiveSession::theInstance().Add((CFIndex)inSessionHandle);
 
     // ƒAƒNƒeƒBƒu‚É‚È‚Á‚½Ž–‚ðŽI‚É“`‚¦‚éB
-    ServerConnectionFactory::theInstance().newConnection().send(
-	kBasicMessageActivated);
+    ServerConnectionFactory::theInstance().newConnection().send(kBasicMessageActivated);
 
     // Ý’è‚ðƒŠƒ[ƒh
     ClientConfiguration::theInstance().reloadConfiguration();
@@ -267,74 +268,66 @@
 }
 
 // ƒZƒbƒVƒ‡ƒ“‚ªƒAƒNƒeƒBƒu‚Å‚È‚­‚È‚éB
-ComponentResult BIMSessionDeactivate( BIMSessionHandle inSessionHandle ) {
+ComponentResult BIMSessionDeactivate(BIMSessionHandle inSessionHandle) {
     ActiveSession::theInstance().Remove((CFIndex)inSessionHandle);
 
     // ƒAƒNƒeƒBƒu‚Å‚È‚­‚È‚Á‚½Ž–‚ðŽI‚É“`‚¦‚éB
     if(ActiveSession::theInstance().Count() == 0) {
-	ServerConnectionFactory::theInstance().newConnection().send(
-	    kBasicMessageDeactivated);
+	ServerConnectionFactory::theInstance().newConnection().send(kBasicMessageDeactivated);
     }
 
     return 0;
 }
 
 // ƒRƒ“ƒ|[ƒlƒ“ƒg‚̃Cƒxƒ“ƒg‚ðˆ—B
-ComponentResult BIMSessionEvent( BIMSessionHandle inSessionHandle, EventRef inEventRef ) {
+ComponentResult BIMSessionEvent(BIMSessionHandle inSessionHandle, EventRef inEventRef) {
     Boolean handled;
     UInt32 eventClass;
     UInt32 eventKind;
     
     handled = FALSE;
     
-    //  eventClass‚ÆeventKind‚ðŽæ“¾B
-    eventClass = GetEventClass( inEventRef );
-    eventKind = GetEventKind( inEventRef );
+    // eventClass‚ÆeventKind‚ðŽæ“¾B
+    eventClass = GetEventClass(inEventRef);
+    eventKind = GetEventKind(inEventRef);
     
-    if( eventClass == kEventClassKeyboard && ( eventKind == kEventRawKeyDown ||
-                                               eventKind == kEventRawKeyRepeat ) ) {
+    if(eventClass == kEventClassKeyboard && (eventKind == kEventRawKeyDown || eventKind == kEventRawKeyRepeat)) {
         UInt32 keyCode;
         unsigned char charCode;
         UInt32 modifiers;
-        
-        //  ƒL[ƒR[ƒh‚ðŽæ“¾
-        GetEventParameter( inEventRef, kEventParamKeyCode, typeUInt32, nil, sizeof (keyCode),
-                           nil, &keyCode );
-        
-        //  ƒLƒƒƒ‰ƒNƒ^ƒR[ƒh‚ðŽæ“¾
-        GetEventParameter( inEventRef, kEventParamKeyMacCharCodes, typeChar, nil,
-                           sizeof( charCode ), nil, &charCode );
-	
-        //  ƒ‚ƒfƒBƒtƒ@ƒCƒA‚̏ó‘Ô‚ðŽæ“¾
-        GetEventParameter( inEventRef, kEventParamKeyModifiers, typeUInt32, nil,
-                           sizeof( modifiers ), nil, &modifiers );
-	
+
+        // ƒL[ƒR[ƒh‚ðŽæ“¾
+        GetEventParameter(inEventRef, kEventParamKeyCode, typeUInt32, nil, sizeof(keyCode), nil, &keyCode);
+
+        // ƒLƒƒƒ‰ƒNƒ^ƒR[ƒh‚ðŽæ“¾
+        GetEventParameter(inEventRef, kEventParamKeyMacCharCodes, typeChar, nil, sizeof(charCode), nil, &charCode);
+
+        // ƒ‚ƒfƒBƒtƒ@ƒCƒA‚̏ó‘Ô‚ðŽæ“¾
+        GetEventParameter(inEventRef, kEventParamKeyModifiers, typeUInt32, nil, sizeof(modifiers), nil, &modifiers);
+
 	D_PRINTF("mod: %lx , keycode: %lx, char: %c,%x\n",modifiers,keyCode,charCode,charCode);
 	
-	if (modifiers & (1 << cmdKeyBit)) { // ƒRƒ}ƒ“ƒhƒL[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚½B 
+	if(modifiers & (1 << cmdKeyBit)) { // ƒRƒ}ƒ“ƒhƒL[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚½B 
 	    handled = false;
 	}
-	else if (SkkConfig::config().isNumericKeypad(keyCode)	//”¼Špƒeƒ“ƒL[“ü—Í
-			&& ClientConfiguration::theInstance().isNumericKeypad_HalfWidth()) {
+	else if(SkkConfig::config().isNumericKeypad(keyCode)	//”¼Špƒeƒ“ƒL[“ü—Í
+		  && ClientConfiguration::theInstance().isNumericKeypad_HalfWidth()) {
 		handled = (*inSessionHandle)->imsession_input_mode->handleNumKey(charCode);
 	}
-	else if (keyCode == 0x66) { // ‰p”
-	    if (SkkConfig::config().useEisuuToSetHenkanPoint()) {
-			handled = BIMHandleInput(inSessionHandle, SkkConfig::config().setHenkanPointKey());
-	    }
-	    else {
-			handled = true;
+	else if(keyCode == 0x66) { // ‰p”
+	    if(SkkConfig::config().useEisuuToSetHenkanPoint()) {
+		handled = BIMHandleInput(inSessionHandle, SkkConfig::config().setHenkanPointKey());
+	    } else {
+		handled = true;
 	    }
 	}
-	else if (keyCode == 0x68) { // ‚©‚È
-	    if (SkkConfig::config().useKanaToSetHenkanPoint()) {
-			handled = BIMHandleInput(inSessionHandle, SkkConfig::config().setHenkanPointKey());
-	    }
-	    else {
-			handled = BIMHandleInput(inSessionHandle, SkkConfig::config().kanaModeKey());
+	else if(keyCode == 0x68) { // ‚©‚È
+	    if(SkkConfig::config().useKanaToSetHenkanPoint()) {
+		handled = BIMHandleInput(inSessionHandle, SkkConfig::config().setHenkanPointKey());
+	    } else {
+		handled = BIMHandleInput(inSessionHandle, SkkConfig::config().kanaModeKey());
 	    }
-	}
-	else {
+	} else {
 	    handled = BIMHandleInput(inSessionHandle,charCode);
 	}
     }
@@ -342,26 +335,24 @@
 }
 
 // TSM‚©‚çŠm’èŽwŽ¦‚ðŽó‚¯‚½
-ComponentResult BIMSessionFix( BIMSessionHandle inSessionHandle ) {
+ComponentResult BIMSessionFix(BIMSessionHandle inSessionHandle) {
     ComponentResult result = 0;
 
-    if (!(*inSessionHandle)->terminate_disabled) {
+    if(!(*inSessionHandle)->terminate_disabled) {
 	(*inSessionHandle)->imsession_input_mode->terminate();
     }
-    
-    if( ( *inSessionHandle )->fInputBufferCount ) {
-        result = BIMUpdateActiveInputArea( inSessionHandle, TRUE );
-        ( *inSessionHandle )->fLastUpdateLength = 0;
-        ( *inSessionHandle )->fInputBufferCount = 0;
+
+    if((*inSessionHandle)->fInputBufferCount) {
+        result = BIMUpdateActiveInputArea(inSessionHandle, TRUE);
+        (*inSessionHandle)->fLastUpdateLength = 0;
+        (*inSessionHandle)->fInputBufferCount = 0;
     }
     return result;
 }
 
 // ƒpƒŒƒbƒg‚ð‰B‚·
-ComponentResult BIMSessionHidePalettes(BIMSessionHandle inSessionHandle)
-{
-    ServerConnectionFactory::theInstance().newConnection().send(
-	kBasicMessageHidePalettes);
+ComponentResult BIMSessionHidePalettes(BIMSessionHandle inSessionHandle) {
+    ServerConnectionFactory::theInstance().newConnection().send(kBasicMessageHidePalettes);
 
     return 0;
 }
@@ -374,10 +365,10 @@
 }
 
 // •¶Žš‚Ì“ü—͂ɑ΂µ‚Ă̏ˆ—B
-Boolean BIMHandleInput( BIMSessionHandle inSessionHandle, unsigned char inCharCode ) {
+Boolean BIMHandleInput(BIMSessionHandle inSessionHandle, unsigned char inCharCode) {
     Boolean handled = FALSE;
     
-    switch( inCharCode ) {
+    switch(inCharCode) {
     case 0: // ‚±‚̃L[‚Í–³Œø
 	handled = TRUE;
 	break;
@@ -392,9 +383,9 @@
 	break;
 	
     default:
-	if (inCharCode >= 0x1c && inCharCode <= 0x1f) { // –îˆó
+	if(inCharCode >= 0x1c && inCharCode <= 0x1f) { // –îˆó
 	    int kind = InputMode::ARROW_LEFT;
-	    switch (inCharCode) {
+	    switch(inCharCode) {
 	    case 0x1c: kind = InputMode::ARROW_LEFT; break;
 	    case 0x1e: kind = InputMode::ARROW_UP; break;
 	    case 0x1d: kind = InputMode::ARROW_RIGHT; break;
@@ -402,63 +393,57 @@
 	    }
 	    handled = (*inSessionHandle)->imsession_input_mode->handleArrow(kind);
 	}
-	else if (SkkConfig::config().isCancelKey(inCharCode)) {
+	else if(SkkConfig::config().isCancelKey(inCharCode)) {
 	    handled = (*inSessionHandle)->imsession_input_mode->handleCg();
 	}
-	else if (SkkConfig::config().isPasteKey(inCharCode)) {
+	else if(SkkConfig::config().isPasteKey(inCharCode)) {
 	    handled = (*inSessionHandle)->imsession_input_mode->handleCy();
 	}
-	else if (inCharCode == '\t') { // Tab
+	else if(inCharCode == '\t') { // Tab
 	    handled = (*inSessionHandle)->imsession_input_mode->handleTab();
 	}
-	else if ((inCharCode >= 0x20 && inCharCode <= 0x7e) // ƒAƒXƒL[‰p”Žš‹L†‚͈̔Í
-		 || SkkConfig::config().isMappedKey(inCharCode)) {
+	else if((inCharCode >= 0x20 && inCharCode <= 0x7e) // ƒAƒXƒL[‰p”Žš‹L†‚͈̔Í
+		|| SkkConfig::config().isMappedKey(inCharCode)) {
 	    handled = (*inSessionHandle)->imsession_input_mode->handleInput(inCharCode);
 	}
 	break;
     }
     
     //ƒoƒbƒtƒ@‚Ì’l‚ª0‚È‚ç‹­§“I‚Ƀtƒ[ƒeƒBƒ“ƒOƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚é
-    if( ( *inSessionHandle )->fInputBufferCount == 0 ){
-        BIMHandleHideWindow( inSessionHandle );
+    if((*inSessionHandle)->fInputBufferCount == 0) {
+        BIMHandleHideWindow(inSessionHandle);
     }
     
     return handled;
 }
 
 // ‰”•Mƒƒjƒ…[‚̃Cƒxƒ“ƒgƒnƒ“ƒhƒ‰
-static pascal OSStatus BIMPencilMenuEventHandler( EventHandlerCallRef inEventHandlerCallRef,
-						  EventRef inEventRef, void *inUserData ) {
+static pascal OSStatus BIMPencilMenuEventHandler(EventHandlerCallRef inEventHandlerCallRef,
+						 EventRef inEventRef, void* inUserData) {
     OSStatus result;
     HICommand command;
     
-    result = GetEventParameter( inEventRef, kEventParamDirectObject, typeHICommand, nil,
-                               sizeof( command ), nil, &command);
-    if( result == noErr ) {
-	switch( command.commandID ) {
+    result = GetEventParameter(inEventRef, kEventParamDirectObject, typeHICommand, nil, sizeof(command), nil, &command);
+    if(result == noErr) {
+	switch(command.commandID) {
 	case kAboutSKKMenuCommand:
-	    ServerConnectionFactory::theInstance().newConnection().send(
-		kSKKShowAboutBox);
+	    ServerConnectionFactory::theInstance().newConnection().send(kSKKShowAboutBox);
 	    break;
 	    
 	case kPreferencesMenuCommand:
-	    ServerConnectionFactory::theInstance().newConnection().send(
-		kSKKShowPreferencesBox);
+	    ServerConnectionFactory::theInstance().newConnection().send(kSKKShowPreferencesBox);
 	    break;
             
 	case kRegisterWordMenuCommand:
-	    ServerConnectionFactory::theInstance().newConnection().send(
-		kSKKShowWordRegistrationBox);
+	    ServerConnectionFactory::theInstance().newConnection().send(kSKKShowWordRegistrationBox);
 	    break;
             
 	default:
-	    BIMLog("unknown menu event[%d], index[%d]\n",
-		   command.commandID, command.menu.menuItemIndex);
+	    BIMLog("unknown menu event[%d], index[%d]\n", command.commandID, command.menu.menuItemIndex);
 	    result = eventNotHandledErr;
 	    break;
         }
-    }
-    else {
+    } else {
 	result = eventNotHandledErr;
     }
     return result;
Index: AquaSKK/ChangeLog
diff -u AquaSKK/ChangeLog:1.15 AquaSKK/ChangeLog:1.16
--- AquaSKK/ChangeLog:1.15	Tue Nov 15 00:37:13 2005
+++ AquaSKK/ChangeLog	Sun Dec  4 12:42:24 2005
@@ -1,3 +1,9 @@
+2005-12-04  Tomotaka SUWA  <t.suw****@mac*****>
+
+	* BIM.cpp (BIMSessionOpen): “ú–{ŒêƒXƒNƒŠƒvƒg‚ð—LŒø‚É‚·‚é‚悤‚ɏC³B
+	ˆÈ‘O BIMSessionActivate ‚É‚ ‚Á‚½ SetScriptVariable ‚ª‚±‚±‚Ɉړ®‚µ
+	‚Ä•œŠˆB‚»‚Ì‘¼Acosmetic ‚ȕύXB
+
 2005-11-15  Tomotaka SUWA  <t.suw****@mac*****>
 
 	* SKKDictionary.cpp (SKKUserDictionary::registerOkuriAri,


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