cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Missing BufferView scrollable()

Open mikart143 opened this issue 3 years ago • 1 comments

Bug/Help

Problem description

Hello! When I add Scrolls via scrollable() method on BufferView from logs example my view behave strangly. With ScrollView I get only single line when previosly I get all the lines of logs. Know every new log rewrite the old line. How can I implement ScrollView for BufferView ?

Code:

pub fn init_tui(rx : mpsc::Receiver<String>){
    let mut siv = cursive::default();

    // siv.add_layer(BufferView::new(200, rx).full_screen());

    let mut tab_panel = TabPanel::new()
        .with_tab("Main", main_tab())
        .with_tab("Logs", log_tab(rx));

    tab_panel.set_active_tab("Main");

    siv.add_layer(tab_panel);

    siv.run();
}

fn log_tab(rx :mpsc::Receiver<String>) -> ResizedView<Dialog> {
    Dialog::around(BufferView::new(200, rx).scrollable())
        .title("Live Logs")
        .min_size(cursive::XY::new(100,50))

}

Image: image

Environment

  • Operating system: Manjaro
  • Backend used: crossterm
  • Current locale (run locale in a terminal):

LANG=en_GB.UTF-8 LC_CTYPE="en_GB.UTF-8" LC_NUMERIC=pl_PL.UTF-8 LC_TIME=pl_PL.UTF-8 LC_COLLATE="en_GB.UTF-8" LC_MONETARY=pl_PL.UTF-8 LC_MESSAGES="en_GB.UTF-8" LC_PAPER=pl_PL.UTF-8 LC_NAME=pl_PL.UTF-8 LC_ADDRESS=pl_PL.UTF-8 LC_TELEPHONE=pl_PL.UTF-8 LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=pl_PL.UTF-8 LC_ALL=

  • Cursive version (from crates.io, from git, ...):0.15.0

mikart143 avatar Sep 09 '20 12:09 mikart143

Hi, and thanks for the report!

The BufferView from the example may not have been implemented super carefully, especially if it's going to be embedded in a ScrollView. It doesn't really define its required size, or its "important area", which ScrollView relies on.

I probably should update the example to correctly implement that, making the BufferView there a bit more re-usable.

gyscos avatar Sep 22 '20 16:09 gyscos