Skip to content

Commit

Permalink
Correct Array 40 input logic and options
Browse files Browse the repository at this point in the history
  • Loading branch information
jrywu committed Feb 28, 2022
1 parent 0a89e4d commit 9e2bd96
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 99 deletions.
6 changes: 3 additions & 3 deletions BuildInfo.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#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
#define BUILD_MONTH 02
#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"
6 changes: 4 additions & 2 deletions CandidateHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
}

Expand Down Expand Up @@ -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);
}
Expand Down
Binary file modified DIME.rc
Binary file not shown.
3 changes: 2 additions & 1 deletion KeyHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 33 additions & 16 deletions KeyProcesser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

//+---------------------------------------------------------------------------
Expand All @@ -264,26 +275,30 @@ 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])
{
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;
Expand Down Expand Up @@ -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;
}
Expand Down
148 changes: 74 additions & 74 deletions SetupCompositionProcesseorEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Tables/array40-DIME-big5.cin
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
%ename Array40
%cname 行列40
%encoding UTF-8
%endkey '[]-="{}_+
%selkey '[]-="{}_+
%endkey '[]-="{}_
%selkey '[]-="{}_
%keyname begin
1 1T
q 1^
Expand Down Expand Up @@ -74,6 +74,8 @@ l 9-
p 0^
; 0-
/ 0v
? ?
* *
%keyname end
%chardef begin
a 一
Expand Down
Binary file modified installer/Array40.cin
Binary file not shown.

0 comments on commit 9e2bd96

Please sign in to comment.