pub struct Clear;
Expand description
A widget to clear/reset a certain area to allow overdrawing (e.g. for popups).
This widget cannot be used to clear the terminal on the first render as ratatui
assumes
the render area is empty. Use crate::Terminal::clear
instead.
§Examples
use ratatui::{
layout::Rect,
widgets::{Block, Clear},
Frame,
};
fn draw_on_clear(f: &mut Frame, area: Rect) {
let block = Block::bordered().title("Block");
f.render_widget(Clear, area); // <- this will clear/reset the area first
f.render_widget(block, area); // now render the block widget
}
§Popup Example
For a more complete example how to utilize Clear
to realize popups see
the example examples/popup.rs
Trait Implementations§
Source§impl WidgetRef for Clear
impl WidgetRef for Clear
Source§fn render_ref(&self, area: Rect, buf: &mut Buffer)
fn render_ref(&self, area: Rect, buf: &mut Buffer)
Draws the current state of the widget in the given buffer. That is the only method required
to implement a custom widget.
impl Eq for Clear
impl StructuralPartialEq for Clear
Auto Trait Implementations§
impl Freeze for Clear
impl RefUnwindSafe for Clear
impl Send for Clear
impl Sync for Clear
impl Unpin for Clear
impl UnwindSafe for Clear
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more