Skip to content

Commit

Permalink
feat(mouse): add extended mouse sequences
Browse files Browse the repository at this point in the history
1006: SGR mouse mode
1016: SGR Pixel mouse mode
  • Loading branch information
aymanbagabas committed Nov 9, 2022
1 parent 6fd0ee9 commit 3f6dcc7
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,20 @@ const (
EraseEntireLineSeq = "2K"

// Mouse.
EnableMousePressSeq = "?9h" // press only (X10)
DisableMousePressSeq = "?9l"
EnableMouseSeq = "?1000h" // press, release, wheel
DisableMouseSeq = "?1000l"
EnableMouseHiliteSeq = "?1001h" // highlight
DisableMouseHiliteSeq = "?1001l"
EnableMouseCellMotionSeq = "?1002h" // press, release, move on pressed, wheel
DisableMouseCellMotionSeq = "?1002l"
EnableMouseAllMotionSeq = "?1003h" // press, release, move, wheel
DisableMouseAllMotionSeq = "?1003l"
EnableMousePressSeq = "?9h" // press only (X10)
DisableMousePressSeq = "?9l"
EnableMouseSeq = "?1000h" // press, release, wheel
DisableMouseSeq = "?1000l"
EnableMouseHiliteSeq = "?1001h" // highlight
DisableMouseHiliteSeq = "?1001l"
EnableMouseCellMotionSeq = "?1002h" // press, release, move on pressed, wheel
DisableMouseCellMotionSeq = "?1002l"
EnableMouseAllMotionSeq = "?1003h" // press, release, move, wheel
DisableMouseAllMotionSeq = "?1003l"
EnableMouseExtendedMotionSeq = "?1003;1006h" // press, release, move, wheel, SGR encoding
DisableMouseExtendedMotionSeq = "?1003;1006l"
EnableMousePixelsMotionSeq = "?1003;1016h" // press, release, move, wheel, SGR encoding, pixel coordinates
DisableMousePixelsMotionSeq = "?1003;1016l"

// Screen.
RestoreScreenSeq = "?47l"
Expand Down Expand Up @@ -259,6 +263,22 @@ func (o Output) DisableMouseAllMotion() {
fmt.Fprint(o.tty, CSI+DisableMouseAllMotionSeq)
}

func (o Output) EnableMouseExtendedMotion() {
fmt.Fprint(o.tty, CSI+EnableMouseExtendedMotionSeq)
}

func (o Output) DisableMouseExtendedMotion() {
fmt.Fprint(o.tty, CSI+DisableMouseExtendedMotionSeq)
}

func (o Output) EnableMousePixelsMotion() {
fmt.Fprint(o.tty, CSI+EnableMousePixelsMotionSeq)
}

func (o Output) DisableMousePixelsMotion() {
fmt.Fprint(o.tty, CSI+DisableMousePixelsMotionSeq)
}

// SetWindowTitle sets the terminal window title.
func (o Output) SetWindowTitle(title string) {
fmt.Fprintf(o.tty, OSC+SetWindowTitleSeq, title)
Expand Down

0 comments on commit 3f6dcc7

Please sign in to comment.