diff --git a/src/editor/mod.rs b/src/editor/mod.rs index b252ae01..ba10430a 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -265,16 +265,6 @@ impl Editor { } self.shared.options = options; } - pub fn switch_character_form(&mut self) { - self.shared.options = EditorOptions { - character_form: match self.shared.options.character_form { - CharacterForm::Halfwidth => CharacterForm::Fullwidth, - CharacterForm::Fullwidth => CharacterForm::Halfwidth, - }, - ..self.shared.options - }; - } - pub fn entering_syllable(&self) -> bool { !self.shared.syl.is_empty() } @@ -647,6 +637,23 @@ impl SharedState { }, ..self.options }; + match self.options.language_mode { + LanguageMode::Chinese => self.notice_buffer = format!("切換為中文模式"), + LanguageMode::English => self.notice_buffer = format!("切換為英數模式"), + } + } + fn switch_character_form(&mut self) { + self.options = EditorOptions { + character_form: match self.options.character_form { + CharacterForm::Halfwidth => CharacterForm::Fullwidth, + CharacterForm::Fullwidth => CharacterForm::Halfwidth, + }, + ..self.options + }; + match self.options.character_form { + CharacterForm::Halfwidth => self.notice_buffer = format!("切換為半形模式"), + CharacterForm::Fullwidth => self.notice_buffer = format!("切換為全形模式"), + } } fn cancel_selecting(&mut self) { self.com.pop_cursor(); @@ -950,10 +957,7 @@ impl State for Entering { } Up => self.spin_ignore(), Space if ev.modifiers.shift && shared.options.enable_fullwidth_toggle_key => { - shared.options.character_form = match shared.options.character_form { - CharacterForm::Halfwidth => CharacterForm::Fullwidth, - CharacterForm::Fullwidth => CharacterForm::Halfwidth, - }; + shared.switch_character_form(); self.spin_absorb() } Space @@ -1709,7 +1713,7 @@ mod tests { let sym_sel = SymbolSelector::default(); let mut editor = Editor::new(conversion_engine, dict, estimate, abbrev, sym_sel); - editor.switch_character_form(); + editor.shared.switch_character_form(); let steps = [ ( diff --git a/tests/genkeystroke.c b/tests/genkeystroke.c index 3b42ab32..fbcb6d81 100644 --- a/tests/genkeystroke.c +++ b/tests/genkeystroke.c @@ -467,11 +467,9 @@ int main(int argc, char *argv[]) else chewing_config_set_int(ctx, "chewing.conversion_engine", 1); break; - case KEY_CTRL_('H'): /* emulate Shift */ - if (chewing_get_ShapeMode(ctx) == FULLSHAPE_MODE) - chewing_set_ShapeMode(ctx, HALFSHAPE_MODE); - else - chewing_set_ShapeMode(ctx, FULLSHAPE_MODE); + case KEY_CTRL_('H'): /* emulate Shift+Space */ + chewing_handle_ShiftSpace(ctx); + fprintf(fout, ""); break; case KEY_NPAGE: chewing_handle_PageDown(ctx); diff --git a/tests/test-bopomofo.c b/tests/test-bopomofo.c index cd4ed216..f825cb15 100644 --- a/tests/test-bopomofo.c +++ b/tests/test-bopomofo.c @@ -937,10 +937,18 @@ void test_Capslock() mode = chewing_get_ChiEngMode(ctx); ok(mode == SYMBOL_MODE, "mode shall change to SYMBOL_MODE"); + ok_aux_buffer(ctx, "切換為英數模式"); ok_bopomofo_buffer(ctx, ""); ok_preedit_buffer(ctx, ""); ok_commit_buffer(ctx, ""); + type_keystroke_by_string(ctx, ""); + + mode = chewing_get_ChiEngMode(ctx); + ok(mode == CHINESE_MODE, "mode shall change to CHINESE_MODE"); + + ok_aux_buffer(ctx, "切換為中文模式"); + chewing_delete(ctx); } @@ -1094,6 +1102,7 @@ void test_ShiftSpace() type_keystroke_by_string(ctx, ""); mode = chewing_get_ShapeMode(ctx); ok(mode == FULLSHAPE_MODE, "mode shall be FULLSHAPE_MODE"); + ok_aux_buffer(ctx, "切換為全形模式"); type_keystroke_by_string(ctx, " "); ok_commit_buffer(ctx, "\xE3\x80\x80"); /* Fullshape Space (U+3000) */ @@ -1106,6 +1115,7 @@ void test_ShiftSpace() type_keystroke_by_string(ctx, ""); mode = chewing_get_ShapeMode(ctx); ok(mode == HALFSHAPE_MODE, "mode shall be HALFSHAPE_MODE"); + ok_aux_buffer(ctx, "切換為半形模式"); type_keystroke_by_string(ctx, " "); ok_commit_buffer(ctx, " ");