buffer: show control char visualizers in yellow (#378)

This commit is contained in:
Dustin L. Howett 2025-06-04 15:32:30 -05:00 committed by GitHub
parent 22e06eb56c
commit 4f3d855afa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1615,6 +1615,7 @@ impl TextBuffer {
let mut global_off = cursor_beg.offset;
let mut cursor_tab = cursor_beg;
let mut cursor_visualizer = cursor_beg;
while global_off < cursor_end.offset {
let chunk = self.read_forward(global_off);
@ -1664,6 +1665,25 @@ impl TextBuffer {
};
// Our manually constructed UTF8 is never going to be invalid. Trust.
line.push_str(unsafe { str::from_utf8_unchecked(&visualizer_buf) });
cursor_visualizer = self.cursor_move_to_offset_internal(
cursor_visualizer,
global_off + chunk_off - 1,
);
let visualizer_rect = {
let left = destination.left
+ self.margin_width
+ cursor_visualizer.visual_pos.x
- origin.x;
let top =
destination.top + cursor_visualizer.visual_pos.y - origin.y;
Rect { left, top, right: left + 1, bottom: top + 1 }
};
let bg = fb.indexed(IndexedColor::Yellow);
let fg = fb.contrasted(bg);
fb.blend_bg(visualizer_rect, bg);
fb.blend_fg(visualizer_rect, fg);
}
}