#116 URXVT extended mouse mode support

This commit is contained in:
Roman Shevchenko 2019-03-17 12:41:41 +03:00
parent 4f308bdbd8
commit 21ae93aa96
3 changed files with 14 additions and 2 deletions

View File

@ -333,13 +333,16 @@ func (gui *GUI) emitButtonEventToTerminal(tx int, ty int, button glfw.MouseButto
gui.prevMotionTY = ty gui.prevMotionTY = ty
var packet string var packet string
if ext == terminal.MouseExtSGR { switch ext {
case terminal.MouseExtSGR:
final := 'M' final := 'M'
if release { if release {
final = 'm' final = 'm'
} }
packet = fmt.Sprintf("\x1b[<%d;%d;%d%c", b, tx, ty, final) 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))) 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) gui.logger.Infof("Sending mouse packet: '%v'", packet)

View File

@ -172,6 +172,14 @@ func csiSetMode(modeStr string, enabled bool, terminal *Terminal) error {
terminal.logger.Infof("Turning off SGR ext mouse mode") terminal.logger.Infof("Turning off SGR ext mouse mode")
terminal.SetMouseExtMode(MouseExtNone) 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": case "?1048":
if enabled { if enabled {
terminal.ActiveBuffer().SaveCursor() terminal.ActiveBuffer().SaveCursor()

View File

@ -31,6 +31,7 @@ const (
MouseExtNone MouseExtMode = iota MouseExtNone MouseExtMode = iota
MouseExtUTF MouseExtUTF
MouseExtSGR MouseExtSGR
MouseExtURXVT
) )
type WindowManipulationInterface interface { type WindowManipulationInterface interface {