cursive_hexview icon indicating copy to clipboard operation
cursive_hexview copied to clipboard

Further improvements

Open hellow554 opened this issue 2 years ago • 1 comments
trafficstars

  • [ ] Add callback for when some data has been changed
    • Probably something like FnMut(usize, u8) -> ()
    • As an alternative use a Broadcast like thing which would be more easy to implement
  • [ ] Add callback when the position has been changed
    • Something like FnMut(usize) -> ()
    • As an alternative use a Broadcast like thing which would be more easy to implement
  • [ ] Goto function
    • Function that takes a usize and jumps to that very position
  • [ ] PageUp/-Down support
    • I'm not sure how many lines should be jumped though. Any ideas?
  • [ ] Add support for non-ascii encoder
    • I think having a single mapping is fine, so Fn(u8) -> char should be good
    • Having multi-byte encoding is probably way too much to ask and not feasible for a hexcode viewer

hellow554 avatar Sep 27 '23 11:09 hellow554

Wow - I love the list - thanks for composing it. Most likely I am going to use all these planned features in my project. Regarding page up/down - Cursive's scroller.scroll_down (and up) automatically move by a visible area - so a "page". There is a bug in the documentation saying it's by one line, but definitely it's a page. Here is the recipe:

        .on_pre_event_inner(Key::PageUp, |v, _| {
            let scroller = v.get_scroller_mut();
            if scroller.can_scroll_up() {
                scroller.scroll_up(scroller.last_outer_size().y.saturating_sub(1));
            }
            Some(EventResult::Consumed(None))
        })
        .on_pre_event_inner(Key::PageDown, |v, _| {
            let scroller = v.get_scroller_mut();
            if scroller.can_scroll_down() {
                scroller.scroll_down(scroller.last_outer_size().y.saturating_sub(1));
            }
            Some(EventResult::Consumed(None))
        });

ddrcode avatar Sep 28 '23 23:09 ddrcode