its now using enum fully for the highlight mode
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
|
||||
pub mod state;
|
||||
pub mod buffer;
|
||||
pub mod highlight;
|
||||
|
||||
20
client/src/state/app/highlight.rs
Normal file
20
client/src/state/app/highlight.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
// src/state/app/highlight.rs
|
||||
|
||||
/// Represents the different states of text highlighting.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum HighlightState {
|
||||
/// Highlighting is inactive.
|
||||
Off,
|
||||
/// Highlighting character by character. Stores the anchor point (line index, char index).
|
||||
Characterwise { anchor: (usize, usize) },
|
||||
/// Highlighting line by line. Stores the anchor line index.
|
||||
Linewise { anchor_line: usize },
|
||||
}
|
||||
|
||||
impl Default for HighlightState {
|
||||
/// The default state is no highlighting.
|
||||
fn default() -> Self {
|
||||
HighlightState::Off
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
use crate::config::colors::themes::Theme;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::Frame;
|
||||
use crate::state::app::highlight::HighlightState;
|
||||
use crate::state::pages::canvas_state::CanvasState;
|
||||
|
||||
pub struct FormState {
|
||||
@@ -33,9 +34,7 @@ impl FormState {
|
||||
area: Rect,
|
||||
theme: &Theme,
|
||||
is_edit_mode: bool,
|
||||
is_highlight_mode: bool,
|
||||
is_linewise_highlight: bool,
|
||||
highlight_anchor: Option<(usize, usize)>,
|
||||
highlight_state: &HighlightState,
|
||||
total_count: u64,
|
||||
current_position: u64,
|
||||
) {
|
||||
@@ -51,9 +50,7 @@ impl FormState {
|
||||
&values,
|
||||
theme,
|
||||
is_edit_mode,
|
||||
is_highlight_mode,
|
||||
is_linewise_highlight,
|
||||
highlight_anchor,
|
||||
highlight_state,
|
||||
total_count,
|
||||
current_position,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user