diff --git a/README.md b/README.md index 439ca6a..30e74f1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/man.md b/man.md index aa593ad..a0d64b2 100644 --- a/man.md +++ b/man.md @@ -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 diff --git a/src/util.go b/src/util.go index 66f005b..1292d7b 100644 --- a/src/util.go +++ b/src/util.go @@ -84,13 +84,20 @@ 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 := "" + // Don't add punctuation after the last word + if i != n-1 { + punct = punctuations[rand.Int()%len(punctuations)] + } + + r += w + punct if i != n-1 { r += " " }