Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist mouse mode during buffer switching #299

Merged
merged 2 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/app/darktile/gui/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions internal/app/darktile/termutil/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
36 changes: 14 additions & 22 deletions internal/app/darktile/termutil/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions internal/app/darktile/termutil/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down