aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/MichaelMure/go-term-text/truncate.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/truncate.go
parentf093be96e98284580d61664adecd0a2ff8b354e4 (diff)
downloadgit-bug-1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6.tar.gz
migrate to go modules
Diffstat (limited to 'vendor/github.com/MichaelMure/go-term-text/truncate.go')
-rw-r--r--vendor/github.com/MichaelMure/go-term-text/truncate.go24
1 files changed, 0 insertions, 24 deletions
diff --git a/vendor/github.com/MichaelMure/go-term-text/truncate.go b/vendor/github.com/MichaelMure/go-term-text/truncate.go
deleted file mode 100644
index b51bb39e..00000000
--- a/vendor/github.com/MichaelMure/go-term-text/truncate.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package text
-
-import "github.com/mattn/go-runewidth"
-
-// TruncateMax truncate a line if its length is greater
-// than the given length. Otherwise, the line is returned
-// as is. If truncating occur, an ellipsis is inserted at
-// the end.
-// Handle properly terminal color escape code
-func TruncateMax(line string, length int) string {
- if length <= 0 {
- return "…"
- }
-
- l := Len(line)
- if l <= length || l == 0 {
- return line
- }
-
- cleaned, escapes := ExtractTermEscapes(line)
- truncated := runewidth.Truncate(cleaned, length-1, "")
-
- return ApplyTermEscapes(truncated, escapes) + "…"
-}