summaryrefslogtreecommitdiffstats
path: root/llgo/third_party/liner/width.go
diff options
context:
space:
mode:
Diffstat (limited to 'llgo/third_party/liner/width.go')
-rw-r--r--llgo/third_party/liner/width.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/llgo/third_party/liner/width.go b/llgo/third_party/liner/width.go
index 5c6bf6854f5..d8984aae9b8 100644
--- a/llgo/third_party/liner/width.go
+++ b/llgo/third_party/liner/width.go
@@ -36,6 +36,25 @@ func countGlyphs(s []rune) int {
return n
}
+func countMultiLineGlyphs(s []rune, columns int, start int) int {
+ n := start
+ for _, r := range s {
+ switch {
+ case unicode.IsOneOf(zeroWidth, r):
+ case unicode.IsOneOf(doubleWidth, r):
+ n += 2
+ // no room for a 2-glyphs-wide char in the ending
+ // so skip a column and display it at the beginning
+ if n%columns == 1 {
+ n++
+ }
+ default:
+ n++
+ }
+ }
+ return n
+}
+
func getPrefixGlyphs(s []rune, num int) []rune {
p := 0
for n := 0; n < num && p < len(s); p++ {
OpenPOWER on IntegriCloud