better and better add script
This commit is contained in:
@@ -14,6 +14,7 @@ use ratatui::{
|
||||
use crate::components::handlers::canvas::render_canvas;
|
||||
use crate::components::common::dialog;
|
||||
use crate::config::binds::config::EditorKeybindingMode;
|
||||
// Remove the CursorStyle import
|
||||
|
||||
pub fn render_add_logic(
|
||||
f: &mut Frame,
|
||||
@@ -42,6 +43,16 @@ pub fn render_add_logic(
|
||||
|
||||
editor_ref.set_cursor_line_style(Style::default());
|
||||
|
||||
// Set cursor style: underscore when not in edit mode, block when in edit mode
|
||||
let cursor_style = if is_edit_mode {
|
||||
// Block cursor (default reversed style)
|
||||
Style::default().bg(theme.highlight).fg(theme.bg)
|
||||
} else {
|
||||
// Underscore cursor (underline style)
|
||||
Style::default().add_modifier(Modifier::UNDERLINED).fg(theme.highlight)
|
||||
};
|
||||
editor_ref.set_cursor_style(cursor_style);
|
||||
|
||||
let script_title_hint = match add_logic_state.editor_keybinding_mode {
|
||||
EditorKeybindingMode::Vim => {
|
||||
let vim_mode_status = crate::components::common::text_editor::TextEditor::get_vim_mode_status(&add_logic_state.vim_state);
|
||||
@@ -138,6 +149,12 @@ pub fn render_add_logic(
|
||||
let mut editor_ref = add_logic_state.script_content_editor.borrow_mut();
|
||||
editor_ref.set_cursor_line_style(Style::default());
|
||||
|
||||
// Set cursor style for preview mode (underscore style)
|
||||
let preview_cursor_style = Style::default()
|
||||
.add_modifier(Modifier::UNDERLINED)
|
||||
.fg(theme.secondary);
|
||||
editor_ref.set_cursor_style(preview_cursor_style);
|
||||
|
||||
let is_script_focused = add_logic_state.current_focus == AddLogicFocus::ScriptContentPreview;
|
||||
let border_style_color = if is_script_focused {
|
||||
theme.highlight // Green highlight when focused and ready to select
|
||||
@@ -167,7 +184,7 @@ pub fn render_add_logic(
|
||||
f.render_widget(&*editor_ref, script_content_area);
|
||||
}
|
||||
|
||||
// Buttons
|
||||
// Buttons (rest remains the same)
|
||||
let get_button_style = |button_focus: AddLogicFocus, current_focus| {
|
||||
let is_focused = current_focus == button_focus;
|
||||
let base_style = Style::default().fg(if is_focused {
|
||||
|
||||
@@ -107,16 +107,18 @@ pub async fn execute_action(
|
||||
state.set_current_cursor_pos(new_pos);
|
||||
} else {
|
||||
// Move focus outside canvas when moving down from the last field
|
||||
// FIX: Go to ScriptContentPreview instead of SaveButton
|
||||
app_state.ui.focus_outside_canvas = true;
|
||||
state.last_canvas_field = 2;
|
||||
state.current_focus = crate::state::pages::add_logic::AddLogicFocus::SaveButton;
|
||||
*command_message = "Focus moved below canvas".to_string();
|
||||
state.current_focus = crate::state::pages::add_logic::AddLogicFocus::ScriptContentPreview; // FIXED!
|
||||
*command_message = "Focus moved to script preview".to_string();
|
||||
}
|
||||
Ok(command_message.clone())
|
||||
}
|
||||
// ... (rest of the actions remain the same) ...
|
||||
"move_first_line" => {
|
||||
key_sequence_tracker.reset();
|
||||
if AddLogicState::INPUT_FIELD_COUNT > 0 { // Changed
|
||||
if AddLogicState::INPUT_FIELD_COUNT > 0 {
|
||||
state.set_current_field(0);
|
||||
let current_input = state.get_current_input();
|
||||
let max_cursor_pos = if current_input.is_empty() { 0 } else { current_input.len().saturating_sub(1) };
|
||||
@@ -128,7 +130,7 @@ pub async fn execute_action(
|
||||
}
|
||||
"move_last_line" => {
|
||||
key_sequence_tracker.reset();
|
||||
let num_fields = AddLogicState::INPUT_FIELD_COUNT; // Changed
|
||||
let num_fields = AddLogicState::INPUT_FIELD_COUNT;
|
||||
if num_fields > 0 {
|
||||
let last_field_index = num_fields - 1;
|
||||
state.set_current_field(last_field_index);
|
||||
|
||||
Reference in New Issue
Block a user