Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/tt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.")
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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, "")
Expand Down Expand Up @@ -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 {
Expand All @@ -383,7 +390,7 @@ func main() {
typer.ShowWpm = showWpm

if timeout != -1 {
timeout *= 1E9
timeout *= 1e9
}

var tests [][]segment
Expand Down Expand Up @@ -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

Expand Down