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); // ZbVÇpÌ[eBeBNX 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ðú»µAMj [ð\z·éB -ComponentResult BIMInitialize( ComponentInstance inComponentInstance, - MenuRef *outTextServiceMenu ) { +ComponentResult BIMInitialize(ComponentInstance inComponentInstance, MenuRef *outTextServiceMenu) { ComponentResult result; short refNum; EventTypeSpec menuEventSpec; @@ -186,9 +187,8 @@ // Mj [ÌCxgnhðCXg[·é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); // bZ[WóM@\ðú» ClientMessageReceiver::start(kAquaSKKClientRunLoopMode); @@ -200,7 +200,7 @@ // ÅãÌCX^Xªjü³êéÉÄÎêéB -void BIMTerminate( ComponentInstance inComponentInstance ) { +void BIMTerminate(ComponentInstance inComponentInstance) { CFRelease(gPencilMenu); gPencilMenu = NULL; } @@ -208,31 +208,33 @@ #pragma mark - // V½ÉZbVðJnB -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); + + // ú{êXNvgðLøÉ·é + long keyboardID = GetScriptVariable(smCurrentScript, smScriptKeys); + SetScriptVariable(smJapanese, smScriptKeys, keyboardID); + KeyScript(smJapanese); + } else { + result = memFullErr; + } + // Cvbgobt@ðú» - if( result == noErr ) { - ( **outSessionHandle )->fInputBuffer = (UniCharPtr) NewPtr( 1024 ); + if(result == noErr) { + (**outSessionHandle)->fInputBuffer = (UniCharPtr)NewPtr(1024); result = MemError(); } @@ -240,25 +242,24 @@ } // ZbVð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 ); } } // ZbVªANeBuÉÈéB -ComponentResult BIMSessionActivate( BIMSessionHandle inSessionHandle ) { +ComponentResult BIMSessionActivate(BIMSessionHandle inSessionHandle) { ActiveSession::theInstance().Add((CFIndex)inSessionHandle); // ANeBuÉÈÁ½ðIÉ`¦éB - ServerConnectionFactory::theInstance().newConnection().send( - kBasicMessageActivated); + ServerConnectionFactory::theInstance().newConnection().send(kBasicMessageActivated); // Ýèð[h ClientConfiguration::theInstance().reloadConfiguration(); @@ -267,74 +268,66 @@ } // ZbVªANeBuÅÈÈéB -ComponentResult BIMSessionDeactivate( BIMSessionHandle inSessionHandle ) { +ComponentResult BIMSessionDeactivate(BIMSessionHandle inSessionHandle) { ActiveSession::theInstance().Remove((CFIndex)inSessionHandle); // ANeBuÅÈÈÁ½ðIÉ`¦éB if(ActiveSession::theInstance().Count() == 0) { - ServerConnectionFactory::theInstance().newConnection().send( - kBasicMessageDeactivated); + ServerConnectionFactory::theInstance().newConnection().send(kBasicMessageDeactivated); } return 0; } // R|[lgÌCxgð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 ); - - // LN^R[hðæ¾ - GetEventParameter( inEventRef, kEventParamKeyMacCharCodes, typeChar, nil, - sizeof( charCode ), nil, &charCode ); - - // fBt@CAÌóÔðæ¾ - GetEventParameter( inEventRef, kEventParamKeyModifiers, typeUInt32, nil, - sizeof( modifiers ), nil, &modifiers ); - + + // L[R[hðæ¾ + GetEventParameter(inEventRef, kEventParamKeyCode, typeUInt32, nil, sizeof(keyCode), nil, &keyCode); + + // LN^R[hðæ¾ + GetEventParameter(inEventRef, kEventParamKeyMacCharCodes, typeChar, nil, sizeof(charCode), nil, &charCode); + + // fBt@CAÌóÔðæ¾ + 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}hL[ª³êÄ¢½B + if(modifiers & (1 << cmdKeyBit)) { // R}hL[ª³êÄ¢½B handled = false; } - else if (SkkConfig::config().isNumericKeypad(keyCode) //¼peL[üÍ - && ClientConfiguration::theInstance().isNumericKeypad_HalfWidth()) { + else if(SkkConfig::config().isNumericKeypad(keyCode) //¼peL[üÍ + && 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; } // pbgð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) // AXL[pLÌÍÍ - || SkkConfig::config().isMappedKey(inCharCode)) { + else if((inCharCode >= 0x20 && inCharCode <= 0x7e) // AXL[pLÌÍÍ + || SkkConfig::config().isMappedKey(inCharCode)) { handled = (*inSessionHandle)->imsession_input_mode->handleInput(inCharCode); } break; } //obt@Ìlª0Èç§IÉt[eBOEBhEð¶é - if( ( *inSessionHandle )->fInputBufferCount == 0 ){ - BIMHandleHideWindow( inSessionHandle ); + if((*inSessionHandle)->fInputBufferCount == 0) { + BIMHandleHideWindow(inSessionHandle); } return handled; } // Mj [ÌCxgnh -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): ú{êXNvgðLøÉ·éæ¤ÉC³B + ÈO BIMSessionActivate É Á½ SetScriptVariable ª±±ÉÚ®µ + ÄB»Ì¼Acosmetic ÈÏXB + 2005-11-15 Tomotaka SUWA <t.suw****@mac*****> * SKKDictionary.cpp (SKKUserDictionary::registerOkuriAri,