mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 15:04:36 +03:00
enable url highlighting over mux
This commit is contained in:
parent
e12f413224
commit
dc3c5cbdd6
@ -19,7 +19,9 @@ use log::debug;
|
||||
use portable_pty::{CommandBuilder, PtySize};
|
||||
use serde_derive::*;
|
||||
use std::io::Cursor;
|
||||
use std::sync::Arc;
|
||||
use term::selection::SelectionRange;
|
||||
use termwiz::hyperlink::Hyperlink;
|
||||
use termwiz::surface::{Change, SequenceNo};
|
||||
use varbincode;
|
||||
|
||||
@ -379,6 +381,7 @@ pub struct SendMouseEvent {
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
pub struct SendMouseEventResponse {
|
||||
pub selection_range: Option<SelectionRange>,
|
||||
pub highlight: Option<Arc<Hyperlink>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
|
@ -761,8 +761,11 @@ impl<S: ReadAndWrite> ClientSession<S> {
|
||||
tab.mouse_event(event, &mut host)?;
|
||||
maybe_push_tab_changes(&surfaces, &tab, sender)?;
|
||||
|
||||
let highlight = tab.renderer().current_highlight().as_ref().cloned();
|
||||
|
||||
Ok(Pdu::SendMouseEventResponse(SendMouseEventResponse {
|
||||
selection_range: tab.selection_range(),
|
||||
highlight,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ struct MouseState {
|
||||
queue: VecDeque<MouseEvent>,
|
||||
selection_range: Arc<Mutex<Option<SelectionRange>>>,
|
||||
something_changed: Arc<Mutex<bool>>,
|
||||
highlight: Arc<Mutex<Option<Arc<Hyperlink>>>>,
|
||||
client: Client,
|
||||
remote_tab_id: TabId,
|
||||
}
|
||||
@ -94,6 +95,7 @@ impl MouseState {
|
||||
if let Some(event) = mouse.pop()? {
|
||||
let selection_range = Arc::clone(&mouse.selection_range);
|
||||
let something_changed = Arc::clone(&mouse.something_changed);
|
||||
let highlight = Arc::clone(&mouse.highlight);
|
||||
let state = Arc::clone(state);
|
||||
|
||||
mouse.future = Some(
|
||||
@ -106,6 +108,7 @@ impl MouseState {
|
||||
.then(move |resp| {
|
||||
if let Ok(r) = resp.as_ref() {
|
||||
*selection_range.lock().unwrap() = r.selection_range;
|
||||
*highlight.lock().unwrap() = r.highlight.clone();
|
||||
*something_changed.lock().unwrap() = true;
|
||||
}
|
||||
Future::with_executor(gui_executor().unwrap(), move || {
|
||||
@ -140,9 +143,12 @@ impl ClientTab {
|
||||
};
|
||||
let selection_range = Arc::new(Mutex::new(None));
|
||||
let something_changed = Arc::new(Mutex::new(true));
|
||||
let highlight = Arc::new(Mutex::new(None));
|
||||
|
||||
let mouse = Arc::new(Mutex::new(MouseState {
|
||||
selection_range: Arc::clone(&selection_range),
|
||||
something_changed: Arc::clone(&something_changed),
|
||||
highlight: Arc::clone(&highlight),
|
||||
remote_tab_id,
|
||||
client: client.client.clone(),
|
||||
future: None,
|
||||
@ -160,6 +166,7 @@ impl ClientTab {
|
||||
local_sequence: RefCell::new(0),
|
||||
selection_range,
|
||||
something_changed,
|
||||
highlight,
|
||||
};
|
||||
|
||||
let reader = Pipe::new().expect("Pipe::new failed");
|
||||
@ -305,6 +312,7 @@ struct RenderableState {
|
||||
poll_interval: RefCell<Duration>,
|
||||
selection_range: Arc<Mutex<Option<SelectionRange>>>,
|
||||
something_changed: Arc<Mutex<bool>>,
|
||||
highlight: Arc<Mutex<Option<Arc<Hyperlink>>>>,
|
||||
}
|
||||
|
||||
const MAX_POLL_INTERVAL: Duration = Duration::from_secs(30);
|
||||
@ -403,7 +411,7 @@ impl Renderable for RenderableState {
|
||||
fn clean_dirty_lines(&mut self) {}
|
||||
|
||||
fn current_highlight(&self) -> Option<Arc<Hyperlink>> {
|
||||
None
|
||||
self.highlight.lock().unwrap().as_ref().cloned()
|
||||
}
|
||||
|
||||
fn physical_dimensions(&self) -> (usize, usize) {
|
||||
|
Loading…
Reference in New Issue
Block a user