From a874edf2a19e57eac62ba5c9c7a300b1df680806 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sat, 24 May 2025 14:24:19 +0200 Subject: [PATCH] text area on focus is now big --- Cargo.lock | 12 +++++ client/Cargo.toml | 1 + client/src/components/admin/add_logic.rs | 60 +++++++++++++++++------- 3 files changed, 57 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77dda58..c943c24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,6 +415,7 @@ dependencies = [ "tonic", "tracing", "tracing-subscriber", + "tui-textarea", "unicode-segmentation", "unicode-width 0.2.0", ] @@ -3606,6 +3607,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78122066b0cb818b8afd08f7ed22f7fdbc3e90815035726f0840d0d26c0747a" +[[package]] +name = "tui-textarea" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a5318dd619ed73c52a9417ad19046724effc1287fb75cdcc4eca1d6ac1acbae" +dependencies = [ + "crossterm 0.28.1", + "ratatui", + "unicode-width 0.2.0", +] + [[package]] name = "typed-arena" version = "2.0.2" diff --git a/client/Cargo.toml b/client/Cargo.toml index 00b7302..e060a02 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -22,5 +22,6 @@ toml = "0.8.20" tonic = "0.13.0" tracing = "0.1.41" tracing-subscriber = "0.3.19" +tui-textarea = "0.7.0" unicode-segmentation = "1.12.0" unicode-width = "0.2.0" diff --git a/client/src/components/admin/add_logic.rs b/client/src/components/admin/add_logic.rs index d9cb673..410992e 100644 --- a/client/src/components/admin/add_logic.rs +++ b/client/src/components/admin/add_logic.rs @@ -33,7 +33,32 @@ pub fn render_add_logic( let inner_area = main_block.inner(area); f.render_widget(main_block, area); - // Calculate areas dynamically like add_table + // --- Fullscreen Script Content Check --- + if add_logic_state.current_focus == AddLogicFocus::InputScriptContent { + let script_block_border_style = Style::default().fg(theme.highlight); // Always highlighted + + let script_block = Block::default() + .title(Span::styled( + " Steel Script Content (Fullscreen) ", + theme.fg, + )) // Indicate fullscreen + .title_alignment(Alignment::Center) + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(script_block_border_style); + + let script_text = + Text::from(add_logic_state.script_content_input.as_str()); + let script_paragraph = Paragraph::new(script_text) + .block(script_block) + .scroll(add_logic_state.script_content_scroll) + .style(Style::default().fg(theme.fg)); + f.render_widget(script_paragraph, inner_area); // Use inner_area for fullscreen + return; // IMPORTANT: Stop rendering here for fullscreen mode + } + + // --- Normal Layout --- + // Calculate areas dynamically let main_chunks = Layout::default() .direction(Direction::Vertical) .constraints([ @@ -49,15 +74,17 @@ pub fn render_add_logic( let script_content_area = main_chunks[2]; let buttons_area = main_chunks[3]; - // Top Info Rendering (like add_table) + // Top Info Rendering let profile_text = Paragraph::new(vec![ Line::from(Span::styled( format!("Profile: {}", add_logic_state.profile_name), theme.fg, )), Line::from(Span::styled( - format!("Table: {}", - add_logic_state.selected_table_id + format!( + "Table: {}", + add_logic_state + .selected_table_id .map(|id| format!("ID {}", id)) .unwrap_or_else(|| "Global".to_string()) ), @@ -71,7 +98,7 @@ pub fn render_add_logic( ); f.render_widget(profile_text, top_info_area); - // Canvas rendering for input fields (like add_table) + // Canvas rendering for input fields let focus_on_canvas_inputs = matches!( add_logic_state.current_focus, AddLogicFocus::InputLogicName @@ -91,12 +118,13 @@ pub fn render_add_logic( highlight_state, ); - // Script Content Area - let script_block_border_style = if add_logic_state.current_focus == AddLogicFocus::InputScriptContent { - Style::default().fg(theme.highlight) - } else { - Style::default().fg(theme.secondary) - }; + // Script Content Area (Normal Mode) + let script_block_border_style = + if add_logic_state.current_focus == AddLogicFocus::InputScriptContent { + Style::default().fg(theme.highlight) + } else { + Style::default().fg(theme.secondary) + }; let script_block = Block::default() .title(" Steel Script Content ") @@ -104,14 +132,15 @@ pub fn render_add_logic( .border_type(BorderType::Rounded) .border_style(script_block_border_style); - let script_text = Text::from(add_logic_state.script_content_input.as_str()); + let script_text = + Text::from(add_logic_state.script_content_input.as_str()); let script_paragraph = Paragraph::new(script_text) .block(script_block) .scroll(add_logic_state.script_content_scroll) .style(Style::default().fg(theme.fg)); f.render_widget(script_paragraph, script_content_area); - // Button Style Helpers (same as add_table) + // Button Style Helpers 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 { @@ -134,7 +163,7 @@ pub fn render_add_logic( } }; - // Bottom Buttons (same style as add_table) + // Bottom Buttons let button_chunks = Layout::default() .direction(Direction::Horizontal) .constraints([ @@ -177,7 +206,7 @@ pub fn render_add_logic( ); f.render_widget(cancel_button, button_chunks[1]); - // Dialog rendering (same as add_table) + // Dialog rendering if app_state.ui.dialog.dialog_show { dialog::render_dialog( f, @@ -191,4 +220,3 @@ pub fn render_add_logic( ); } } -