|
|
@ -402,7 +402,7 @@ impl<'a> TextRenderer<'a> {
|
|
|
|
is_in_indent_area: &mut bool,
|
|
|
|
is_in_indent_area: &mut bool,
|
|
|
|
position: Position,
|
|
|
|
position: Position,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let cut_off_start = self.col_offset.saturating_sub(position.col as usize);
|
|
|
|
let cut_off_start = self.col_offset.saturating_sub(position.col);
|
|
|
|
let is_whitespace = grapheme.is_whitespace();
|
|
|
|
let is_whitespace = grapheme.is_whitespace();
|
|
|
|
|
|
|
|
|
|
|
|
// TODO is it correct to apply the whitspace style to all unicode white spaces?
|
|
|
|
// TODO is it correct to apply the whitspace style to all unicode white spaces?
|
|
|
@ -413,7 +413,7 @@ impl<'a> TextRenderer<'a> {
|
|
|
|
let width = grapheme.width();
|
|
|
|
let width = grapheme.width();
|
|
|
|
let grapheme = match grapheme {
|
|
|
|
let grapheme = match grapheme {
|
|
|
|
Grapheme::Tab { width } => {
|
|
|
|
Grapheme::Tab { width } => {
|
|
|
|
let grapheme_tab_width = char_to_byte_idx(&self.tab, width as usize);
|
|
|
|
let grapheme_tab_width = char_to_byte_idx(&self.tab, width);
|
|
|
|
&self.tab[..grapheme_tab_width]
|
|
|
|
&self.tab[..grapheme_tab_width]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO special rendering for other whitespaces?
|
|
|
|
// TODO special rendering for other whitespaces?
|
|
|
@ -423,8 +423,8 @@ impl<'a> TextRenderer<'a> {
|
|
|
|
Grapheme::Newline => &self.newline,
|
|
|
|
Grapheme::Newline => &self.newline,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let in_bounds = self.col_offset <= (position.col as usize)
|
|
|
|
let in_bounds = self.col_offset <= position.col
|
|
|
|
&& (position.col as usize) < self.viewport.width as usize + self.col_offset;
|
|
|
|
&& position.col < self.viewport.width as usize + self.col_offset;
|
|
|
|
|
|
|
|
|
|
|
|
if in_bounds {
|
|
|
|
if in_bounds {
|
|
|
|
self.surface.set_string(
|
|
|
|
self.surface.set_string(
|
|
|
@ -433,10 +433,10 @@ impl<'a> TextRenderer<'a> {
|
|
|
|
grapheme,
|
|
|
|
grapheme,
|
|
|
|
style,
|
|
|
|
style,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else if cut_off_start != 0 && cut_off_start < width as usize {
|
|
|
|
} else if cut_off_start != 0 && cut_off_start < width {
|
|
|
|
// partially on screen
|
|
|
|
// partially on screen
|
|
|
|
let rect = Rect::new(
|
|
|
|
let rect = Rect::new(
|
|
|
|
self.viewport.x as u16,
|
|
|
|
self.viewport.x,
|
|
|
|
self.viewport.y + position.row as u16,
|
|
|
|
self.viewport.y + position.row as u16,
|
|
|
|
(width - cut_off_start) as u16,
|
|
|
|
(width - cut_off_start) as u16,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|