Skip to content

Commit

Permalink
Updated: Readme
Browse files Browse the repository at this point in the history
Restyled: Final screen
  • Loading branch information
onelikeandidie committed Sep 29, 2022
1 parent 8f0a529 commit 16beb09
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[package]
name = "typo-eq"
description = "Typo-eq is a typing training app for other languages. All it needs is a dictionary for words and their translations."
license = "GPL-3.0"
version = "0.1.1"
edition = "2021"

Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@ command in your terminal.
cargo run -- --dict path/to/xdxf/file
```

An application window should start up with a short blank screen while the
dictionary is being loaded. Then a word will appear and you can begin typing.
A short loading screen should appear as your dictionary is loaded. Bigger
dictionaries typically take longer (_obvio_), the Svenska-English dictionary
from the Swedish People's Dictionary takes around 1.06 seconds.

## Screenshots

![First Line](docs/screenshot01.png)
![Completed 1 Word](docs/screenshot02.png)
![Final Screen](docs/screenshot03.png)
Binary file added docs/screenshot01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshot02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshot03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 25 additions & 18 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,22 @@ pub fn create_app(config: Config) {
});

let mut dict: Option<Dictionary> = None;
let mut load_time = 0;
while let Ok(event) = lrx.recv() {
match event {
AppEvent::LoadingStarted => {
load_time = Utc::now().timestamp_millis();
renderer.print_at_center_default("Loading Started");
}
AppEvent::DictionaryLoaded(loaded_dict) => {
dict = Some(loaded_dict);
renderer.print_at_center_default("Dictionary Loaded");
}
AppEvent::LoadingFinished => {
renderer.print_at_center_default("Finished Loading");
renderer.print_at_center_default( format!(
"Finished Loading ({} sec)",
(Utc::now().timestamp_millis() - load_time) as f64 / 1000.0
).as_str());
}
_ => {},
}
Expand Down Expand Up @@ -143,7 +148,7 @@ pub fn create_app(config: Config) {
// Update progress display
renderer.print_at_center(
format!("{}/{}", state.progress, word.size).as_str(),
(6, -2), Some(TextAlign::Left),
(2, -2), Some(TextAlign::Left),
Some(Color::DarkGrey), None,
None
);
Expand All @@ -153,7 +158,7 @@ pub fn create_app(config: Config) {
state.wpm = 1.0 / (diff as f64 / 1000.0 / 60.0);
renderer.print_at_center(
format!("{} wpm", state.wpm.round()).as_str(),
(-6, -2), Some(TextAlign::Right),
(-2, -2), Some(TextAlign::Right),
Some(Color::DarkYellow), None,
None
);
Expand All @@ -172,16 +177,8 @@ pub fn create_app(config: Config) {
None, Some(Color::DarkGrey), None,
Some(Clear(ClearType::CurrentLine)),
);
// Clear the user input to output the right word in case
// there was any rendering mistake
// Clear the user input
renderer.clear_line_at_center((0, 2));
// execute!(stdout,
// SetForegroundColor(Color::DarkGreen),
// MoveToNextLine(1),
// Clear(ClearType::CurrentLine),
// MoveToColumn(0),
// ).unwrap();
// println!("{}", word.original);
// New word
word = new_word(&dict);
state.progress = 0;
Expand All @@ -197,22 +194,32 @@ pub fn create_app(config: Config) {
}
}

println!();
// Update wpm
let current_timestamp = Utc::now().timestamp_millis();
let diff = current_timestamp - state.started_at;
state.wpm = state.stats.completed as f64 / (diff as f64 / 1000.0 / 60.0);
let out = format!(
"Completed: {} words. {} chars typed, of which {} were misses ({}% Accuracy). Average wpm: {}",
state.stats.completed, state.stats.chars_typed, state.stats.chars_failed,
100.0 - (state.stats.chars_failed as f64 / state.stats.chars_typed as f64 * 100.0).round(),
// Render final screen
let out1 = format!(
"Completed: {} words. Average wpm: {}",
state.stats.completed,
state.wpm.round(),
);
let out2 = format!(
"{} chars typed, of which {} were misses ({}% Accuracy).",
state.stats.chars_typed, state.stats.chars_failed,
100.0 - (state.stats.chars_failed as f64 / state.stats.chars_typed as f64 * 100.0).round(),
);
renderer.print_at_center(
out1.as_str(), (0, 2),
None, Some(Color::DarkYellow), None,
Some(Clear(ClearType::CurrentLine))
);
renderer.print_at_center(
out.as_str(), (0, -2),
out2.as_str(), (0, 3),
None, Some(Color::DarkYellow), None,
Some(Clear(ClearType::CurrentLine))
);
// Move cursor out of frame as to continue out of raw mode [rp[[er]]]
Cursor::move_to_center((0, 8));
}

Expand Down

0 comments on commit 16beb09

Please sign in to comment.