aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/terminal.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-21 19:56:47 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-21 19:56:47 -0400
commit55ad16bb706a013711c555259c37292d441894f2 (patch)
tree7b5df695d246ef2615f95bdcd451ca88764f8251 /widgets/terminal.go
parent28f393bdbdd865702cc8c928607d43a05dc7e6b8 (diff)
downloadaerc-55ad16bb706a013711c555259c37292d441894f2.tar.gz
Fix cursor handling in embedded terminal
Diffstat (limited to 'widgets/terminal.go')
-rw-r--r--widgets/terminal.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 29a619c5..d9772e66 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -92,7 +92,6 @@ type Terminal struct {
cmd *exec.Cmd
colors map[tcell.Color]tcell.Color
ctx *ui.Context
- cursorPos vterm.Pos
cursorShown bool
damage []vterm.Rect
err error
@@ -202,6 +201,7 @@ func (term *Terminal) Close(err error) {
term.OnClose(err)
}
term.closed = true
+ term.ctx.HideCursor()
}
func (term *Terminal) OnInvalidate(cb func(d ui.Drawable)) {
@@ -283,11 +283,17 @@ func (term *Terminal) Draw(ctx *ui.Context) {
}
}
}
+
+ if !term.cursorShown {
+ ctx.HideCursor()
+ } else {
+ row, col := term.vterm.ObtainState().GetCursorPos()
+ ctx.SetCursor(col, row)
+ }
}
func (term *Terminal) Focus(focus bool) {
term.focus = focus
- term.resetCursor()
}
func convertMods(mods tcell.ModMask) vterm.Modifier {
@@ -373,22 +379,10 @@ func (term *Terminal) onDamage(rect *vterm.Rect) int {
return 1
}
-func (term *Terminal) resetCursor() {
- if term.ctx != nil && term.focus {
- if !term.cursorShown {
- term.ctx.HideCursor()
- } else {
- term.ctx.SetCursor(term.cursorPos.Col(), term.cursorPos.Row())
- }
- }
-}
-
func (term *Terminal) onMoveCursor(old *vterm.Pos,
pos *vterm.Pos, visible bool) int {
term.cursorShown = visible
- term.cursorPos = *pos
- term.resetCursor()
return 1
}