mirror of
https://github.com/mii443/akaza.git
synced 2025-08-22 14:55:31 +00:00
数字を入力した時に、ルックアップテーブルが出てなければ preedit
に入れるようにした
This commit is contained in:
@ -11,7 +11,7 @@ use crate::AkazaContext;
|
||||
/**
|
||||
* shortcut key を設定可能な機能。
|
||||
*/
|
||||
pub type IbusAkazaCommand = fn(&mut AkazaContext, *mut IBusEngine);
|
||||
pub type IbusAkazaCommand = fn(&mut AkazaContext, *mut IBusEngine) -> bool;
|
||||
|
||||
pub(crate) fn ibus_akaza_commands_map() -> HashMap<&'static str, IbusAkazaCommand> {
|
||||
let mut function_map: HashMap<&'static str, IbusAkazaCommand> = HashMap::new();
|
||||
@ -21,107 +21,132 @@ pub(crate) fn ibus_akaza_commands_map() -> HashMap<&'static str, IbusAkazaComman
|
||||
|
||||
register("commit_candidate", |context, engine| {
|
||||
context.commit_candidate(engine);
|
||||
true
|
||||
});
|
||||
// 無変換状態では、ひらがなに変換してコミットします
|
||||
register("commit_preedit", |context, engine| {
|
||||
let (_, surface) = context.make_preedit_word();
|
||||
context.commit_string(engine, surface.as_str());
|
||||
true
|
||||
});
|
||||
register("escape", |context, engine| {
|
||||
context.escape(engine);
|
||||
true
|
||||
});
|
||||
register("escape", |context, engine| context.escape(engine));
|
||||
register("page_up", |context, engine| {
|
||||
context.page_up(engine);
|
||||
true
|
||||
});
|
||||
register("page_down", |context, engine| {
|
||||
context.page_down(engine);
|
||||
true
|
||||
});
|
||||
|
||||
register("set_input_mode_hiragana", |context, engine| {
|
||||
context.set_input_mode(engine, &INPUT_MODE_HIRAGANA)
|
||||
context.set_input_mode(engine, &INPUT_MODE_HIRAGANA);
|
||||
true
|
||||
});
|
||||
register("set_input_mode_alnum", |context, engine| {
|
||||
context.set_input_mode(engine, &INPUT_MODE_ALNUM)
|
||||
context.set_input_mode(engine, &INPUT_MODE_ALNUM);
|
||||
true
|
||||
});
|
||||
register("set_input_mode_fullwidth_alnum", |context, engine| {
|
||||
context.set_input_mode(engine, &INPUT_MODE_FULLWIDTH_ALNUM)
|
||||
context.set_input_mode(engine, &INPUT_MODE_FULLWIDTH_ALNUM);
|
||||
true
|
||||
});
|
||||
register("set_input_mode_katakana", |context, engine| {
|
||||
context.set_input_mode(engine, &INPUT_MODE_KATAKANA)
|
||||
context.set_input_mode(engine, &INPUT_MODE_KATAKANA);
|
||||
true
|
||||
});
|
||||
register("set_input_mode_halfwidth_katakana", |context, engine| {
|
||||
context.set_input_mode(engine, &INPUT_MODE_HALFWIDTH_KATAKANA)
|
||||
context.set_input_mode(engine, &INPUT_MODE_HALFWIDTH_KATAKANA);
|
||||
true
|
||||
});
|
||||
|
||||
register("update_candidates", |context, engine| {
|
||||
context.update_candidates(engine, true)
|
||||
context.update_candidates(engine, true);
|
||||
true
|
||||
});
|
||||
register("erase_character_before_cursor", |context, engine| {
|
||||
context.erase_character_before_cursor(engine)
|
||||
context.erase_character_before_cursor(engine);
|
||||
true
|
||||
});
|
||||
register("cursor_up", |context, engine| {
|
||||
context.cursor_up(engine);
|
||||
true
|
||||
});
|
||||
register("cursor_down", |context, engine| {
|
||||
context.cursor_down(engine);
|
||||
true
|
||||
});
|
||||
register("cursor_right", |context, engine| {
|
||||
context.cursor_right(engine);
|
||||
true
|
||||
});
|
||||
register("cursor_left", |context, engine| {
|
||||
context.cursor_left(engine);
|
||||
true
|
||||
});
|
||||
register("extend_clause_right", |context, engine| {
|
||||
context.extend_clause_right(engine).unwrap();
|
||||
true
|
||||
});
|
||||
register("extend_clause_left", |context, engine| {
|
||||
context.extend_clause_left(engine).unwrap();
|
||||
true
|
||||
});
|
||||
register("convert_to_full_hiragana", |context, engine| {
|
||||
context.convert_to_full_hiragana(engine).unwrap();
|
||||
true
|
||||
});
|
||||
register("convert_to_full_katakana", |context, engine| {
|
||||
context.convert_to_full_katakana(engine).unwrap();
|
||||
true
|
||||
});
|
||||
register("convert_to_half_katakana", |context, engine| {
|
||||
context.convert_to_half_katakana(engine).unwrap();
|
||||
true
|
||||
});
|
||||
register("convert_to_full_romaji", |context, engine| {
|
||||
context.convert_to_full_romaji(engine).unwrap();
|
||||
true
|
||||
});
|
||||
register("convert_to_half_romaji", |context, engine| {
|
||||
context.convert_to_half_romaji(engine).unwrap();
|
||||
true
|
||||
});
|
||||
|
||||
{
|
||||
// TODO コピペがすごい。マクロかうまいなにかでまとめて登録できるようにしたい。
|
||||
register("press_number_1", |context, engine| {
|
||||
context.process_num_key(1, engine);
|
||||
context.process_num_key(1, engine)
|
||||
});
|
||||
register("press_number_2", |context, engine| {
|
||||
context.process_num_key(2, engine);
|
||||
context.process_num_key(2, engine)
|
||||
});
|
||||
register("press_number_3", |context, engine| {
|
||||
context.process_num_key(3, engine);
|
||||
context.process_num_key(3, engine)
|
||||
});
|
||||
register("press_number_4", |context, engine| {
|
||||
context.process_num_key(4, engine);
|
||||
context.process_num_key(4, engine)
|
||||
});
|
||||
register("press_number_5", |context, engine| {
|
||||
context.process_num_key(5, engine);
|
||||
context.process_num_key(5, engine)
|
||||
});
|
||||
register("press_number_6", |context, engine| {
|
||||
context.process_num_key(6, engine);
|
||||
context.process_num_key(6, engine)
|
||||
});
|
||||
register("press_number_7", |context, engine| {
|
||||
context.process_num_key(7, engine);
|
||||
context.process_num_key(7, engine)
|
||||
});
|
||||
register("press_number_8", |context, engine| {
|
||||
context.process_num_key(8, engine);
|
||||
context.process_num_key(8, engine)
|
||||
});
|
||||
register("press_number_9", |context, engine| {
|
||||
context.process_num_key(9, engine);
|
||||
context.process_num_key(9, engine)
|
||||
});
|
||||
register("press_number_0", |context, engine| {
|
||||
context.process_num_key(0, engine);
|
||||
context.process_num_key(0, engine)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ pub struct AkazaContext {
|
||||
lookup_table: IBusLookupTable,
|
||||
prop_controller: PropController,
|
||||
live_conversion: bool,
|
||||
lookup_table_visible: bool,
|
||||
}
|
||||
|
||||
impl AkazaContext {
|
||||
@ -92,6 +93,7 @@ impl AkazaContext {
|
||||
prop_controller: PropController::new(input_mode)?,
|
||||
consonant_suffix_extractor: ConsonantSuffixExtractor::default(),
|
||||
live_conversion: config.live_conversion,
|
||||
lookup_table_visible: false,
|
||||
})
|
||||
}
|
||||
|
||||
@ -130,11 +132,19 @@ impl AkazaContext {
|
||||
}
|
||||
|
||||
impl AkazaContext {
|
||||
pub(crate) fn process_num_key(&mut self, nn: i32, engine: *mut IBusEngine) {
|
||||
pub(crate) fn process_num_key(&mut self, nn: i32, engine: *mut IBusEngine) -> bool {
|
||||
let idx = if nn == 0 { 9 } else { nn - 1 };
|
||||
|
||||
if self.set_lookup_table_cursor_pos_in_current_page(idx) {
|
||||
self.refresh(engine, true)
|
||||
if self.lookup_table_visible {
|
||||
if self.set_lookup_table_cursor_pos_in_current_page(idx) {
|
||||
self.refresh(engine, true);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
info!("ignore process_num_key. lookup table is not enabled.");
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +220,9 @@ impl AkazaContext {
|
||||
)
|
||||
.cloned()
|
||||
{
|
||||
return self.run_callback_by_name(engine, callback.as_str());
|
||||
if self.run_callback_by_name(engine, callback.as_str()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
match self.current_state.input_mode.prop_name {
|
||||
@ -355,8 +367,7 @@ impl AkazaContext {
|
||||
) -> bool {
|
||||
if let Some(function) = self.command_map.get(function_name) {
|
||||
info!("Calling function '{}'", function_name);
|
||||
function(self, engine);
|
||||
true
|
||||
function(self, engine)
|
||||
} else {
|
||||
error!("Unknown function '{}'", function_name);
|
||||
false
|
||||
@ -539,6 +550,7 @@ impl AkazaContext {
|
||||
&mut self.lookup_table as *mut _,
|
||||
to_gboolean(visible),
|
||||
);
|
||||
self.lookup_table_visible = visible;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user