Skip to content

Commit e1d88e7

Browse files
committed
debugui: refactoring remove error from gridCell callback
1 parent f11832c commit e1d88e7

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

layout.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,16 @@ func (c *Context) popLayout() error {
8585

8686
func (c *Context) GridCell(f func(bounds image.Rectangle)) {
8787
_ = c.wrapEventHandlerAndError(func() (EventHandler, error) {
88-
if err := c.gridCell(func(bounds image.Rectangle) error {
88+
if err := c.gridCell(func(bounds image.Rectangle) {
8989
f(bounds)
90-
return nil
9190
}); err != nil {
9291
return nil, err
9392
}
9493
return nil, nil
9594
})
9695
}
9796

98-
func (c *Context) gridCell(f func(bounds image.Rectangle) error) error {
97+
func (c *Context) gridCell(f func(bounds image.Rectangle)) error {
9998
_, err := c.widget(emptyWidgetID, 0, func(bounds image.Rectangle, wasFocused bool) (e EventHandler, err error) {
10099
if err := c.pushLayout(bounds, image.Pt(0, 0), false); err != nil {
101100
return nil, err
@@ -105,9 +104,7 @@ func (c *Context) gridCell(f func(bounds image.Rectangle) error) error {
105104
err = err2
106105
}
107106
}()
108-
if err := f(bounds); err != nil {
109-
return nil, err
110-
}
107+
f(bounds)
111108
b := &c.layoutStack[len(c.layoutStack)-1]
112109
// inherit position/next_row/max from child layout if they are greater
113110
a := &c.layoutStack[len(c.layoutStack)-2]

text.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,14 @@ func lines(text string, width int) iter.Seq[string] {
6464
// Text creates a text label.
6565
func (c *Context) Text(text string) {
6666
_ = c.wrapEventHandlerAndError(func() (EventHandler, error) {
67-
if err := c.gridCell(func(bounds image.Rectangle) error {
67+
if err := c.gridCell(func(bounds image.Rectangle) {
6868
c.SetGridLayout([]int{-1}, []int{lineHeight()})
6969
for line := range lines(text, bounds.Dx()-c.style().padding) {
70-
if _, err := c.widget(emptyWidgetID, 0, func(bounds image.Rectangle, wasFocused bool) (EventHandler, error) {
70+
_, _ = c.widget(emptyWidgetID, 0, func(bounds image.Rectangle, wasFocused bool) (EventHandler, error) {
7171
c.drawWidgetText(line, bounds, colorText, 0)
7272
return nil, nil
73-
}); err != nil {
74-
return err
75-
}
73+
})
7674
}
77-
return nil
7875
}); err != nil {
7976
return nil, err
8077
}

0 commit comments

Comments
 (0)