-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsg.go
More file actions
69 lines (58 loc) · 1.79 KB
/
Copy pathmsg.go
File metadata and controls
69 lines (58 loc) · 1.79 KB
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
package wui
// Msg is the message type for the Elm Update loop. Any value can be a
// Msg, including application-defined types — analogous to tea.Msg.
type Msg interface{}
// Cmd is a function that produces a Msg asynchronously.
type Cmd func() Msg
// KeyMsg represents a key press. Key is a normalized name such as
// "enter", "ctrl+c", "tab", "backspace", or a single printable rune.
type KeyMsg struct {
Key string
Rune rune
}
// ClickMsg is sent when a Link is activated. Buttons instead invoke
// their own OnClick callback directly.
type ClickMsg struct {
TargetID string
}
// ToggleMsg is sent when a Checkbox is toggled and it has no OnToggle
// callback of its own. Checked is the new state.
type ToggleMsg struct {
ID string
Checked bool
}
// InputMsg is sent when a TextInput's value changes and it has no
// OnChange callback of its own.
type InputMsg struct {
ID string
Value string
}
// SubmitMsg is sent when a Form is submitted and it has no OnSubmit
// callback of its own.
type SubmitMsg struct {
FormValues map[string]string
}
// NavigateMsg is sent in WASM builds when the browser URL hash names a
// path — on initial load with a "#/path" fragment and on every
// hashchange (back/forward navigation). TUI programs never receive it.
// See Pather.
type NavigateMsg struct {
Path string
}
// ResizeMsg is sent when the terminal or window is resized.
type ResizeMsg struct {
Width int
Height int
}
// NoneMsg is a no-op message.
type NoneMsg struct{}
// firstRune returns the first rune of a normalized key name — the
// printable character for single-rune keys, or the first letter of a
// named key ("enter" → 'e'); callers should treat Rune as meaningful
// only for single-rune keys.
func firstRune(key string) rune {
for _, r := range key {
return r
}
return 0
}