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 10, 2022
1 parent 6fd0ee9 commit e40e7b4
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions screen.go
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, extended coordinates
DisableMouseExtendedMotionSeq = "?1003;1006l"
EnableMousePixelsMotionSeq = "?1003;1016h" // press, release, move, wheel, extended pixel coordinates
DisableMousePixelsMotionSeq = "?1003;1016l"

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

// EnableMouseExtendedMotion enables Extended Mouse mode (SGR).
func (o Output) EnableMouseExtendedMotion() {
fmt.Fprint(o.tty, CSI+EnableMouseExtendedMotionSeq)
}

// DisableMouseExtendedMotion disables Extended Mouse mode (SGR).
func (o Output) DisableMouseExtendedMotion() {
fmt.Fprint(o.tty, CSI+DisableMouseExtendedMotionSeq)
}

// EnableMousePixelsMotion enables Pixel Motion Mouse mode (SGR-Pixels).
func (o Output) EnableMousePixelsMotion() {
fmt.Fprint(o.tty, CSI+EnableMousePixelsMotionSeq)
}

// DisableMousePixelsMotion disables Pixel Motion Mouse mode (SGR-Pixels).
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 e40e7b4

Please sign in to comment.