vim keybinings are now working properly well
This commit is contained in:
@@ -6,13 +6,15 @@ use crate::state::pages::add_logic::{AddLogicFocus, AddLogicState};
|
||||
use crate::state::pages::canvas_state::CanvasState;
|
||||
use ratatui::{
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::{Modifier, Style, Stylize}, // Added Stylize for .dim()
|
||||
style::{Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, BorderType, Borders, Paragraph}, // Removed unused Widget
|
||||
widgets::{Block, BorderType, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
use crate::components::handlers::canvas::render_canvas;
|
||||
use crate::components::common::dialog;
|
||||
use crate::config::binds::config::EditorKeybindingMode;
|
||||
use crate::components::common::text_editor::TextEditor;
|
||||
|
||||
pub fn render_add_logic(
|
||||
f: &mut Frame,
|
||||
@@ -34,35 +36,44 @@ pub fn render_add_logic(
|
||||
f.render_widget(main_block, area);
|
||||
|
||||
if add_logic_state.current_focus == AddLogicFocus::InputScriptContent {
|
||||
let mut editor = add_logic_state.script_content_editor.borrow_mut();
|
||||
let border_style = if is_edit_mode {
|
||||
Style::default().fg(theme.highlight)
|
||||
} else {
|
||||
Style::default().fg(theme.highlight)
|
||||
let mut editor_ref = add_logic_state.script_content_editor.borrow_mut();
|
||||
let border_style_color = if is_edit_mode { theme.highlight } else { theme.secondary };
|
||||
let border_style = Style::default().fg(border_style_color);
|
||||
|
||||
editor_ref.set_cursor_line_style(Style::default().bg(theme.secondary));
|
||||
|
||||
let script_title_hint = match add_logic_state.editor_keybinding_mode {
|
||||
EditorKeybindingMode::Vim => {
|
||||
let vim_mode_status = TextEditor::get_vim_mode_status(&add_logic_state.vim_state);
|
||||
if is_edit_mode {
|
||||
format!("Script (VIM {}) - Esc for Normal. Tab navigates from Normal.", vim_mode_status)
|
||||
} else {
|
||||
format!("Script (VIM {}) - 'i'/'a'/'o' for Insert. Tab to navigate.", vim_mode_status)
|
||||
}
|
||||
}
|
||||
EditorKeybindingMode::Emacs | EditorKeybindingMode::Default => {
|
||||
if is_edit_mode {
|
||||
"Script (Editing - Esc to exit edit. Tab navigates after exit.)".to_string()
|
||||
} else {
|
||||
"Script (Press Enter or Ctrl+E to edit. Tab to navigate.)".to_string()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
editor.set_cursor_line_style(
|
||||
Style::default().bg(theme.secondary),
|
||||
);
|
||||
editor.set_line_number_style(
|
||||
Style::default().fg(theme.secondary),
|
||||
);
|
||||
|
||||
editor.set_block(
|
||||
editor_ref.set_block(
|
||||
Block::default()
|
||||
.title(Span::styled(
|
||||
" Steel Script Content (Ctrl+E or Enter to edit, Esc to unfocus/exit edit) ",
|
||||
Style::default().fg(theme.fg),
|
||||
))
|
||||
.title(Span::styled(script_title_hint, Style::default().fg(theme.fg)))
|
||||
.title_alignment(Alignment::Center)
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(border_style),
|
||||
);
|
||||
f.render_widget(&*editor, inner_area);
|
||||
// Remove .widget() call - just pass the reference directly
|
||||
f.render_widget(&*editor_ref, inner_area);
|
||||
return;
|
||||
}
|
||||
|
||||
// ... rest of the layout code ...
|
||||
let main_chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
@@ -109,7 +120,6 @@ pub fn render_add_logic(
|
||||
| AddLogicFocus::InputTargetColumn
|
||||
| AddLogicFocus::InputDescription
|
||||
);
|
||||
|
||||
render_canvas(
|
||||
f,
|
||||
canvas_area,
|
||||
@@ -123,20 +133,29 @@ pub fn render_add_logic(
|
||||
);
|
||||
|
||||
{
|
||||
let mut editor = add_logic_state.script_content_editor.borrow_mut();
|
||||
editor.set_cursor_line_style(Style::default());
|
||||
editor.set_line_number_style(
|
||||
Style::default().fg(theme.secondary).dim(), // Fixed: apply .dim() to Style, not Color
|
||||
);
|
||||
let mut editor_ref = add_logic_state.script_content_editor.borrow_mut();
|
||||
editor_ref.set_cursor_line_style(Style::default());
|
||||
|
||||
editor.set_block(
|
||||
let border_style_color = if add_logic_state.current_focus == AddLogicFocus::InputScriptContent {
|
||||
theme.highlight
|
||||
} else {
|
||||
theme.secondary
|
||||
};
|
||||
|
||||
let title_hint = match add_logic_state.editor_keybinding_mode {
|
||||
EditorKeybindingMode::Vim => "Script Preview (VIM - Focus with Tab, then 'i'/'a'/'o' to edit)",
|
||||
_ => "Script Preview (Focus with Tab, then Enter/Ctrl+E to edit)",
|
||||
};
|
||||
|
||||
editor_ref.set_block(
|
||||
Block::default()
|
||||
.title(" Steel Script Content ")
|
||||
.title(title_hint)
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(Style::default().fg(theme.secondary)),
|
||||
.border_style(Style::default().fg(border_style_color)),
|
||||
);
|
||||
f.render_widget(&*editor, script_content_area);
|
||||
// Remove .widget() call here too
|
||||
f.render_widget(&*editor_ref, script_content_area);
|
||||
}
|
||||
|
||||
let get_button_style = |button_focus: AddLogicFocus, current_focus| {
|
||||
|
||||
Reference in New Issue
Block a user