Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A terminal based typing test.

![](demo.gif)

By default, generated word lists now include random common punctuation (periods, commas, semicolons, etc.) after some words for a more natural typing experience.

# Installation

## Linux
Expand Down
2 changes: 2 additions & 0 deletions man.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ usage: tt \[OPTION\]... \[FILE\]
test. Each paragraph of the input is treated as a segment unless '-multi' is
supplied in which case each paragraph is treated as a separate test.

By default, generated word lists now include random common punctuation (periods, commas, semicolons, etc.) after some words for a more natural typing experience.

# OPTIONS

## Modes
Expand Down
15 changes: 13 additions & 2 deletions src/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func init() {
}

type cell struct {
c rune
c rune
style tcell.Style
}

Expand Down Expand Up @@ -84,13 +84,24 @@ func randomText(n int, words []string) string {
r := ""

var last string
punctuations := []string{"", ".", ",", ";", ":", "?", "!", ")", "]", "}", "(", "[", "{", `"`, "'"}

for i := 0; i < n; i++ {
w := words[rand.Int()%len(words)]
for last == w {
w = words[rand.Int()%len(words)]
}

r += w
punct := ""

// Only add punctuation if:
// - it's the 6th word in a group (i+1 % 6 == 0)
// - and NOT the last word overall
if (i+1)%6 == 0 && i != n-1 {
punct = punctuations[rand.Int()%len(punctuations)]
}

r += w + punct
if i != n-1 {
r += " "
}
Expand Down