2025-05-15 14:50:30 -07:00
|
|
|
use crate::user_approval_widget::ApprovalRequest;
|
2025-05-14 10:13:29 -07:00
|
|
|
use crossterm::event::KeyEvent;
|
|
|
|
|
use ratatui::buffer::Buffer;
|
|
|
|
|
use ratatui::layout::Rect;
|
|
|
|
|
|
|
|
|
|
use super::BottomPane;
|
2025-07-28 12:00:06 -07:00
|
|
|
use super::CancellationEvent;
|
2025-05-14 10:13:29 -07:00
|
|
|
|
|
|
|
|
/// Type to use for a method that may require a redraw of the UI.
|
|
|
|
|
pub(crate) enum ConditionalUpdate {
|
|
|
|
|
NeedsRedraw,
|
|
|
|
|
NoRedraw,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Trait implemented by every view that can be shown in the bottom pane.
|
|
|
|
|
pub(crate) trait BottomPaneView<'a> {
|
|
|
|
|
/// Handle a key event while the view is active. A redraw is always
|
|
|
|
|
/// scheduled after this call.
|
2025-05-15 14:50:30 -07:00
|
|
|
fn handle_key_event(&mut self, _pane: &mut BottomPane<'a>, _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.
|
|
|
|
|
fn on_ctrl_c(&mut self, _pane: &mut BottomPane<'a>) -> CancellationEvent {
|
|
|
|
|
CancellationEvent::Ignored
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-14 10:13:29 -07:00
|
|
|
/// Render the view: this will be displayed in place of the composer.
|
|
|
|
|
fn render(&self, area: Rect, buf: &mut Buffer);
|
|
|
|
|
|
|
|
|
|
/// Update the status indicator text.
|
|
|
|
|
fn update_status_text(&mut self, _text: String) -> ConditionalUpdate {
|
|
|
|
|
ConditionalUpdate::NoRedraw
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Called when task completes to check if the view should be hidden.
|
|
|
|
|
fn should_hide_when_task_is_done(&mut self) -> bool {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 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)
|
|
|
|
|
}
|
|
|
|
|
}
|