Skip to content

Commit

Permalink
[libgui - Rust] TextView.clear() actually erases drawn text
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Feb 7, 2024
1 parent 14eeec2 commit e35967c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rust_programs/libgui/src/text_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,17 @@ impl TextView {
}

pub fn clear(&self) {
// Create a bounding box that covers all the text
let mut bounding_box = Rect::zero();
let onto = &mut self.get_slice().get_slice(self.text_entry_frame());
for drawn_ch in self.text.borrow().iter() {
//bounding_box = bounding_box.union(drawn_ch.draw_box);
let ch_slice = onto.get_slice(drawn_ch.draw_box);
ch_slice.fill(Color::white());
}
// And fill it with the background color
//let slice = self.get_slice();

*self.text.borrow_mut() = vec![];
*self.cursor_pos.borrow_mut() = CursorPos(0, Point::zero());
Bordered::draw(&*self.view);
Expand Down

0 comments on commit e35967c

Please sign in to comment.