mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Reset the Mouse Cursor While Selecting
This change disabled the mouse cursor and URL highlight (underline) while a selection is in progress. A click to clear the selection doesn't trigger a URL action, but will re-enable the URL highlighting to indicate the next click will trigger the launcher.
This commit is contained in:
parent
20846ef925
commit
86ffa181b3
3 changed files with 21 additions and 19 deletions
|
@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Wayland clipboard integration
|
||||
- Use text mouse cursor when mouse mode is temporarily disabled with shift
|
||||
- Wayland primary selection clipboard not storing text when selection is stopped outside of the window
|
||||
- Block URL highlight while a selection is active
|
||||
|
||||
## 0.3.3
|
||||
|
||||
|
|
|
@ -449,6 +449,8 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
|
|||
if self.mouse_config.url.mods().relaxed_eq(mods)
|
||||
&& (!self.ctx.terminal().mode().intersects(mouse_mode) || mods.shift)
|
||||
&& self.mouse_config.url.launcher.is_some()
|
||||
&& self.ctx.selection_is_empty()
|
||||
&& self.ctx.mouse().left_button_state != ElementState::Pressed
|
||||
{
|
||||
let buffer_point = self.ctx.terminal().visible_to_buffer(point);
|
||||
if let Some(url) =
|
||||
|
@ -691,34 +693,33 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
|
|||
self.mouse_report(code, ElementState::Released, modifiers);
|
||||
return;
|
||||
} else if let (Some(point), true) = (point, button == MouseButton::Left) {
|
||||
self.launch_url(modifiers, point);
|
||||
let mouse_state = self.mouse_state(point, modifiers);
|
||||
self.update_mouse_cursor(mouse_state);
|
||||
if let MouseState::Url(url) = mouse_state {
|
||||
let url_bounds = url.linear_bounds(self.ctx.terminal());
|
||||
self.ctx.terminal_mut().set_url_highlight(url_bounds);
|
||||
self.launch_url(url);
|
||||
}
|
||||
}
|
||||
|
||||
self.copy_selection();
|
||||
}
|
||||
|
||||
// Spawn URL launcher when clicking on URLs
|
||||
fn launch_url(&self, modifiers: ModifiersState, point: Point) -> Option<()> {
|
||||
if !self.mouse_config.url.mods().relaxed_eq(modifiers)
|
||||
|| self.ctx.mouse().block_url_launcher
|
||||
{
|
||||
return None;
|
||||
fn launch_url(&self, url: Url) {
|
||||
if self.ctx.mouse().block_url_launcher {
|
||||
return;
|
||||
}
|
||||
|
||||
let point = self.ctx.terminal().visible_to_buffer(point);
|
||||
let url = self.ctx.terminal().urls().drain(..).find(|url| url.contains(point))?;
|
||||
let text = self.ctx.terminal().url_to_string(&url);
|
||||
if let Some(ref launcher) = self.mouse_config.url.launcher {
|
||||
let mut args = launcher.args().to_vec();
|
||||
args.push(self.ctx.terminal().url_to_string(url));
|
||||
|
||||
let launcher = self.mouse_config.url.launcher.as_ref()?;
|
||||
let mut args = launcher.args().to_vec();
|
||||
args.push(text);
|
||||
|
||||
match start_daemon(launcher.program(), &args) {
|
||||
Ok(_) => debug!("Launched {} with args {:?}", launcher.program(), args),
|
||||
Err(_) => warn!("Unable to launch {} with args {:?}", launcher.program(), args),
|
||||
match start_daemon(launcher.program(), &args) {
|
||||
Ok(_) => debug!("Launched {} with args {:?}", launcher.program(), args),
|
||||
Err(_) => warn!("Unable to launch {} with args {:?}", launcher.program(), args),
|
||||
}
|
||||
}
|
||||
|
||||
Some(())
|
||||
}
|
||||
|
||||
pub fn on_mouse_wheel(
|
||||
|
|
|
@ -1359,7 +1359,7 @@ impl Term {
|
|||
urls
|
||||
}
|
||||
|
||||
pub fn url_to_string(&self, url: &Url) -> String {
|
||||
pub fn url_to_string(&self, url: Url) -> String {
|
||||
let mut url_text = String::new();
|
||||
|
||||
let mut iter = self.grid.iter_from(url.start);
|
||||
|
|
Loading…
Reference in a new issue