From cf47a5c935586768083749e3b8b75f75c21742b7 Mon Sep 17 00:00:00 2001 From: Johnny Santamaria Date: Tue, 27 May 2025 17:37:03 +0000 Subject: [PATCH 1/2] feat: add random punctuation to generated word lists and update documentation to reflect this behavior --- README.md | 2 ++ man.md | 2 ++ src/util.go | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) 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 += " " } From 3607c6369b2906f2e3a806c9cdcd93f5a422a803 Mon Sep 17 00:00:00 2001 From: David <12832280+David-Else@users.noreply.github.com> Date: Fri, 14 Nov 2025 10:15:24 +0000 Subject: [PATCH 2/2] Random punctuation every 6 chars and no smart quotes --- src/util.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util.go b/src/util.go index 1292d7b..75bc2f3 100644 --- a/src/util.go +++ b/src/util.go @@ -25,7 +25,7 @@ func init() { } type cell struct { - c rune + c rune style tcell.Style } @@ -84,7 +84,8 @@ func randomText(n int, words []string) string { r := "" var last string - punctuations := []string{"", ".", ",", ";", ":", "?", "!", ")", "]", "}", "(", "[", "{", "\"", "'", "“", "”", "‘", "’"} + punctuations := []string{"", ".", ",", ";", ":", "?", "!", ")", "]", "}", "(", "[", "{", `"`, "'"} + for i := 0; i < n; i++ { w := words[rand.Int()%len(words)] for last == w { @@ -92,8 +93,11 @@ func randomText(n int, words []string) string { } punct := "" - // Don't add punctuation after the last word - if i != n-1 { + + // 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)] }