-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtui.go
More file actions
63 lines (51 loc) · 1.28 KB
/
Copy pathtui.go
File metadata and controls
63 lines (51 loc) · 1.28 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
package server
import "github.com/tinywasm/fmt"
func (h *ServerHandler) Name() string {
return "SERVER"
}
// Label implements HandlerEdit.Label
func (h *ServerHandler) Label() string {
return "Server Modes"
}
// Value implements HandlerEdit.Value
func (h *ServerHandler) Value() string {
h.strategyMu.RLock()
isExternal := !h.executionInternal
h.strategyMu.RUnlock()
exec := "F"
if isExternal {
exec = "T"
}
return "Execution External:" + exec
}
// Change implements HandlerEdit.Change
func (h *ServerHandler) Change(newValue string) {
pairs := fmt.Convert(newValue).Split(",")
for _, pair := range pairs {
// e.g., pair = "Execution External:T" or " Build OnDisk:F"
s := fmt.Convert(pair).TrimSpace().String()
pos := fmt.Index(s, ":")
if pos == -1 {
continue
}
key := fmt.Convert(s[:pos]).TrimSpace().String()
val := fmt.Convert(s[pos+1:]).TrimSpace().ToLower().String()
isTrue := val == "t" || val == "true"
switch key {
case "Execution External":
if err := h.SetExternalServerMode(isTrue); err != nil {
h.log("Mode change error:", err)
}
}
}
h.RefreshUI()
}
// SetLog implements devtui.Loggable
func (h *ServerHandler) SetLog(fn func(...any)) {
h.SetLogger(fn)
}
func (h *ServerHandler) RefreshUI() {
if h.UI != nil {
h.UI.RefreshUI()
}
}