T12: a terminal about to be hidden ends its mouse gesture as releases would: its selection drag ends and its program hears each held button come up
This commit is contained in:
3 files changed
+48
-23
No files matched your search
+39
-20
@@ -195,31 +195,50 @@ impl TerminalView {
|
||||
_: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if event.button == MouseButton::Left && std::mem::take(&mut self.pointer.selecting) {
|
||||
let selected = self.selected();
|
||||
let count = selected.as_ref().map_or(0, |text| text.chars().count());
|
||||
log::debug!(
|
||||
"terminal {}: the selection ends on {count} characters",
|
||||
self.pty.pid
|
||||
);
|
||||
if let Some(text) = selected.filter(|_| SettingsStore::get(cx).copy_on_select) {
|
||||
self.copy_text(text, true, cx);
|
||||
}
|
||||
if event.button == MouseButton::Left {
|
||||
self.end_selection(cx);
|
||||
}
|
||||
let Some(released) = button(event.button) else {
|
||||
if let Some(released) = button(event.button) {
|
||||
let (cell, ..) = self.cell_at(event.position);
|
||||
self.release(released, cell, &event.modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ends the mouse's gesture as releases would: a hidden terminal hears none.
|
||||
pub fn let_go(&mut self, cx: &mut Context<Self>) {
|
||||
self.end_selection(cx);
|
||||
for held in self.pointer.pressed.clone() {
|
||||
log::debug!("terminal {}: hidden with {held:?} down", self.pty.pid);
|
||||
let cell = self
|
||||
.pointer
|
||||
.last
|
||||
.expect("a press the program heard set a cell");
|
||||
self.release(held, cell, &Modifiers::default());
|
||||
}
|
||||
}
|
||||
|
||||
/// Ends a selection drag; copy on select takes its text.
|
||||
fn end_selection(&mut self, cx: &mut Context<Self>) {
|
||||
if !std::mem::take(&mut self.pointer.selecting) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
let selected = self.selected();
|
||||
let count = selected.as_ref().map_or(0, |text| text.chars().count());
|
||||
log::debug!(
|
||||
"terminal {}: the selection ends on {count} characters",
|
||||
self.pty.pid
|
||||
);
|
||||
if let Some(text) = selected.filter(|_| SettingsStore::get(cx).copy_on_select) {
|
||||
self.copy_text(text, true, cx);
|
||||
}
|
||||
}
|
||||
|
||||
/// Reports `released` coming up when its press went to the program.
|
||||
fn release(&mut self, released: Button, cell: (usize, usize), modifiers: &Modifiers) {
|
||||
if self.pointer.pressed.contains(&released) {
|
||||
self.pointer.pressed.retain(|held| *held != released);
|
||||
let (cell, ..) = self.cell_at(event.position);
|
||||
let tracking = self.mouse.tracking;
|
||||
self.report(
|
||||
Some(released),
|
||||
Gesture::Release,
|
||||
cell,
|
||||
&event.modifiers,
|
||||
tracking,
|
||||
);
|
||||
self.report(Some(released), Gesture::Release, cell, modifiers, tracking);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -159,9 +159,15 @@ impl Workspace {
|
||||
|
||||
/// Shows session `index`, clears its bell, and gives its terminal the keys.
|
||||
pub fn select(&mut self, index: usize, window: &mut Window, cx: &mut Context<Self>) {
|
||||
let Some(session) = self.sessions.get_mut(index) else {
|
||||
if index >= self.sessions.len() {
|
||||
return;
|
||||
};
|
||||
}
|
||||
if index != self.active
|
||||
&& let Some(hidden) = self.sessions.get(self.active)
|
||||
{
|
||||
hidden.terminal.update(cx, |view, cx| view.let_go(cx));
|
||||
}
|
||||
let session = &mut self.sessions[index];
|
||||
session.bell = false;
|
||||
window.focus(&session.terminal.focus_handle(cx), cx);
|
||||
self.active = index;
|
||||
|
||||
Reference in new issue
Block a user