logic is being implemented properly well
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// src/state/pages/add_logic.rs
|
||||
use crate::config::binds::config::{EditorConfig, EditorKeybindingMode};
|
||||
use crate::state::pages::canvas_state::CanvasState;
|
||||
use crate::components::common::text_editor::{TextEditor, VimState}; // Add VimState import
|
||||
use crate::components::common::text_editor::{TextEditor, VimState};
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use tui_textarea::TextArea;
|
||||
@@ -11,8 +11,9 @@ pub enum AddLogicFocus {
|
||||
#[default]
|
||||
InputLogicName,
|
||||
InputTargetColumn,
|
||||
InputScriptContent,
|
||||
InputDescription,
|
||||
ScriptContentPreview, // Like ColumnsTable - can be highlighted/selected
|
||||
InsideScriptContent, // Like InsideColumnsTable - full editing mode
|
||||
SaveButton,
|
||||
CancelButton,
|
||||
}
|
||||
@@ -27,12 +28,13 @@ pub struct AddLogicState {
|
||||
pub script_content_editor: Rc<RefCell<TextArea<'static>>>,
|
||||
pub description_input: String,
|
||||
pub current_focus: AddLogicFocus,
|
||||
pub last_canvas_field: usize,
|
||||
pub logic_name_cursor_pos: usize,
|
||||
pub target_column_cursor_pos: usize,
|
||||
pub description_cursor_pos: usize,
|
||||
pub has_unsaved_changes: bool,
|
||||
pub editor_keybinding_mode: EditorKeybindingMode,
|
||||
pub vim_state: VimState, // Add this field
|
||||
pub vim_state: VimState,
|
||||
}
|
||||
|
||||
impl AddLogicState {
|
||||
@@ -47,12 +49,13 @@ impl AddLogicState {
|
||||
script_content_editor: Rc::new(RefCell::new(editor)),
|
||||
description_input: String::new(),
|
||||
current_focus: AddLogicFocus::InputLogicName,
|
||||
last_canvas_field: 2,
|
||||
logic_name_cursor_pos: 0,
|
||||
target_column_cursor_pos: 0,
|
||||
description_cursor_pos: 0,
|
||||
has_unsaved_changes: false,
|
||||
editor_keybinding_mode: editor_config.keybinding_mode.clone(),
|
||||
vim_state: VimState::default(), // Add this field initialization
|
||||
vim_state: VimState::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,14 +68,13 @@ impl Default for AddLogicState {
|
||||
}
|
||||
}
|
||||
|
||||
// ... rest of the CanvasState implementation remains the same
|
||||
impl CanvasState for AddLogicState {
|
||||
fn current_field(&self) -> usize {
|
||||
match self.current_focus {
|
||||
AddLogicFocus::InputLogicName => 0,
|
||||
AddLogicFocus::InputTargetColumn => 1,
|
||||
AddLogicFocus::InputDescription => 2,
|
||||
_ => 0,
|
||||
_ => self.last_canvas_field,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +123,18 @@ impl CanvasState for AddLogicState {
|
||||
|
||||
fn set_current_field(&mut self, index: usize) {
|
||||
self.current_focus = match index {
|
||||
0 => AddLogicFocus::InputLogicName,
|
||||
1 => AddLogicFocus::InputTargetColumn,
|
||||
2 => AddLogicFocus::InputDescription,
|
||||
0 => {
|
||||
self.last_canvas_field = 0;
|
||||
AddLogicFocus::InputLogicName
|
||||
},
|
||||
1 => {
|
||||
self.last_canvas_field = 1;
|
||||
AddLogicFocus::InputTargetColumn
|
||||
},
|
||||
2 => {
|
||||
self.last_canvas_field = 2;
|
||||
AddLogicFocus::InputDescription
|
||||
},
|
||||
_ => self.current_focus,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user