diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-17 14:02:33 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-17 14:02:33 -0400 |
commit | 1170893e395ff5e3e7bee7ff51224b4a572f01cf (patch) | |
tree | f15e996bb529293c772159dbcf7a8b3fcd1a312f /widgets/exline.go | |
parent | 13ba53c9d03c375877395a6580d6f694bd19020f (diff) | |
download | aerc-1170893e395ff5e3e7bee7ff51224b4a572f01cf.tar.gz |
Add basic terminal widget
Diffstat (limited to 'widgets/exline.go')
-rw-r--r-- | widgets/exline.go | 9 |
1 files changed, 9 insertions, 0 deletions
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:] |