Persist mouse mode during buffer switching (#299)

* Persist mouse mode during buffer switching

* Update mouse.go
This commit is contained in:
Liam Galvin 2021-07-31 14:34:02 +01:00 committed by GitHub
parent 80b4d6ac9c
commit 1f2980cbb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 34 deletions

View File

@ -271,7 +271,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
tx, ty := 1+(x/g.fontManager.CharSize().X), 1+(y/g.fontManager.CharSize().Y)
mode := g.terminal.GetActiveBuffer().GetMouseMode()
mode := g.terminal.GetMouseMode()
switch mode {
case termutil.MouseModeNone:
@ -295,7 +295,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
var button rune
extMode := g.terminal.GetActiveBuffer().GetMouseExtMode()
extMode := g.terminal.GetMouseExtMode()
switch true {
case pressedLeft:

View File

@ -25,8 +25,6 @@ type Buffer struct {
charsets []*map[rune]rune // array of 2 charsets, nil means ASCII (no conversion)
currentCharset int // active charset index in charsets array, valid values are 0 or 1
modes Modes
mouseMode MouseMode
mouseExtMode MouseExtMode
selectionStart *Position
selectionEnd *Position
highlightStart *Position
@ -80,14 +78,6 @@ func (buffer *Buffer) IsCursorVisible() bool {
return buffer.modes.ShowCursor
}
func (buffer *Buffer) GetMouseMode() MouseMode {
return buffer.mouseMode
}
func (buffer *Buffer) GetMouseExtMode() MouseExtMode {
return buffer.mouseExtMode
}
func (buffer *Buffer) IsApplicationCursorKeysModeEnabled() bool {
return buffer.modes.ApplicationCursorKeys
}

View File

@ -717,11 +717,9 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
t.activeBuffer.modes.AutoWrap = enabled
case "?9":
if enabled {
//terminal.logger.Infof("Turning on X10 mouse mode")
t.activeBuffer.mouseMode = (MouseModeX10)
t.mouseMode = (MouseModeX10)
} else {
//terminal.logger.Infof("Turning off X10 mouse mode")
t.activeBuffer.mouseMode = (MouseModeNone)
t.mouseMode = (MouseModeNone)
}
case "?12", "?13":
t.activeBuffer.modes.BlinkingCursor = enabled
@ -737,46 +735,40 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
// enable mouse tracking
// 1000 refers to ext mode for extended mouse click area - otherwise only x <= 255-31
if enabled {
t.activeBuffer.mouseMode = (MouseModeVT200)
t.mouseMode = (MouseModeVT200)
} else {
t.activeBuffer.mouseMode = (MouseModeNone)
t.mouseMode = (MouseModeNone)
}
case "?1002":
if enabled {
//terminal.logger.Infof("Turning on Button Event mouse mode")
t.activeBuffer.mouseMode = (MouseModeButtonEvent)
t.mouseMode = (MouseModeButtonEvent)
} else {
//terminal.logger.Infof("Turning off Button Event mouse mode")
t.activeBuffer.mouseMode = (MouseModeNone)
t.mouseMode = (MouseModeNone)
}
case "?1003":
if enabled {
t.activeBuffer.mouseMode = MouseModeAnyEvent
t.mouseMode = MouseModeAnyEvent
} else {
t.activeBuffer.mouseMode = MouseModeNone
t.mouseMode = MouseModeNone
}
case "?1005":
if enabled {
t.activeBuffer.mouseExtMode = MouseExtUTF
t.mouseExtMode = MouseExtUTF
} else {
t.activeBuffer.mouseExtMode = MouseExtNone
t.mouseExtMode = MouseExtNone
}
case "?1006":
if enabled {
//.logger.Infof("Turning on SGR ext mouse mode")
t.activeBuffer.mouseExtMode = MouseExtSGR
t.mouseExtMode = MouseExtSGR
} else {
//terminal.logger.Infof("Turning off SGR ext mouse mode")
t.activeBuffer.mouseExtMode = (MouseExtNone)
t.mouseExtMode = (MouseExtNone)
}
case "?1015":
if enabled {
//terminal.logger.Infof("Turning on URXVT ext mouse mode")
t.activeBuffer.mouseExtMode = (MouseExtURXVT)
t.mouseExtMode = (MouseExtURXVT)
} else {
//terminal.logger.Infof("Turning off URXVT ext mouse mode")
t.activeBuffer.mouseExtMode = (MouseExtNone)
t.mouseExtMode = (MouseExtNone)
}
case "?1048":
if enabled {

View File

@ -27,6 +27,8 @@ type Terminal struct {
closeChan chan struct{}
buffers []*Buffer
activeBuffer *Buffer
mouseMode MouseMode
mouseExtMode MouseExtMode
logFile *os.File
theme *Theme
running bool
@ -285,6 +287,14 @@ func (t *Terminal) switchBuffer(index uint8) {
}
}
func (t *Terminal) GetMouseMode() MouseMode {
return t.mouseMode
}
func (t *Terminal) GetMouseExtMode() MouseExtMode {
return t.mouseExtMode
}
func (t *Terminal) GetActiveBuffer() *Buffer {
return t.activeBuffer
}