gitstack

grindlemire/go-tui code browser

1.3 KB Go 60 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
60
// Code generated by tui generate. DO NOT EDIT.
// Source: input.gsx

package testdata

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

type myInput struct {
	app *tui.App
}

func MyInput() *myInput {
	return &myInput{}
}

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

func (c *myInput) 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.NewInput(
			tui.WithInputPlaceholder("Type here..."),
			tui.WithInputValue(tui.NewState("hello")),
			tui.WithInputWidth(30),
			tui.WithInputBorder(tui.BorderRounded),
			tui.WithInputOnSubmit(c.handleSubmit),
		)
	})
	__tui_0.AddChild(__tui_1)

	return __tui_0
}

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

var _ tui.PropsUpdater = (*myInput)(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 *myInput) bindAppFields(app *tui.App) {
	c.app = app
}

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

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