gitstack

grindlemire/go-tui code browser

1.2 KB Go 59 lines 2026-04-18 · dcf2824 raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Code generated by tui generate. DO NOT EDIT.
// Source: textarea.gsx

package testdata

import (
	tui "github.com/grindlemire/go-tui"
)

type myForm struct {
	app *tui.App
}

func MyForm() *myForm {
	return &myForm{}
}

func (c *myForm) handleSubmit(text string) {}

func (c *myForm) Render(app *tui.App) *tui.Element {
	__tui_0 := tui.New(
		tui.WithDisplay(tui.DisplayFlex), tui.WithDirection(tui.Column),
		tui.WithGap(1),
	)
	__tui_1 := app.MountPersistent(c, 0, func() tui.Component {
		return tui.NewTextArea(
			tui.WithTextAreaPlaceholder("Enter text..."),
			tui.WithTextAreaWidth(50),
			tui.WithTextAreaBorder(tui.BorderRounded),
			tui.WithTextAreaOnSubmit(c.handleSubmit),
		)
	})
	__tui_0.AddChild(__tui_1)

	return __tui_0
}

func (c *myForm) UpdateProps(fresh tui.Component) {
	f, ok := fresh.(*myForm)
	if !ok {
		return
	}
	c.app = f.app
}

var _ tui.PropsUpdater = (*myForm)(nil)

// bindAppFields is generated. It wires the component's *tui.App,
// State, Events, and TextArea fields to app. When you override BindApp,
// call this helper instead of hand-maintaining the delegation list.
func (c *myForm) bindAppFields(app *tui.App) {
	c.app = app
}

func (c *myForm) BindApp(app *tui.App) {
	c.bindAppFields(app)
}

var _ tui.AppBinder = (*myForm)(nil)