mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-25 06:00:34 +00:00
feat(frame): replace Frame::size() with Frame::area() (#1293)
Area is the more correct term for the result of this method. The Frame::size() method is marked as deprecated and will be removed around Ratatui version 0.30 or later. Fixes: https://github.com/ratatui-org/ratatui/pull/1254#issuecomment-2268061409
This commit is contained in:
parent
bb68bc6968
commit
f97e07c08a
48 changed files with 101 additions and 139 deletions
|
@ -100,7 +100,7 @@ impl App {
|
|||
|
||||
fn draw(&self, terminal: &mut Terminal) -> Result<()> {
|
||||
terminal.draw(|frame| {
|
||||
let area = frame.size();
|
||||
let area = frame.area();
|
||||
frame.render_widget(
|
||||
Line::from("ratatui async example").centered().cyan().bold(),
|
||||
area,
|
||||
|
|
|
@ -159,7 +159,7 @@ fn run_app<B: Backend>(
|
|||
fn ui(frame: &mut Frame, app: &App) {
|
||||
let vertical = Layout::vertical([Constraint::Ratio(1, 3), Constraint::Ratio(2, 3)]);
|
||||
let horizontal = Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)]);
|
||||
let [top, bottom] = vertical.areas(frame.size());
|
||||
let [top, bottom] = vertical.areas(frame.area());
|
||||
let [left, right] = horizontal.areas(bottom);
|
||||
|
||||
let barchart = BarChart::default()
|
||||
|
|
|
@ -90,7 +90,7 @@ fn handle_events() -> Result<ControlFlow<()>> {
|
|||
}
|
||||
|
||||
fn ui(frame: &mut Frame) {
|
||||
let (title_area, layout) = calculate_layout(frame.size());
|
||||
let (title_area, layout) = calculate_layout(frame.area());
|
||||
|
||||
render_title(frame, title_area);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
}
|
||||
|
||||
fn draw(frame: &mut Frame) {
|
||||
let app_area = frame.size();
|
||||
let app_area = frame.area();
|
||||
|
||||
let calarea = Rect {
|
||||
x: app_area.x + 1,
|
||||
|
|
|
@ -132,7 +132,7 @@ impl App {
|
|||
let horizontal =
|
||||
Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)]);
|
||||
let vertical = Layout::vertical([Constraint::Percentage(50), Constraint::Percentage(50)]);
|
||||
let [map, right] = horizontal.areas(frame.size());
|
||||
let [map, right] = horizontal.areas(frame.area());
|
||||
let [pong, boxes] = vertical.areas(right);
|
||||
|
||||
frame.render_widget(self.map_canvas(), map);
|
||||
|
|
|
@ -151,9 +151,7 @@ fn run_app<B: Backend>(
|
|||
}
|
||||
|
||||
fn ui(frame: &mut Frame, app: &App) {
|
||||
let area = frame.size();
|
||||
|
||||
let [top, bottom] = Layout::vertical([Constraint::Fill(1); 2]).areas(area);
|
||||
let [top, bottom] = Layout::vertical([Constraint::Fill(1); 2]).areas(frame.area());
|
||||
let [animated_chart, bar_chart] =
|
||||
Layout::horizontal([Constraint::Fill(1), Constraint::Length(29)]).areas(top);
|
||||
let [line_chart, scatter] = Layout::horizontal([Constraint::Fill(1); 2]).areas(bottom);
|
||||
|
|
|
@ -70,7 +70,7 @@ fn ui(frame: &mut Frame) {
|
|||
Constraint::Length(17),
|
||||
Constraint::Length(2),
|
||||
])
|
||||
.split(frame.size());
|
||||
.split(frame.area());
|
||||
|
||||
render_named_colors(frame, layout[0]);
|
||||
render_indexed_colors(frame, layout[1]);
|
||||
|
|
|
@ -113,7 +113,7 @@ impl App {
|
|||
/// This is the main event loop for the app.
|
||||
pub fn run(mut self, mut terminal: Terminal<impl Backend>) -> Result<()> {
|
||||
while self.is_running() {
|
||||
terminal.draw(|frame| frame.render_widget(&mut self, frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(&mut self, frame.area()))?;
|
||||
self.handle_events()?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -125,7 +125,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn draw(&self, terminal: &mut Terminal<impl Backend>) -> io::Result<()> {
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.area()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn draw(self, terminal: &mut Terminal<impl Backend>) -> io::Result<()> {
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.area()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ fn ui(frame: &mut Frame, states: [State; 3]) {
|
|||
Constraint::Length(1),
|
||||
Constraint::Min(0), // ignore remaining space
|
||||
]);
|
||||
let [title, buttons, help, _] = vertical.areas(frame.size());
|
||||
let [title, buttons, help, _] = vertical.areas(frame.area());
|
||||
|
||||
frame.render_widget(
|
||||
Paragraph::new("Custom Widget Example (mouse enabled)"),
|
||||
|
|
|
@ -14,7 +14,7 @@ use ratatui::{
|
|||
use crate::app::App;
|
||||
|
||||
pub fn draw(f: &mut Frame, app: &mut App) {
|
||||
let chunks = Layout::vertical([Constraint::Length(3), Constraint::Min(0)]).split(f.size());
|
||||
let chunks = Layout::vertical([Constraint::Length(3), Constraint::Min(0)]).split(f.area());
|
||||
let tabs = app
|
||||
.tabs
|
||||
.titles
|
||||
|
|
|
@ -71,7 +71,7 @@ impl App {
|
|||
fn draw(&self, terminal: &mut Terminal<impl Backend>) -> Result<()> {
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
frame.render_widget(self, frame.size());
|
||||
frame.render_widget(self, frame.area());
|
||||
if self.mode == Mode::Destroy {
|
||||
destroy::destroy(frame);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ pub fn destroy(frame: &mut Frame<'_>) {
|
|||
return;
|
||||
}
|
||||
|
||||
let area = frame.size();
|
||||
let area = frame.area();
|
||||
let buf = frame.buffer_mut();
|
||||
|
||||
drip(frame_count, area, buf);
|
||||
|
|
|
@ -57,7 +57,7 @@ fn main() -> io::Result<()> {
|
|||
fn hello_world(frame: &mut Frame) {
|
||||
frame.render_widget(
|
||||
Paragraph::new("Hello World!").block(Block::bordered().title("Greeting")),
|
||||
frame.size(),
|
||||
frame.area(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ fn layout(frame: &mut Frame) {
|
|||
Constraint::Length(1),
|
||||
]);
|
||||
let horizontal = Layout::horizontal([Constraint::Ratio(1, 2); 2]);
|
||||
let [title_bar, main_area, status_bar] = vertical.areas(frame.size());
|
||||
let [title_bar, main_area, status_bar] = vertical.areas(frame.area());
|
||||
let [left, right] = horizontal.areas(main_area);
|
||||
|
||||
frame.render_widget(
|
||||
|
@ -102,7 +102,7 @@ fn styling(frame: &mut Frame) {
|
|||
Constraint::Length(1),
|
||||
Constraint::Min(0),
|
||||
])
|
||||
.split(frame.size());
|
||||
.split(frame.area());
|
||||
|
||||
let span1 = Span::raw("Hello ");
|
||||
let span2 = Span::styled(
|
||||
|
|
|
@ -185,7 +185,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn draw(self, terminal: &mut Terminal<impl Backend>) -> io::Result<()> {
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.area()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn draw(&self, terminal: &mut Terminal<impl Backend>) -> Result<()> {
|
||||
terminal.draw(|f| f.render_widget(self, f.size()))?;
|
||||
terminal.draw(|f| f.render_widget(self, f.area()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ fn run(terminal: &mut Terminal<CrosstermBackend<Stdout>>) -> Result<()> {
|
|||
/// draws a greeting.
|
||||
fn render_app(frame: &mut Frame) {
|
||||
let greeting = Paragraph::new("Hello World! (press 'q' to quit)");
|
||||
frame.render_widget(greeting, frame.size());
|
||||
frame.render_widget(greeting, frame.area());
|
||||
}
|
||||
|
||||
/// Check if the user has pressed 'q'. This is where you would handle events. This example just
|
||||
|
|
|
@ -56,7 +56,7 @@ impl App {
|
|||
|
||||
fn run(self, terminal: &mut Terminal<CrosstermBackend<Stdout>>) -> io::Result<()> {
|
||||
loop {
|
||||
terminal.draw(|frame| frame.render_widget(&self.hyperlink, frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(&self.hyperlink, frame.area()))?;
|
||||
if let Event::Key(key) = event::read()? {
|
||||
if matches!(key.code, KeyCode::Char('q') | KeyCode::Esc) {
|
||||
break;
|
||||
|
|
|
@ -240,7 +240,7 @@ fn run_app<B: Backend>(
|
|||
}
|
||||
|
||||
fn ui(f: &mut Frame, downloads: &Downloads) {
|
||||
let area = f.size();
|
||||
let area = f.area();
|
||||
|
||||
let block = Block::new().title(block::Title::from("Progress").alignment(Alignment::Center));
|
||||
f.render_widget(block, area);
|
||||
|
|
|
@ -80,7 +80,7 @@ fn ui(frame: &mut Frame) {
|
|||
Length(50), // examples
|
||||
Min(0), // fills remaining space
|
||||
]);
|
||||
let [text_area, examples_area, _] = vertical.areas(frame.size());
|
||||
let [text_area, examples_area, _] = vertical.areas(frame.area());
|
||||
|
||||
// title
|
||||
frame.render_widget(
|
||||
|
|
|
@ -66,7 +66,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn draw(&self, terminal: &mut Terminal<impl Backend>) -> Result<()> {
|
||||
terminal.draw(|f| f.render_widget(self, f.size()))?;
|
||||
terminal.draw(|f| f.render_widget(self, f.area()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ impl TodoItem {
|
|||
impl App {
|
||||
fn run(&mut self, mut terminal: Terminal<impl Backend>) -> io::Result<()> {
|
||||
while !self.should_exit {
|
||||
terminal.draw(|f| f.render_widget(&mut *self, f.size()))?;
|
||||
terminal.draw(|f| f.render_widget(&mut *self, f.area()))?;
|
||||
if let Event::Key(key) = event::read()? {
|
||||
self.handle_key(key);
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
enable_raw_mode()?;
|
||||
execute!(terminal.backend_mut(), EnterAlternateScreen)?;
|
||||
loop {
|
||||
terminal.draw(|frame| frame.render_widget(Text::raw("Hello World!"), frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(Text::raw("Hello World!"), frame.area()))?;
|
||||
if let Event::Key(key) = event::read()? {
|
||||
if key.kind == KeyEventKind::Press && key.code == KeyCode::Char('q') {
|
||||
break;
|
||||
|
|
|
@ -68,7 +68,7 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>) -> io::Result<()> {
|
|||
|
||||
fn ui(frame: &mut Frame) {
|
||||
let vertical = Layout::vertical([Constraint::Length(1), Constraint::Min(0)]);
|
||||
let [text_area, main_area] = vertical.areas(frame.size());
|
||||
let [text_area, main_area] = vertical.areas(frame.area());
|
||||
frame.render_widget(
|
||||
Paragraph::new("Note: not all terminals support all modifiers")
|
||||
.style(Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)),
|
||||
|
|
|
@ -148,5 +148,5 @@ fn ui(f: &mut Frame, app: &App) {
|
|||
.block(Block::bordered().title("Panic Handler Demo"))
|
||||
.centered();
|
||||
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ impl App {
|
|||
|
||||
/// Draw the app to the terminal.
|
||||
fn draw(&mut self, terminal: &mut Tui) -> io::Result<()> {
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.area()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
|||
}
|
||||
|
||||
fn ui(f: &mut Frame, app: &App) {
|
||||
let area = f.size();
|
||||
let area = f.area();
|
||||
|
||||
let vertical = Layout::vertical([Constraint::Percentage(20), Constraint::Percentage(80)]);
|
||||
let [instructions, content] = vertical.areas(area);
|
||||
|
|
|
@ -64,9 +64,7 @@ fn logo() -> String {
|
|||
|
||||
fn main() -> io::Result<()> {
|
||||
let mut terminal = init()?;
|
||||
terminal.draw(|frame| {
|
||||
frame.render_widget(Paragraph::new(logo()), frame.size());
|
||||
})?;
|
||||
terminal.draw(|frame| frame.render_widget(Paragraph::new(logo()), frame.area()))?;
|
||||
sleep(Duration::from_secs(5));
|
||||
restore()?;
|
||||
println!();
|
||||
|
|
|
@ -119,11 +119,11 @@ fn run_app<B: Backend>(
|
|||
|
||||
#[allow(clippy::too_many_lines, clippy::cast_possible_truncation)]
|
||||
fn ui(f: &mut Frame, app: &mut App) {
|
||||
let size = f.size();
|
||||
let area = f.area();
|
||||
|
||||
// Words made "loooong" to demonstrate line breaking.
|
||||
let s = "Veeeeeeeeeeeeeeeery loooooooooooooooooong striiiiiiiiiiiiiiiiiiiiiiiiiing. ";
|
||||
let mut long_line = s.repeat(usize::from(size.width) / s.len() + 4);
|
||||
let mut long_line = s.repeat(usize::from(area.width) / s.len() + 4);
|
||||
long_line.push('\n');
|
||||
|
||||
let chunks = Layout::vertical([
|
||||
|
@ -133,7 +133,7 @@ fn ui(f: &mut Frame, app: &mut App) {
|
|||
Constraint::Percentage(25),
|
||||
Constraint::Percentage(25),
|
||||
])
|
||||
.split(size);
|
||||
.split(area);
|
||||
|
||||
let text = vec![
|
||||
Line::from("This is a line "),
|
||||
|
|
|
@ -151,7 +151,7 @@ fn ui(f: &mut Frame, app: &App) {
|
|||
Constraint::Length(3),
|
||||
Constraint::Min(0),
|
||||
])
|
||||
.split(f.size());
|
||||
.split(f.area());
|
||||
let sparkline = Sparkline::default()
|
||||
.block(
|
||||
Block::new()
|
||||
|
|
|
@ -234,7 +234,7 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
|||
}
|
||||
|
||||
fn ui(f: &mut Frame, app: &mut App) {
|
||||
let rects = Layout::vertical([Constraint::Min(5), Constraint::Length(3)]).split(f.size());
|
||||
let rects = Layout::vertical([Constraint::Min(5), Constraint::Length(3)]).split(f.area());
|
||||
|
||||
app.set_colors();
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn draw(&self, terminal: &mut Terminal<impl Backend>) -> Result<()> {
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.size()))?;
|
||||
terminal.draw(|frame| frame.render_widget(self, frame.area()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -88,11 +88,10 @@ fn handle_events(events: &mut Vec<Event>) -> Result<()> {
|
|||
fn ui(frame: &mut ratatui::Frame, events: &[Event]) {
|
||||
// To view this event, run the example with `RUST_LOG=tracing=debug cargo run --example tracing`
|
||||
trace!(frame_count = frame.count(), event_count = events.len());
|
||||
let area = frame.size();
|
||||
let events = events.iter().map(|e| format!("{e:?}")).collect::<Vec<_>>();
|
||||
let paragraph = Paragraph::new(events.join("\n"))
|
||||
.block(Block::bordered().title("Tracing example. Press 'q' to quit."));
|
||||
frame.render_widget(paragraph, area);
|
||||
frame.render_widget(paragraph, frame.area());
|
||||
}
|
||||
|
||||
/// Initialize the tracing subscriber to log to a file
|
||||
|
|
|
@ -209,7 +209,7 @@ fn ui(f: &mut Frame, app: &App) {
|
|||
Constraint::Length(3),
|
||||
Constraint::Min(1),
|
||||
]);
|
||||
let [help_area, input_area, messages_area] = vertical.areas(f.size());
|
||||
let [help_area, input_area, messages_area] = vertical.areas(f.area());
|
||||
|
||||
let (msg, style) = match app.input_mode {
|
||||
InputMode::Normal => (
|
||||
|
|
|
@ -42,13 +42,25 @@ pub struct CompletedFrame<'a> {
|
|||
}
|
||||
|
||||
impl Frame<'_> {
|
||||
/// The size of the current frame
|
||||
/// The area of the current frame
|
||||
///
|
||||
/// This is guaranteed not to change during rendering, so may be called multiple times.
|
||||
///
|
||||
/// If your app listens for a resize event from the backend, it should ignore the values from
|
||||
/// the event for any calculations that are used to render the current frame and use this value
|
||||
/// instead as this is the size of the buffer that is used to render the current frame.
|
||||
/// instead as this is the area of the buffer that is used to render the current frame.
|
||||
pub const fn area(&self) -> Rect {
|
||||
self.viewport_area
|
||||
}
|
||||
|
||||
/// The area of the current frame
|
||||
///
|
||||
/// This is guaranteed not to change during rendering, so may be called multiple times.
|
||||
///
|
||||
/// If your app listens for a resize event from the backend, it should ignore the values from
|
||||
/// the event for any calculations that are used to render the current frame and use this value
|
||||
/// instead as this is the area of the buffer that is used to render the current frame.
|
||||
#[deprecated = "use .area() as its the more correct name"]
|
||||
pub const fn size(&self) -> Rect {
|
||||
self.viewport_area
|
||||
}
|
||||
|
|
|
@ -1151,10 +1151,7 @@ mod tests {
|
|||
.scroll_padding(padding)
|
||||
.highlight_symbol(">> ");
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
})
|
||||
.draw(|f| f.render_stateful_widget(list, f.area(), &mut state))
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
}
|
||||
|
@ -1177,19 +1174,13 @@ mod tests {
|
|||
let list = List::new(items).scroll_padding(3).highlight_symbol(">> ");
|
||||
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_stateful_widget(&list, size, &mut state);
|
||||
})
|
||||
.draw(|f| f.render_stateful_widget(&list, f.area(), &mut state))
|
||||
.unwrap();
|
||||
|
||||
let offset_after_render = state.offset();
|
||||
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_stateful_widget(&list, size, &mut state);
|
||||
})
|
||||
.draw(|f| f.render_stateful_widget(&list, f.area(), &mut state))
|
||||
.unwrap();
|
||||
|
||||
// Offset after rendering twice should remain the same as after once
|
||||
|
@ -1213,10 +1204,7 @@ mod tests {
|
|||
let list = List::new(items).scroll_padding(1).highlight_symbol(">> ");
|
||||
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
})
|
||||
.draw(|f| f.render_stateful_widget(list, f.area(), &mut state))
|
||||
.unwrap();
|
||||
|
||||
#[rustfmt::skip]
|
||||
|
@ -1248,10 +1236,7 @@ mod tests {
|
|||
let list = List::new(items).scroll_padding(2).highlight_symbol(">> ");
|
||||
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
})
|
||||
.draw(|f| f.render_stateful_widget(list, f.area(), &mut state))
|
||||
.unwrap();
|
||||
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
|
|
@ -485,10 +485,7 @@ mod test {
|
|||
let backend = TestBackend::new(expected.area.width, expected.area.height);
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_widget(paragraph.clone(), size);
|
||||
})
|
||||
.draw(|f| f.render_widget(paragraph.clone(), f.area()))
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer(expected);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ where
|
|||
Constraint::Length(10),
|
||||
Constraint::Length(1),
|
||||
])
|
||||
.split(f.size());
|
||||
.split(f.area());
|
||||
let list = List::new(items)
|
||||
.highlight_symbol(">>")
|
||||
.block(Block::new().borders(Borders::RIGHT));
|
||||
|
|
|
@ -34,14 +34,14 @@ fn terminal_draw_returns_the_completed_frame() -> Result<(), Box<dyn Error>> {
|
|||
let mut terminal = Terminal::new(backend)?;
|
||||
let frame = terminal.draw(|f| {
|
||||
let paragraph = Paragraph::new("Test");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
assert_eq!(frame.buffer.get(0, 0).symbol(), "T");
|
||||
assert_eq!(frame.area, Rect::new(0, 0, 10, 10));
|
||||
terminal.backend_mut().resize(8, 8);
|
||||
let frame = terminal.draw(|f| {
|
||||
let paragraph = Paragraph::new("test");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
assert_eq!(frame.buffer.get(0, 0).symbol(), "t");
|
||||
assert_eq!(frame.area, Rect::new(0, 0, 8, 8));
|
||||
|
@ -55,19 +55,19 @@ fn terminal_draw_increments_frame_count() -> Result<(), Box<dyn Error>> {
|
|||
let frame = terminal.draw(|f| {
|
||||
assert_eq!(f.count(), 0);
|
||||
let paragraph = Paragraph::new("Test");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
assert_eq!(frame.count, 0);
|
||||
let frame = terminal.draw(|f| {
|
||||
assert_eq!(f.count(), 1);
|
||||
let paragraph = Paragraph::new("test");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
assert_eq!(frame.count, 1);
|
||||
let frame = terminal.draw(|f| {
|
||||
assert_eq!(f.count(), 2);
|
||||
let paragraph = Paragraph::new("test");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
assert_eq!(frame.count, 2);
|
||||
Ok(())
|
||||
|
@ -100,7 +100,7 @@ fn terminal_insert_before_moves_viewport() -> Result<(), Box<dyn Error>> {
|
|||
|
||||
terminal.draw(|f| {
|
||||
let paragraph = Paragraph::new("[---- Viewport ----]");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
@ -142,7 +142,7 @@ fn terminal_insert_before_scrolls_on_large_input() -> Result<(), Box<dyn Error>>
|
|||
|
||||
terminal.draw(|f| {
|
||||
let paragraph = Paragraph::new("[---- Viewport ----]");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
@ -194,7 +194,7 @@ fn terminal_insert_before_scrolls_on_many_inserts() -> Result<(), Box<dyn Error>
|
|||
|
||||
terminal.draw(|f| {
|
||||
let paragraph = Paragraph::new("[---- Viewport ----]");
|
||||
f.render_widget(paragraph, f.size());
|
||||
f.render_widget(paragraph, f.area());
|
||||
})?;
|
||||
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
|
|
@ -13,14 +13,13 @@ fn widgets_barchart_not_full_below_max_value() {
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let barchart = BarChart::default()
|
||||
.block(Block::bordered())
|
||||
.data(&[("empty", 0), ("half", 50), ("almost", 99), ("full", 100)])
|
||||
.max(100)
|
||||
.bar_width(7)
|
||||
.bar_gap(0);
|
||||
f.render_widget(barchart, size);
|
||||
f.render_widget(barchart, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
@ -44,7 +43,6 @@ fn widgets_barchart_group() {
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let barchart = BarChart::default()
|
||||
.block(Block::bordered())
|
||||
.data(
|
||||
|
@ -66,7 +64,7 @@ fn widgets_barchart_group() {
|
|||
.group_gap(2)
|
||||
.bar_width(4)
|
||||
.bar_gap(1);
|
||||
f.render_widget(barchart, size);
|
||||
f.render_widget(barchart, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ fn test_render<W: Widget>(widget: W, width: u16, height: u16, expected: &Buffer)
|
|||
let backend = TestBackend::new(width, height);
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| f.render_widget(widget, f.size()))
|
||||
.draw(|f| f.render_widget(widget, f.area()))
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer(expected);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ fn widgets_canvas_draw_labels() {
|
|||
Span::styled(label.clone(), Style::default().fg(Color::Blue)),
|
||||
);
|
||||
});
|
||||
f.render_widget(canvas, f.size());
|
||||
f.render_widget(canvas, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ fn axis_test_case<'line, Lines>(
|
|||
terminal
|
||||
.draw(|f| {
|
||||
let chart = Chart::new(vec![]).x_axis(x_axis).y_axis(y_axis);
|
||||
f.render_widget(chart, f.size());
|
||||
f.render_widget(chart, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -63,7 +63,7 @@ fn widgets_chart_can_render_on_small_areas(#[case] width: u16, #[case] height: u
|
|||
.bounds([0.0, 0.0])
|
||||
.labels(create_labels(&["0.0", "1.0"])),
|
||||
);
|
||||
f.render_widget(chart, f.size());
|
||||
f.render_widget(chart, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ fn widgets_chart_top_line_styling_is_correct() {
|
|||
.labels(create_labels(&["a", "b"])),
|
||||
)
|
||||
.x_axis(Axis::default().bounds([0.0, 1.0]));
|
||||
f.render_widget(widget, f.size());
|
||||
f.render_widget(widget, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ fn widgets_gauge_renders() {
|
|||
.direction(Direction::Vertical)
|
||||
.margin(2)
|
||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||
.split(f.size());
|
||||
.split(f.area());
|
||||
|
||||
let gauge = Gauge::default()
|
||||
.block(Block::bordered().title("Percentage"))
|
||||
|
@ -68,7 +68,7 @@ fn widgets_gauge_renders_no_unicode() {
|
|||
.direction(Direction::Vertical)
|
||||
.margin(2)
|
||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||
.split(f.size());
|
||||
.split(f.area());
|
||||
|
||||
let gauge = Gauge::default()
|
||||
.block(Block::bordered().title("Percentage"))
|
||||
|
@ -115,7 +115,7 @@ fn widgets_gauge_applies_styles() {
|
|||
.fg(Color::Green)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
));
|
||||
f.render_widget(gauge, f.size());
|
||||
f.render_widget(gauge, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
let mut expected = Buffer::with_lines([
|
||||
|
@ -167,7 +167,7 @@ fn widgets_gauge_supports_large_labels() {
|
|||
let gauge = Gauge::default()
|
||||
.percent(43)
|
||||
.label("43333333333333333333333333333%");
|
||||
f.render_widget(gauge, f.size());
|
||||
f.render_widget(gauge, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(["4333333333"]);
|
||||
|
|
|
@ -34,7 +34,6 @@ fn widgets_list_should_highlight_the_selected_item() {
|
|||
state.select(Some(1));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let items = vec![
|
||||
ListItem::new("Item 1"),
|
||||
ListItem::new("Item 2"),
|
||||
|
@ -43,7 +42,7 @@ fn widgets_list_should_highlight_the_selected_item() {
|
|||
let list = List::new(items)
|
||||
.highlight_style(Style::default().bg(Color::Yellow))
|
||||
.highlight_symbol(">> ");
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
f.render_stateful_widget(list, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
#[rustfmt::skip]
|
||||
|
@ -69,7 +68,6 @@ fn widgets_list_should_highlight_the_selected_item_wide_symbol() {
|
|||
state.select(Some(1));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let items = vec![
|
||||
ListItem::new("Item 1"),
|
||||
ListItem::new("Item 2"),
|
||||
|
@ -78,7 +76,7 @@ fn widgets_list_should_highlight_the_selected_item_wide_symbol() {
|
|||
let list = List::new(items)
|
||||
.highlight_style(Style::default().bg(Color::Yellow))
|
||||
.highlight_symbol(wide_symbol);
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
f.render_stateful_widget(list, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
#[rustfmt::skip]
|
||||
|
@ -155,7 +153,6 @@ fn widgets_list_should_clamp_offset_if_items_are_removed() {
|
|||
state.select(Some(5));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let items = vec![
|
||||
ListItem::new("Item 0"),
|
||||
ListItem::new("Item 1"),
|
||||
|
@ -165,7 +162,7 @@ fn widgets_list_should_clamp_offset_if_items_are_removed() {
|
|||
ListItem::new("Item 5"),
|
||||
];
|
||||
let list = List::new(items).highlight_symbol(">> ");
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
f.render_stateful_widget(list, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
@ -179,10 +176,9 @@ fn widgets_list_should_clamp_offset_if_items_are_removed() {
|
|||
state.select(Some(1));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let items = vec![ListItem::new("Item 3")];
|
||||
let list = List::new(items).highlight_symbol(">> ");
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
f.render_stateful_widget(list, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
@ -201,7 +197,6 @@ fn widgets_list_should_display_multiline_items() {
|
|||
state.select(Some(1));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let items = vec![
|
||||
ListItem::new(vec![Line::from("Item 1"), Line::from("Item 1a")]),
|
||||
ListItem::new(vec![Line::from("Item 2"), Line::from("Item 2b")]),
|
||||
|
@ -210,7 +205,7 @@ fn widgets_list_should_display_multiline_items() {
|
|||
let list = List::new(items)
|
||||
.highlight_style(Style::default().bg(Color::Yellow))
|
||||
.highlight_symbol(">> ");
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
f.render_stateful_widget(list, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
let mut expected = Buffer::with_lines([
|
||||
|
@ -236,7 +231,6 @@ fn widgets_list_should_repeat_highlight_symbol() {
|
|||
state.select(Some(1));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let items = vec![
|
||||
ListItem::new(vec![Line::from("Item 1"), Line::from("Item 1a")]),
|
||||
ListItem::new(vec![Line::from("Item 2"), Line::from("Item 2b")]),
|
||||
|
@ -246,7 +240,7 @@ fn widgets_list_should_repeat_highlight_symbol() {
|
|||
.highlight_style(Style::default().bg(Color::Yellow))
|
||||
.highlight_symbol(">> ")
|
||||
.repeat_highlight_symbol(true);
|
||||
f.render_stateful_widget(list, size, &mut state);
|
||||
f.render_stateful_widget(list, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
let mut expected = Buffer::with_lines([
|
||||
|
@ -281,7 +275,7 @@ fn widget_list_should_not_ignore_empty_string_items() {
|
|||
.style(Style::default())
|
||||
.highlight_style(Style::default());
|
||||
|
||||
f.render_widget(list, f.size());
|
||||
f.render_widget(list, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal
|
||||
|
@ -363,7 +357,6 @@ fn widgets_list_enable_always_highlight_spacing<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = List::new(vec![
|
||||
ListItem::new(vec![Line::from("Item 1"), Line::from("Item 1a")]),
|
||||
ListItem::new(vec![Line::from("Item 2"), Line::from("Item 2b")]),
|
||||
|
@ -372,7 +365,7 @@ fn widgets_list_enable_always_highlight_spacing<'line, Lines>(
|
|||
.block(Block::bordered())
|
||||
.highlight_symbol(">> ")
|
||||
.highlight_spacing(space);
|
||||
f.render_stateful_widget(table, size, &mut state);
|
||||
f.render_stateful_widget(table, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
terminal
|
||||
|
|
|
@ -14,10 +14,7 @@ fn test_case(paragraph: Paragraph, expected: &Buffer) {
|
|||
let backend = TestBackend::new(expected.area.width, expected.area.height);
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_widget(paragraph, size);
|
||||
})
|
||||
.draw(|f| f.render_widget(paragraph, f.area()))
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer(expected);
|
||||
}
|
||||
|
@ -56,12 +53,11 @@ fn widgets_paragraph_renders_mixed_width_graphemes() {
|
|||
let s = "aコンピュータ上で文字を扱う場合、";
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let text = vec![Line::from(s)];
|
||||
let paragraph = Paragraph::new(text)
|
||||
.block(Block::bordered())
|
||||
.wrap(Wrap { trim: true });
|
||||
f.render_widget(paragraph, size);
|
||||
f.render_widget(paragraph, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
|
|
@ -71,7 +71,6 @@ fn widgets_table_column_spacing_can_be_changed<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"]),
|
||||
|
@ -88,7 +87,7 @@ fn widgets_table_column_spacing_can_be_changed<'line, Lines>(
|
|||
.header(Row::new(vec!["Head1", "Head2", "Head3"]).bottom_margin(1))
|
||||
.block(Block::bordered())
|
||||
.column_spacing(column_spacing);
|
||||
f.render_widget(table, size);
|
||||
f.render_widget(table, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -154,7 +153,6 @@ fn widgets_table_columns_widths_can_use_fixed_length_constraints<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"]),
|
||||
|
@ -166,7 +164,7 @@ fn widgets_table_columns_widths_can_use_fixed_length_constraints<'line, Lines>(
|
|||
)
|
||||
.header(Row::new(vec!["Head1", "Head2", "Head3"]).bottom_margin(1))
|
||||
.block(Block::bordered());
|
||||
f.render_widget(table, size);
|
||||
f.render_widget(table, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -244,7 +242,6 @@ fn widgets_table_columns_widths_can_use_percentage_constraints<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"]),
|
||||
|
@ -257,7 +254,7 @@ fn widgets_table_columns_widths_can_use_percentage_constraints<'line, Lines>(
|
|||
.header(Row::new(vec!["Head1", "Head2", "Head3"]).bottom_margin(1))
|
||||
.block(Block::bordered())
|
||||
.column_spacing(0);
|
||||
f.render_widget(table, size);
|
||||
f.render_widget(table, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -339,7 +336,6 @@ fn widgets_table_columns_widths_can_use_mixed_constraints<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"]),
|
||||
|
@ -351,7 +347,7 @@ fn widgets_table_columns_widths_can_use_mixed_constraints<'line, Lines>(
|
|||
)
|
||||
.header(Row::new(vec!["Head1", "Head2", "Head3"]).bottom_margin(1))
|
||||
.block(Block::bordered());
|
||||
f.render_widget(table, size);
|
||||
f.render_widget(table, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -425,7 +421,6 @@ fn widgets_table_columns_widths_can_use_ratio_constraints<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"]),
|
||||
|
@ -438,7 +433,7 @@ fn widgets_table_columns_widths_can_use_ratio_constraints<'line, Lines>(
|
|||
.header(Row::new(vec!["Head1", "Head2", "Head3"]).bottom_margin(1))
|
||||
.block(Block::bordered())
|
||||
.column_spacing(0);
|
||||
f.render_widget(table, size);
|
||||
f.render_widget(table, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -509,7 +504,6 @@ fn widgets_table_can_have_rows_with_multi_lines<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"]),
|
||||
|
@ -527,7 +521,7 @@ fn widgets_table_can_have_rows_with_multi_lines<'line, Lines>(
|
|||
.block(Block::bordered())
|
||||
.highlight_symbol(">> ")
|
||||
.column_spacing(1);
|
||||
f.render_stateful_widget(table, size, &mut state);
|
||||
f.render_stateful_widget(table, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -608,7 +602,6 @@ fn widgets_table_enable_always_highlight_spacing<'line, Lines>(
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"]),
|
||||
|
@ -627,7 +620,7 @@ fn widgets_table_enable_always_highlight_spacing<'line, Lines>(
|
|||
.highlight_symbol(">> ")
|
||||
.highlight_spacing(space)
|
||||
.column_spacing(1);
|
||||
f.render_stateful_widget(table, size, &mut state);
|
||||
f.render_stateful_widget(table, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines(expected);
|
||||
|
@ -641,7 +634,6 @@ fn widgets_table_can_have_elements_styled_individually() {
|
|||
state.select(Some(0));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row11", "Row12", "Row13"])
|
||||
|
@ -668,7 +660,7 @@ fn widgets_table_can_have_elements_styled_individually() {
|
|||
.highlight_symbol(">> ")
|
||||
.highlight_style(Style::default().add_modifier(Modifier::BOLD))
|
||||
.column_spacing(1);
|
||||
f.render_stateful_widget(table, size, &mut state);
|
||||
f.render_stateful_widget(table, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
@ -719,7 +711,6 @@ fn widgets_table_should_render_even_if_empty() {
|
|||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
Vec::<Row>::new(),
|
||||
[
|
||||
|
@ -731,7 +722,7 @@ fn widgets_table_should_render_even_if_empty() {
|
|||
.header(Row::new(vec!["Head1", "Head2", "Head3"]))
|
||||
.block(Block::new().borders(Borders::LEFT | Borders::RIGHT))
|
||||
.column_spacing(1);
|
||||
f.render_widget(table, size);
|
||||
f.render_widget(table, f.area());
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
@ -768,10 +759,7 @@ fn widgets_table_columns_dont_panic() {
|
|||
let backend = TestBackend::new(table_width, 8);
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
f.render_stateful_widget(table, size, &mut state);
|
||||
})
|
||||
.draw(|f| f.render_stateful_widget(table, f.area(), &mut state))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
@ -785,7 +773,6 @@ fn widgets_table_should_clamp_offset_if_rows_are_removed() {
|
|||
state.select(Some(5));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![
|
||||
Row::new(vec!["Row01", "Row02", "Row03"]),
|
||||
|
@ -804,7 +791,7 @@ fn widgets_table_should_clamp_offset_if_rows_are_removed() {
|
|||
.header(Row::new(vec!["Head1", "Head2", "Head3"]).bottom_margin(1))
|
||||
.block(Block::bordered())
|
||||
.column_spacing(1);
|
||||
f.render_stateful_widget(table, size, &mut state);
|
||||
f.render_stateful_widget(table, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
@ -822,7 +809,6 @@ fn widgets_table_should_clamp_offset_if_rows_are_removed() {
|
|||
state.select(Some(1));
|
||||
terminal
|
||||
.draw(|f| {
|
||||
let size = f.size();
|
||||
let table = Table::new(
|
||||
vec![Row::new(vec!["Row31", "Row32", "Row33"])],
|
||||
[
|
||||
|
@ -834,7 +820,7 @@ fn widgets_table_should_clamp_offset_if_rows_are_removed() {
|
|||
.header(Row::new(vec!["Head1", "Head2", "Head3"]).bottom_margin(1))
|
||||
.block(Block::bordered())
|
||||
.column_spacing(1);
|
||||
f.render_stateful_widget(table, size, &mut state);
|
||||
f.render_stateful_widget(table, f.area(), &mut state);
|
||||
})
|
||||
.unwrap();
|
||||
terminal.backend().assert_buffer_lines([
|
||||
|
|
Loading…
Reference in a new issue