diff options
author | Wim <wim@42.be> | 2020-11-22 15:55:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-22 15:55:57 +0100 |
commit | 4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf (patch) | |
tree | 92d3b8d27cd35455eae7423e4d47aad67cc6a43b /vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go | |
parent | cbb46293ab670c1989bfcd9aae5d853223074038 (diff) | |
download | matterbridge-msglm-4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf.tar.gz matterbridge-msglm-4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf.tar.bz2 matterbridge-msglm-4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf.zip |
Update vendor (#1297)
Diffstat (limited to 'vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go')
-rw-r--r-- | vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go b/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go index d6650bb1..ec04e8f1 100644 --- a/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go +++ b/vendor/github.com/shazow/ssh-chat/sshd/terminal/terminal.go @@ -10,6 +10,8 @@ import ( "strconv" "sync" "unicode/utf8" + + "golang.org/x/text/width" ) // EscapeCodes contains escape sequences that can be written to the terminal in @@ -262,7 +264,7 @@ func (t *Terminal) moveCursorToPos(pos int) { return } - x := visualLength(t.prompt) + pos + x := visualLength(t.prompt) + visualLength(t.line[:pos]) y := x / t.termWidth x = x % t.termWidth @@ -351,6 +353,7 @@ func (t *Terminal) setLine(newLine []rune, newPos int) { for i := len(newLine); i < len(t.line); i++ { t.writeLine(space) } + t.line = newLine t.moveCursorToPos(newPos) } t.line = newLine @@ -462,6 +465,10 @@ func visualLength(runes []rune) int { inEscapeSeq = true default: length++ + kind := width.LookupRune(r).Kind() + if kind == width.EastAsianFullwidth || kind == width.EastAsianWide { + length++ + } } } |