@@ -34,36 +34,29 @@ var (
34
34
35
35
// Init initialize UI
36
36
func Init (csvStationsList * stations.List , debugFlag bool ) error {
37
+ fullLineFormatter = fmt .Sprintf ("%%-%ds" , w )
37
38
debug = debugFlag
39
+ stationsList = csvStationsList
40
+
38
41
if err := tui .Init (); nil != err {
39
42
return err
40
43
}
41
44
42
- w , h = tui .TerminalDimensions ()
43
-
44
- stationsList = csvStationsList
45
-
46
- fullLineFormatter = fmt .Sprintf ("%%-%ds" , w )
47
-
48
45
uiPlayingParagraph = widgets .NewParagraph ()
49
- uiPlayingParagraph .SetRect (0 , - 1 , w , 3 )
50
46
uiPlayingParagraph .Border = false
51
47
uiPlayingParagraph .TextStyle .Fg = tui .ColorRed
52
- setCurrentlyPlaying ("" )
53
48
54
49
uiFooterParagraph = widgets .NewParagraph ()
55
50
uiFooterParagraph .Text = fmt .Sprintf (fullLineFormatter , helpFooter )
56
51
uiFooterParagraph .WrapText = false
57
52
uiFooterParagraph .PaddingLeft = - 1
58
53
uiFooterParagraph .PaddingRight = - 1
59
- uiFooterParagraph .SetRect (0 , h - 3 , w , h )
60
54
uiFooterParagraph .Border = false
61
55
uiFooterParagraph .TextStyle .Fg = tui .ColorBlack
62
56
uiFooterParagraph .TextStyle .Bg = colorGray
63
57
64
58
uiLoggerList = widgets .NewList ()
65
- uiLoggerList .Title = "[ sendToLog ]"
66
- uiLoggerList .SetRect (w / 2 , 1 , w - 1 , h - 2 )
59
+ uiLoggerList .Title = "[ log ]"
67
60
uiLoggerList .TextStyle .Fg = tui .ColorBlue
68
61
uiLoggerList .BorderStyle .Fg = colorGray
69
62
uiLoggerList .SelectedRowStyle .Fg = uiLoggerList .TextStyle .Fg
@@ -81,18 +74,10 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
81
74
82
75
volumeGauge = widgets .NewGauge ()
83
76
volumeGauge .Border = false
84
- volumeGauge .SetRect (w - 21 , - 1 , w - 1 , 2 )
85
77
volumeGauge .Percent = 25
86
78
volumeGauge .Label = "25"
87
79
88
- if debug {
89
- uiStationsList .SetRect (0 , 1 , (w / 2 )- 1 , h - 2 )
90
- } else {
91
- uiStationsList .SetRect (0 , 1 , w , h - 2 )
92
- }
93
-
94
- uiStationsList .Rows = csvStationsList .GetRows (uiStationsList .Size ().X )
95
-
80
+ windowResize ()
96
81
drawables = []tui.Drawable {
97
82
uiPlayingParagraph ,
98
83
volumeGauge ,
@@ -107,6 +92,25 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
107
92
return nil
108
93
}
109
94
95
+ // Init initialize UI
96
+ func windowResize () {
97
+ tui .Clear ()
98
+ w , h = tui .TerminalDimensions ()
99
+
100
+ uiPlayingParagraph .SetRect (0 , - 1 , w , 3 )
101
+ uiFooterParagraph .SetRect (0 , h - 3 , w , h )
102
+ uiLoggerList .SetRect (w / 2 , 1 , w - 1 , h - 2 )
103
+ volumeGauge .SetRect (w - 21 , - 1 , w - 1 , 2 )
104
+
105
+ if debug {
106
+ uiStationsList .SetRect (0 , 1 , (w / 2 )- 1 , h - 2 )
107
+ } else {
108
+ uiStationsList .SetRect (0 , 1 , w , h - 2 )
109
+ }
110
+
111
+ uiStationsList .Rows = stationsList .GetRows (uiStationsList .Size ().X )
112
+ }
113
+
110
114
// Run run UI and events
111
115
func Run (d driver.Driver ) {
112
116
render ()
0 commit comments