commit 354c1cca7947cf0743f718f5ec9b26ec068f695e parent ff76969e987eddc90e3c6f5b6fa02bb0cc490387 Author: dwrz <dwrz@dwrz.net> Date: Sat, 20 May 2023 19:15:45 +0000 Remove text wrap Pipe output to fold instead. Diffstat:
D | pkg/text/wrap.go | | | 30 | ------------------------------ |
1 file changed, 0 insertions(+), 30 deletions(-)
diff --git a/pkg/text/wrap.go b/pkg/text/wrap.go @@ -1,30 +0,0 @@ -package text - -import "strings" - -func Wrap(text string, width int) string { - if width < 0 { - return text - } - - var words = strings.Fields(text) - if len(words) == 0 { - return "" - } - - var ( - wrapped = words[0] - remaining = width - len(wrapped) - ) - for _, word := range words[1:] { - if len(word)+1 > remaining { - wrapped += "\n" + word - remaining = width - len(word) - } else { - wrapped += " " + word - remaining -= 1 + len(word) - } - } - - return wrapped -}