From 745f7a111cf7adf973313ccf5b79cad4f17d1808 Mon Sep 17 00:00:00 2001 From: rrrooommmaaa Date: Sat, 23 Mar 2019 01:49:00 +0300 Subject: [PATCH] #116 URXVT extended mouse mode support (#267) --- 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 19703e9..daff8fc 100644 --- a/gui/mouse.go +++ b/gui/mouse.go @@ -412,13 +412,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 {