Skip to content

Commit bedef6a

Browse files
committed
save ascii mode state
1 parent d402755 commit bedef6a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/rime/gear/ascii_composer.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ void AsciiComposer::LoadConfig(Schema* schema) {
178178
&good_old_caps_lock_);
179179
}
180180
}
181+
if (!config->GetBool("ascii_composer/save_ascii_mode_state",
182+
&save_ascii_mode_state_)) {
183+
if (preset_config) {
184+
preset_config->GetBool("ascii_composer/save_ascii_mode_state",
185+
&save_ascii_mode_state_);
186+
}
187+
}
181188
if (auto bindings = config->GetMap("ascii_composer/switch_key")) {
182189
load_bindings(bindings, &bindings_);
183190
} else if (auto bindings = preset_config ? preset_config->GetMap(
@@ -234,6 +241,11 @@ void AsciiComposer::SwitchAsciiMode(bool ascii_mode,
234241
}
235242
// refresh non-confirmed composition with new mode
236243
ctx->set_option("ascii_mode", ascii_mode);
244+
if (save_ascii_mode_state_ && style != kAsciiModeSwitchInline) {
245+
the<Config> user_config(Config::Require("user_config")->Create("user"));
246+
if (user_config)
247+
user_config->SetBool("var/option/ascii_mode", ascii_mode);
248+
}
237249
}
238250

239251
void AsciiComposer::OnContextUpdate(Context* ctx) {

src/rime/gear/ascii_composer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class AsciiComposer : public Processor {
4545
AsciiModeSwitchKeyBindings bindings_;
4646
AsciiModeSwitchStyle caps_lock_switch_style_ = kAsciiModeSwitchNoop;
4747
bool good_old_caps_lock_ = false;
48+
bool save_ascii_mode_state_ = false;
4849
// state
4950
bool toggle_with_caps_ = false;
5051
bool shift_key_pressed_ = false;

0 commit comments

Comments
 (0)