pub struct Chunks { /* private fields */ }
Implementations§
source§impl Chunks
impl Chunks
pub fn clear(&mut self)
sourcepub fn register_chunk<T: Any>(&mut self, rect: Rect)
pub fn register_chunk<T: Any>(&mut self, rect: Rect)
Examples found in repository?
examples/custom_chunk.rs (line 19)
11 12 13 14 15 16 17 18 19 20 21 22
pub fn chunk_generator(frame: &mut WidgetFrame, mut chunks: RefMut<Chunks>) -> WidgetResult {
let chunk = layout! {
frame.size(),
constraint!(%50),
constraint!(#1) => {constraint!(#3), constraint!(%100), constraint!(#3)},
constraint!(%50)
}[1][1];
chunks.register_chunk::<TestChunk>(chunk);
Ok(())
}
More examples
examples/message.rs (line 21)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
fn chunk_builder(frame: &mut WidgetFrame, mut chunks: RefMut<Chunks>) -> WidgetResult {
let popup = layout![
frame.size(),
constraint!(%50),
constraint!(>3) => {
constraint!(%10),
constraint!(%80),
constraint!(%10)
},
constraint!(%50)
][1][1];
chunks.register_chunk::<MessageChunk>(popup);
Ok(())
}
examples/custom_state.rs (line 20)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
pub fn handle_state(
frame: &mut WidgetFrame,
mut custom_state: RefMut<CustomState>,
mut events: RefMut<Events>,
mut chunks: RefMut<Chunks>,
) -> WidgetResult {
// Register A Test Chunk
chunks.register_chunk::<CustomChunk>(frame.size());
let chunk = chunks.get_chunk::<CustomChunk>()?;
custom_state.state += 1;
if custom_state.state >= 50 {
events.register_exit();
}
frame.render_widget(
Paragraph::new(format!("Custom State: {}", custom_state.state)),
chunk,
);
Ok(())
}
sourcepub fn get_chunk<T: Any>(&self) -> Result<Rect, Box<dyn Error>>
pub fn get_chunk<T: Any>(&self) -> Result<Rect, Box<dyn Error>>
Examples found in repository?
examples/custom_chunk.rs (line 29)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
pub fn render(
frame: &mut WidgetFrame,
chunks: RefMut<Chunks>,
mut events: RefMut<Events>,
) -> WidgetResult {
let chunk = chunks.get_chunk::<TestChunk>()?;
frame.render_widget(Paragraph::new("Hello, world!"), chunk);
if events.key(crossterm::event::KeyCode::Char('q')) {
events.register_exit();
}
Ok(())
}
More examples
examples/custom_state.rs (line 21)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
pub fn handle_state(
frame: &mut WidgetFrame,
mut custom_state: RefMut<CustomState>,
mut events: RefMut<Events>,
mut chunks: RefMut<Chunks>,
) -> WidgetResult {
// Register A Test Chunk
chunks.register_chunk::<CustomChunk>(frame.size());
let chunk = chunks.get_chunk::<CustomChunk>()?;
custom_state.state += 1;
if custom_state.state >= 50 {
events.register_exit();
}
frame.render_widget(
Paragraph::new(format!("Custom State: {}", custom_state.state)),
chunk,
);
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Chunks
impl Send for Chunks
impl Sync for Chunks
impl Unpin for Chunks
impl UnwindSafe for Chunks
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