bug fixes and clean code
This commit is contained in:
+14
-27
@@ -8,6 +8,20 @@ import (
|
||||
"github.com/orus-dev/osui"
|
||||
)
|
||||
|
||||
func WithPosition(x, y int, c osui.Component) osui.Component {
|
||||
data := c.GetComponentData()
|
||||
data.X = x
|
||||
data.Y = y
|
||||
return c
|
||||
}
|
||||
|
||||
func WithSize(width, height int, c osui.Component) osui.Component {
|
||||
data := c.GetComponentData()
|
||||
data.Width = width
|
||||
data.Height = height
|
||||
return c
|
||||
}
|
||||
|
||||
func centerText(text string, width int) string {
|
||||
if len(text) > width {
|
||||
return text[:width]
|
||||
@@ -19,33 +33,6 @@ func centerText(text string, width int) string {
|
||||
return fmt.Sprintf("%s%s%s", leftPadding, text, rightPadding)
|
||||
}
|
||||
|
||||
func fnLogicValue(f func(*ButtonComponent) bool) func(*ButtonComponent) bool {
|
||||
if f == nil {
|
||||
return func(*ButtonComponent) bool { return false }
|
||||
} else {
|
||||
return f
|
||||
}
|
||||
}
|
||||
|
||||
func WithPosition(x, y int, c osui.Component) osui.Component {
|
||||
data := c.GetComponentData()
|
||||
data.X = x
|
||||
data.Y = y
|
||||
return c
|
||||
}
|
||||
|
||||
func WithStyle(style interface{}, c osui.Component) osui.Component {
|
||||
c.SetStyle(style)
|
||||
return c
|
||||
}
|
||||
|
||||
func WithSize(width, height int, c osui.Component) osui.Component {
|
||||
data := c.GetComponentData()
|
||||
data.Width = width
|
||||
data.Height = height
|
||||
return c
|
||||
}
|
||||
|
||||
func findClosestComponent(a []osui.Component, i int, d string) int {
|
||||
if len(a) == 0 || i < 0 || i >= len(a) {
|
||||
return -1 // Invalid input
|
||||
|
||||
Reference in New Issue
Block a user