diff --git a/src/tt.go b/src/tt.go index aba3ada..a36aa08 100644 --- a/src/tt.go +++ b/src/tt.go @@ -127,7 +127,7 @@ func createDefaultTyper(scr tcell.Screen) *typer { tcell.ColorMaroon) } -func createTyper(scr tcell.Screen, bold bool, themeName string) *typer { +func createTyper(scr tcell.Screen, bold bool, themeName string, transparentBg bool) *typer { var theme map[string]string if b := readResource("themes", themeName); b == nil { @@ -139,8 +139,12 @@ func createTyper(scr tcell.Screen, bold bool, themeName string) *typer { var bgcol, fgcol, hicol, hicol2, hicol3, errcol tcell.Color var err error - if bgcol, err = newTcellColor(theme["bgcol"]); err != nil { - die("bgcol is not defined and/or a valid hex colour.") + if transparentBg { + bgcol = tcell.ColorDefault + } else { + if bgcol, err = newTcellColor(theme["bgcol"]); err != nil { + die("bgcol is not defined and/or a valid hex colour.") + } } if fgcol, err = newTcellColor(theme["fgcol"]); err != nil { die("fgcol is not defined and/or a valid hex colour.") @@ -186,6 +190,7 @@ Aesthetics -notheme Attempt to use the default terminal theme. This may produce odd results depending on the theme colours. + -transparent Uses a transparent background. -blockcursor Use the default cursor style. -bold Embolden typed text. ignored if -raw is present. @@ -241,6 +246,7 @@ func main() { var noBackspace bool var noReport bool var noTheme bool + var transparentBg bool var normalCursor bool var timeout int var startParagraph int @@ -275,6 +281,7 @@ func main() { flag.BoolVar(&normalCursor, "blockcursor", false, "") flag.BoolVar(&noBackspace, "nobackspace", false, "") flag.BoolVar(&noTheme, "notheme", false, "") + flag.BoolVar(&transparentBg, "transparent", false, "") flag.BoolVar(&oneShotMode, "oneshot", false, "") flag.BoolVar(&noHighlight, "nohighlight", false, "") flag.BoolVar(&noHighlightCurrent, "highlight2", false, "") @@ -365,7 +372,7 @@ func main() { if noTheme { typer = createDefaultTyper(scr) } else { - typer = createTyper(scr, boldFlag, themeName) + typer = createTyper(scr, boldFlag, themeName, transparentBg) } if noHighlightNext || noHighlight { @@ -383,7 +390,7 @@ func main() { typer.ShowWpm = showWpm if timeout != -1 { - timeout *= 1E9 + timeout *= 1e9 } var tests [][]segment @@ -415,7 +422,7 @@ func main() { idx-- } case TyperComplete: - cpm := int(float64(ncorrect) / (float64(t) / 60E9)) + cpm := int(float64(ncorrect) / (float64(t) / 60e9)) wpm := cpm / 5 accuracy := float64(ncorrect) / float64(nerrs+ncorrect) * 100