macos: rectangle select only requires option + drag

Fixes #2537

This matches Terminal.app. iTerm2 requires cmd+option (our old
behavior). Kitty doesn't seem to support rectangle select or I couldn't
figure out how to make it work. WezTerm matches Terminal.app too.
Outside of terminal emulators, this is also the rectangular select
binding for neovim.
This commit is contained in:
Mitchell Hashimoto
2024-10-30 20:44:47 -04:00
parent 569d887de8
commit c97c0858be
3 changed files with 12 additions and 7 deletions

View File

@ -3468,7 +3468,7 @@ fn dragLeftClickSingle(
try self.setSelection(if (selected) terminal.Selection.init(
drag_pin,
drag_pin,
self.mouse.mods.ctrlOrSuper() and self.mouse.mods.alt,
SurfaceMouse.isRectangleSelectState(self.mouse.mods),
) else null);
return;
@ -3503,7 +3503,7 @@ fn dragLeftClickSingle(
try self.setSelection(terminal.Selection.init(
start,
drag_pin,
self.mouse.mods.ctrlOrSuper() and self.mouse.mods.alt,
SurfaceMouse.isRectangleSelectState(self.mouse.mods),
));
return;
}

View File

@ -113,14 +113,19 @@ fn eligibleMouseShapeKeyEvent(physical_key: input.Key) bool {
physical_key.leftOrRightAlt();
}
fn isRectangleSelectState(mods: input.Mods) bool {
return mods.ctrlOrSuper() and mods.alt;
}
fn isMouseModeOverrideState(mods: input.Mods) bool {
return mods.shift;
}
/// Returns true if our modifiers put us in a state where dragging
/// should cause a rectangle select.
pub fn isRectangleSelectState(mods: input.Mods) bool {
return if (comptime builtin.target.isDarwin())
mods.alt
else
mods.ctrlOrSuper() and mods.alt;
}
test "keyToMouseShape" {
const testing = std.testing;