Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
[ui] better colors
Browse files Browse the repository at this point in the history
  • Loading branch information
bomgar committed Feb 15, 2018
1 parent 7039aa3 commit 5346587
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions goat.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ import (
"fmt"
"math"
"os"
"time"
"strings"
"strconv"
"strings"
"time"
)

type opts struct {
Time int `short:"t" long:"time" description:"timer in seconds" required:"true"`
Title string `long:"title" description:"title"`
Time int `short:"t" long:"time" description:"timer in seconds" required:"true"`
Title string `long:"title" description:"title"`
Mappings []string `short:"m" long:"mapping" description:"Keybinding mapping. Format: <retcode>:<key>:<label> (64 <= retcode <= 113)"`
}

type mapping struct {
exitCode int
label string
key string
label string
key string
}

func parseMappings(rawMappings []string) ([]mapping, error) {
var mappings []mapping
for _, rawMapping := range rawMappings {
var slicedMapping = strings.Split(rawMapping, ":")
if(len(slicedMapping) != 3){
var slicedMapping = strings.Split(rawMapping, ":")
if len(slicedMapping) != 3 {
return nil, fmt.Errorf("Invalid mapping '%s', format should be <retcode>:<key>:<label>", rawMapping)
}
var exitCode, err = strconv.Atoi(slicedMapping[0])
if err != nil || exitCode < 64 || exitCode > 113 {
return nil, fmt.Errorf("Invalid mapping '%s', retcode '%s' is either not a number or < 64 or > 113", rawMapping, slicedMapping[0])
}

mappings = append(mappings, mapping {exitCode: exitCode, key: slicedMapping[1], label: slicedMapping[2] })
mappings = append(mappings, mapping{exitCode: exitCode, key: slicedMapping[1], label: slicedMapping[2]})
}
return mappings, nil
}
Expand All @@ -54,7 +54,6 @@ func main() {
os.Exit(1)
}


os.Exit(runUI(opts, mappings))
}

Expand All @@ -65,17 +64,17 @@ func timerGauge() *ui.Gauge {
timerGauge.Height = 5
timerGauge.Y = 6
timerGauge.BorderLabel = "Timer"
timerGauge.PercentColor = ui.ColorYellow
timerGauge.BarColor = ui.ColorGreen
timerGauge.PercentColor = ui.ColorBlack
timerGauge.BarColor = ui.ColorCyan
timerGauge.BorderFg = ui.ColorWhite
timerGauge.BorderLabelFg = ui.ColorMagenta
timerGauge.BorderLabelFg = ui.ColorBlack
return timerGauge
}

func headerBox(title string, mappings []mapping) *ui.Par {
var shortcuts []string
shortcuts = append(shortcuts, "'q' -> abort")
shortcuts = append(shortcuts, "'c' -> continue")
shortcuts = append(shortcuts, "'c' -> continue")
for _, mapping := range mappings {
shortcuts = append(shortcuts, fmt.Sprintf("'%s' -> %s", mapping.key, mapping.label))
}
Expand All @@ -93,6 +92,7 @@ func headerBox(title string, mappings []mapping) *ui.Par {
p.TextFgColor = ui.ColorBlack
p.BorderLabel = boxTitle
p.BorderFg = ui.ColorCyan
p.BorderLabelFg = ui.ColorBlack
return p
}

Expand Down

0 comments on commit 5346587

Please sign in to comment.