Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions cursive-core/src/cursive_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ pub struct Cursive {

menubar: views::Menubar,

pub(crate) needs_clear: bool,
needs_clear: bool,
needs_complete_clear: bool,

running: bool,

Expand Down Expand Up @@ -97,6 +98,7 @@ impl Cursive {
menubar: views::Menubar::new(),
last_size: Vec2::zero(),
needs_clear: true,
needs_complete_clear: false,
running: true,
cb_source,
cb_sink,
Expand Down Expand Up @@ -128,7 +130,11 @@ impl Cursive {

let printer = Printer::new(size, &self.theme, buffer);

if self.needs_clear {
if self.needs_complete_clear {
buffer.write().clear();
self.needs_complete_clear = false;
self.needs_clear = false;
} else if self.needs_clear {
printer.clear();
self.needs_clear = false;
}
Expand Down Expand Up @@ -408,6 +414,14 @@ impl Cursive {
self.needs_clear = true;
}

/// Force a full redraw on the next frame.
///
/// [`clear`](Self::clear) clears only working area (that cursive writes to), while this method
/// will do a complete clear. Use it after running external programs, i.e. editor.
pub fn complete_clear(&mut self) {
self.needs_complete_clear = true;
}

/// Loads a theme from the given file.
///
/// `filename` must point to a valid toml file.
Expand Down