mirror of
https://github.com/microsoft/edit.git
synced 2025-07-07 21:35:16 +00:00
buffer: show control char visualizers in yellow (#378)
This commit is contained in:
parent
22e06eb56c
commit
4f3d855afa
1 changed files with 20 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue