Skip to content

Attempt to let the cursor show up in the preedit area. #7883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions alacritty/src/display/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,45 @@ impl<'a> RenderableContent<'a> {
let focused_match = search_state.focused_match();
let terminal_content = term.renderable_content();

let mut has_preedit_cursor_pos = false;
let mut preedit_cursor_delta: usize = 0;
let mut preedit_text_length: usize = 0;

match display.ime.preedit() {
None => {}
Some(the_preedit) => {
match the_preedit.cursor_byte_offset {
None => {}
Some(retriedved_offset) => {
has_preedit_cursor_pos = true;
preedit_cursor_delta = retriedved_offset;
preedit_text_length = the_preedit.text.chars().count();
}
}
}
}

// Find terminal cursor shape.
let cursor_shape = if terminal_content.cursor.shape == CursorShape::Hidden
|| display.cursor_hidden
|| search_state.regex().is_some()
|| display.ime.preedit().is_some()
|| (display.ime.preedit().is_some() && !has_preedit_cursor_pos)
{
CursorShape::Hidden
} else if !term.is_focused && config.cursor.unfocused_hollow {
CursorShape::HollowBlock
} else if has_preedit_cursor_pos {
CursorShape::Beam
} else {
terminal_content.cursor.shape
};

// Convert terminal cursor point to viewport position.
let cursor_point = terminal_content.cursor.point;
let mut cursor_point = terminal_content.cursor.point;
if has_preedit_cursor_pos {
cursor_point.column += preedit_cursor_delta;
cursor_point.column -= preedit_text_length;
}
let display_offset = terminal_content.display_offset;
let cursor_point = term::point_to_viewport(display_offset, cursor_point).unwrap();

Expand Down
Loading