summary refs log tree commit diff stats
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
parentd43684cd901b4a6d6e9c1439e762bd06d3b16f4a (diff)
downloadaerc-038bf711fae3305a57467392ae2c281caa15bbb9.tar.gz
Fix text input cursor position with non-ASCII text
Fixes #171
-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)
 	}
' href='#n141'>141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184