/
tui.go
62 lines (48 loc) · 1010 Bytes
/
tui.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
package main
import (
"fmt"
"github.com/rivo/tview"
)
type TUI struct {
app *tview.Application
facts *Facts
photoCount int
rawCount int
videoCount int
}
/*
* Create a progress-bar
*/
func NewProgressBar(count int64, facts *Facts) *TUI {
tui := TUI{}
app := tview.NewApplication()
app.EnableMouse(false)
tui.app = app
return &tui
}
/*
* Receive a media item,and update the progress bar
*/
func (tui *TUI) Update(media *Media) {
}
func (tui *TUI) SummaryText() *tview.TextView {
return tview.NewTextView()
}
/*
* Initialise a grid containing all progress-information to share
*/
func (tui *TUI) Grid() *tview.Grid {
return tview.NewGrid().
SetRows(1).SetColumns(1, 1).AddItem(tui.SummaryText(), 1, 1, 2, 1, 1, 1, true)
}
/*
* Stat the tcell progress-bar
*/
func (tui *TUI) Start() int {
grid := tui.Grid()
if err := tui.app.SetRoot(grid, true).SetFocus(grid).Run(); err != nil {
fmt.Printf("Badger: Application crashed! %v", err)
return 1
}
return 0
}