Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ wpm confidence_level 0.95 The confidence level for WPM
wpm cpm 0 If positive, report CPM in stats instead of WPM
wpm tab_spaces 1 Number of spaces to expand tabs to
wpm wrap_width -1 If positive, wrap text at this width
wpm redlist_threshold 90 Minimum WPM to pass redlisted text
xterm256colors Color codes for 256-color terminals (foreground, background)
xtermcolors Color codes for ordinary terminals (foreground, background)
============== =========================== ======= =============================================================================
Expand Down
8 changes: 5 additions & 3 deletions wpm/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def parse_args():
help="Starts wpm with monochrome colors")

argp.add_argument("--redlist", default=False, action="store_true",
help="Starts wpm with redlisted texts")
help="Starts wpm with redlisted texts. To redlist a text, press the \"up\" arrow key. To remove a texts from the redlist, complete each text fast enough or run wpm --flush_redlist.")

argp.add_argument("--flush_redlist", default=False, action="store_true",
help="Starts wpm with redlisted texts")
help="Cleans the redlist.")



Expand Down Expand Up @@ -258,6 +258,8 @@ def main():
if config.wpm.cpm:
opts.cpm = True

redlist_threshold = config.wpm.redlist_threshold

stats = load_stats(opts.stats_file, opts.tag)

if opts.load_json is not None:
Expand Down Expand Up @@ -289,7 +291,7 @@ def main():
sys.exit(1)

try:
with wpm.game.GameManager(quotes, stats, opts.cpm, opts.monochrome, opts.hard, opts.redlist) as gm:
with wpm.game.GameManager(quotes, stats, opts.cpm, opts.monochrome, opts.hard, opts.redlist, redlist_threshold) as gm:
try:
gm.run(to_front=text_ids)
gm.stats.save(opts.stats_file)
Expand Down
1 change: 1 addition & 0 deletions wpm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def int_tuple(s):
"wrap_width": (int, -1, "Wrap text to this width"),
"tab_spaces": (int, 1, "Expand tabs to N spaces"),
"cpm": (int, 0, "Report CPM instead of WPM in stats"),
"redlist_threshold": (int, 90, "Minimum WPM to pass redlisted text"),
},

"xterm256colors": {
Expand Down
6 changes: 3 additions & 3 deletions wpm/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class GameManager(object):
"""The main game runner."""

def __init__(self, quotes, stats, cpm_flag, monochrome, hard_flag, redlist_flag):
def __init__(self, quotes, stats, cpm_flag, monochrome, hard_flag, redlist_flag, redlist_threshold):

self.config = Config()
self.stats = stats
Expand All @@ -35,7 +35,7 @@ def __init__(self, quotes, stats, cpm_flag, monochrome, hard_flag, redlist_flag)
self.tab_spaces = None

self.redlist = Quotes.load_redlist()

self.redlist_threshold = redlist_threshold
if redlist_flag and not self.redlist:
print("Redlist is empty")
exit(0)
Expand Down Expand Up @@ -84,7 +84,7 @@ def mark_finished(self):

self.average = self.stats.average(self.stats.tag, last_n=10)

if self.redlist_flag and self.wpm(self.elapsed) > 90:
if self.redlist_flag and self.wpm(self.elapsed) > self.redlist_threshold:
if self.quotes.text_id not in self.redlist:
return
self.redlist[self.quotes.text_id] -= 1
Expand Down