Skip to content

Commit e79f694

Browse files
author
Mateusz Lopacinski
committed
pack release files with upx, refactor ui refresh update
1 parent 9cfb5af commit e79f694

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ clear-build: ## Clear content of build directory
1818

1919
release: ## Build for windows, linux and darwin
2020
for os in darwin linux windows; do \
21-
env GOOS=$$os GOARCH=amd64 go build -o build/goradio-$$os-amd64; \
21+
env GOOS=$$os GOARCH=amd64 go build -ldflags="-s -w" -o build/goradio-$$os-amd64; \
22+
upx --brute build/goradio-$$os-amd64; \
2223
done; \
2324
mv build/goradio-windows-amd64 build/goradio-windows-amd64.exe

pkg/ui/events.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package ui
33
import (
44
"bufio"
55
"fmt"
6-
"log"
76
"regexp"
87
"strconv"
98

@@ -21,10 +20,7 @@ var colorSelected = "(fg:black,bg:white)"
2120

2221
func manageKeyboardEvent(e tui.Event, d driver.Driver) int {
2322
if e.Type == tui.ResizeEvent {
24-
tui.Clear()
25-
if err := Init(stationsList, debug); err != nil {
26-
log.Fatalf("failed to initialize ui: %v", err)
27-
}
23+
windowResize()
2824
}
2925

3026
switch e.ID {

pkg/ui/ui.go

+24-20
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,29 @@ var (
3434

3535
// Init initialize UI
3636
func Init(csvStationsList *stations.List, debugFlag bool) error {
37+
fullLineFormatter = fmt.Sprintf("%%-%ds", w)
3738
debug = debugFlag
39+
stationsList = csvStationsList
40+
3841
if err := tui.Init(); nil != err {
3942
return err
4043
}
4144

42-
w, h = tui.TerminalDimensions()
43-
44-
stationsList = csvStationsList
45-
46-
fullLineFormatter = fmt.Sprintf("%%-%ds", w)
47-
4845
uiPlayingParagraph = widgets.NewParagraph()
49-
uiPlayingParagraph.SetRect(0, -1, w, 3)
5046
uiPlayingParagraph.Border = false
5147
uiPlayingParagraph.TextStyle.Fg = tui.ColorRed
52-
setCurrentlyPlaying("")
5348

5449
uiFooterParagraph = widgets.NewParagraph()
5550
uiFooterParagraph.Text = fmt.Sprintf(fullLineFormatter, helpFooter)
5651
uiFooterParagraph.WrapText = false
5752
uiFooterParagraph.PaddingLeft = -1
5853
uiFooterParagraph.PaddingRight = -1
59-
uiFooterParagraph.SetRect(0, h-3, w, h)
6054
uiFooterParagraph.Border = false
6155
uiFooterParagraph.TextStyle.Fg = tui.ColorBlack
6256
uiFooterParagraph.TextStyle.Bg = colorGray
6357

6458
uiLoggerList = widgets.NewList()
65-
uiLoggerList.Title = "[ sendToLog ]"
66-
uiLoggerList.SetRect(w/2, 1, w-1, h-2)
59+
uiLoggerList.Title = "[ log ]"
6760
uiLoggerList.TextStyle.Fg = tui.ColorBlue
6861
uiLoggerList.BorderStyle.Fg = colorGray
6962
uiLoggerList.SelectedRowStyle.Fg = uiLoggerList.TextStyle.Fg
@@ -81,18 +74,10 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
8174

8275
volumeGauge = widgets.NewGauge()
8376
volumeGauge.Border = false
84-
volumeGauge.SetRect(w-21, -1, w-1, 2)
8577
volumeGauge.Percent = 25
8678
volumeGauge.Label = "25"
8779

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()
9681
drawables = []tui.Drawable{
9782
uiPlayingParagraph,
9883
volumeGauge,
@@ -107,6 +92,25 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
10792
return nil
10893
}
10994

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+
110114
// Run run UI and events
111115
func Run(d driver.Driver) {
112116
render()

0 commit comments

Comments
 (0)