From 7a2502bfdc859c553b1c64708cb322bfdd4271aa Mon Sep 17 00:00:00 2001 From: fxliang Date: Mon, 10 Jul 2023 16:30:22 +0800 Subject: [PATCH 01/13] Composition.cpp: TF_ANCHOR_START when not inline_preedit --- WeaselTSF/Composition.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WeaselTSF/Composition.cpp b/WeaselTSF/Composition.cpp index 3fd40ffd3..8fe747e4a 100644 --- a/WeaselTSF/Composition.cpp +++ b/WeaselTSF/Composition.cpp @@ -54,7 +54,10 @@ STDAPI CStartCompositionEditSession::DoEditSession(TfEditCookie ec) /* set selection */ TF_SELECTION tfSelection; - pRangeComposition->Collapse(ec, TF_ANCHOR_END); + if(_inlinePreeditEnabled) + pRangeComposition->Collapse(ec, TF_ANCHOR_END); + else + pRangeComposition->Collapse(ec, TF_ANCHOR_START); tfSelection.range = pRangeComposition; tfSelection.style.ase = TF_AE_NONE; tfSelection.style.fInterimChar = FALSE; From 3f539cc91f63f8ccb86b25b76773c299118a513e Mon Sep 17 00:00:00 2001 From: fxliang Date: Thu, 13 Jul 2023 18:48:37 +0800 Subject: [PATCH 02/13] feat: WeaselSetup to change user data dir and rerun the server, if installed. --- WeaselSetup/InstallOptionsDlg.cpp | 10 +++++++++ WeaselSetup/InstallOptionsDlg.h | 2 ++ WeaselSetup/WeaselSetup.cpp | 34 +++++++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/WeaselSetup/InstallOptionsDlg.cpp b/WeaselSetup/InstallOptionsDlg.cpp index 8df48611f..b6b45034b 100644 --- a/WeaselSetup/InstallOptionsDlg.cpp +++ b/WeaselSetup/InstallOptionsDlg.cpp @@ -32,6 +32,14 @@ LRESULT InstallOptionsDialog::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { remove_.EnableWindow(installed); dir_.EnableWindow(user_dir.empty() ? FALSE : TRUE); + ok_.Attach(GetDlgItem(IDOK)); + if (installed) + ok_.SetWindowTextW(L"\u4fee\u6539\u8cc7\u6599\u593e"); + + ime_.Attach(GetDlgItem(IDC_CHECK_INSTIME)); + if (installed) + ime_.EnableWindow(FALSE); + CenterWindow(); return 0; } @@ -60,6 +68,8 @@ LRESULT InstallOptionsDialog::OnRemove(WORD, WORD code, HWND, BOOL&) { const bool non_silent = false; uninstall(non_silent); installed = false; + ime_.EnableWindow(!installed); + ok_.SetWindowTextW(L"\u5b89\u88dd"); cn_.EnableWindow(!installed); tw_.EnableWindow(!installed); remove_.EnableWindow(installed); diff --git a/WeaselSetup/InstallOptionsDlg.h b/WeaselSetup/InstallOptionsDlg.h index 5d0477b38..304dfdae5 100644 --- a/WeaselSetup/InstallOptionsDlg.h +++ b/WeaselSetup/InstallOptionsDlg.h @@ -39,5 +39,7 @@ class InstallOptionsDialog : public CDialogImpl CButton remove_; CButton default_dir_; CButton custom_dir_; + CButton ok_; + CButton ime_; CEdit dir_; }; diff --git a/WeaselSetup/WeaselSetup.cpp b/WeaselSetup/WeaselSetup.cpp index 561c37b78..2a1b0347d 100644 --- a/WeaselSetup/WeaselSetup.cpp +++ b/WeaselSetup/WeaselSetup.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include "resource.h" +#include #include "InstallOptionsDlg.h" @@ -34,6 +35,16 @@ int install(bool hant, bool silent, bool old_ime_support); int uninstall(bool silent); bool has_installed(); +static std::wstring install_dir() +{ + WCHAR exe_path[MAX_PATH] = { 0 }; + GetModuleFileNameW(GetModuleHandle(NULL), exe_path, _countof(exe_path)); + std::wstring dir(exe_path); + size_t pos = dir.find_last_of(L"\\"); + dir.resize(pos); + return dir; +} + static int CustomInstall(bool installing) { bool hant = false; @@ -65,11 +76,11 @@ static int CustomInstall(bool installing) } RegCloseKey(hKey); } - + bool _has_installed = has_installed(); if (!silent) { InstallOptionsDialog dlg; - dlg.installed = has_installed(); + dlg.installed = _has_installed; dlg.hant = hant; dlg.user_dir = user_dir; if (IDOK != dlg.DoModal()) { @@ -80,10 +91,12 @@ static int CustomInstall(bool installing) hant = dlg.hant; user_dir = dlg.user_dir; old_ime_support = dlg.old_ime_support; + _has_installed = dlg.installed; } } - if (0 != install(hant, silent, old_ime_support)) - return 1; + if(!_has_installed) + if (0 != install(hant, silent, old_ime_support)) + return 1; ret = RegCreateKeyEx(HKEY_CURRENT_USER, KEY, 0, NULL, 0, KEY_ALL_ACCESS, 0, &hKey, NULL); @@ -109,6 +122,19 @@ static int CustomInstall(bool installing) MessageBox(NULL, L"無法寫入 Hant", L"安裝失敗", MB_ICONERROR | MB_OK); return 1; } + if (_has_installed) + { + std::wstring dir(install_dir()); + std::thread th([dir]() { + ShellExecuteW(NULL, NULL, (dir + L"\\WeaselServer.exe").c_str(), L"/q", NULL, SW_SHOWNORMAL); + Sleep(500); + ShellExecuteW(NULL, NULL, (dir + L"\\WeaselServer.exe").c_str(), L"", NULL, SW_SHOWNORMAL); + Sleep(500); + ShellExecuteW(NULL, NULL, (dir + L"\\WeaselDeployer.exe").c_str(), L"/deploy", NULL, SW_SHOWNORMAL); + }); + th.detach(); + MessageBox(NULL, L"修改用戶資料夾位置成功:)", L"修改成功", MB_ICONINFORMATION | MB_OK); + } return 0; } From b7d0d54c8bedcd768b3f3193d7f959066130c9c3 Mon Sep 17 00:00:00 2001 From: fxliang Date: Fri, 14 Jul 2023 13:16:55 +0800 Subject: [PATCH 03/13] feat: now it's OK to define preset_color_schemes/color_scheme_for_schema in schema file. --- RimeWithWeasel/RimeWithWeasel.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/RimeWithWeasel/RimeWithWeasel.cpp b/RimeWithWeasel/RimeWithWeasel.cpp index 67ec47deb..43516a914 100644 --- a/RimeWithWeasel/RimeWithWeasel.cpp +++ b/RimeWithWeasel/RimeWithWeasel.cpp @@ -441,11 +441,20 @@ void RimeWithWeaselHandler::_LoadSchemaSpecificSettings(const std::string& schem memset(buffer, '\0', sizeof(buffer)); if (RimeConfigGetString(&config, "style/color_scheme", buffer, BUF_SIZE)) { - RimeConfig weaselconfig; - if (RimeConfigOpen("weasel", &weaselconfig)) + std::string color_name(buffer); + RimeConfigIterator preset = {0}; + if(RimeConfigBeginMap(&preset, &config, ("preset_color_schemes/" + color_name).c_str())) { - _UpdateUIStyleColor(&weaselconfig, m_ui->style(), std::string(buffer)); - RimeConfigClose(&weaselconfig); + _UpdateUIStyleColor(&config, m_ui->style(), color_name); + } + else + { + RimeConfig weaselconfig; + if (RimeConfigOpen("weasel", &weaselconfig)) + { + _UpdateUIStyleColor(&weaselconfig, m_ui->style(), std::string(buffer)); + RimeConfigClose(&weaselconfig); + } } } // load schema icon start From 02ea139131a16274c80d9dc68f695820a980e89a Mon Sep 17 00:00:00 2001 From: fxliang Date: Fri, 14 Jul 2023 21:54:34 +0800 Subject: [PATCH 04/13] feat: enable highlight mark when hilited_mark_color not transparent and mark text empty --- WeaselUI/HorizontalLayout.cpp | 8 ++++++-- WeaselUI/VHorizontalLayout.cpp | 16 ++++++++++++---- WeaselUI/VerticalLayout.cpp | 8 ++++++-- WeaselUI/WeaselPanel.cpp | 23 +++++++++++++++++++++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/WeaselUI/HorizontalLayout.cpp b/WeaselUI/HorizontalLayout.cpp index 4411a967b..d3d3e136e 100644 --- a/WeaselUI/HorizontalLayout.cpp +++ b/WeaselUI/HorizontalLayout.cpp @@ -10,10 +10,14 @@ void HorizontalLayout::DoLayout(CDCHandle dc, PDWR pDWR ) int w = offsetX + real_margin_x; /* calc mark_text sizes */ - if (!_style.mark_text.empty() && (_style.hilited_mark_color & 0xff000000)) + if ((_style.hilited_mark_color & 0xff000000)) { CSize sg; - GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + if(_style.mark_text.empty()) + GetTextSizeDW(L"|", 1, pDWR->pTextFormat, pDWR, &sg); + else + GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + MARK_WIDTH = sg.cx; MARK_HEIGHT = sg.cy; MARK_GAP = MARK_WIDTH + 4; diff --git a/WeaselUI/VHorizontalLayout.cpp b/WeaselUI/VHorizontalLayout.cpp index b4847ff0a..8283f02e4 100644 --- a/WeaselUI/VHorizontalLayout.cpp +++ b/WeaselUI/VHorizontalLayout.cpp @@ -16,10 +16,14 @@ void VHorizontalLayout::DoLayout(CDCHandle dc, PDWR pDWR ) int height = offsetY, width = offsetX + real_margin_x; int h = offsetY + real_margin_y; - if (!_style.mark_text.empty() && (_style.hilited_mark_color & 0xff000000)) + if ((_style.hilited_mark_color & 0xff000000)) { CSize sg; - GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + if(_style.mark_text.empty()) + GetTextSizeDW(L"|", 1, pDWR->pTextFormat, pDWR, &sg); + else + GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + MARK_WIDTH = sg.cx; MARK_HEIGHT = sg.cy; MARK_GAP = MARK_HEIGHT + 4; @@ -221,10 +225,14 @@ void VHorizontalLayout::DoLayoutWithWrap(CDCHandle dc, PDWR pDWR) int height = offsetY, width = offsetX + real_margin_x; int h = offsetY + real_margin_y; - if (!_style.mark_text.empty() && (_style.hilited_mark_color & 0xff000000)) + if ((_style.hilited_mark_color & 0xff000000)) { CSize sg; - GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + if(_style.mark_text.empty()) + GetTextSizeDW(L"|", 1, pDWR->pTextFormat, pDWR, &sg); + else + GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + MARK_WIDTH = sg.cx; MARK_HEIGHT = sg.cy; MARK_GAP = MARK_HEIGHT + 4; diff --git a/WeaselUI/VerticalLayout.cpp b/WeaselUI/VerticalLayout.cpp index 06014b51e..ab8a6d182 100644 --- a/WeaselUI/VerticalLayout.cpp +++ b/WeaselUI/VerticalLayout.cpp @@ -8,10 +8,14 @@ void weasel::VerticalLayout::DoLayout(CDCHandle dc, PDWR pDWR) const int space = _style.hilite_spacing; int width = 0, height = real_margin_y; - if (!_style.mark_text.empty() && (_style.hilited_mark_color & 0xff000000)) + if ((_style.hilited_mark_color & 0xff000000)) { CSize sg; - GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + if(_style.mark_text.empty()) + GetTextSizeDW(L"|", 1, pDWR->pTextFormat, pDWR, &sg); + else + GetTextSizeDW(_style.mark_text, _style.mark_text.length(), pDWR->pTextFormat, pDWR, &sg); + MARK_WIDTH = sg.cx; MARK_HEIGHT = sg.cy; MARK_GAP = MARK_WIDTH + 4; diff --git a/WeaselUI/WeaselPanel.cpp b/WeaselUI/WeaselPanel.cpp index a74079f18..3b27b8b09 100644 --- a/WeaselUI/WeaselPanel.cpp +++ b/WeaselUI/WeaselPanel.cpp @@ -621,6 +621,29 @@ bool WeaselPanel::_DrawCandidates(CDCHandle &dc, bool back) ReconfigRoundInfo(rd, m_ctx.cinfo.highlighted, m_candidateCount); } rect.InflateRect(m_style.hilite_padding_x, m_style.hilite_padding_y); + if (m_style.mark_text.empty() && COLORNOTTRANSPARENT(m_style.hilited_mark_color)) + { + BYTE r = GetRValue(m_style.hilited_mark_color); + BYTE g = GetGValue(m_style.hilited_mark_color); + BYTE b = GetBValue(m_style.hilited_mark_color); + BYTE alpha = (BYTE)((m_style.hilited_mark_color >> 24) & 255); + Gdiplus::Graphics g_back(dc); + g_back.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeHighQuality); + Gdiplus::Color mark_color = Gdiplus::Color::MakeARGB(alpha, r, g, b); + Gdiplus::SolidBrush mk_brush(mark_color); + if (m_style.layout_type == UIStyle::LAYOUT_VERTICAL_TEXT) + { + CRect mkrc{ rect.left + m_style.round_corner, rect.top, rect.right - m_style.round_corner, rect.top + m_layout->MARK_HEIGHT / 2 }; + GraphicsRoundRectPath mk_path(mkrc, 2); + g_back.FillPath(&mk_brush, &mk_path); + } + else + { + CRect mkrc{ rect.left, rect.top + m_style.round_corner, rect.left + m_layout->MARK_WIDTH / 2, rect.bottom - m_style.round_corner }; + GraphicsRoundRectPath mk_path(mkrc, 2); + g_back.FillPath(&mk_brush, &mk_path); + } + } _HighlightText(dc, rect, m_style.hilited_candidate_back_color, m_style.hilited_candidate_shadow_color, m_style.round_corner, bkType, rd, m_style.hilited_candidate_border_color); drawn = true; } From fd5972abad8a16155eb6653d5992963473e38171 Mon Sep 17 00:00:00 2001 From: fxliang Date: Fri, 14 Jul 2023 23:18:29 +0800 Subject: [PATCH 05/13] fixed: ShouldDisplayStatusIcon, not works with english.schema.yaml in ascii mode, if inline_preedit set true. --- WeaselUI/StandardLayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WeaselUI/StandardLayout.cpp b/WeaselUI/StandardLayout.cpp index f1b32e2ad..b6e1757a4 100644 --- a/WeaselUI/StandardLayout.cpp +++ b/WeaselUI/StandardLayout.cpp @@ -394,5 +394,5 @@ bool StandardLayout::ShouldDisplayStatusIcon() const // rule 2. show status icon when switching mode // rule 3. always show status icon with tips // rule 4. rule 3 excluding tips FullScreenLayout with strings - return (_status.ascii_mode || !_status.composing || !_context.aux.empty()) && !((_style.layout_type == UIStyle::LAYOUT_HORIZONTAL_FULLSCREEN || _style.layout_type == UIStyle::LAYOUT_VERTICAL_FULLSCREEN) && !_context.aux.empty()); + return ((_status.ascii_mode && !_style.inline_preedit)|| !_status.composing || !_context.aux.empty()) && !((_style.layout_type == UIStyle::LAYOUT_HORIZONTAL_FULLSCREEN || _style.layout_type == UIStyle::LAYOUT_VERTICAL_FULLSCREEN) && !_context.aux.empty()); } From 79467c711e496b2d4894e0d45b63f5f42da4dc68 Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 16 Jul 2023 22:53:20 +0800 Subject: [PATCH 06/13] feat: inline_preedit in app options works. inline_preedit in app_options over settings in schema and weasel.yaml --- RimeWithWeasel/RimeWithWeasel.cpp | 59 +++++++++++++++++++++++++++++++ include/RimeWithWeasel.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/RimeWithWeasel/RimeWithWeasel.cpp b/RimeWithWeasel/RimeWithWeasel.cpp index 43516a914..cec6b474d 100644 --- a/RimeWithWeasel/RimeWithWeasel.cpp +++ b/RimeWithWeasel/RimeWithWeasel.cpp @@ -138,8 +138,10 @@ UINT RimeWithWeaselHandler::AddSession(LPWSTR buffer, EatLine eat) std::string schema_id = status.schema_id; m_last_schema_id = schema_id; _LoadSchemaSpecificSettings(schema_id); + _LoadAppInlinePreeditSet(session_id, true); _UpdateInlinePreeditStatus(session_id); _RefreshTrayIcon(session_id, _UpdateUICallback); + RimeFreeStatus(&status); } // show session's welcome message :-) if any if (eat) { @@ -470,6 +472,57 @@ void RimeWithWeaselHandler::_LoadSchemaSpecificSettings(const std::string& schem RimeConfigClose(&config); } +void RimeWithWeaselHandler::_LoadAppInlinePreeditSet(UINT session_id, bool ignore_app_name) +{ + static char _app_name[50]; + RimeGetProperty(session_id, "client_app", _app_name, sizeof(_app_name) - 1); + std::string app_name(_app_name); + if(!ignore_app_name && m_last_app_name == app_name) + return; + m_last_app_name = app_name; + if (!app_name.empty()) + { + if (m_app_options.find(app_name) != m_app_options.end()) + { + AppOptions& options(m_app_options[app_name]); + bool* pfind = new bool(false); + std::for_each(options.begin(), options.end(), [session_id, app_name, pfind, this](std::pair &pair) + { + if(pair.first == "inline_preedit") + { + *pfind = true; + RimeSetOption(session_id, pair.first.c_str(), Bool(pair.second)); + m_ui->style().inline_preedit = Bool(pair.second); + _UpdateInlinePreeditStatus(session_id); + } + }); + if (!(*pfind)) + { + delete pfind; + goto load_schema_inline; + } + delete pfind; + } + else + { +load_schema_inline: + RIME_STRUCT(RimeStatus, status); + if (RimeGetStatus(session_id, &status)) + { + std::string schema_id = status.schema_id; + RimeConfig config; + if (!RimeSchemaOpen(schema_id.c_str(), &config)) return; + Bool inline_preedit = m_ui->style().inline_preedit; + if (RimeConfigGetBool(&config, "style/inline_preedit", &inline_preedit)) + m_ui->style().inline_preedit = !!inline_preedit; + RimeConfigClose(&config); + RimeFreeStatus(&status); + _UpdateInlinePreeditStatus(session_id); + } + } + } +} + bool RimeWithWeaselHandler::_ShowMessage(Context& ctx, Status& status) { // show as auxiliary string std::wstring& tips(ctx.aux.str); @@ -526,6 +579,8 @@ bool RimeWithWeaselHandler::_Respond(UINT session_id, EatLine eat) std::set actions; std::list messages; + // load App inline_preedit setting if app_name changed + _LoadAppInlinePreeditSet(session_id); // extract information RIME_STRUCT(RimeCommit, commit); @@ -1009,6 +1064,7 @@ void RimeWithWeaselHandler::_GetStatus(Status & stat, UINT session_id, Context& if(schema_id != ".default") { // don't load for schema select menu RimeSetOption(session_id, "__synced", false); // Sync new schema options with front end _LoadSchemaSpecificSettings(schema_id); + _LoadAppInlinePreeditSet(session_id, true); _UpdateInlinePreeditStatus(session_id); // in case of inline_preedit set in schema _RefreshTrayIcon(session_id, _UpdateUICallback); // refresh icon after schema changed ctx.aux.str = stat.schema_name; @@ -1016,6 +1072,8 @@ void RimeWithWeaselHandler::_GetStatus(Status & stat, UINT session_id, Context& m_ui->ShowWithTimeout(1200); } } + else + _LoadAppInlinePreeditSet(session_id); RimeFreeStatus(&status); } } @@ -1063,3 +1121,4 @@ void RimeWithWeaselHandler::_UpdateInlinePreeditStatus(UINT session_id) // show soft cursor on weasel panel but not inline RimeSetOption(session_id, "soft_cursor", Bool(!inline_preedit)); } + diff --git a/include/RimeWithWeasel.h b/include/RimeWithWeasel.h index fbf75e7e9..cc75bc4fa 100644 --- a/include/RimeWithWeasel.h +++ b/include/RimeWithWeasel.h @@ -37,6 +37,7 @@ class RimeWithWeaselHandler : bool _IsDeployerRunning(); void _UpdateUI(UINT session_id); void _LoadSchemaSpecificSettings(const std::string& schema_id); + void _LoadAppInlinePreeditSet(UINT session_id, bool ignore_app_name = false); bool _ShowMessage(weasel::Context& ctx, weasel::Status& status); bool _Respond(UINT session_id, EatLine eat); void _ReadClientInfo(UINT session_id, LPWSTR buffer); @@ -52,6 +53,7 @@ class RimeWithWeaselHandler : UINT m_active_session; bool m_disabled; std::string m_last_schema_id; + std::string m_last_app_name; weasel::UIStyle m_base_style; std::function _UpdateUICallback; From c66792cc6a0872be506db516a1d05a8169b5959c Mon Sep 17 00:00:00 2001 From: fxliang Date: Fri, 21 Jul 2023 23:15:20 +0800 Subject: [PATCH 07/13] feat: new language bar menu item, restart service --- WeaselTSF/LanguageBar.cpp | 39 +++++++++++++++++++++++++++++++++++++- WeaselTSF/WeaselTSF.rc | Bin 6424 -> 6450 bytes include/resource.h | Bin 2614 -> 2708 bytes output/install.nsi | 2 ++ output/start_service.bat | 2 ++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 output/start_service.bat diff --git a/WeaselTSF/LanguageBar.cpp b/WeaselTSF/LanguageBar.cpp index d576cd5b3..cdf589b58 100644 --- a/WeaselTSF/LanguageBar.cpp +++ b/WeaselTSF/LanguageBar.cpp @@ -1,5 +1,7 @@ #include "stdafx.h" #include +#include +#include #include "WeaselTSF.h" #include "LanguageBar.h" #include "CandidateList.h" @@ -277,10 +279,45 @@ void CLangBarItemButton::SetLangbarStatus(DWORD dwStatus, BOOL fSet) return; } +BOOL is_wow64() +{ + DWORD errorCode; + if (GetSystemWow64DirectoryW(NULL, 0) == 0) + if ((errorCode = GetLastError()) == ERROR_CALL_NOT_IMPLEMENTED) + return FALSE; + else + ExitProcess((UINT)errorCode); + else + return TRUE; +} void WeaselTSF::_HandleLangBarMenuSelect(UINT wID) { - m_client.TrayCommand(wID); + if(wID != ID_WEASELTRAY_RERUN_SERVICE) + m_client.TrayCommand(wID); + else + { + std::wstring WEASEL_REG_NAME_; + if(is_wow64()) + WEASEL_REG_NAME_ = L"Software\\WOW6432Node\\Rime\\Weasel"; + else + WEASEL_REG_NAME_ = L"Software\\Rime\\Weasel"; + + TCHAR szValue[MAX_PATH]; + DWORD dwBufLen = MAX_PATH; + + LONG lRes = RegGetValue(HKEY_LOCAL_MACHINE, WEASEL_REG_NAME_.c_str(), L"WeaselRoot", RRF_RT_REG_SZ, NULL, szValue, &dwBufLen); + if(lRes == ERROR_SUCCESS) + { + std::wstring dir(szValue); + std::thread th([dir]() { + ShellExecuteW(NULL, L"open", (dir + L"\\stop_service.bat").c_str(), NULL, dir.c_str(), SW_HIDE); + Sleep(100); + ShellExecuteW(NULL, L"open", (dir + L"\\start_service.bat").c_str(), NULL, dir.c_str(), SW_HIDE); + }); + th.detach(); + } + } } HWND WeaselTSF::_GetFocusedContextWindow() diff --git a/WeaselTSF/WeaselTSF.rc b/WeaselTSF/WeaselTSF.rc index 35304a655a4e6f324a5c16af7e303425e8a4aefc..7ccbcbd940c787c209ed0a7f97c9150c7f5884da 100644 GIT binary patch delta 184 zcmbPXw8?10I%WY~zxGrOhKA~3f1dxket*L@-(x<+C46>baOm{vt2w;sH-i)yG#Jzv zTqpPQs!k5zl93EzaAgQ$2xahNh-U}}v%?rX8JvMC?71~3FW|EQshY&^hGF#Nd(2Xs zC-8eQa(!%i+pWRSSN}H*DAuyMOK=X;WF?U)lQ#jeljxkuX6$mPYNRGl;9s`+iI@o! E00_uHO#lD@ delta 271 zcmdmFG{b1aI%Y#>h75*GhCGH;hGHOAV9;O)2J&+m3K(*LbQ%z+GNdr*0A&Igf*70` zG$$)c2v2qsEZFSCV#hUEjNfMR20oR^dHinV8MXNae*mMdE6@e$U>l2p?g6Zh}0_lfy(NOnwE#b)qvSOR-ClZp`Ex{A)J<6Ek4~05(HB AK>z>% diff --git a/include/resource.h b/include/resource.h index e4a384679a268c951abe78c8eadceaed803a5561..952436eb386c0cc451ac1cc50a645a3137edb616 100644 GIT binary patch delta 62 zcmdlcGDUR5752$(EIPVD46Y184518u4Dk%XV0IXTCxbJPr2vN}3 Date: Thu, 27 Jul 2023 17:26:40 +0800 Subject: [PATCH 08/13] fixed: cursor position error when preedit_type set preview. --- RimeWithWeasel/RimeWithWeasel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RimeWithWeasel/RimeWithWeasel.cpp b/RimeWithWeasel/RimeWithWeasel.cpp index cec6b474d..590ab2c4a 100644 --- a/RimeWithWeasel/RimeWithWeasel.cpp +++ b/RimeWithWeasel/RimeWithWeasel.cpp @@ -621,7 +621,7 @@ bool RimeWithWeaselHandler::_Respond(UINT session_id, EatLine eat) messages.push_back(std::string("ctx.preedit.cursor=") + std::to_string(utf8towcslen(first.c_str(), 0)) + ',' + std::to_string(utf8towcslen(first.c_str(), first.size())) + ',' + - std::to_string(utf8towcslen(first.c_str(), ctx.composition.cursor_pos)) + '\n'); + std::to_string(utf8towcslen(first.c_str(), first.size())) + '\n'); break; } // no preview, fall back to composition From 9404766b4b7092e73181f365b962ae85ec8947c6 Mon Sep 17 00:00:00 2001 From: Azuk 443 Date: Wed, 9 Aug 2023 22:50:56 +0800 Subject: [PATCH 09/13] add bom to WeaselSetup/InstallOptionsDlg.cpp use Hanzi literals instead of unicode sequences --- WeaselSetup/InstallOptionsDlg.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WeaselSetup/InstallOptionsDlg.cpp b/WeaselSetup/InstallOptionsDlg.cpp index b6b45034b..892cf70d4 100644 --- a/WeaselSetup/InstallOptionsDlg.cpp +++ b/WeaselSetup/InstallOptionsDlg.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "InstallOptionsDlg.h" #include @@ -34,7 +34,7 @@ LRESULT InstallOptionsDialog::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { ok_.Attach(GetDlgItem(IDOK)); if (installed) - ok_.SetWindowTextW(L"\u4fee\u6539\u8cc7\u6599\u593e"); + ok_.SetWindowTextW(L"修改資料夾"); ime_.Attach(GetDlgItem(IDC_CHECK_INSTIME)); if (installed) @@ -69,7 +69,7 @@ LRESULT InstallOptionsDialog::OnRemove(WORD, WORD code, HWND, BOOL&) { uninstall(non_silent); installed = false; ime_.EnableWindow(!installed); - ok_.SetWindowTextW(L"\u5b89\u88dd"); + ok_.SetWindowTextW(L"安裝"); cn_.EnableWindow(!installed); tw_.EnableWindow(!installed); remove_.EnableWindow(installed); From 247b8b8250bac5c4c40a78a2600c3afb20a4f738 Mon Sep 17 00:00:00 2001 From: Azuk 443 Date: Wed, 9 Aug 2023 22:52:15 +0800 Subject: [PATCH 10/13] misc fixes in WeaselSetup/WeaselSetup.vcxproj - import "weasel.props" before import default compiling props - fix resource include dirs in debug builds --- WeaselSetup/WeaselSetup.vcxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WeaselSetup/WeaselSetup.vcxproj b/WeaselSetup/WeaselSetup.vcxproj index b184f0fac..cb9656273 100644 --- a/WeaselSetup/WeaselSetup.vcxproj +++ b/WeaselSetup/WeaselSetup.vcxproj @@ -16,6 +16,7 @@ 10.0 WeaselSetup + Application @@ -50,7 +51,6 @@ true $(SolutionDir)output\ - Use @@ -72,7 +72,7 @@ 0x7804 - $(SolutionDir)\include\wtl;$(IntDir);%(AdditionalIncludeDirectories) + $(IntDir);$(SolutionDir)\include\wtl NDEBUG;%(PreprocessorDefinitions) @@ -115,7 +115,7 @@ 0x7804 - $(SolutionDir)\include\wtl10;$(IntDir);%(AdditionalIncludeDirectories) + $(IntDir);$(SolutionDir)\include\wtl _DEBUG;%(PreprocessorDefinitions) From 35694cba0fafcc708a069e651030f8bac862dffe Mon Sep 17 00:00:00 2001 From: fxliang Date: Thu, 10 Aug 2023 13:07:36 +0800 Subject: [PATCH 11/13] replace bool* with shared_ptr --- RimeWithWeasel/RimeWithWeasel.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/RimeWithWeasel/RimeWithWeasel.cpp b/RimeWithWeasel/RimeWithWeasel.cpp index 590ab2c4a..7fb501313 100644 --- a/RimeWithWeasel/RimeWithWeasel.cpp +++ b/RimeWithWeasel/RimeWithWeasel.cpp @@ -485,7 +485,7 @@ void RimeWithWeaselHandler::_LoadAppInlinePreeditSet(UINT session_id, bool ignor if (m_app_options.find(app_name) != m_app_options.end()) { AppOptions& options(m_app_options[app_name]); - bool* pfind = new bool(false); + auto pfind = std::make_shared(false); std::for_each(options.begin(), options.end(), [session_id, app_name, pfind, this](std::pair &pair) { if(pair.first == "inline_preedit") @@ -498,10 +498,8 @@ void RimeWithWeaselHandler::_LoadAppInlinePreeditSet(UINT session_id, bool ignor }); if (!(*pfind)) { - delete pfind; goto load_schema_inline; } - delete pfind; } else { From 1567d609bba35bbb836289cfd1c6756922f61185 Mon Sep 17 00:00:00 2001 From: fxliang Date: Thu, 10 Aug 2023 14:23:48 +0800 Subject: [PATCH 12/13] if shadow_color transparent, decrease the capture rectangle size --- WeaselUI/WeaselPanel.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/WeaselUI/WeaselPanel.cpp b/WeaselUI/WeaselPanel.cpp index 3b27b8b09..66a252e08 100644 --- a/WeaselUI/WeaselPanel.cpp +++ b/WeaselUI/WeaselPanel.cpp @@ -241,7 +241,21 @@ LRESULT WeaselPanel::OnLeftClicked(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL recth.InflateRect(m_style.hilite_padding_x, m_style.hilite_padding_y); // capture widow if (recth.PtInRect(point)) _CaptureRect(recth); - else _CaptureRect(rcw); + else { + // if shadow_color transparent, decrease the capture rectangle size + if(COLORTRANSPARENT(m_style.shadow_color) && m_style.shadow_radius != 0) { + CRect crc(rcw); + int shadow_gap = (m_style.shadow_offset_x ==0 && m_style.shadow_offset_y == 0) ? 2 * m_style.shadow_radius : m_style.shadow_radius + m_style.shadow_radius / 2; + int ofx = m_style.hilite_padding_x + abs(m_style.shadow_offset_x) + shadow_gap > abs(m_style.margin_x) ? + m_style.hilite_padding_x + abs(m_style.shadow_offset_x) + shadow_gap - abs(m_style.margin_x) : 0; + int ofy = m_style.hilite_padding_y + abs(m_style.shadow_offset_y) + shadow_gap > abs(m_style.margin_y) ? + m_style.hilite_padding_y + abs(m_style.shadow_offset_y) + shadow_gap - abs(m_style.margin_y) : 0; + crc.DeflateRect(m_layout->offsetX - ofx, m_layout->offsetY - ofy); + _CaptureRect(crc); + } else { + _CaptureRect(rcw); + } + } } // button response { From 8dcc49c127e2c0834181483a52335db2665cd5cb Mon Sep 17 00:00:00 2001 From: fxliang Date: Thu, 10 Aug 2023 14:29:04 +0800 Subject: [PATCH 13/13] fixed: round corner radius for highlighted candidate not correct when hemispherical triggered --- WeaselUI/WeaselPanel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WeaselUI/WeaselPanel.cpp b/WeaselUI/WeaselPanel.cpp index 66a252e08..7ca9a0728 100644 --- a/WeaselUI/WeaselPanel.cpp +++ b/WeaselUI/WeaselPanel.cpp @@ -355,7 +355,7 @@ void WeaselPanel::_HighlightText(CDCHandle &dc, CRect rc, COLORREF color, COLORR GraphicsRoundRectPath* hiliteBackPath; if (rd.Hemispherical && type!= BackType::BACKGROUND && NOT_FULLSCREENLAYOUT(m_style)) - hiliteBackPath = new GraphicsRoundRectPath(rc, m_style.round_corner_ex - m_style.border/2 + (m_style.border % 2), rd.IsTopLeftNeedToRound, rd.IsTopRightNeedToRound, rd.IsBottomRightNeedToRound, rd.IsBottomLeftNeedToRound); + hiliteBackPath = new GraphicsRoundRectPath(rc, m_style.round_corner_ex - (m_style.border%2 ? m_style.border / 2 : 0) , rd.IsTopLeftNeedToRound, rd.IsTopRightNeedToRound, rd.IsBottomRightNeedToRound, rd.IsBottomLeftNeedToRound); else // background or current candidate background not out of window background hiliteBackPath = new GraphicsRoundRectPath(rc, radius);