2025-09-26 07:13:29 -07:00
|
|
|
use crate::bottom_pane::ApprovalRequest;
|
2025-10-01 14:29:05 -07:00
|
|
|
use crate::render::renderable::Renderable;
|
2025-05-14 10:13:29 -07:00
|
|
|
use crossterm::event::KeyEvent;
|
|
|
|
|
use ratatui::layout::Rect;
|
|
|
|
|
|
2025-07-28 12:00:06 -07:00
|
|
|
use super::CancellationEvent;
|
2025-05-14 10:13:29 -07:00
|
|
|
|
|
|
|
|
/// Trait implemented by every view that can be shown in the bottom pane.
|
2025-10-01 14:29:05 -07:00
|
|
|
pub(crate) trait BottomPaneView: Renderable {
|
2025-05-14 10:13:29 -07:00
|
|
|
/// Handle a key event while the view is active. A redraw is always
|
|
|
|
|
/// scheduled after this call.
|
2025-09-22 11:29:39 -07:00
|
|
|
fn handle_key_event(&mut self, _key_event: KeyEvent) {}
|
2025-05-14 10:13:29 -07:00
|
|
|
|
|
|
|
|
/// Return `true` if the view has finished and should be removed.
|
|
|
|
|
fn is_complete(&self) -> bool {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-28 12:00:06 -07:00
|
|
|
/// Handle Ctrl-C while this view is active.
|
2025-09-22 11:29:39 -07:00
|
|
|
fn on_ctrl_c(&mut self) -> CancellationEvent {
|
2025-09-07 20:21:53 -07:00
|
|
|
CancellationEvent::NotHandled
|
2025-07-28 12:00:06 -07:00
|
|
|
}
|
|
|
|
|
|
2025-09-21 20:18:35 -07:00
|
|
|
/// Optional paste handler. Return true if the view modified its state and
|
|
|
|
|
/// needs a redraw.
|
2025-09-22 11:29:39 -07:00
|
|
|
fn handle_paste(&mut self, _pasted: String) -> bool {
|
2025-09-21 20:18:35 -07:00
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Cursor position when this view is active.
|
|
|
|
|
fn cursor_pos(&self, _area: Rect) -> Option<(u16, u16)> {
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-14 10:13:29 -07:00
|
|
|
/// Try to handle approval request; return the original value if not
|
|
|
|
|
/// consumed.
|
|
|
|
|
fn try_consume_approval_request(
|
|
|
|
|
&mut self,
|
|
|
|
|
request: ApprovalRequest,
|
|
|
|
|
) -> Option<ApprovalRequest> {
|
|
|
|
|
Some(request)
|
|
|
|
|
}
|
|
|
|
|
}
|