diff --git a/utils.go b/utils.go index f7becb3..e491cfa 100644 --- a/utils.go +++ b/utils.go @@ -3,6 +3,7 @@ package tui import ( "strings" + "git.milar.in/milarin/gmath" "github.com/gdamore/tcell" "github.com/mattn/go-runewidth" ) @@ -32,7 +33,7 @@ func WriteMultiLineString(b *ViewBuffer, str string, style Style, x, y int) (max return } lineWidth := WriteString(b, line, style, x, y+dy) - maxLineWidth = max(maxLineWidth, lineWidth) + maxLineWidth = gmath.Max(maxLineWidth, lineWidth) } return maxLineWidth, len(lines) } @@ -51,7 +52,7 @@ func MeasureMultiLineString(str string) (maxLineWidth, lineCount int) { lines := strings.Split(str, "\n") for _, line := range lines { lineWidth := MeasureString(line) - maxLineWidth = max(maxLineWidth, lineWidth) + maxLineWidth = gmath.Max(maxLineWidth, lineWidth) } return maxLineWidth, len(lines) } @@ -69,20 +70,6 @@ func runeWidth(r rune) int { // } } -func min(x, y int) int { - if x < y { - return x - } - return y -} - -func max(x, y int) int { - if x > y { - return x - } - return y -} - func iff[T any](condition bool, trueValue, falseValue T) T { if condition { return trueValue