mirror of
https://github.com/openai/codex.git
synced 2026-10-21 23:19:44 +00:00
rm unused func
This commit is contained in:
@@ -116,34 +116,6 @@ where
|
||||
|| mods.contains(crossterm::event::KeyModifiers::SUPER);
|
||||
|
||||
if key_event.kind == KeyEventKind::Press && is_v && has_paste_modifier {
|
||||
// On macOS, prefer attaching a file URL from the pasteboard if present.
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if let Some(path) = crate::clipboard_paste::image_file_from_clipboard_macos() {
|
||||
let (mut w, mut h) = (0u32, 0u32);
|
||||
if let Ok((dw, dh)) = image::image_dimensions(&path) {
|
||||
w = dw;
|
||||
h = dh;
|
||||
}
|
||||
let fmt = match path
|
||||
.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
.map(|s| s.to_ascii_lowercase())
|
||||
.as_deref()
|
||||
{
|
||||
Some("png") => "PNG",
|
||||
Some("jpg") | Some("jpeg") => "JPEG",
|
||||
_ => "IMG",
|
||||
};
|
||||
app_event_tx.send(AppEvent::AttachImage {
|
||||
path,
|
||||
width: w,
|
||||
height: h,
|
||||
format_label: fmt,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
match paste_fn() {
|
||||
Ok((path, info)) => {
|
||||
tracing::info!(
|
||||
|
||||
@@ -72,60 +72,3 @@ pub fn paste_image_to_temp_png() -> Result<(PathBuf, PastedImageInfo), PasteImag
|
||||
Ok((path, info))
|
||||
}
|
||||
|
||||
/// macOS-specific: Try extracting image file paths from the system pasteboard
|
||||
/// when the user copied a file in Finder. Prefer attaching the actual file
|
||||
/// instead of the small icon bitmap that may also be present on the clipboard.
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn image_file_from_clipboard_macos() -> Option<PathBuf> {
|
||||
fn run_osascript(lines: &[&str]) -> Option<String> {
|
||||
use std::process::Command;
|
||||
let output = Command::new("osascript")
|
||||
.args(lines.iter().flat_map(|l| ["-e", *l]))
|
||||
.output()
|
||||
.ok()?;
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
Some(String::from_utf8_lossy(&output.stdout).to_string())
|
||||
}
|
||||
|
||||
// 1) Try to read a list of aliases (multiple files)
|
||||
if let Some(out) = run_osascript(&[
|
||||
"try",
|
||||
"set theFiles to the clipboard as alias list",
|
||||
"set out to \"\"",
|
||||
"repeat with f in theFiles",
|
||||
"set out to out & POSIX path of f & \"\n\"",
|
||||
"end repeat",
|
||||
"out",
|
||||
"end try",
|
||||
]) {
|
||||
for line in out.lines() {
|
||||
let p = std::path::PathBuf::from(line.trim());
|
||||
if p.is_file() {
|
||||
if let Some(ext) = p.extension().and_then(|e| e.to_str()) {
|
||||
let ext = ext.to_ascii_lowercase();
|
||||
if matches!(ext.as_str(), "png" | "jpg" | "jpeg") {
|
||||
return Some(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Fallback: single alias
|
||||
if let Some(out) = run_osascript(&["try", "POSIX path of (the clipboard as alias)", "end try"])
|
||||
{
|
||||
let p = std::path::PathBuf::from(out.trim());
|
||||
if p.is_file() {
|
||||
if let Some(ext) = p.extension().and_then(|e| e.to_str()) {
|
||||
let ext = ext.to_ascii_lowercase();
|
||||
if matches!(ext.as_str(), "png" | "jpg" | "jpeg") {
|
||||
return Some(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user