line different color changed

This commit is contained in:
filipriec
2025-08-03 21:09:58 +02:00
parent dbaa32f589
commit 4146d0820b
2 changed files with 56 additions and 9 deletions

View File

@@ -395,18 +395,69 @@ fn handle_key_press(
editor.set_debug_message("✏️ INSERT (open line) - Cursor: Steady Bar |".to_string()); editor.set_debug_message("✏️ INSERT (open line) - Cursor: Steady Bar |".to_string());
editor.clear_command_buffer(); editor.clear_command_buffer();
} }
// From Normal Mode: Enter visual modes
(AppMode::ReadOnly, KeyCode::Char('v'), _) => { (AppMode::ReadOnly, KeyCode::Char('v'), _) => {
editor.enter_visual_mode(); // 🎯 Automatic: cursor becomes blinking block editor.enter_visual_mode();
editor.clear_command_buffer(); editor.clear_command_buffer();
} }
(AppMode::ReadOnly, KeyCode::Char('V'), _) => { (AppMode::ReadOnly, KeyCode::Char('V'), _) => {
editor.enter_visual_line_mode(); // 🎯 Automatic: cursor becomes blinking block editor.enter_visual_line_mode();
editor.clear_command_buffer(); editor.clear_command_buffer();
} }
(_, KeyCode::Esc, _) => {
editor.exit_edit_mode(); // 🎯 Automatic: cursor becomes steady block // From Visual Mode: Switch between visual modes or exit
(AppMode::Highlight, KeyCode::Char('v'), _) => {
use canvas::canvas::state::SelectionState;
match editor.editor.selection_state() {
SelectionState::Characterwise { .. } => {
// Already in characterwise mode, exit visual mode (vim behavior)
editor.exit_visual_mode();
editor.set_debug_message("🔒 Exited visual mode".to_string());
}
_ => {
// Switch from linewise to characterwise mode
editor.editor.enter_highlight_mode();
editor.update_visual_selection();
editor.set_debug_message("🔥 Switched to VISUAL mode".to_string());
}
}
editor.clear_command_buffer(); editor.clear_command_buffer();
} }
(AppMode::Highlight, KeyCode::Char('V'), _) => {
use canvas::canvas::state::SelectionState;
match editor.editor.selection_state() {
SelectionState::Linewise { .. } => {
// Already in linewise mode, exit visual mode (vim behavior)
editor.exit_visual_mode();
editor.set_debug_message("🔒 Exited visual mode".to_string());
}
_ => {
// Switch from characterwise to linewise mode
editor.editor.enter_highlight_line_mode();
editor.update_visual_selection();
editor.set_debug_message("🔥 Switched to VISUAL LINE mode".to_string());
}
}
editor.clear_command_buffer();
}
// Escape: Exit any mode back to normal
(_, KeyCode::Esc, _) => {
match mode {
AppMode::Edit => {
editor.exit_edit_mode(); // Exit insert mode
}
AppMode::Highlight => {
editor.exit_visual_mode(); // Exit visual mode
}
_ => {
// Already in normal mode, just clear command buffer
editor.clear_command_buffer();
}
}
}
// === CURSOR MANAGEMENT DEMONSTRATION === // === CURSOR MANAGEMENT DEMONSTRATION ===
(AppMode::ReadOnly, KeyCode::F(1), _) => { (AppMode::ReadOnly, KeyCode::F(1), _) => {

View File

@@ -253,11 +253,7 @@ fn apply_highlighting<'a, T: CanvasTheme>(
HighlightState::Off => { HighlightState::Off => {
Line::from(Span::styled( Line::from(Span::styled(
text, text,
if is_active { Style::default().fg(theme.fg())
Style::default().fg(theme.highlight())
} else {
Style::default().fg(theme.fg())
},
)) ))
} }
HighlightState::Characterwise { anchor } => { HighlightState::Characterwise { anchor } => {