Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions codex-rs/tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,6 @@ impl App {
},
)?;
}
TuiEvent::AttachImage {
path,
width,
height,
format_label,
} => {
self.chat_widget
.attach_image(path, width, height, format_label);
}
}
}
Ok(true)
Expand Down
12 changes: 12 additions & 0 deletions codex-rs/tui/src/chatwidget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use crate::bottom_pane::CancellationEvent;
use crate::bottom_pane::InputResult;
use crate::bottom_pane::SelectionAction;
use crate::bottom_pane::SelectionItem;
use crate::clipboard_paste::paste_image_to_temp_png;
use crate::get_git_diff::get_git_diff;
use crate::history_cell;
use crate::history_cell::CommandOutput;
Expand Down Expand Up @@ -743,6 +744,17 @@ impl ChatWidget {
self.on_ctrl_c();
return;
}
KeyEvent {
code: KeyCode::Char('v'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
} => {
if let Ok((path, info)) = paste_image_to_temp_png() {
self.attach_image(path, info.width, info.height, info.encoded_format.label());
}
return;
}
other if other.kind == KeyEventKind::Press => {
self.bottom_pane.clear_ctrl_c_quit_hint();
}
Expand Down
34 changes: 0 additions & 34 deletions codex-rs/tui/src/tui.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::io::Result;
use std::io::Stdout;
use std::io::stdout;
use std::path::PathBuf;
use std::pin::Pin;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
Expand All @@ -20,10 +19,7 @@ use crossterm::cursor::MoveTo;
use crossterm::event::DisableBracketedPaste;
use crossterm::event::EnableBracketedPaste;
use crossterm::event::Event;
use crossterm::event::KeyCode;
use crossterm::event::KeyEvent;
use crossterm::event::KeyEventKind;
use crossterm::event::KeyModifiers;
use crossterm::event::KeyboardEnhancementFlags;
use crossterm::event::PopKeyboardEnhancementFlags;
use crossterm::event::PushKeyboardEnhancementFlags;
Expand All @@ -38,7 +34,6 @@ use ratatui::crossterm::terminal::enable_raw_mode;
use ratatui::layout::Offset;
use ratatui::text::Line;

use crate::clipboard_paste::paste_image_to_temp_png;
use crate::custom_terminal;
use crate::custom_terminal::Terminal as CustomTerminal;
use tokio::select;
Expand Down Expand Up @@ -154,12 +149,6 @@ pub enum TuiEvent {
Key(KeyEvent),
Paste(String),
Draw,
AttachImage {
path: PathBuf,
width: u32,
height: u32,
format_label: &'static str,
},
}

pub struct Tui {
Expand Down Expand Up @@ -305,29 +294,6 @@ impl Tui {
select! {
Some(Ok(event)) = crossterm_events.next() => {
match event {
// Detect Ctrl+V to attach an image from the clipboard.
Event::Key(key_event @ KeyEvent {
code: KeyCode::Char('v'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
}) => {
match paste_image_to_temp_png() {
Ok((path, info)) => {
yield TuiEvent::AttachImage {
path,
width: info.width,
height: info.height,
format_label: info.encoded_format.label(),
};
}
Err(_) => {
// Fall back to normal key handling if no image is available.
yield TuiEvent::Key(key_event);
}
}
}

crossterm::event::Event::Key(key_event) => {
#[cfg(unix)]
if matches!(
Expand Down
Loading