From 1170893e395ff5e3e7bee7ff51224b4a572f01cf Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 17 Mar 2019 14:02:33 -0400 Subject: Add basic terminal widget --- widgets/exline.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'widgets/exline.go') diff --git a/widgets/exline.go b/widgets/exline.go index 7eff74a..5c9f065 100644 --- a/widgets/exline.go +++ b/widgets/exline.go @@ -17,6 +17,7 @@ type ExLine struct { ctx *ui.Context cancel func() cells int + focus bool index int scroll int @@ -52,6 +53,14 @@ func (ex *ExLine) Draw(ctx *ui.Context) { } } +func (ex *ExLine) Focus(focus bool) { + ex.focus = focus + if focus && ex.ctx != nil { + cells := runewidth.StringWidth(string(ex.command[:ex.index])) + ex.ctx.SetCursor(cells+1, 0) + } +} + func (ex *ExLine) insert(ch rune) { left := ex.command[:ex.index] right := ex.command[ex.index:] -- cgit 1.4.1-2-gfad0