File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ scoop install ttyper
5050For usage instructions, you can run ` ttyper --help ` :
5151
5252```
53- ttyper 1.5.0
53+ ttyper 1.6.1
5454Terminal-based typing test.
5555
5656USAGE:
6262 --list-languages List installed languages
6363 --no-backtrack Disable backtracking to completed words
6464 --sudden-death Enable sudden death mode to restart on first error
65+ --no-backspace Disable backspace
6566 -V, --version Prints version information
6667
6768OPTIONS:
Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ struct Opt {
6464 /// Enable sudden death mode to restart on first error
6565 #[ arg( long) ]
6666 sudden_death : bool ,
67+
68+ /// Disable backspace
69+ #[ arg( long) ]
70+ no_backspace : bool ,
6771}
6872
6973impl Opt {
@@ -234,6 +238,7 @@ fn main() -> io::Result<()> {
234238 ) ,
235239 !opt. no_backtrack ,
236240 opt. sudden_death ,
241+ !opt. no_backspace ,
237242 ) ) ;
238243
239244 state. render_into ( & mut terminal, & config) ?;
@@ -283,7 +288,8 @@ fn main() -> io::Result<()> {
283288 "Couldn't get test contents. Make sure the specified language actually exists." ,
284289 ) ,
285290 !opt. no_backtrack ,
286- opt. sudden_death
291+ opt. sudden_death ,
292+ !opt. no_backspace ,
287293 ) ) ;
288294 }
289295 Event :: Key ( KeyEvent {
@@ -305,6 +311,7 @@ fn main() -> io::Result<()> {
305311 practice_words,
306312 !opt. no_backtrack ,
307313 opt. sudden_death ,
314+ !opt. no_backspace ,
308315 ) ) ;
309316 }
310317 Event :: Key ( KeyEvent {
Original file line number Diff line number Diff line change @@ -53,16 +53,23 @@ pub struct Test {
5353 pub complete : bool ,
5454 pub backtracking_enabled : bool ,
5555 pub sudden_death_enabled : bool ,
56+ pub backspace_enabled : bool ,
5657}
5758
5859impl Test {
59- pub fn new ( words : Vec < String > , backtracking_enabled : bool , sudden_death_enabled : bool ) -> Self {
60+ pub fn new (
61+ words : Vec < String > ,
62+ backtracking_enabled : bool ,
63+ sudden_death_enabled : bool ,
64+ backspace_enabled : bool ,
65+ ) -> Self {
6066 Self {
6167 words : words. into_iter ( ) . map ( TestWord :: from) . collect ( ) ,
6268 current_word : 0 ,
6369 complete : false ,
6470 backtracking_enabled,
6571 sudden_death_enabled,
72+ backspace_enabled,
6673 }
6774 }
6875
@@ -96,9 +103,9 @@ impl Test {
96103 }
97104 }
98105 KeyCode :: Backspace => {
99- if word. progress . is_empty ( ) && self . backtracking_enabled {
106+ if word. progress . is_empty ( ) && self . backtracking_enabled && self . backspace_enabled {
100107 self . last_word ( ) ;
101- } else {
108+ } else if self . backspace_enabled {
102109 word. events . push ( TestEvent {
103110 time : Instant :: now ( ) ,
104111 correct : Some ( !word. text . starts_with ( & word. progress [ ..] ) ) ,
You can’t perform that action at this time.
0 commit comments