diff options
| author | 2026-03-07 21:50:12 -0500 | |
|---|---|---|
| committer | 2026-03-07 21:50:12 -0500 | |
| commit | 3c47dd2c4802cfe959a628ea55c17a61832a57b1 (patch) | |
| tree | 82467378ffa7a3f3be6191434df556b7b91c3e5f /src/tui/app.rs | |
| parent | make chatbot fill from bottom (diff) | |
added chat scrolling
Diffstat (limited to 'src/tui/app.rs')
| -rw-r--r-- | src/tui/app.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tui/app.rs b/src/tui/app.rs index 82342c0..7786858 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -23,6 +23,8 @@ pub struct AppState { pub input: String, /// Cursor position within `input` (byte index) pub cursor: usize, + /// Line scroll offset (byte index) + pub scroll_offset: usize, /// Status line text (connection state, errors, etc.) pub status: String, /// Whether we've fully registered @@ -38,6 +40,7 @@ impl AppState { members: Vec::new(), input: String::new(), cursor: 0, + scroll_offset: 0, status: "Set nick with /nick to connect.".into(), connected: false, } @@ -101,6 +104,16 @@ impl AppState { } } + /// Scroll up one line + pub fn scroll_up(&mut self) { + self.scroll_offset += 1; + } + + /// Scroll down one line + pub fn scroll_down(&mut self) { + self.scroll_offset = self.scroll_offset.saturating_sub(1); + } + /// Take the current input, clear the box, return the text pub fn take_input(&mut self) -> String { self.cursor = 0; |
