Skip to content

[BUG] adding content causes views to be pushed off screen. #613

@TwoClocks

Description

@TwoClocks

The following code walks the bottom panel off the bottom of the screen.

While I suppose its height is still the required height, but it's off the screen, so who knows.

I think this is a bug?

If it's not, how do I keep both panels on the screen?

Great crate BTW. It's been fun to use.

fn main() {
    let mut ui = CursiveRunnable::default();
    let mut ui = ui.runner();

    let mut bottom_content = String::with_capacity(1023);
    for n in (1..11).rev() {
        bottom_content.push_str(&format!("{} Line num\n", n));
    }

    ui.add_layer(
        LinearLayout::vertical()
            .child(ResizedView::with_min_height(
                10,
                Panel::new(TextView::new("top content\n").with_name("top")).title("Top Panel"),
            ))
            .child(ResizedView::with_min_height(
                10,
                Panel::new(TextView::new(bottom_content).with_name("bottom")).title("Bottom Panel"),
            )),
    );

    ui.add_global_callback('q', |s| s.quit());

    ui.refresh();
    ui.step();

    while ui.is_running() {
        std::thread::sleep(std::time::Duration::from_millis(500));

        ui.call_on_name("top", |view: &mut TextView| {
            view.append(format!("now is {:?}\n", std::time::Instant::now()))
        });

        ui.refresh();
        ui.step();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions