-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_ms.go
123 lines (108 loc) · 2.94 KB
/
view_ms.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
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
package main
import (
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
// TODO: Implement adding new field
func GetMainScreen(activeView string) *tview.Flex {
if wrapperFlex != nil {
return wrapperFlex
}
var err error
wrapperFlex = tview.NewFlex().SetDirection(tview.FlexRow)
searchFlex := GetSearchFlex()
mainFlex := tview.NewFlex()
buttonsFlex := GetButtonsFlex()
// Getting items list from the database
itemsList, err = GetItemsList()
if err != nil {
NavToError("Items reading error: "+err.Error(), cScreenLogin)
return nil
}
itemsList.SetInputCapture(processItemsEvents)
itemsList.SetBorder(true).SetTitle(" Items (Ctrl+I) ").SetBorderPadding(1, 1, 1, 1)
// Getting fields list from the database
fieldsList = tview.NewList().ShowSecondaryText(true)
fieldsList.SetInputCapture(processFieldsEvents)
fieldsList.SetBorder(true).SetTitle(" Fields (F) ").SetBorderPadding(1, 1, 1, 1)
// Joining items and fields in one horizontal flex
mainFlex.AddItem(itemsList, 0, 1, true).
AddItem(fieldsList, 0, 2, false)
// Top level flex
wrapperFlex.AddItem(mainFlex, 0, 1, true).
AddItem(searchFlex, 1, 99, false).
AddItem(tview.NewBox(), 1, 0, false).
AddItem(buttonsFlex, 1, 0, false)
wrapperFlex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyTab:
if NavToNext() {
return nil
}
case tcell.KeyBacktab:
if NavToPrevious() {
return nil
}
case tcell.KeyRight:
if NavToNext() {
return nil
}
case tcell.KeyLeft:
if NavToPrevious() {
return nil
}
case tcell.KeyCtrlF:
mainSetFocus(searchInput)
return nil
case tcell.KeyCtrlT:
mainSetFocus(tagsFilter)
return nil
case tcell.KeyCtrlQ:
actionStopApp()
return nil
}
return event
})
mainFlex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyTab:
NavToNext()
//if itemsList.HasFocus() {
// mainSetFocus(fieldsList)
//} else if fieldsList.HasFocus() {
// mainSetFocus(buttonLock)
//}
return nil
case tcell.KeyCtrlF:
mainSetFocus(searchInput)
return nil
case tcell.KeyCtrlQ:
actionStopApp()
return nil
}
return event
})
return wrapperFlex
}
func ItemSelected() {
switch itemsList.GetCurrentItem() {
case 0:
fieldsList.Clear()
fieldsList.AddItem("🗄 User", " "+"alexanrb", 0, FieldSelected)
fieldsList.AddItem("🗄 Password", " "+"Bsyu87z1", 0, FieldSelected)
fieldsList.AddItem("🗄 PIN", " "+"1799", 0, FieldSelected)
case 1:
fieldsList.Clear()
fieldsList.AddItem("🗄 Paypal User", "", 0, FieldSelected)
fieldsList.AddItem("🗄 Paypal Password", "", 0, FieldSelected)
default:
fieldsList.Clear()
fieldsList.AddItem("🗄 User", "", 0, FieldSelected)
fieldsList.AddItem("🗄 Password", "", 0, FieldSelected)
fieldsList.AddItem("🗄 PIN", "", 0, FieldSelected)
}
//log.Println("Item selected")
}
func FieldSelected() {
//log.Println("Field selected")
}