about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-14 08:07:24 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-14 08:07:24 -0500
commitd35213eaabeda8749cd0aab103e5895cfcd96e94 (patch)
tree7722340021b0ffe0482eaabf902421883435b6ed /lib
parent501c95d852971775d64b97872fe63ecea367c525 (diff)
downloadaerc-d35213eaabeda8749cd0aab103e5895cfcd96e94.tar.gz
Add cursor handling in ex line
Diffstat (limited to 'lib')
-rw-r--r--lib/ui/context.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/ui/context.go b/lib/ui/context.go
index d7796bf..d450fd8 100644
--- a/lib/ui/context.go
+++ b/lib/ui/context.go
@@ -10,7 +10,9 @@ import (
 
 // A context allows you to draw in a sub-region of the terminal
 type Context struct {
+	screen   tcell.Screen
 	viewport *views.ViewPort
+	x, y     int
 }
 
 func (ctx *Context) X() int {
@@ -35,7 +37,7 @@ func (ctx *Context) Height() int {
 
 func NewContext(width, height int, screen tcell.Screen) *Context {
 	vp := views.NewViewPort(screen, 0, 0, width, height)
-	return &Context{vp}
+	return &Context{screen, vp, 0, 0}
 }
 
 func (ctx *Context) Subcontext(x, y, width, height int) *Context {
@@ -47,7 +49,7 @@ func (ctx *Context) Subcontext(x, y, width, height int) *Context {
 		panic(fmt.Errorf("Attempted to create context larger than parent"))
 	}
 	vp := views.NewViewPort(ctx.viewport, x, y, width, height)
-	return &Context{vp}
+	return &Context{ctx.screen, vp, ctx.x + x, ctx.y + y}
 }
 
 func (ctx *Context) SetCell(x, y int, ch rune, style tcell.Style) {
@@ -105,10 +107,9 @@ func (ctx *Context) Fill(x, y, width, height int, rune rune, style tcell.Style)
 }
 
 func (ctx *Context) SetCursor(x, y int) {
-	// FIXME: Cursor needs to be set on tcell.Screen, or layout has to
-	// provide a CellModel
-	// cv := views.NewCellView()
-	// cv.Init()
-	// cv.SetView(ctx.viewport)
-	// cv.SetCursor(x, y)
+	ctx.screen.ShowCursor(ctx.x+x, ctx.y+y)
+}
+
+func (ctx *Context) HideCursor() {
+	ctx.screen.HideCursor()
 }