-
Notifications
You must be signed in to change notification settings - Fork 0
/
sshm.go
75 lines (61 loc) · 1.82 KB
/
sshm.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
package main
import (
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
func main() {
readConfig()
itemsFlex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Rune() {
case 113: // q
app.Stop()
case 102: //f
index := itemsList.GetCurrentItem()
executeShell(&data.Items[index], Transfer)
case 97: // a
addForm.Clear(true)
addConnectionForm()
pages.SwitchToPage(addConnectionsPage)
case 101: // e
editConnection()
pages.SwitchToPage(editConnectionsPage)
case 100: // d
pages.SwitchToPage(deleteConnectionPage)
}
return event
})
addFormFlex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 126 { // ~
pages.SwitchToPage(savedConnectionsPage)
}
return event
})
editFormFlex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 126 { // ~
pages.SwitchToPage(savedConnectionsPage)
}
return event
})
fillItemsListData()
itemsFlex.SetDirection(tview.FlexRow).
AddItem(itemsList, 0, 1, true).
AddItem(mainMenu, 0, 1, false)
addFormFlex.SetDirection(tview.FlexRow).
AddItem(addForm, 0, 1, true).
AddItem(formMenu, 0, 1, false)
editFormFlex.SetDirection(tview.FlexRow).
AddItem(editForm, 0, 1, true).
AddItem(formMenu, 0, 1, false)
deleteFlex.SetDirection(tview.FlexRow).
AddItem(modal, 0, 1, true)
pages.AddPage(savedConnectionsPage, itemsFlex, true, true)
pages.AddPage(addConnectionsPage, addFormFlex, true, false)
pages.AddPage(editConnectionsPage, editFormFlex, true, false)
pages.AddPage(deleteConnectionPage, deleteFlex, true, false)
itemsList.SetSelectedFunc(func(index int, name string, second_name string, shortcut rune) {
executeShell(&data.Items[index], Shell)
})
if err := app.SetRoot(pages, true).EnableMouse(true).Run(); err != nil {
panic(err)
}
}