Skip to content

Commit

Permalink
pack release files with upx, refactor ui refresh update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Lopacinski committed Nov 25, 2019
1 parent 9cfb5af commit e79f694
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ clear-build: ## Clear content of build directory

release: ## Build for windows, linux and darwin
for os in darwin linux windows; do \
env GOOS=$$os GOARCH=amd64 go build -o build/goradio-$$os-amd64; \
env GOOS=$$os GOARCH=amd64 go build -ldflags="-s -w" -o build/goradio-$$os-amd64; \
upx --brute build/goradio-$$os-amd64; \
done; \
mv build/goradio-windows-amd64 build/goradio-windows-amd64.exe
6 changes: 1 addition & 5 deletions pkg/ui/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ui
import (
"bufio"
"fmt"
"log"
"regexp"
"strconv"

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

func manageKeyboardEvent(e tui.Event, d driver.Driver) int {
if e.Type == tui.ResizeEvent {
tui.Clear()
if err := Init(stationsList, debug); err != nil {
log.Fatalf("failed to initialize ui: %v", err)
}
windowResize()
}

switch e.ID {
Expand Down
44 changes: 24 additions & 20 deletions pkg/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,29 @@ var (

// Init initialize UI
func Init(csvStationsList *stations.List, debugFlag bool) error {
fullLineFormatter = fmt.Sprintf("%%-%ds", w)
debug = debugFlag
stationsList = csvStationsList

if err := tui.Init(); nil != err {
return err
}

w, h = tui.TerminalDimensions()

stationsList = csvStationsList

fullLineFormatter = fmt.Sprintf("%%-%ds", w)

uiPlayingParagraph = widgets.NewParagraph()
uiPlayingParagraph.SetRect(0, -1, w, 3)
uiPlayingParagraph.Border = false
uiPlayingParagraph.TextStyle.Fg = tui.ColorRed
setCurrentlyPlaying("")

uiFooterParagraph = widgets.NewParagraph()
uiFooterParagraph.Text = fmt.Sprintf(fullLineFormatter, helpFooter)
uiFooterParagraph.WrapText = false
uiFooterParagraph.PaddingLeft = -1
uiFooterParagraph.PaddingRight = -1
uiFooterParagraph.SetRect(0, h-3, w, h)
uiFooterParagraph.Border = false
uiFooterParagraph.TextStyle.Fg = tui.ColorBlack
uiFooterParagraph.TextStyle.Bg = colorGray

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

volumeGauge = widgets.NewGauge()
volumeGauge.Border = false
volumeGauge.SetRect(w-21, -1, w-1, 2)
volumeGauge.Percent = 25
volumeGauge.Label = "25"

if debug {
uiStationsList.SetRect(0, 1, (w/2)-1, h-2)
} else {
uiStationsList.SetRect(0, 1, w, h-2)
}

uiStationsList.Rows = csvStationsList.GetRows(uiStationsList.Size().X)

windowResize()
drawables = []tui.Drawable{
uiPlayingParagraph,
volumeGauge,
Expand All @@ -107,6 +92,25 @@ func Init(csvStationsList *stations.List, debugFlag bool) error {
return nil
}

// Init initialize UI
func windowResize() {
tui.Clear()
w, h = tui.TerminalDimensions()

uiPlayingParagraph.SetRect(0, -1, w, 3)
uiFooterParagraph.SetRect(0, h-3, w, h)
uiLoggerList.SetRect(w/2, 1, w-1, h-2)
volumeGauge.SetRect(w-21, -1, w-1, 2)

if debug {
uiStationsList.SetRect(0, 1, (w/2)-1, h-2)
} else {
uiStationsList.SetRect(0, 1, w, h-2)
}

uiStationsList.Rows = stationsList.GetRows(uiStationsList.Size().X)
}

// Run run UI and events
func Run(d driver.Driver) {
render()
Expand Down

0 comments on commit e79f694

Please sign in to comment.