Fixed cursor drawing for texts with graphemes in them.
This commit is contained in:
parent
2e9c2b2704
commit
f221b90a82
|
@ -401,7 +401,7 @@ impl TermUI {
|
||||||
let gutter_width = editor.editor_dim.1 - editor.view_dim.1;
|
let gutter_width = editor.editor_dim.1 - editor.view_dim.1;
|
||||||
let (line_index, col_i) = editor.buffer.index_to_line_col(editor.view_pos.0);
|
let (line_index, col_i) = editor.buffer.index_to_line_col(editor.view_pos.0);
|
||||||
let (mut line_block_index, _) = block_index_and_offset(col_i);
|
let (mut line_block_index, _) = block_index_and_offset(col_i);
|
||||||
let mut grapheme_index = editor
|
let mut char_index = editor
|
||||||
.buffer
|
.buffer
|
||||||
.line_col_to_index((line_index, line_block_index * LINE_BLOCK_LENGTH));
|
.line_col_to_index((line_index, line_block_index * LINE_BLOCK_LENGTH));
|
||||||
let temp_line = editor.buffer.get_line(line_index);
|
let temp_line = editor.buffer.get_line(line_index);
|
||||||
|
@ -415,7 +415,7 @@ impl TermUI {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.graphemes(),
|
.graphemes(),
|
||||||
editor.view_pos.0 - grapheme_index,
|
editor.view_pos.0 - char_index,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut screen_line = c1.0 as isize - vis_line_offset as isize;
|
let mut screen_line = c1.0 as isize - vis_line_offset as isize;
|
||||||
|
@ -480,7 +480,7 @@ impl TermUI {
|
||||||
// Check if the character is within a cursor
|
// Check if the character is within a cursor
|
||||||
let mut at_cursor = false;
|
let mut at_cursor = false;
|
||||||
for c in editor.cursors.iter() {
|
for c in editor.cursors.iter() {
|
||||||
if grapheme_index >= c.range.0 && grapheme_index <= c.range.1 {
|
if char_index >= c.range.0 && char_index <= c.range.1 {
|
||||||
at_cursor = true;
|
at_cursor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,13 +544,13 @@ impl TermUI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char_index += g.chars().count();
|
||||||
|
line_g_index += 1;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
grapheme_index += 1;
|
|
||||||
line_g_index += 1;
|
|
||||||
|
|
||||||
if line_g_index >= LINE_BLOCK_LENGTH {
|
if line_g_index >= LINE_BLOCK_LENGTH {
|
||||||
line_block_index += 1;
|
line_block_index += 1;
|
||||||
line_g_index = 0;
|
line_g_index = 0;
|
||||||
|
@ -575,7 +575,7 @@ impl TermUI {
|
||||||
// Check if the character is within a cursor
|
// Check if the character is within a cursor
|
||||||
let mut at_cursor = false;
|
let mut at_cursor = false;
|
||||||
for c in editor.cursors.iter() {
|
for c in editor.cursors.iter() {
|
||||||
if grapheme_index >= c.range.0 && grapheme_index <= c.range.1 {
|
if char_index >= c.range.0 && char_index <= c.range.1 {
|
||||||
at_cursor = true;
|
at_cursor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user