diff --git a/BuildInfo.h b/BuildInfo.h index 01830e0..0be6408 100644 --- a/BuildInfo.h +++ b/BuildInfo.h @@ -1,6 +1,6 @@ #define BUILD_VER_MAJOR 1 #define BUILD_VER_MINOR 2 -#define BUILD_COMMIT_COUNT 297 +#define BUILD_COMMIT_COUNT 298 #define BUILD_YEAR_4 2022 #define BUILD_YEAR_2 22 #define BUILD_YEAR_1 22 @@ -8,5 +8,5 @@ #define BUILD_DAY 28 #define BUILD_DATE_1 220228 #define BUILD_DATE_4 20220228 -#define BUILD_VERSION 1.2.297.220228 -#define BUILD_VERSION_STR "1.2.297.220228" +#define BUILD_VERSION 1.2.298.220228 +#define BUILD_VERSION_STR "1.2.298.220228" diff --git a/CandidateHandler.cpp b/CandidateHandler.cpp index c86e041..d708c2d 100644 --- a/CandidateHandler.cpp +++ b/CandidateHandler.cpp @@ -59,7 +59,8 @@ HRESULT CDIME::_HandleCandidateWorker(TfEditCookie ec, _In_ ITfContext *pContext candidateLen = _pUIPresenter->_GetSelectedCandidateString(&pCandidateString); - if (Global::imeMode == IME_MODE_ARRAY)// check if the _strokebuffer is array special code + if (Global::imeMode == IME_MODE_ARRAY && CConfig::GetArrayScope() != ARRAY40_BIG5) + // check if the _strokebuffer is array special code { if(_pCompositionProcessorEngine->CollectWordFromArraySpeicalCode(&pCandidateString)) @@ -134,7 +135,8 @@ HRESULT CDIME::_HandleCandidateWorker(TfEditCookie ec, _In_ ITfContext *pContext } //-----------------do array spcial code notify. We should not show notify in UI-less mode, thus cancel forceSP mode in UILess Mode--- BOOL ArraySPFound = FALSE; - if(Global::imeMode == IME_MODE_ARRAY && !_IsUILessMode() && !arrayUsingSPCode && (CConfig::GetArrayForceSP() || CConfig::GetArrayNotifySP())) + if(Global::imeMode == IME_MODE_ARRAY && CConfig::GetArrayScope() != ARRAY40_BIG5 && + !_IsUILessMode() && !arrayUsingSPCode && (CConfig::GetArrayForceSP() || CConfig::GetArrayNotifySP())) { CStringRange specialCode; CStringRange notifyText; diff --git a/Config.cpp b/Config.cpp index c079e32..e60e1c4 100644 --- a/Config.cpp +++ b/Config.cpp @@ -229,9 +229,15 @@ INT_PTR CALLBACK CConfig::CommonPropertyPageWndProc(HWND hDlg, UINT message, WPA { ShowWindow(GetDlgItem(hDlg, IDC_EDIT_MAXWIDTH), SW_HIDE); ShowWindow(GetDlgItem(hDlg, IDC_STATIC_EDIT_MAXWIDTH), SW_HIDE); - ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_AUTOCOMPOSE), SW_HIDE); if (_arrayScope == ARRAY40_BIG5) + { ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_ARRAY_SINGLEQUOTE_CUSTOM_PHRASE), SW_HIDE); + ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_ARRAY_FORCESP), SW_HIDE); + ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_ARRAY_NOTIFYSP), SW_HIDE); + } + else + ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_AUTOCOMPOSE), SW_HIDE); + } } @@ -560,6 +566,12 @@ INT_PTR CALLBACK CConfig::CommonPropertyPageWndProc(HWND hDlg, UINT message, WPA _arrayScope = (ARRAY_SCOPE)SendMessage(hwnd, CB_GETCURSEL, 0, 0); ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_ARRAY_SINGLEQUOTE_CUSTOM_PHRASE), (_arrayScope == ARRAY40_BIG5)?SW_HIDE:SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_ARRAY_FORCESP), + (_arrayScope == ARRAY40_BIG5) ? SW_HIDE : SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_ARRAY_NOTIFYSP), + (_arrayScope == ARRAY40_BIG5) ? SW_HIDE : SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDC_CHECKBOX_AUTOCOMPOSE), + (_arrayScope == ARRAY40_BIG5) ? SW_SHOW : SW_HIDE); debugPrint(L"selected arrray scope item is %d", _arrayScope); } diff --git a/DIME.rc b/DIME.rc index 65e9690..03e8ad1 100644 Binary files a/DIME.rc and b/DIME.rc differ diff --git a/KeyHandler.cpp b/KeyHandler.cpp index e316c58..fee4b08 100644 --- a/KeyHandler.cpp +++ b/KeyHandler.cpp @@ -186,7 +186,8 @@ HRESULT CDIME::_HandleCompositionInputWorker(_In_ CCompositionProcessorEngine *p // Get candidate string from composition processor engine // BOOL symbolMode = pCompositionProcessorEngine->IsSymbol(); - BOOL autoComposeMode = CConfig::GetAutoCompose(); + BOOL autoComposeMode = CConfig::GetAutoCompose() || + (Global::imeMode == IME_MODE_ARRAY && CConfig::GetArrayScope() != ARRAY40_BIG5); if (autoComposeMode // auto composing mode: show candidates while composition updated imeediately. || (Global::imeMode == IME_MODE_PHONETIC && _pCompositionProcessorEngine->isPhoneticComposingKey()) || symbolMode) // fetch candidate in symobl mode with composition started with '='(DAYI) or 'W' (Array) diff --git a/KeyProcesser.cpp b/KeyProcesser.cpp index 6810c62..5867d57 100644 --- a/KeyProcesser.cpp +++ b/KeyProcesser.cpp @@ -245,16 +245,27 @@ UINT CCompositionProcessorEngine::removeLastPhoneticSymbol() //---------------------------------------------------------------------------- BOOL CCompositionProcessorEngine::IsSymbol() { - if (_keystrokeBuffer.Get() == nullptr) return FALSE; - if (Global::imeMode == IME_MODE_DAYI) - return (_keystrokeBuffer.GetLength() < 3 && *_keystrokeBuffer.Get() == L'='); + if (_keystrokeBuffer.Get() == nullptr) + return FALSE; + + WCHAR c = *_keystrokeBuffer.Get(); + UINT len = (UINT) _keystrokeBuffer.GetLength(); - else if (Global::imeMode == IME_MODE_ARRAY) - return (_keystrokeBuffer.GetLength() == 2 && towupper(*_keystrokeBuffer.Get()) == L'W' - && *(_keystrokeBuffer.Get() + 1) <= L'9' && *(_keystrokeBuffer.Get() + 1) >= L'0'); + if (Global::imeMode == IME_MODE_DAYI && (len < 3 && c == L'=')) + return TRUE; + + if (Global::imeMode == IME_MODE_ARRAY && len==2) + { + WCHAR c2 = *(_keystrokeBuffer.Get() + 1); + if (CConfig::GetArrayScope() != ARRAY40_BIG5 && towupper(c) == L'W' && c2 <= L'9' && c2 >= L'0') + return TRUE; + if (CConfig::GetArrayScope() == ARRAY40_BIG5 + && (towupper(c) == L'H' || c == L'8') && (c2 == L'\'' || c2 == L'[' || c2 == L']' || c2 == L'-' || c2 == L'=')) + return TRUE; - else - return FALSE; + } + + return FALSE; } //+--------------------------------------------------------------------------- @@ -264,7 +275,9 @@ BOOL CCompositionProcessorEngine::IsSymbol() //---------------------------------------------------------------------------- BOOL CCompositionProcessorEngine::IsSymbolChar(WCHAR wch) { - if (_keystrokeBuffer.Get() == nullptr) return FALSE; + if (_keystrokeBuffer.Get() == nullptr) + return FALSE; + if ((_keystrokeBuffer.GetLength() == 1) && (*_keystrokeBuffer.Get() == L'=') && Global::imeMode == IME_MODE_DAYI && _pTableDictionaryEngine[IME_MODE_DAYI]) @@ -272,18 +285,20 @@ BOOL CCompositionProcessorEngine::IsSymbolChar(WCHAR wch) for (UINT i = 0; i < wcslen(Global::DayiSymbolCharTable); i++) { if (Global::DayiSymbolCharTable[i] == wch) - { return TRUE; - } } } - if ((_keystrokeBuffer.GetLength() == 1) && (towupper(*_keystrokeBuffer.Get()) == L'W') && Global::imeMode == IME_MODE_ARRAY) + if ((_keystrokeBuffer.GetLength() == 1) && Global::imeMode == IME_MODE_ARRAY) { - if (wch >= L'0' && wch <= L'9') - { + WCHAR c = *_keystrokeBuffer.Get(); + if( CConfig::GetArrayScope() != ARRAY40_BIG5 && (towupper(c)== L'W') && + (wch >= L'0' && wch <= L'9') ) + return TRUE; + if (CConfig::GetArrayScope() == ARRAY40_BIG5 + && (towupper(c) == L'H' || c == L'8') && + (wch == L'\'' || wch == L'[' || wch == L']' || wch == L'-' || wch == L'=') ) return TRUE; - } } return FALSE; @@ -318,7 +333,9 @@ BOOL CCompositionProcessorEngine::IsDayiAddressChar(WCHAR wch) //---------------------------------------------------------------------------- BOOL CCompositionProcessorEngine::IsArrayShortCode() { - if (Global::imeMode == IME_MODE_ARRAY && _keystrokeBuffer.GetLength() < 3) return TRUE; + if (Global::imeMode == IME_MODE_ARRAY && CConfig::GetArrayScope()!=ARRAY40_BIG5 && + _keystrokeBuffer.GetLength() < 3) + return TRUE; else return FALSE; } diff --git a/SetupCompositionProcesseorEngine.cpp b/SetupCompositionProcesseorEngine.cpp index a418f96..9615b83 100644 --- a/SetupCompositionProcesseorEngine.cpp +++ b/SetupCompositionProcesseorEngine.cpp @@ -1032,94 +1032,94 @@ BOOL CCompositionProcessorEngine::SetupDictionaryFile(IME_MODE imeMode) _pArrayPhraseTableDictionaryEngine->ParseConfig(imeMode); // parse config to reload dictionary } } - } - //Special - StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszAppData, L"\\DIME\\Array-special.cin"); - StringCchPrintf(pwszCINFileNameProgramFiles, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-special.cin"); + //Special + StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszAppData, L"\\DIME\\Array-special.cin"); + StringCchPrintf(pwszCINFileNameProgramFiles, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-special.cin"); - wstatFailed = TRUE; updated = TRUE; - if (PathFileExists(pwszCINFileNameProgramFiles)) - _wstat(pwszCINFileNameProgramFiles, &programFilesTimeStamp); - if (PathFileExists(pwszCINFileName)) - wstatFailed = _wstat(pwszCINFileName, &appDataTimeStamp) == -1; - updated = difftime(programFilesTimeStamp.st_mtime, appDataTimeStamp.st_mtime) > 0; - if (!PathFileExists(pwszCINFileName) || (!wstatFailed && updated)) - CopyFile(pwszCINFileNameProgramFiles, pwszCINFileName, FALSE); + wstatFailed = TRUE; updated = TRUE; + if (PathFileExists(pwszCINFileNameProgramFiles)) + _wstat(pwszCINFileNameProgramFiles, &programFilesTimeStamp); + if (PathFileExists(pwszCINFileName)) + wstatFailed = _wstat(pwszCINFileName, &appDataTimeStamp) == -1; + updated = difftime(programFilesTimeStamp.st_mtime, appDataTimeStamp.st_mtime) > 0; + if (!PathFileExists(pwszCINFileName) || (!wstatFailed && updated)) + CopyFile(pwszCINFileNameProgramFiles, pwszCINFileName, FALSE); - if (!PathFileExists(pwszCINFileName)) //failed back to preload array-special.cin in program files. - StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-special.cin"); - else if (_pArraySpecialCodeDictionaryFile && _pTextService && - CompareString(_pTextService->GetLocale(), NORM_IGNORECASE, pwszCINFileName, -1, _pArraySpecialCodeDictionaryFile->GetFileName(), -1) != CSTR_EQUAL) - { //indicate the prevoius table is built with system preload file in program files, and now user provides their own. - delete _pArraySpecialCodeDictionaryFile; - _pArraySpecialCodeDictionaryFile = nullptr; - } + if (!PathFileExists(pwszCINFileName)) //failed back to preload array-special.cin in program files. + StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-special.cin"); + else if (_pArraySpecialCodeDictionaryFile && _pTextService && + CompareString(_pTextService->GetLocale(), NORM_IGNORECASE, pwszCINFileName, -1, _pArraySpecialCodeDictionaryFile->GetFileName(), -1) != CSTR_EQUAL) + { //indicate the prevoius table is built with system preload file in program files, and now user provides their own. + delete _pArraySpecialCodeDictionaryFile; + _pArraySpecialCodeDictionaryFile = nullptr; + } - if (PathFileExists(pwszCINFileName)) - { - if (_pArraySpecialCodeDictionaryFile == nullptr) + if (PathFileExists(pwszCINFileName)) { - _pArraySpecialCodeDictionaryFile = new (std::nothrow) CFile(); - if (_pArraySpecialCodeDictionaryFile && _pTextService && - _pArraySpecialCodeDictionaryFile->CreateFile(pwszCINFileName, GENERIC_READ, OPEN_EXISTING, FILE_SHARE_READ)) + if (_pArraySpecialCodeDictionaryFile == nullptr) { - if (_pArraySpecialCodeTableDictionaryEngine) - _pArraySpecialCodeTableDictionaryEngine; - _pArraySpecialCodeTableDictionaryEngine = - new (std::nothrow) CTableDictionaryEngine(_pTextService->GetLocale(), _pArraySpecialCodeDictionaryFile, CIN_DICTIONARY); //cin files use tab as delimiter - if (_pArraySpecialCodeTableDictionaryEngine) - _pArraySpecialCodeTableDictionaryEngine->ParseConfig(imeMode); // to release the file handle + _pArraySpecialCodeDictionaryFile = new (std::nothrow) CFile(); + if (_pArraySpecialCodeDictionaryFile && _pTextService && + _pArraySpecialCodeDictionaryFile->CreateFile(pwszCINFileName, GENERIC_READ, OPEN_EXISTING, FILE_SHARE_READ)) + { + if (_pArraySpecialCodeTableDictionaryEngine) + _pArraySpecialCodeTableDictionaryEngine; + _pArraySpecialCodeTableDictionaryEngine = + new (std::nothrow) CTableDictionaryEngine(_pTextService->GetLocale(), _pArraySpecialCodeDictionaryFile, CIN_DICTIONARY); //cin files use tab as delimiter + if (_pArraySpecialCodeTableDictionaryEngine) + _pArraySpecialCodeTableDictionaryEngine->ParseConfig(imeMode); // to release the file handle + } + } + else if (_pArraySpecialCodeTableDictionaryEngine && _pArraySpecialCodeDictionaryFile->IsFileUpdated()) + { + _pArraySpecialCodeTableDictionaryEngine->ParseConfig(imeMode); // parse config to reload dictionary } } - else if (_pArraySpecialCodeTableDictionaryEngine && _pArraySpecialCodeDictionaryFile->IsFileUpdated()) - { - _pArraySpecialCodeTableDictionaryEngine->ParseConfig(imeMode); // parse config to reload dictionary - } - } + //Short-code + StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszAppData, L"\\DIME\\Array-shortcode.cin"); + StringCchPrintf(pwszCINFileNameProgramFiles, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-shortcode.cin"); - //Short-code - StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszAppData, L"\\DIME\\Array-shortcode.cin"); - StringCchPrintf(pwszCINFileNameProgramFiles, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-shortcode.cin"); - - wstatFailed = TRUE; updated = TRUE; - if (PathFileExists(pwszCINFileNameProgramFiles)) - _wstat(pwszCINFileNameProgramFiles, &programFilesTimeStamp); - if (PathFileExists(pwszCINFileName)) - wstatFailed = _wstat(pwszCINFileName, &appDataTimeStamp) == -1; - updated = difftime(programFilesTimeStamp.st_mtime, appDataTimeStamp.st_mtime) > 0; - if (!PathFileExists(pwszCINFileName) || (!wstatFailed && updated)) - CopyFile(pwszCINFileNameProgramFiles, pwszCINFileName, FALSE); + wstatFailed = TRUE; updated = TRUE; + if (PathFileExists(pwszCINFileNameProgramFiles)) + _wstat(pwszCINFileNameProgramFiles, &programFilesTimeStamp); + if (PathFileExists(pwszCINFileName)) + wstatFailed = _wstat(pwszCINFileName, &appDataTimeStamp) == -1; + updated = difftime(programFilesTimeStamp.st_mtime, appDataTimeStamp.st_mtime) > 0; + if (!PathFileExists(pwszCINFileName) || (!wstatFailed && updated)) + CopyFile(pwszCINFileNameProgramFiles, pwszCINFileName, FALSE); - if (!PathFileExists(pwszCINFileName)) //failed back to preload array-shortcode.cin in program files. - StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-shortcode.cin"); - else if (_pArrayShortCodeDictionaryFile && _pTextService && - CompareString(_pTextService->GetLocale(), NORM_IGNORECASE, pwszCINFileName, -1, _pArrayShortCodeDictionaryFile->GetFileName(), -1) != CSTR_EQUAL) - { //indicate the prevoius table is built with system preload file in program files, and now user provides their own. - delete _pArrayShortCodeDictionaryFile; - _pArrayShortCodeDictionaryFile = nullptr; - } - if (PathFileExists(pwszCINFileName)) - { - if (_pArrayShortCodeDictionaryFile == nullptr) + if (!PathFileExists(pwszCINFileName)) //failed back to preload array-shortcode.cin in program files. + StringCchPrintf(pwszCINFileName, MAX_PATH, L"%s%s", pwszProgramFiles, L"\\DIME\\Array-shortcode.cin"); + else if (_pArrayShortCodeDictionaryFile && _pTextService && + CompareString(_pTextService->GetLocale(), NORM_IGNORECASE, pwszCINFileName, -1, _pArrayShortCodeDictionaryFile->GetFileName(), -1) != CSTR_EQUAL) + { //indicate the prevoius table is built with system preload file in program files, and now user provides their own. + delete _pArrayShortCodeDictionaryFile; + _pArrayShortCodeDictionaryFile = nullptr; + } + if (PathFileExists(pwszCINFileName)) { - _pArrayShortCodeDictionaryFile = new (std::nothrow) CFile(); - if (_pArrayShortCodeDictionaryFile && _pTextService && - _pArrayShortCodeDictionaryFile->CreateFile(pwszCINFileName, GENERIC_READ, OPEN_EXISTING, FILE_SHARE_READ)) + if (_pArrayShortCodeDictionaryFile == nullptr) + { + _pArrayShortCodeDictionaryFile = new (std::nothrow) CFile(); + if (_pArrayShortCodeDictionaryFile && _pTextService && + _pArrayShortCodeDictionaryFile->CreateFile(pwszCINFileName, GENERIC_READ, OPEN_EXISTING, FILE_SHARE_READ)) + { + if (_pArrayShortCodeTableDictionaryEngine) + delete _pArrayShortCodeTableDictionaryEngine; + _pArrayShortCodeTableDictionaryEngine = + new (std::nothrow) CTableDictionaryEngine(_pTextService->GetLocale(), _pArrayShortCodeDictionaryFile, CIN_DICTIONARY); //cin files use tab as delimiter + if (_pArrayShortCodeTableDictionaryEngine) + _pArrayShortCodeTableDictionaryEngine->ParseConfig(imeMode);// to release the file handle + } + } + else if (_pArrayShortCodeTableDictionaryEngine && _pArrayShortCodeDictionaryFile->IsFileUpdated()) { - if (_pArrayShortCodeTableDictionaryEngine) - delete _pArrayShortCodeTableDictionaryEngine; - _pArrayShortCodeTableDictionaryEngine = - new (std::nothrow) CTableDictionaryEngine(_pTextService->GetLocale(), _pArrayShortCodeDictionaryFile, CIN_DICTIONARY); //cin files use tab as delimiter - if (_pArrayShortCodeTableDictionaryEngine) - _pArrayShortCodeTableDictionaryEngine->ParseConfig(imeMode);// to release the file handle + _pArrayShortCodeTableDictionaryEngine->ParseConfig(imeMode); // parse config to reload dictionary } } - else if (_pArrayShortCodeTableDictionaryEngine && _pArrayShortCodeDictionaryFile->IsFileUpdated()) - { - _pArrayShortCodeTableDictionaryEngine->ParseConfig(imeMode); // parse config to reload dictionary - } } - + + } // now load Dayi custom table diff --git a/Tables/array40-DIME-big5.cin b/Tables/array40-DIME-big5.cin index 46bc5f1..241c816 100644 --- a/Tables/array40-DIME-big5.cin +++ b/Tables/array40-DIME-big5.cin @@ -31,8 +31,8 @@ %ename Array40 %cname 行列40 %encoding UTF-8 -%endkey '[]-="{}_+ -%selkey '[]-="{}_+ +%endkey '[]-="{}_ +%selkey '[]-="{}_ %keyname begin 1 1T q 1^ @@ -74,6 +74,8 @@ l 9- p 0^ ; 0- / 0v +? ? +* * %keyname end %chardef begin a 一 diff --git a/installer/Array40.cin b/installer/Array40.cin index 70f5b2b..4725c7e 100644 Binary files a/installer/Array40.cin and b/installer/Array40.cin differ