Skip to content

Commit

Permalink
Merge branch 'ascii_cmd' into pb
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Feb 22, 2024
2 parents 7ab0f98 + 132de53 commit c7bee7c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion RimeWithWeasel/RimeWithWeasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,19 @@ void RimeWithWeaselHandler::EndMaintenance()

void RimeWithWeaselHandler::SetOption(UINT session_id, const std::string & opt, bool val)
{
RimeSetOption(session_id, opt.c_str(), val);
// from no-session client, not actual typing session
if (!session_id)
{
if (m_global_ascii_mode && opt == "ascii_mode")
{
for (auto& pair : m_session_status_map)
RimeSetOption(pair.first, "ascii_mode", val);
}
else
RimeSetOption(m_active_session, opt.c_str(), val);
}
else
RimeSetOption(session_id, opt.c_str(), val);
}

void RimeWithWeaselHandler::OnUpdateUI(std::function<void()> const &cb)
Expand Down
13 changes: 13 additions & 0 deletions WeaselServer/WeaselServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lp
WeaselServerApp::explore(WeaselServerApp::install_dir());
return 0;
}
if (!wcscmp(L"/ascii", lpstrCmdLine) || !wcscmp(L"/nascii", lpstrCmdLine))
{
weasel::Client client;
bool ascii = !wcscmp(L"/ascii", lpstrCmdLine);
if (client.Connect()) // try to connect to running server
{
if (ascii)
client.TrayCommand(ID_WEASELTRAY_ENABLE_ASCII);
else
client.TrayCommand(ID_WEASELTRAY_DISABLE_ASCII);
}
return 0;
}

// command line option /q stops the running server
bool quit = !wcscmp(L"/q", lpstrCmdLine) || !wcscmp(L"/quit", lpstrCmdLine);
Expand Down

0 comments on commit c7bee7c

Please sign in to comment.