From 21ae93aa9606d071409d43efbbb8357b5244cffc Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Sun, 17 Mar 2019 12:41:41 +0300 Subject: [PATCH] #116 URXVT extended mouse mode support --- gui/mouse.go | 7 +++++-- terminal/modes.go | 8 ++++++++ terminal/terminal.go | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gui/mouse.go b/gui/mouse.go index 14c71c5..3a9a0f2 100644 --- a/gui/mouse.go +++ b/gui/mouse.go @@ -333,13 +333,16 @@ func (gui *GUI) emitButtonEventToTerminal(tx int, ty int, button glfw.MouseButto gui.prevMotionTY = ty var packet string - if ext == terminal.MouseExtSGR { + switch ext { + case terminal.MouseExtSGR: final := 'M' if release { final = 'm' } packet = fmt.Sprintf("\x1b[<%d;%d;%d%c", b, tx, ty, final) - } else { + case terminal.MouseExtURXVT: + packet = fmt.Sprintf("\x1b[%d;%d;%dM", b+32, tx, ty) + default: packet = fmt.Sprintf("\x1b[M%c%c%c", (rune(b + 32)), (rune(tx + 32)), (rune(ty + 32))) } gui.logger.Infof("Sending mouse packet: '%v'", packet) diff --git a/terminal/modes.go b/terminal/modes.go index 3630e44..60a8c1f 100644 --- a/terminal/modes.go +++ b/terminal/modes.go @@ -172,6 +172,14 @@ func csiSetMode(modeStr string, enabled bool, terminal *Terminal) error { terminal.logger.Infof("Turning off SGR ext mouse mode") terminal.SetMouseExtMode(MouseExtNone) } + case "?1015": + if enabled { + terminal.logger.Infof("Turning on URXVT ext mouse mode") + terminal.SetMouseExtMode(MouseExtURXVT) + } else { + terminal.logger.Infof("Turning off URXVT ext mouse mode") + terminal.SetMouseExtMode(MouseExtNone) + } case "?1048": if enabled { terminal.ActiveBuffer().SaveCursor() diff --git a/terminal/terminal.go b/terminal/terminal.go index 170031c..f80210c 100644 --- a/terminal/terminal.go +++ b/terminal/terminal.go @@ -31,6 +31,7 @@ const ( MouseExtNone MouseExtMode = iota MouseExtUTF MouseExtSGR + MouseExtURXVT ) type WindowManipulationInterface interface {