Skip to content

Commit

Permalink
save ascii mode state
Browse files Browse the repository at this point in the history
  • Loading branch information
groverlynn committed Feb 2, 2024
1 parent d402755 commit bedef6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit bedef6a

Please sign in to comment.