AMythicDev / minus

An asynchronous, runtime data feedable terminal paging library for Rust
https://crates.io/crates/minus/
Apache License 2.0
317 stars 23 forks source link

A couple of issues using the static output mode #94

Closed rwestphal closed 1 year ago

rwestphal commented 1 year ago

Hello! I would like to report a few issues I have encountered while using minus version 5.3.0 for paginating static output. Here is a sample program to illustrate the problems:

fn page_output(data: &str) -> Result<(), minus::error::MinusError> {
    let pager = minus::Pager::new();
    pager.set_exit_strategy(minus::ExitStrategy::PagerQuit)?;
    //pager.set_run_no_overflow(true)?;
    pager.set_text(data)?;
    minus::page_all(pager)?;

    Ok(())
}

fn main() {
    page_output("Lorem ipsum dolor sit amet, consectetur adipiscing elit.").unwrap();
    page_output("Morbi enim purus, maximus eget justo vel, efficitur pretium arcu.").unwrap();
}

The issues I've encountered are:

1 - Selecting paginated text using the mouse doesn't work. This is a regression that occurred between 5.0.1 and 5.0.2 2 - If I uncomment the set_run_no_overflow(true) line, the program crashes with the following output:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
thread 'main' panicked at 'Failed to set the RUNMODE. This is caused probably bcause another instance of minus is already running', /home/renato/.cargo/registry/src/index.crates.io-6f17d22bba15001f/minus-5.3.0/src/static_pager.rs:29:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

3 - The documentation of Pager::set_run_no_overflow says the following:

Setting this to true will cause a full pager to start and display the data even if there is less number of lines to display than available rows.

However, the actual behavior is the opposite, and passing false will cause a full pager to start no matter how much data is provided.

Thank you for your hard work on minus, and I appreciate any help you can provide to resolve these issues.

AMythicDev commented 1 year ago

Thanks for pointing out these issues. Let me get to each of them.

  1. Selecting paginated text is currently not implemented in minus. I have plans to add this feature but I am not getting time these days to implement it. I will get it done as I get more time to work on minus.
  2. The pager crashes because the static RUNMODE variable isn't being reset. This is a bug.
  3. The docs have the correct information but by some mistake, the reverse is being done in PagerState::set_run_no_overflow. This too is also a bug.

I will get a patch for the above two bug as soon as possible. If you can devote some time to implement the mouse selection feature, feel free to contribute. ♥️

rwestphal commented 1 year ago

Thank you @arijit79! I'm looking forward to test your fixes once they are available. As for the mouse selection feature, I'm afraid I won't be able to work on that right away, but I'll definitely keep you updated if anything changes. Thanks again :)

AMythicDev commented 1 year ago

I have fixed the two bugs that you mentioned. Could you please check on your side if things work correctly. Regarding the text selection feature, I have created #96 and will try to get it onboard by the next feature release. Thanks again.

rwestphal commented 1 year ago

Thanks for the quick fixes! I confirm issues 2 and 3 were solved. Looking forward to the next minus release!

AMythicDev commented 1 year ago

I have released v5.3.1 containing the latest patches.