diff --git a/src/app_state.rs b/src/app_state.rs index 9fc76f5..05e64bb 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -14,6 +14,7 @@ pub struct AppState { pub ai_response: String, pub terminal_context: Arc>, pub user_chat_to_send_to_gpt: String, + pub terminal_scroll: usize, // Added to track the scroll position } impl AppState { @@ -25,6 +26,7 @@ impl AppState { ai_response: "".to_string(), tick: 0, user_chat_to_send_to_gpt: "".to_string(), + terminal_scroll: 0, // Initialized to 0 } } diff --git a/src/services/ui_service.rs b/src/services/ui_service.rs index a05f03d..fef2b45 100644 --- a/src/services/ui_service.rs +++ b/src/services/ui_service.rs @@ -61,7 +61,8 @@ impl UiService { Mode::Terminal => Style::default().cyan(), Mode::Chat => Style::default(), }; - let pseudo_terminal = PseudoTerminal::new(screen); + let pseudo_terminal = PseudoTerminal::new(screen) + .scroll((self.app_state.terminal_scroll, 0)); // Added scroll functionality based on AppState::terminal_scroll frame.render_widget( pseudo_terminal.block( Block::default() @@ -139,6 +140,14 @@ impl UiService { "tell me a two paragraph story".to_string(), )) .unwrap(), + KeyCode::Up => { + if self.app_state.terminal_scroll > 0 { + self.app_state.terminal_scroll -= 1; // Handle scroll up + } + } + KeyCode::Down => { + self.app_state.terminal_scroll += 1; // Handle scroll down + } _ => {} }, _ => {}