pub trait Modal: Send {
// Required methods
fn handle_key(
&mut self,
code: KeyCode,
mods: KeyModifiers,
buf: &mut Buffer,
state: &mut UiState,
ctx: &mut LoopCtx,
renderer: &mut dyn Renderer,
) -> Result<ModalAction>;
fn draw(
&self,
buf: &Buffer,
state: &UiState,
ctx: &LoopCtx,
renderer: &mut dyn Renderer,
);
// Provided method
fn handle_paste(
&mut self,
text: &str,
buf: &mut Buffer,
state: &mut UiState,
ctx: &mut LoopCtx,
renderer: &mut dyn Renderer,
) -> Result<ModalAction> { ... }
}Expand description
A modal overlay: takes over key handling until it returns
ModalAction::Close. The implementation owns its own state (the
selected index, the wizard step, the filter query, etc.) and is
responsible for painting itself whenever its visible state changes
— the event loop only calls draw once at open time and once more
after Close to restore the idle prompt.
Required Methods§
Sourcefn handle_key(
&mut self,
code: KeyCode,
mods: KeyModifiers,
buf: &mut Buffer,
state: &mut UiState,
ctx: &mut LoopCtx,
renderer: &mut dyn Renderer,
) -> Result<ModalAction>
fn handle_key( &mut self, code: KeyCode, mods: KeyModifiers, buf: &mut Buffer, state: &mut UiState, ctx: &mut LoopCtx, renderer: &mut dyn Renderer, ) -> Result<ModalAction>
Process one keystroke. Must either fully handle it (including any re-paint the modal wants) or report that the modal is now done so the caller can tear it down.
Provided Methods§
Sourcefn handle_paste(
&mut self,
text: &str,
buf: &mut Buffer,
state: &mut UiState,
ctx: &mut LoopCtx,
renderer: &mut dyn Renderer,
) -> Result<ModalAction>
fn handle_paste( &mut self, text: &str, buf: &mut Buffer, state: &mut UiState, ctx: &mut LoopCtx, renderer: &mut dyn Renderer, ) -> Result<ModalAction>
Handle a bracketed-paste payload while the modal is active.
Default: append the text to buf (so text-input wizard steps
naturally accept URL / API-key paste) and redraw. Modals that
only present pickers (no text input) can leave the default —
buf updates are harmless when the modal isn’t displaying it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".