-
Notifications
You must be signed in to change notification settings - Fork 5
/
types_panel.go
61 lines (51 loc) · 1.03 KB
/
types_panel.go
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
package main
import (
"fmt"
"regexp"
"sort"
"gioui.org/widget"
. "github.com/emad-elsaid/debugger/ui"
)
type TypesPanel struct {
List List
Filter widget.Editor
}
func NewTypesPanel() TypesPanel {
return TypesPanel{
List: NewVerticalList(),
Filter: LineEditor(),
}
}
func (t *TypesPanel) Layout(d *Debugger) W {
filter := t.Filter.Text()
regex, err := regexp.Compile(filter)
if err != nil {
regex, _ = regexp.Compile(regexp.QuoteMeta(filter))
}
allTypes, err := d.Target().BinInfo().Types()
if err != nil {
allTypes = []string{}
}
types := make([]string, 0, len(allTypes))
for _, typ := range allTypes {
if regex.Match([]byte(typ)) {
types = append(types, typ)
}
}
sort.Strings(types)
ele := func(c C, i int) D {
return Inset1(Label(types[i]))(c)
}
return Rows(
RowSpacer1,
Rigid(
FormRow(
Rigid(Label(fmt.Sprintf(" %d", len(types)))),
ColSpacer1,
Flexed(1, TextInput(&t.Filter, "Search types...")),
),
),
RowSpacer1,
Flexed(1, ZebraList(&t.List, len(types), ele)),
)
}