63 lines
2.2 KiB
Rust
63 lines
2.2 KiB
Rust
// src/modes/highlight/highlight.rs
|
|
// (This file is intentionally simple for now, reusing ReadOnly logic)
|
|
|
|
use crate::config::binds::config::Config;
|
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
|
use crate::services::grpc_client::GrpcClient;
|
|
use crate::state::app::state::AppState;
|
|
use crate::state::pages::auth::{LoginState, RegisterState};
|
|
use crate::state::pages::form::FormState;
|
|
use crate::modes::handlers::event::EventOutcome;
|
|
use crate::modes::read_only; // Import the ReadOnly handler
|
|
use crossterm::event::KeyEvent;
|
|
|
|
/// Handles events when in Highlight mode.
|
|
/// Currently, it mostly delegates to the read_only handler for movement.
|
|
/// Exiting highlight mode is handled directly in the main event handler.
|
|
pub async fn handle_highlight_event(
|
|
app_state: &mut AppState,
|
|
key: KeyEvent,
|
|
config: &Config,
|
|
form_state: &mut FormState,
|
|
login_state: &mut LoginState,
|
|
register_state: &mut RegisterState,
|
|
key_sequence_tracker: &mut KeySequenceTracker,
|
|
current_position: &mut u64,
|
|
total_count: u64,
|
|
grpc_client: &mut GrpcClient,
|
|
command_message: &mut String,
|
|
edit_mode_cooldown: &mut bool,
|
|
ideal_cursor_column: &mut usize,
|
|
) -> Result<EventOutcome, Box<dyn std::error::Error>> {
|
|
// Delegate movement and other actions to the read_only handler
|
|
// The rendering logic will use the highlight_anchor to draw the selection
|
|
let (should_exit, message) = read_only::handle_read_only_event(
|
|
app_state,
|
|
key,
|
|
config,
|
|
form_state,
|
|
login_state,
|
|
register_state,
|
|
key_sequence_tracker,
|
|
current_position,
|
|
total_count,
|
|
grpc_client,
|
|
command_message, // Pass the message buffer
|
|
edit_mode_cooldown,
|
|
ideal_cursor_column,
|
|
)
|
|
.await?;
|
|
|
|
// ReadOnly handler doesn't return EventOutcome directly, adapt if needed
|
|
// For now, assume Ok outcome unless ReadOnly signals an exit (which we ignore here)
|
|
if should_exit {
|
|
// This exit is likely for the whole app, let the main loop handle it
|
|
// We just return the message from read_only
|
|
Ok(EventOutcome::Ok(message))
|
|
} else {
|
|
Ok(EventOutcome::Ok(message))
|
|
}
|
|
}
|
|
|
|
|