aboutsummaryrefslogtreecommitdiffstats
path: root/util/text/left_padded.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-11-03 14:00:35 +0100
committerMichael Muré <batolettre@gmail.com>2019-11-03 14:00:35 +0100
commitf72a9dc62ba20546b2cdeb466434fc1900741a4f (patch)
tree8b68dc12c312d0a1fe6d5b1a1388cee82d44c634 /util/text/left_padded.go
parent809abf9244f64683fe2d9f8489a4dcff0904d5b5 (diff)
downloadgit-bug-f72a9dc62ba20546b2cdeb466434fc1900741a4f.tar.gz
switch to go-term-text to fix bad underflow for label rendering
Diffstat (limited to 'util/text/left_padded.go')
-rw-r--r--util/text/left_padded.go42
1 files changed, 0 insertions, 42 deletions
diff --git a/util/text/left_padded.go b/util/text/left_padded.go
deleted file mode 100644
index eae65d34..00000000
--- a/util/text/left_padded.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package text
-
-import (
- "bytes"
- "fmt"
- "github.com/mattn/go-runewidth"
- "strings"
-)
-
-// LeftPadMaxLine pads a string on the left by a specified amount and pads the
-// string on the right to fill the maxLength
-func LeftPadMaxLine(text string, length, leftPad int) string {
- var rightPart string = text
-
- scrWidth := runewidth.StringWidth(text)
- // truncate and ellipse if needed
- if scrWidth+leftPad > length {
- rightPart = runewidth.Truncate(text, length-leftPad, "…")
- } else if scrWidth+leftPad < length {
- rightPart = runewidth.FillRight(text, length-leftPad)
- }
-
- return fmt.Sprintf("%s%s",
- strings.Repeat(" ", leftPad),
- rightPart,
- )
-}
-
-// LeftPad left pad each line of the given text
-func LeftPad(text string, leftPad int) string {
- var result bytes.Buffer
-
- pad := strings.Repeat(" ", leftPad)
-
- for _, line := range strings.Split(text, "\n") {
- result.WriteString(pad)
- result.WriteString(line)
- result.WriteString("\n")
- }
-
- return result.String()
-}