Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save ascii mode state #805

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/rime/gear/ascii_composer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ void AsciiComposer::LoadConfig(Schema* schema) {
&good_old_caps_lock_);
}
}
if (!config->GetBool("ascii_composer/save_ascii_mode_state",
&save_ascii_mode_state_)) {
if (preset_config) {
preset_config->GetBool("ascii_composer/save_ascii_mode_state",
&save_ascii_mode_state_);
}
}
if (auto bindings = config->GetMap("ascii_composer/switch_key")) {
load_bindings(bindings, &bindings_);
} else if (auto bindings = preset_config ? preset_config->GetMap(
Expand Down Expand Up @@ -234,6 +241,11 @@ void AsciiComposer::SwitchAsciiMode(bool ascii_mode,
}
// refresh non-confirmed composition with new mode
ctx->set_option("ascii_mode", ascii_mode);
if (save_ascii_mode_state_ && style != kAsciiModeSwitchInline) {
the<Config> user_config(Config::Require("user_config")->Create("user"));
if (user_config)
user_config->SetBool("var/option/ascii_mode", ascii_mode);
}
}

void AsciiComposer::OnContextUpdate(Context* ctx) {
Expand Down
1 change: 1 addition & 0 deletions src/rime/gear/ascii_composer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AsciiComposer : public Processor {
AsciiModeSwitchKeyBindings bindings_;
AsciiModeSwitchStyle caps_lock_switch_style_ = kAsciiModeSwitchNoop;
bool good_old_caps_lock_ = false;
bool save_ascii_mode_state_ = false;
// state
bool toggle_with_caps_ = false;
bool shift_key_pressed_ = false;
Expand Down
Loading