use gmath instead of locally implemented min/max functions
This commit is contained in:
parent
e0874e6e4c
commit
9a2c61d953
19
utils.go
19
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
|
||||
|
Loading…
Reference in New Issue
Block a user