Skip to content
Myr

Handle wide unicode characters in --prompt

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent f1cd0e2 · Browse files · 1 file+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:src/terminal.go+3 added-3 removed
389 unmodified lines
390 }391}392393func (t *Terminal) placeCursor() {394 t.move(0, len(t.prompt)+displayWidth(t.input[:t.cx]), false)394 t.move(0, displayWidth([]rune(t.prompt))+displayWidth(t.input[:t.cx]), false)395}396397func (t *Terminal) printPrompt() {398 t.move(0, 0, true)
2 unmodified lines
401}402403func (t *Terminal) printInfo() {404 if t.inlineInfo {405 t.move(0, len(t.prompt)+displayWidth(t.input)+1, true)405 t.move(0, displayWidth([]rune(t.prompt))+displayWidth(t.input)+1, true)406 if t.reading {407 C.CPrint(C.ColSpinner, true, " < ")408 } else {409 C.CPrint(C.ColPrompt, true, " < ")
612 unmodified lines
1022 } else if mx >= t.marginInt[3] && mx < C.MaxX()-t.marginInt[1] &&1023 my >= t.marginInt[0] && my < C.MaxY()-t.marginInt[2] {1024 mx -= t.marginInt[3]1025 my -= t.marginInt[0]1026 mx = util.Constrain(mx-len(t.prompt), 0, len(t.input))1026 mx = util.Constrain(mx-displayWidth([]rune(t.prompt)), 0, len(t.input))1027 if !t.reverse {1028 my = t.maxHeight() - my - 11029 }1030 min := 2 + len(t.header)
104 unmodified lines