-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partial rewrite. Changes too numerous to list (see the man page). Highlights: - Added -quotes. - Added support for navigating between tests via right/left. - Now store the user's position within a file if one is specified. - Improved documentation.
- Loading branch information
Showing
19 changed files
with
22,527 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Keep track of errors. | ||
Generate word sets based on errors | ||
Consolidate documentation. | ||
Add option to export errors. | ||
Add -nobackspace | ||
-adaptive/-tutor mode which learns from your mistake. | ||
Add -blind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
func generateTestFromData(data []byte, raw bool, split bool) func() []segment { | ||
if raw { | ||
return func() []segment { return []segment{segment{string(data), ""}} } | ||
} else if split { | ||
paragraphs := getParagraphs(string(data)) | ||
i := 0 | ||
|
||
return func() []segment { | ||
if i < len(paragraphs) { | ||
p := paragraphs[i] | ||
i++ | ||
return []segment{segment{p, ""}} | ||
} else { | ||
return nil | ||
} | ||
} | ||
} else { | ||
return func() []segment { | ||
var segments []segment | ||
|
||
for _, p := range getParagraphs(string(data)) { | ||
segments = append(segments, segment{p, ""}) | ||
} | ||
|
||
return segments | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
var FILE_STATE_DB string | ||
var MISTAKE_DB string | ||
|
||
func init() { | ||
if home, ok := os.LookupEnv("HOME"); !ok { | ||
die("Could not resolve home directory.") | ||
} else { | ||
FILE_STATE_DB = filepath.Join(home, ".tt/", ".db") | ||
MISTAKE_DB = filepath.Join(home, ".tt/", ".errors") | ||
} | ||
} | ||
|
||
func readValue(path string, o interface{}) error { | ||
b, err := ioutil.ReadFile(path) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return json.Unmarshal(b, o) | ||
} | ||
|
||
func writeValue(path string, o interface{}) { | ||
b, err := json.Marshal(o) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
err = ioutil.WriteFile(path, b, 0600) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
usage: tt [options] [file] | ||
|
||
Modes | ||
-words WORDFILE Specifies the file from which words are randomly | ||
generated (default: 1000en). | ||
-quotes QUOTEFILE Starts quote mode in which quotes are randomly generated | ||
from the given file. The file should be JSON encoded and | ||
have the following form: | ||
|
||
[{"text": "foo", attribution: "bar"}] | ||
|
||
Word Mode | ||
-n GROUPSZ Sets the number of words which constitute a group. | ||
-g NGROUPS Sets the number of groups which constitute a test. | ||
|
||
File Mode | ||
-start PARAGRAPH The offset of the starting paragraph, set this to 0 to | ||
reset progress on a given file. | ||
Aesthetics | ||
-showwpm Display WPM whilst typing. | ||
-theme THEMEFILE The theme to use. | ||
-w The maximum line length in characters. This option is | ||
ignored if -raw is present. | ||
|
||
Test Parameters | ||
-t SECONDS Terminate the test after the given number of seconds. | ||
-noskip Disable word skipping when space is pressed. | ||
|
||
Scripting | ||
-oneshot Automatically exit after a single run. | ||
-noreport Don't show a report at the end of a test. | ||
-csv Print the test results to stdout in the form: | ||
[wpm],[cpm],[accuracy],[timestamp]. | ||
-raw Don't reflow STDIN text or show one paragraph at a time. | ||
Note that line breaks are determined exclusively by the | ||
input. | ||
-multi Treat each input paragraph as a self contained test. | ||
|
||
Misc | ||
-list TYPE Lists internal resources of the given type. | ||
TYPE=[themes|quotes|words] | ||
|
||
Version | ||
-v Print the current version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"path/filepath" | ||
) | ||
|
||
func generateTestFromFile(path string, startParagraph int) func() []segment { | ||
var paragraphs []string | ||
var db map[string]int | ||
var err error | ||
|
||
if path, err = filepath.Abs(path); err != nil { | ||
panic(err) | ||
} | ||
|
||
if err := readValue(FILE_STATE_DB, &db); err != nil { | ||
db = map[string]int{} | ||
} | ||
|
||
if startParagraph != -1 { | ||
db[path] = startParagraph | ||
writeValue(FILE_STATE_DB, db) | ||
} | ||
|
||
idx := db[path] - 1 | ||
|
||
if b, err := ioutil.ReadFile(path); err != nil { | ||
die("Failed to read %s.", path) | ||
} else { | ||
paragraphs = getParagraphs(string(b)) | ||
} | ||
|
||
return func() []segment { | ||
idx++ | ||
db[path] = idx | ||
writeValue(FILE_STATE_DB, db) | ||
|
||
if idx >= len(paragraphs) { | ||
return nil | ||
} | ||
|
||
return []segment{segment{paragraphs[idx], ""}} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.