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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
package tui
type TextAreaOption func(*TextArea)
func WithTextAreaWidth(cells int) TextAreaOption {
return func(t *TextArea) {
t.width = cells
}
}
func WithTextAreaMaxHeight(rows int) TextAreaOption {
return func(t *TextArea) {
t.maxHeight = rows
}
}
func WithTextAreaBorder(b BorderStyle) TextAreaOption {
return func(t *TextArea) {
t.border = b
}
}
func WithTextAreaTextStyle(s Style) TextAreaOption {
return func(t *TextArea) {
t.textStyle = s
}
}
func WithTextAreaPlaceholder(text string) TextAreaOption {
return func(t *TextArea) {
t.placeholder = text
}
}
func WithTextAreaPlaceholderStyle(s Style) TextAreaOption {
return func(t *TextArea) {
t.placeholderStyle = s
}
}
func WithTextAreaCursorRune(r rune) TextAreaOption {
return func(t *TextArea) {
t.cursorRune = r
}
}
func WithTextAreaCursor(r rune) TextAreaOption {
return WithTextAreaCursorRune(r)
}
func WithTextAreaVirtualCursor() TextAreaOption {
return func(t *TextArea) {
t.hideVirtualCursor = false
}
}
func WithTextAreaFocusColor(c Color) TextAreaOption {
return func(t *TextArea) {
t.focusColor = &c
}
}
func WithTextAreaBorderGradient(g Gradient) TextAreaOption {
return func(t *TextArea) {
t.borderGradient = &g
}
}
func WithTextAreaFocusGradient(g Gradient) TextAreaOption {
return func(t *TextArea) {
t.focusGradient = &g
}
}
func WithTextAreaSubmitKey(k Key) TextAreaOption {
return func(t *TextArea) {
t.submitKey = k
}
}
func WithTextAreaValue(state *State[string]) TextAreaOption {
return func(t *TextArea) {
t.text = state
t.cursorPos = NewState(len([]rune(state.Get())))
}
}
func WithTextAreaAutoFocus(auto bool) TextAreaOption {
return func(t *TextArea) {
t.autoFocus = auto
}
}
func WithTextAreaOnSubmit(fn func(string)) TextAreaOption {
return func(t *TextArea) {
t.onSubmit = fn
}
}
func WithTextAreaOnChange(fn func(string)) TextAreaOption {
return func(t *TextArea) {
t.onChange = fn
}
}
|