AMythicDev / minus

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

Introduce native input matching definition #75

Closed AMythicDev closed 1 year ago

AMythicDev commented 2 years ago

This set of changes will allow minus to define key, mouse and resize events to be declared natively through minus's APIs and not requiring end applications to interact with the underlying crossterm crate.

This means that keybindings like Ctrl+L can be declared into minus like this

pager.add_input_event(KeyBind("c-l", |pagerstate| {
     ...
}));

Note: Do note that this is not the final implementation and there will be large variations between this and the actual implementation that comes-up.

This has the advantage that end-applications can now add to, modify, or remove minus's default event binding without needing to copy the entire matcher function and then change the parts that they want.

This new API will not deprecate the previous way of defining input binding so existing code will work without any breakage.