Skip to content

Commit

Permalink
Unimplement Component for Canvas
Browse files Browse the repository at this point in the history
Summary: For the following diff D44812407

Differential Revision: D44812165

fbshipit-source-id: 4b4977a8a2b078338f14a890c5e21c8835c007ef
  • Loading branch information
stepancheg authored and facebook-github-bot committed Apr 10, 2023
1 parent 61d6e0c commit 0d74a2c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions superconsole/src/components/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crossterm::terminal::ClearType;
use crate::components::Blank;
use crate::components::Dimensions;
use crate::components::DrawMode;
use crate::content::LinesExt;
use crate::Component;
use crate::Line;
use crate::State;
Expand All @@ -43,17 +44,19 @@ impl Default for Canvas {
}
}

impl Component for Canvas {
impl Canvas {
/// A passthrough method that resizes the Canvas to reflect the size of the root.
/// Allows dynamic resizing.
/// Cuts off any lines that are too for long a single row
fn draw_unchecked(
pub(crate) fn draw(
&self,
state: &State,
dimensions: Dimensions,
mode: DrawMode,
) -> anyhow::Result<Vec<Line>> {
let output = self.child.draw(state, dimensions, mode)?;
let mut output = self.child.draw(state, dimensions, mode)?;
// We don't trust the child to not truncate the result.
output.shrink_lines_to_dimensions(dimensions);
self.len.set(output.len().try_into()?);
Ok(output)
}
Expand Down

0 comments on commit 0d74a2c

Please sign in to comment.