/
files.go
66 lines (57 loc) · 1.32 KB
/
files.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
package main
import (
fp "github.com/kuzzmi/monk/filepanel"
gc "github.com/rthornton128/goncurses"
"log"
)
func main() {
stdscr, err := gc.Init()
if err != nil {
log.Fatal(err)
}
defer gc.End()
gc.Echo(false)
gc.CBreak(true)
gc.Cursor(0)
var panels [2]fp.FilePanel
rows, cols := stdscr.MaxYX()
height, width := rows, cols/2
y, x := 0, 0
activePanel := 0
panels[0] = fp.FilePanel{Height: height, Width: width, Y: y, X: x, Directory: "./", Selected: 0, IsActive: true}
panels[1] = fp.FilePanel{Height: height, Width: width, Y: y, X: x + width, Directory: "/home/kuzzmi/", Selected: 2, IsActive: false}
panels[0].Draw()
panels[1].Draw()
gc.UpdatePanels()
gc.Update()
stdscr.Keypad(true)
// stdscr.GetChar()
main:
for {
switch panels[activePanel].Panel.Window().GetChar() {
case 'q':
break main
case gc.KEY_RETURN:
panels[activePanel].Execute()
case gc.KEY_TAB:
panels[0].ToggleActivity()
panels[1].ToggleActivity()
gc.UpdatePanels()
gc.Update()
if activePanel == 0 {
activePanel = 1
} else {
activePanel = 0
}
case 'u':
panels[activePanel].GoUp()
case 'k':
panels[activePanel].Select(panels[activePanel].Selected - 1)
case 'j':
panels[activePanel].Select(panels[activePanel].Selected + 1)
case 'i':
panels[activePanel].HideHidden()
}
}
stdscr.Delete()
}