parent
5c9b8e8321
commit
37fa42d5cc
1 changed files with 13 additions and 12 deletions
|
@ -691,17 +691,9 @@ fn handle_ime_composition_inner(
|
||||||
lparam: LPARAM,
|
lparam: LPARAM,
|
||||||
state_ptr: Rc<WindowsWindowStatePtr>,
|
state_ptr: Rc<WindowsWindowStatePtr>,
|
||||||
) -> Option<isize> {
|
) -> Option<isize> {
|
||||||
if lparam.0 == 0 {
|
|
||||||
// Japanese IME may send this message with lparam = 0, which indicates that
|
|
||||||
// there is no composition string.
|
|
||||||
with_input_handler(&state_ptr, |input_handler| {
|
|
||||||
input_handler.replace_text_in_range(None, "");
|
|
||||||
})?;
|
|
||||||
return Some(0);
|
|
||||||
}
|
|
||||||
let mut ime_input = None;
|
let mut ime_input = None;
|
||||||
if lparam.0 as u32 & GCS_COMPSTR.0 > 0 {
|
if lparam.0 as u32 & GCS_COMPSTR.0 > 0 {
|
||||||
let comp_string = parse_ime_compostion_string(ctx)?;
|
let comp_string = parse_ime_composition_string(ctx)?;
|
||||||
with_input_handler(&state_ptr, |input_handler| {
|
with_input_handler(&state_ptr, |input_handler| {
|
||||||
input_handler.replace_and_mark_text_in_range(None, &comp_string, None);
|
input_handler.replace_and_mark_text_in_range(None, &comp_string, None);
|
||||||
})?;
|
})?;
|
||||||
|
@ -719,12 +711,21 @@ fn handle_ime_composition_inner(
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
if lparam.0 as u32 & GCS_RESULTSTR.0 > 0 {
|
if lparam.0 as u32 & GCS_RESULTSTR.0 > 0 {
|
||||||
let comp_result = parse_ime_compostion_result(ctx)?;
|
let comp_result = parse_ime_composition_result(ctx)?;
|
||||||
with_input_handler(&state_ptr, |input_handler| {
|
with_input_handler(&state_ptr, |input_handler| {
|
||||||
input_handler.replace_text_in_range(None, &comp_result);
|
input_handler.replace_text_in_range(None, &comp_result);
|
||||||
})?;
|
})?;
|
||||||
return Some(0);
|
return Some(0);
|
||||||
}
|
}
|
||||||
|
if lparam.0 == 0 {
|
||||||
|
// Japanese IME may send this message with lparam = 0, which indicates that
|
||||||
|
// there is no composition string.
|
||||||
|
with_input_handler(&state_ptr, |input_handler| {
|
||||||
|
input_handler.replace_text_in_range(None, "");
|
||||||
|
})?;
|
||||||
|
return Some(0);
|
||||||
|
}
|
||||||
|
|
||||||
// currently, we don't care other stuff
|
// currently, we don't care other stuff
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1353,7 +1354,7 @@ fn parse_normal_key(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_ime_compostion_string(ctx: HIMC) -> Option<String> {
|
fn parse_ime_composition_string(ctx: HIMC) -> Option<String> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let string_len = ImmGetCompositionStringW(ctx, GCS_COMPSTR, None, 0);
|
let string_len = ImmGetCompositionStringW(ctx, GCS_COMPSTR, None, 0);
|
||||||
if string_len >= 0 {
|
if string_len >= 0 {
|
||||||
|
@ -1380,7 +1381,7 @@ fn retrieve_composition_cursor_position(ctx: HIMC) -> usize {
|
||||||
unsafe { ImmGetCompositionStringW(ctx, GCS_CURSORPOS, None, 0) as usize }
|
unsafe { ImmGetCompositionStringW(ctx, GCS_CURSORPOS, None, 0) as usize }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_ime_compostion_result(ctx: HIMC) -> Option<String> {
|
fn parse_ime_composition_result(ctx: HIMC) -> Option<String> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let string_len = ImmGetCompositionStringW(ctx, GCS_RESULTSTR, None, 0);
|
let string_len = ImmGetCompositionStringW(ctx, GCS_RESULTSTR, None, 0);
|
||||||
if string_len >= 0 {
|
if string_len >= 0 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue