aboutsummaryrefslogtreecommitdiff
path: root/lib/ui
diff options
context:
space:
mode:
authorTuomas Siipola <tuomas@zpl.fi>2019-07-16 10:12:52 +0000
committerDrew DeVault <sir@cmpwn.com>2019-07-17 15:59:52 -0400
commit038bf711fae3305a57467392ae2c281caa15bbb9 (patch)
tree09cb9b84c4ddad68e234c52e13d68ea8a7d47d59 /lib/ui
parentd43684cd901b4a6d6e9c1439e762bd06d3b16f4a (diff)
Fix text input cursor position with non-ASCII text
Fixes #171
Diffstat (limited to 'lib/ui')
-rw-r--r--lib/ui/textinput.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go
index a3127e5..2feeb84 100644
--- a/lib/ui/textinput.go
+++ b/lib/ui/textinput.go
@@ -73,16 +73,16 @@ func (ti *TextInput) Draw(ctx *Context) {
ti.ctx = ctx // gross
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
- text := string(ti.text[scroll:])
+ text := ti.text[scroll:]
sindex := ti.index - scroll
if ti.password {
x := ctx.Printf(0, 0, tcell.StyleDefault, "%s", ti.prompt)
cells := runewidth.StringWidth(string(text))
ctx.Fill(x, 0, cells, 1, '*', tcell.StyleDefault)
} else {
- ctx.Printf(0, 0, tcell.StyleDefault, "%s%s", ti.prompt, text)
+ ctx.Printf(0, 0, tcell.StyleDefault, "%s%s", ti.prompt, string(text))
}
- cells := runewidth.StringWidth(text[:sindex] + ti.prompt)
+ cells := runewidth.StringWidth(string(text[:sindex]) + ti.prompt)
if ti.focus {
ctx.SetCursor(cells, 0)
}