Specify the line height to the IME cursor height
This commit is contained in:
parent
888b1b5f6b
commit
768ee43d5a
1 changed files with 6 additions and 4 deletions
|
|
@ -252,22 +252,24 @@ where
|
||||||
let mut col = cursor.point.column.0;
|
let mut col = cursor.point.column.0;
|
||||||
let line = cursor.point.line.0;
|
let line = cursor.point.line.0;
|
||||||
let width = terminal.size().cell_width;
|
let width = terminal.size().cell_width;
|
||||||
let mut bottom_left = Vector::<f32>::ZERO;
|
let mut cursor_position = Vector::<f32>::ZERO;
|
||||||
|
let mut line_height = 0.0;
|
||||||
terminal.with_buffer(|buffer| {
|
terminal.with_buffer(|buffer| {
|
||||||
let layout = buffer.layout_runs().nth(line as usize).unwrap();
|
let layout = buffer.layout_runs().nth(line as usize).unwrap();
|
||||||
for glyph in layout.glyphs {
|
for glyph in layout.glyphs {
|
||||||
bottom_left.x += glyph.w;
|
cursor_position.x += glyph.w;
|
||||||
let ch_width = if glyph.w > width { 2 } else { 1 };
|
let ch_width = if glyph.w > width { 2 } else { 1 };
|
||||||
if ch_width > col {
|
if ch_width > col {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
col -= ch_width;
|
col -= ch_width;
|
||||||
}
|
}
|
||||||
bottom_left.y = layout.line_top + layout.line_height;
|
cursor_position.y = layout.line_top;
|
||||||
|
line_height = layout.line_height;
|
||||||
});
|
});
|
||||||
|
|
||||||
InputMethod::Enabled {
|
InputMethod::Enabled {
|
||||||
cursor: Rectangle::new(view_position + bottom_left, Size::default()),
|
cursor: Rectangle::new(view_position + cursor_position, Size::new(1.0, line_height)),
|
||||||
purpose: input_method::Purpose::Normal,
|
purpose: input_method::Purpose::Normal,
|
||||||
preedit: state.preedit.as_ref().map(input_method::Preedit::as_ref),
|
preedit: state.preedit.as_ref().map(input_method::Preedit::as_ref),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue