cleanup: remove term::Clipboard::get_contents method

This dates back to long ago, and is never called.
Remove it, and cleanup some state associated with it.
This commit is contained in:
Wez Furlong committed 2021-07-17 07:38:48 -07:00
1 parent f6a7df9678
commit 020c0991e4
6 files changed
+4 -62

No files matched your search

-5
View File
@@ -10,7 +10,6 @@ pub enum ClipboardSelection {
}
pub trait Clipboard {
fn get_contents(&self, selection: ClipboardSelection) -> anyhow::Result<String>;
fn set_contents(
&self,
selection: ClipboardSelection,
@@ -19,10 +18,6 @@ pub trait Clipboard {
}
impl Clipboard for Box<dyn Clipboard> {
fn get_contents(&self, selection: ClipboardSelection) -> anyhow::Result<String> {
self.as_ref().get_contents(selection)
}
fn set_contents(
&self,
selection: ClipboardSelection,
-8
View File
@@ -37,14 +37,6 @@ impl Clipboard for LocalClip {
*self.clip.borrow_mut() = clip;
Ok(())
}
fn get_contents(&self, _selection: ClipboardSelection) -> anyhow::Result<String> {
self.clip
.borrow()
.as_ref()
.map(|c| c.clone())
.ok_or_else(|| anyhow::anyhow!("no clipboard"))
}
}
struct TestTerm {
+2 -25
View File
@@ -5,7 +5,7 @@ use mux::pane::Pane;
use mux::window::WindowId as MuxWindowId;
use mux::Mux;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::sync::Arc;
use wezterm_term::ClipboardSelection;
use window::{Clipboard, Window, WindowOps};
@@ -14,27 +14,9 @@ use window::{Clipboard, Window, WindowOps};
#[derive(Clone)]
pub struct ClipboardHelper {
pub window: Window,
pub clipboard_contents: Arc<Mutex<Option<String>>>,
}
impl wezterm_term::Clipboard for ClipboardHelper {
fn get_contents(&self, _selection: ClipboardSelection) -> anyhow::Result<String> {
// Even though we could request the clipboard contents using a call
// like `self.window.get_clipboard().wait()` here, that requires
// that the event loop be processed to do its work.
// Since we are typically called in a blocking fashion on the
// event loop, we have to manually arrange to populate the
// clipboard_contents cache prior to calling the code that
// might call us.
Ok(self
.clipboard_contents
.lock()
.unwrap()
.as_ref()
.cloned()
.unwrap_or_else(String::new))
}
fn set_contents(
&self,
selection: ClipboardSelection,
@@ -52,14 +34,9 @@ impl wezterm_term::Clipboard for ClipboardHelper {
}
impl TermWindow {
pub fn setup_clipboard(
window: &Window,
mux_window_id: MuxWindowId,
clipboard_contents: Arc<Mutex<Option<String>>>,
) {
pub fn setup_clipboard(window: &Window, mux_window_id: MuxWindowId) {
let clipboard: Arc<dyn wezterm_term::Clipboard> = Arc::new(ClipboardHelper {
window: window.clone(),
clipboard_contents,
});
let mux = Mux::get().unwrap();
+2 -19
View File
@@ -204,10 +204,6 @@ pub struct TermWindow {
window_background: Option<Arc<ImageData>>,
/// Gross workaround for managing async keyboard fetching
/// just for middle mouse button paste function
clipboard_contents: Arc<Mutex<Option<String>>>,
current_mouse_button: Option<MousePress>,
/// Keeps track of double and triple clicks
@@ -444,8 +440,6 @@ impl TermWindow {
let render_state = None;
let clipboard_contents = Arc::new(Mutex::new(None));
let myself = Self {
config_subscription: None,
gl: None,
@@ -476,7 +470,6 @@ impl TermWindow {
current_mouse_event: None,
prev_cursor: PrevCursorPos::new(),
last_scroll_info: RenderableDimensions::default(),
clipboard_contents: Arc::clone(&clipboard_contents),
tab_state: RefCell::new(HashMap::new()),
pane_state: RefCell::new(HashMap::new()),
current_mouse_button: None,
@@ -515,7 +508,7 @@ impl TermWindow {
tw.borrow_mut().window.replace(window.clone());
Self::apply_icon(&window)?;
Self::setup_clipboard(&window, mux_window_id, clipboard_contents);
Self::setup_clipboard(&window, mux_window_id);
let config_subscription = config::subscribe_to_config_reload({
let window = window.clone();
@@ -757,7 +750,6 @@ impl TermWindow {
window: &Window,
mux_window_id: MuxWindowId,
dead: &Arc<AtomicBool>,
clipboard_contents: &Arc<Mutex<Option<String>>>,
) -> bool {
if dead.load(Ordering::Relaxed) {
// Subscription cancelled asynchronously
@@ -794,7 +786,6 @@ impl TermWindow {
let clipboard: Arc<dyn wezterm_term::Clipboard> =
Arc::new(ClipboardHelper {
window: window.clone(),
clipboard_contents: Arc::clone(clipboard_contents),
});
pos.pane.set_clipboard(&clipboard);
break;
@@ -826,15 +817,8 @@ impl TermWindow {
let mux_window_id = self.mux_window_id;
let mux = Mux::get().expect("mux started and running on main thread");
let dead = Arc::new(AtomicBool::new(false));
let clipboard_contents = Arc::clone(&self.clipboard_contents);
mux.subscribe(move |n| {
Self::mux_pane_output_event_callback(
n,
&window,
mux_window_id,
&dead,
&clipboard_contents,
)
Self::mux_pane_output_event_callback(n, &window, mux_window_id, &dead)
});
}
@@ -1380,7 +1364,6 @@ impl TermWindow {
let clipboard = ClipboardHelper {
window: self.window.as_ref().unwrap().clone(),
clipboard_contents: Arc::clone(&self.clipboard_contents),
};
let mut domains = mux.iter_domains();
-1
View File
@@ -30,7 +30,6 @@ impl super::TermWindow {
self.mux_window_id,
ClipboardHelper {
window: self.window.as_ref().unwrap().clone(),
clipboard_contents: Arc::clone(&self.clipboard_contents),
},
)
}
@@ -614,10 +614,6 @@ struct RemoteClipboard {
}
impl Clipboard for RemoteClipboard {
fn get_contents(&self, _selection: ClipboardSelection) -> anyhow::Result<String> {
Ok("".to_owned())
}
fn set_contents(
&self,
selection: ClipboardSelection,