Context: I'm building a TUI app in Rust.
say we have something like:
pub trait Widget_T { ... }
pub Repl_Widget {
pub editor: Rc<dyn Widge_T>,
pub eval_history: Rc<dyn Widget_T>,
pub some_other_component: Rc<dyn Widget_T>,
}
Imagine for a moment that all our hot keys are a single key, i.e. C-x
, or C-y
, but not C-s C-s
or C-x C-e
.
In this world, if a hot key hits Repl_Widget, it is pretty easy: if we can handle it, we handle it, if not, we find the focused component, and send the key to the Rc<dyn Widget_T>
question
Now suppose we allow multi key hotkeys, things like C-x C-e
or C-x C-s
, ... (or, 3, 4, 5 key combos).
Is there an idiomatic way to handle this ? (I.e. some standard algorithm / data structure / ... ).