aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/MichaelMure/go-term-text/len.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-05 22:03:19 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-05 22:33:03 +0100
commit1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6 (patch)
treee088b0fa43058afde1db71541d8fcb4b94905d6e /vendor/github.com/MichaelMure/go-term-text/len.go
parentf093be96e98284580d61664adecd0a2ff8b354e4 (diff)
downloadgit-bug-1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6.tar.gz
migrate to go modules
Diffstat (limited to 'vendor/github.com/MichaelMure/go-term-text/len.go')
-rw-r--r--vendor/github.com/MichaelMure/go-term-text/len.go45
1 files changed, 0 insertions, 45 deletions
diff --git a/vendor/github.com/MichaelMure/go-term-text/len.go b/vendor/github.com/MichaelMure/go-term-text/len.go
deleted file mode 100644
index c6bcaeac..00000000
--- a/vendor/github.com/MichaelMure/go-term-text/len.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package text
-
-import (
- "strings"
-
- "github.com/mattn/go-runewidth"
-)
-
-// Len return the length of a string in a terminal, while ignoring the terminal
-// escape sequences.
-func Len(text string) int {
- length := 0
- escape := false
-
- for _, char := range text {
- if char == '\x1b' {
- escape = true
- }
- if !escape {
- length += runewidth.RuneWidth(char)
- }
- if char == 'm' {
- escape = false
- }
- }
-
- return length
-}
-
-// MaxLineLen return the length in a terminal of the longest line, while
-// ignoring the terminal escape sequences.
-func MaxLineLen(text string) int {
- lines := strings.Split(text, "\n")
-
- max := 0
-
- for _, line := range lines {
- length := Len(line)
- if length > max {
- max = length
- }
- }
-
- return max
-}