diff --git a/ansipixels/mouse.go b/ansipixels/mouse.go index 44e5935..7653e4d 100644 --- a/ansipixels/mouse.go +++ b/ansipixels/mouse.go @@ -3,6 +3,9 @@ package ansipixels import "bytes" func (ap *AnsiPixels) MouseClickOn() { + // https://github.com/ghostty-org/ghostty/blame/main/website/app/vt/xtshiftescape/page.mdx + // Let us see shift key modifiers: + ap.WriteString("\033[>1s") ap.WriteString("\033[?1000h") } @@ -11,7 +14,6 @@ func (ap *AnsiPixels) MouseClickOff() { } func (ap *AnsiPixels) MouseTrackingOn() { - // Note default is supposed to be 1 but it isn't as of 2024-11-02 // https://github.com/ghostty-org/ghostty/blame/main/website/app/vt/xtshiftescape/page.mdx // Let us see shift key modifiers: ap.WriteString("\033[>1s") @@ -63,6 +65,7 @@ func (ap *AnsiPixels) MouseDecode() { const ( MouseLeft = 0b00 + MouseMiddle = 0b01 MouseRight = 0b10 MouseMove = 0b100000 MouseWheelUp = 0b1000000 @@ -72,7 +75,8 @@ const ( Ctrl = 0b010000 AllModifiers = Shift | Alt | Ctrl AnyModifierMask = ^AllModifiers - // For some reason iterm2 and kitty etc set the MouseRight bit when shift-mousewheeling. + // On a mac with a physical mouse, shift mousewheel is translated to button 6,7 which + // here looks like we set the MouseRight bit (when shift-mousewheeling). MouseWheelMask = ^(AllModifiers | MouseRight) ) @@ -104,6 +108,10 @@ func (ap *AnsiPixels) LeftClick() bool { return ap.Mouse && ((ap.Mbuttons & AnyModifierMask) == MouseLeft) } +func (ap *AnsiPixels) Middle() bool { + return ap.Mouse && ((ap.Mbuttons & AnyModifierMask) == MouseMiddle) +} + func (ap *AnsiPixels) RightClick() bool { return ap.Mouse && ((ap.Mbuttons & AnyModifierMask) == MouseRight) } @@ -112,6 +120,10 @@ func (ap *AnsiPixels) LeftDrag() bool { return ap.Mouse && ((ap.Mbuttons & AnyModifierMask) == MouseMove|MouseLeft) } +func (ap *AnsiPixels) MiddleDrag() bool { + return ap.Mouse && ((ap.Mbuttons & AnyModifierMask) == MouseMove|MouseMiddle) +} + func (ap *AnsiPixels) RightDrag() bool { return ap.Mouse && ((ap.Mbuttons & AnyModifierMask) == MouseMove|MouseRight) }