@@ -9,15 +9,26 @@ import (
9
9
"github.com/gizak/termui/v3/widgets"
10
10
)
11
11
12
+ const (
13
+ currentlyPlayingFormat = "Currently playing: %s"
14
+ helpFooter = "k/↑ : Up | j/↓: Down | Enter: Select | p: Pause | m: Mute | s: Stop | +: Louder | -: Quieter | R: Refresh | q: Quit"
15
+ )
16
+
17
+ const (
18
+ colorGray tui.Color = 8
19
+ )
20
+
12
21
var (
13
22
current = - 1
14
23
debug bool
15
24
w , h int
25
+ fullLineFormatter string
16
26
stationsList * stations.List
17
27
uiPlayingParagraph * widgets.Paragraph
18
28
uiFooterParagraph * widgets.Paragraph
19
29
uiStationsList * widgets.List
20
30
uiLoggerList * widgets.List
31
+ volumeGauge * widgets.Gauge
21
32
drawables []tui.Drawable
22
33
)
23
34
@@ -32,29 +43,29 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
32
43
33
44
stationsList = csvStationsList
34
45
35
- formatter : = fmt .Sprintf ("%%-%ds" , w )
46
+ fullLineFormatter = fmt .Sprintf ("%%-%ds" , w )
36
47
37
48
uiPlayingParagraph = widgets .NewParagraph ()
38
- uiPlayingParagraph .Text = fmt .Sprintf (formatter , "Currently playing: None" )
39
49
uiPlayingParagraph .SetRect (0 , - 1 , w , 3 )
40
50
uiPlayingParagraph .Border = false
41
51
uiPlayingParagraph .TextStyle .Fg = tui .ColorRed
52
+ setCurrentlyPlaying ("" )
42
53
43
54
uiFooterParagraph = widgets .NewParagraph ()
44
- uiFooterParagraph .Text = fmt .Sprintf (formatter , "k/↑ : Up | j/↓: Down | Enter: Select | p: Pause | m: Mute | s: Stop | +: Louder | -: Quieter | R: Refresh | q: Quit" )
55
+ uiFooterParagraph .Text = fmt .Sprintf (fullLineFormatter , helpFooter )
45
56
uiFooterParagraph .WrapText = false
46
57
uiFooterParagraph .PaddingLeft = - 1
47
58
uiFooterParagraph .PaddingRight = - 1
48
59
uiFooterParagraph .SetRect (0 , h - 3 , w , h )
49
60
uiFooterParagraph .Border = false
50
61
uiFooterParagraph .TextStyle .Fg = tui .ColorBlack
51
- uiFooterParagraph .TextStyle .Bg = 8
62
+ uiFooterParagraph .TextStyle .Bg = colorGray
52
63
53
64
uiLoggerList = widgets .NewList ()
54
- uiLoggerList .Title = "[ log ]"
65
+ uiLoggerList .Title = "[ sendToLog ]"
55
66
uiLoggerList .SetRect (w / 2 , 1 , w - 1 , h - 2 )
56
67
uiLoggerList .TextStyle .Fg = tui .ColorBlue
57
- uiLoggerList .BorderStyle .Fg = 8
68
+ uiLoggerList .BorderStyle .Fg = colorGray
58
69
uiLoggerList .SelectedRowStyle .Fg = uiLoggerList .TextStyle .Fg
59
70
uiLoggerList .Rows = []string {"" }
60
71
@@ -64,10 +75,16 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
64
75
uiStationsList .TextStyle .Modifier = tui .ModifierBold
65
76
uiStationsList .SelectedRowStyle .Modifier = tui .ModifierBold
66
77
uiStationsList .SelectedRowStyle .Fg = tui .ColorWhite
67
- uiStationsList .SelectedRowStyle .Bg = 8
68
- uiStationsList .BorderStyle .Fg = 8
78
+ uiStationsList .SelectedRowStyle .Bg = colorGray
79
+ uiStationsList .BorderStyle .Fg = colorGray
69
80
uiStationsList .WrapText = false
70
81
82
+ volumeGauge = widgets .NewGauge ()
83
+ volumeGauge .Border = false
84
+ volumeGauge .SetRect (w - 21 , - 1 , w - 1 , 2 )
85
+ volumeGauge .Percent = 25
86
+ volumeGauge .Label = "25"
87
+
71
88
if debug {
72
89
uiStationsList .SetRect (0 , 1 , (w / 2 )- 1 , h - 2 )
73
90
} else {
@@ -78,6 +95,7 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
78
95
79
96
drawables = []tui.Drawable {
80
97
uiPlayingParagraph ,
98
+ volumeGauge ,
81
99
uiFooterParagraph ,
82
100
uiStationsList ,
83
101
}
@@ -117,7 +135,7 @@ func render() {
117
135
tui .Render (drawables ... )
118
136
}
119
137
120
- func log (m string ) {
138
+ func sendToLog (m string ) {
121
139
if ! debug {
122
140
return
123
141
}
0 commit comments