Enhance TUI: add paste event handling, integrate bracketed paste mode, and implement paste support in editing mode.

Fixes #20
This commit is contained in:
2025-09-30 02:27:09 +02:00
parent 63ca71c6ae
commit a5727c0a1d
3 changed files with 27 additions and 3 deletions

View File

@@ -381,6 +381,24 @@ impl ChatApp {
Event::Tick => {
// Future: update streaming timers
}
Event::Paste(text) => {
// Handle paste events - insert text directly without triggering sends
if matches!(self.mode, InputMode::Editing) {
// In editing mode, insert the pasted text directly into textarea
let lines: Vec<&str> = text.lines().collect();
for (i, line) in lines.iter().enumerate() {
for ch in line.chars() {
self.textarea.insert_char(ch);
}
// Insert newline between lines (but not after the last line)
if i < lines.len() - 1 {
self.textarea.insert_newline();
}
}
self.sync_textarea_to_buffer();
}
// Ignore paste events in other modes
}
Event::Key(key) => match self.mode {
InputMode::Normal => {
// Handle multi-key sequences first