AMythicDev / minus

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

Show search and prefix_num progress #68

Closed itsjunetime closed 2 years ago

itsjunetime commented 2 years ago

This PR adds support for showing the current prefix_num and search progress (specifically, search_mark / search_idx.len(). The picture below shows what it looks like if you have 20 typed and your current search has 20 matches and the search mark is currently on the first one (the message on the left is the current prompt).

Screen Shot 2022-04-09 at 9 01 33 PM

To do this, a few changes are made:

  1. an extra variable was added to PagerState, called displayed_prompt, which contains the prompt as it will be printed next time it is printed. It is formatted by PagerState::format_prompt() every time that the prefix_num changes, the search_mark changes, or PagerState::format_lines() is called.
  2. PagerState::prompt and PagerState::message are now stored as a string, not a vector of strings, and are no longer wrapped at all.
  3. rewrap() was removed, since it is no longer used.