Persist mouse mode during buffer switching (#299)
* Persist mouse mode during buffer switching * Update mouse.go
This commit is contained in:
parent
80b4d6ac9c
commit
1f2980cbb4
|
@ -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)
|
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 {
|
switch mode {
|
||||||
case termutil.MouseModeNone:
|
case termutil.MouseModeNone:
|
||||||
|
@ -295,7 +295,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
||||||
|
|
||||||
var button rune
|
var button rune
|
||||||
|
|
||||||
extMode := g.terminal.GetActiveBuffer().GetMouseExtMode()
|
extMode := g.terminal.GetMouseExtMode()
|
||||||
|
|
||||||
switch true {
|
switch true {
|
||||||
case pressedLeft:
|
case pressedLeft:
|
||||||
|
|
|
@ -25,8 +25,6 @@ type Buffer struct {
|
||||||
charsets []*map[rune]rune // array of 2 charsets, nil means ASCII (no conversion)
|
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
|
currentCharset int // active charset index in charsets array, valid values are 0 or 1
|
||||||
modes Modes
|
modes Modes
|
||||||
mouseMode MouseMode
|
|
||||||
mouseExtMode MouseExtMode
|
|
||||||
selectionStart *Position
|
selectionStart *Position
|
||||||
selectionEnd *Position
|
selectionEnd *Position
|
||||||
highlightStart *Position
|
highlightStart *Position
|
||||||
|
@ -80,14 +78,6 @@ func (buffer *Buffer) IsCursorVisible() bool {
|
||||||
return buffer.modes.ShowCursor
|
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 {
|
func (buffer *Buffer) IsApplicationCursorKeysModeEnabled() bool {
|
||||||
return buffer.modes.ApplicationCursorKeys
|
return buffer.modes.ApplicationCursorKeys
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,11 +717,9 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
|
||||||
t.activeBuffer.modes.AutoWrap = enabled
|
t.activeBuffer.modes.AutoWrap = enabled
|
||||||
case "?9":
|
case "?9":
|
||||||
if enabled {
|
if enabled {
|
||||||
//terminal.logger.Infof("Turning on X10 mouse mode")
|
t.mouseMode = (MouseModeX10)
|
||||||
t.activeBuffer.mouseMode = (MouseModeX10)
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off X10 mouse mode")
|
t.mouseMode = (MouseModeNone)
|
||||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
|
||||||
}
|
}
|
||||||
case "?12", "?13":
|
case "?12", "?13":
|
||||||
t.activeBuffer.modes.BlinkingCursor = enabled
|
t.activeBuffer.modes.BlinkingCursor = enabled
|
||||||
|
@ -737,46 +735,40 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
|
||||||
// enable mouse tracking
|
// enable mouse tracking
|
||||||
// 1000 refers to ext mode for extended mouse click area - otherwise only x <= 255-31
|
// 1000 refers to ext mode for extended mouse click area - otherwise only x <= 255-31
|
||||||
if enabled {
|
if enabled {
|
||||||
t.activeBuffer.mouseMode = (MouseModeVT200)
|
t.mouseMode = (MouseModeVT200)
|
||||||
} else {
|
} else {
|
||||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
t.mouseMode = (MouseModeNone)
|
||||||
}
|
}
|
||||||
case "?1002":
|
case "?1002":
|
||||||
if enabled {
|
if enabled {
|
||||||
//terminal.logger.Infof("Turning on Button Event mouse mode")
|
t.mouseMode = (MouseModeButtonEvent)
|
||||||
t.activeBuffer.mouseMode = (MouseModeButtonEvent)
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off Button Event mouse mode")
|
t.mouseMode = (MouseModeNone)
|
||||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
|
||||||
}
|
}
|
||||||
case "?1003":
|
case "?1003":
|
||||||
if enabled {
|
if enabled {
|
||||||
t.activeBuffer.mouseMode = MouseModeAnyEvent
|
t.mouseMode = MouseModeAnyEvent
|
||||||
} else {
|
} else {
|
||||||
t.activeBuffer.mouseMode = MouseModeNone
|
t.mouseMode = MouseModeNone
|
||||||
}
|
}
|
||||||
case "?1005":
|
case "?1005":
|
||||||
if enabled {
|
if enabled {
|
||||||
t.activeBuffer.mouseExtMode = MouseExtUTF
|
t.mouseExtMode = MouseExtUTF
|
||||||
} else {
|
} else {
|
||||||
t.activeBuffer.mouseExtMode = MouseExtNone
|
t.mouseExtMode = MouseExtNone
|
||||||
}
|
}
|
||||||
|
|
||||||
case "?1006":
|
case "?1006":
|
||||||
if enabled {
|
if enabled {
|
||||||
//.logger.Infof("Turning on SGR ext mouse mode")
|
t.mouseExtMode = MouseExtSGR
|
||||||
t.activeBuffer.mouseExtMode = MouseExtSGR
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off SGR ext mouse mode")
|
t.mouseExtMode = (MouseExtNone)
|
||||||
t.activeBuffer.mouseExtMode = (MouseExtNone)
|
|
||||||
}
|
}
|
||||||
case "?1015":
|
case "?1015":
|
||||||
if enabled {
|
if enabled {
|
||||||
//terminal.logger.Infof("Turning on URXVT ext mouse mode")
|
t.mouseExtMode = (MouseExtURXVT)
|
||||||
t.activeBuffer.mouseExtMode = (MouseExtURXVT)
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off URXVT ext mouse mode")
|
t.mouseExtMode = (MouseExtNone)
|
||||||
t.activeBuffer.mouseExtMode = (MouseExtNone)
|
|
||||||
}
|
}
|
||||||
case "?1048":
|
case "?1048":
|
||||||
if enabled {
|
if enabled {
|
||||||
|
|
|
@ -27,6 +27,8 @@ type Terminal struct {
|
||||||
closeChan chan struct{}
|
closeChan chan struct{}
|
||||||
buffers []*Buffer
|
buffers []*Buffer
|
||||||
activeBuffer *Buffer
|
activeBuffer *Buffer
|
||||||
|
mouseMode MouseMode
|
||||||
|
mouseExtMode MouseExtMode
|
||||||
logFile *os.File
|
logFile *os.File
|
||||||
theme *Theme
|
theme *Theme
|
||||||
running bool
|
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 {
|
func (t *Terminal) GetActiveBuffer() *Buffer {
|
||||||
return t.activeBuffer
|
return t.activeBuffer
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue