-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmini.go
executable file
·87 lines (75 loc) · 2.17 KB
/
mini.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
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
package main
import (
"strings"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"golang.org/x/exp/slices"
)
func sublineEntry() *widget.Entry {
subButn := widget.NewEntry()
subButn.Move(fyne.NewPos(100, 30))
return subButn
}
func newLnEntry() *widget.Entry { return widget.NewEntry() }
func oneAdd() *widget.Button {
b := widget.NewButton("NewLine", func() {})
return b
}
func createNewList(notes []string, listEnt *widget.Entry, bind binding.ExternalStringList) *widget.List {
// var intt *int
/*alist := widget.NewList(
func() int {
return len(notes)
},
func() fyne.CanvasObject {
noteEntry := widget.NewEntry()
delButn := widget.NewButtonWithIcon("", theme.DeleteIcon(), func() {
position := slices.Index(notes, noteEntry.Text)
nwList := removeElementByIndex(notes, position)
bind.Set(nwList)
})
delButn.Resize(fyne.NewSize(10, 10))
moveButn := widget.NewButtonWithIcon("", theme.ListIcon(), func() {
})
cont := container.NewBorder(nil, nil, moveButn, delButn, noteEntry)
return cont
},
func(lii widget.ListItemID, co fyne.CanvasObject) {
ent := co.(*fyne.Container).Objects[0].(*widget.Entry)
if strings.Contains(notes[lii], "\t") {
ent = sublineEntry()
ent.SetText(notes[lii])
}
ent.SetText(notes[lii])
},
)*/
listing := widget.NewListWithData(
bind,
func() fyne.CanvasObject {
delButn := widget.NewButtonWithIcon("", theme.DeleteIcon(), func() {
position := slices.Index(notes, listEnt.Text)
nwList := removeElementByIndex(notes, position)
bind.Set(nwList)
})
delButn.Resize(fyne.NewSize(10, 10))
moveButn := widget.NewButtonWithIcon("", theme.ListIcon(), func() {
})
cont := container.NewBorder(nil, nil, moveButn, delButn, listEnt)
return cont
},
func(di binding.DataItem, co fyne.CanvasObject) {
line, _ := di.(binding.String).Get()
if !strings.Contains(line, "\t") {
entry := co.(*fyne.Container).Objects[0].(*widget.Entry)
entry = sublineEntry()
entry.Bind(binding.BindString(&line))
}
// entry = newLnEntry()
// entry.SetText(line)
},
)
return listing
}