✨ sleek typing tui with visualized results and historical logging

Last update: Jun 21, 2022

thokr

sleek typing tui with visualized results and historical logging

GitHub Build Workflow GitHub Deploy Workflow License Crate Version Github Stars

demo

Usage

For detailed usage run thokr -h.

thokr 0.4.1
sleek typing tui with visualized results and historical logging

USAGE:
    thokr [OPTIONS]

OPTIONS:
    -f, --full-sentences <NUMBER_OF_SENTENCES>
            number of sentences to use in test

    -h, --help
            Print help information

    -l, --supported-language <SUPPORTED_LANGUAGE>
            language to pull words from [default: english] [possible values: english, english1k,
            english10k]

    -p, --prompt <PROMPT>
            custom prompt to use

    -s, --number-of-secs <NUMBER_OF_SECS>
            number of seconds to run test

    -V, --version
            Print version information

    -w, --number-of-words <NUMBER_OF_WORDS>
            number of words to use in test [default: 15]

Installation

Cargo

$ cargo install thokr

Docker

$ docker run -it thatvegandev/thokr

Arch Linux

Install thokr-git from the AUR

Usage

For detailed usage run thokr -h.

Examples

command test contents
thokr 50 of the 200 most common english words
thokr -w 100 100 of the 200 most common English words
thokr -w 100 -l english1k 100 of the 1000 most common English words
thokr -w 10 -s 5 10 of the 200 most common English words (hard stop at 5 seconds)
thokr -p "$(cat foo.txt)" custom prompt with the output of cat foo.txt
thokr -f 4 4 grammatical sentences with full stops; overrides word settings

During a test you can press ← to start over or → to see a new prompt (assuming you didn't supply a custom one)

Supported Languages

The following languages are available by default:

name description
english 200 most common English words
english1k 1000 most common English words
english10k 10000 most common English words

Logging

Upon completion of a test, a row outlining your results is appended to the log.csv file found in the following platform-specific folders. This way you can easily track your progress over time.

platform value example
Linux $XDGCONFIG_HOME/_project_path or $HOME/.config/project_path /home/colby/.config/thokr
macOS $HOME/Library/Application Support/project_path /Users/Colby/Library/Application Support/thokr
Windows {FOLDERIDRoamingAppData}_project_path\config C:\Users\Colby\AppData\Roaming\thokr\config

Roadmap

  • ⚡️ Performance
    • Right now there are known performance issues surrounding the rendering of the tui at each tick interval and/or key press. Ideally each render uses the prior render as a base and only makes the necessary adjustments (possibly using StatefulWidget), but I haven't been able to figure that out yet.
  • 🔠 Multi-language support
    • I decided not to launch thokr with languages besides english because of some odd rendering issues I was experiencing when trying to input characters with accents. It's as though I'm not able to properly input the character in raw mode. I'd love to have that figure out before shipping other languages because I personally felt the experience was a bit jarring. I'll open an bug report for it with more details and replication steps -- would love more eyes on that problem!
  • 🧪 Tests
    • I've only written a small amount of tests at this point. I haven't sat down to really think through what tests look like when the output is dependent on the users terminal size, font size, etc. If you have any ideas for this please open up an issue and start the discussion!

Contributing

All contributions are greatly appreciated.

If you have a suggestion that would make thokr better, please fork the repo and create a pull request. You can also simply open an issue and select Feature Request

  1. Fork the repo
  2. Create your feature branch (git checkout -b [your_username]/xyz)
  3. Commit your changes (git commit -m 'add some xyz')
  4. Rebase off main (git fetch --all && git rebase origin/main)
  5. Push to your branch (git push origin [your_username]/xyz)
  6. Fill out pull request template

See the open issues for a full list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE.md for more information.

Acknowledgments

Check out these amazing projects that inspired thokr!

Follow

github twitter youtube

GitHub

https://github.com/thatvegandev/thokr
Comments
  • 1. Add AUR package

    What: Added AUR Package

    Why: It can be installed from the AUR directly.

    How: Creating the PKGBUILD

    Checklist:

    • [x] Documentation added
    • [ ] Tests added
    • [ ] No linting errors / broken tests
    • [x] Merge ready
    Reviewed by crstian19 at 2022-04-26 22:13
  • 2. ctrl+backspace to delete last word

    Problem

    When I press Ctrl+Backspace, I'd expect the last word to be deleted – this is the behavior of most text input boxes, and Monkeytype. Instead, it adds a new character.

    Solution

    I don't know exactly how to implement this feature. It could be an optional argument in the CLI.

    Additional context

    Video demonstrating the behavior. I mistype the word "possible" and attempt to delete the whole word.

    https://user-images.githubusercontent.com/62364808/166745675-61dd4d1f-3972-4353-b151-3eec35ea3da9.mp4

    Reviewed by RomanHN at 2022-05-04 17:32
  • 3. Adds sentence functionality. Allows the -f flag…

    … to indicate that the user wishes to type-test full, grammatical sentences.

    What: Added -f as a flag to allow for the generation of random sentences instead of just words.

    Why: Personally, I felt that thokr's random words didn't really help certain typists as much (such as myself) due to the lack of structure. While nonsensical, the sentences generated by thokr with this new flag are grammatical, and have the necessary full stops and spaces.

    How: Through use of cgisf_lib. I shamelessly reused one of my own side-projects to expedite the process of sentence generation.

    Checklist:

    • [x] Allow edits from maintainers option checked
    • [x] Documentation added
    • [ ] Tests added N/A
    • [x] No failing actions
    • [x] Merge ready
    • Do note that get_random_sentence() has to return two results because there would be no other way to get the necessary word count for analysis later on.
    • I have also manually tested it myself and everything seems to be working.
    Reviewed by merelymyself at 2022-05-02 16:21
  • 4. Fix unwrap() causing panic at exit on Windows.

    What: Fix process always panicking on exit on Windows.

    Why: This bug isn't critical as it mainly occurs when the process is already exiting, but I think it would be better for the process to exit nominally instead of panicking so as not to confuse the user.

    How: The problem is caused by resize event arriving when the main thread and, therefore, the receiver end of the channel is already dead. All I did was replacing unwrap with a conditional break. Even though the problem presents itself only with the resize event at the moment, I figured it would be better and more consistent to change all three cases to a conditional break. Another option would be to return the join handles main and join them in the end, but since the code inside both threads is just an infinite cycle, breaking seems like a more straightforward and cleaner choice.

    Checklist:

    • [ ] Documentation added
    • [ ] Tests added
    • [x] No linting errors / broken tests
    • [x] Merge ready
    Reviewed by dmitr101 at 2022-04-27 21:00
  • 5. Log results to platform specific location

    What: Logging historical data to $XDG_DATA_HOME/thokr.log

    Why: So nerds like me can plot progress over time

    How: Results are logged whenever results are calculated. It may be smart to add a configuration to disable this, but that could be another comit

    Checklist: N/A

    • [x] Documentation added
    • [ ] Tests added
    • [x] No linting errors / broken tests
    • [x] Merge ready
    Reviewed by nickwanninger at 2022-04-27 02:13
  • 6. (t)weet doesn't work in Docker container

    Description

    After running a typing test and pressing t, nothing happens.

    To Reproduce

    1. Run in Docker (docker run -it coloradocolby/thokr)
    2. Complete a typing test
    3. Press t

    Expected behavior

    I would expect some sort of Twitter-friendly text to copy paste or Twitter opens up with the tweet pre-filled.

    Environment

    • OS: macOS
    • Terminal Emulator: xterm
    • Crate version: 0.1.0
    Reviewed by amorriscode at 2022-04-26 16:04
  • 7. Problem with custom prompt

    Description

    I have a test file with around 50 words that have this structure : (word in each line with no space at the end)

    dependencies
    visualization
    description
    parse
    duplicates
    possible
    nootropics
    scissors
    

    now when i run thokr -p "$(cat Notes/typing/words)" the app show like this : ( wiht no spaces between words)

    dependenciesvisualizationdescriptionparseduplicatespossible
    nootropicsscissors
    

    To Reproduce

    I tried to add space after each word in the text file and it worded almost : the problem i had is that i need to type twice for each

    Expected behavior

    To show the words with spaces

    Environment

    • OS: Linux Fedora 36 KDE
    • Terminal Emulator: kitty
    • Font: JetBrainsMono Nerd Font
    • Thokr Version: 0.3.0
    Reviewed by SamDc73 at 2022-05-30 14:27
  • 8. fix: remove tweet functionality if no browser available

    What: Remove tweet functionality if no browser is available.

    Why: Makes it so users running thokr in a docker container aren't shown a tweet option that won't work.

    This How: Uses the newly updated 0.7.1 version of webbrowser-rs which exposes Browser::is_available().

    Checklist:

    • [x] Documentation added
    • [ ] Tests added
    • [x] No linting errors / broken tests
    • [x] Merge ready
    Reviewed by thatvegandev at 2022-04-27 15:35
  • 9. Added wikipedia support

    asciicast

    Summary

    This PR adds support for Wikipedia!!

    I added an option, -W, which will select a random article from Wikipedia and then make you type the summary of the article.

    I tried to add all the logic into its own file, to avoid cluttering the main.rs file.

    Changes

    • Cargo.toml → Added dependency reqwest to make requests to Wikipedia's API
    • main.rs → Added the module wiki, imported the appropriate function and added code to have a flag and check if the flag is present. The call to random_article() is a bit bloated because wikipedia can sometimes return an empty article (rarely), so I had to do a match (although most errors are caught inside the wiki module).
    • wiki.rs → Contains all the structs and the two functions to make the requests. It's honestly very simple, but seems complicated because all the structs and all the parsing...

    Why

    I think this is a cool addition to the program! Typing real-world text is better than randomly generated chains of words.

    In the future, an option could be added to change the article's language, or for the user to be able to provide an article title and select that one.

    How

    With reqwest! Wikipedia has an awesome API (here is the documentation), so I just tell it to give me a random article and then make a summary of that article. That summary is what will be displayed.

    Really all the complexity is because all the error checking and parsing.

    Checklist:

    • [x] Allow edits from maintainers option checked
    • [x] Branch name is prefixed with [your_username]/ (ex. coloradocolby/featureX)
    • [ ] Documentation added
    • [ ] Tests added
    • [x] No failing actions
    • [x] Merge ready

    I tried to comment all the relevant code. I would love feedback on how you would like to handle the errors when parsing or making a request.

    Hope you like this addition! 😄

    Reviewed by margual56 at 2022-05-30 18:10
  • 10. visualize historical test results

    Problem

    There's no way to visualize historical test data, such as WPM and accuracy.

    Solution

    I would love to help write some code (in Python, if you're alright with that) to generate graphs that show average WPM and accuracy over time, for example. The logs would have to record the game mode for this to work. Let me know what you think.

    Alternatives

    A simple statistics summary page could show one's PB for each game mode, total time spent typing, etc.

    Additional context

    Statistics graph in Monkeytype.

    Thokr_graph

    Reviewed by RomanHN at 2022-05-04 18:10
  • 11. pace caret

    Problem

    One of my favorite features of Monkeytype is called the "pace caret":

    Displays a second caret that moves at constant speed. The 'average' option averages the speed of last 10 results.

    This gives me a good idea of how fast I'm typing in each trial and helps me keep pace.

    Solution

    A pace caret feature in thokr could include "PB", "average", and "custom" WPM options, and would work just like in Monkeytype.

    Alternatives

    A live WPM counter could serve a similar purpose but is hard to pay attention to when focusing on typing. Also, it only indicates how fast I'm typing in the moment, and doesn't give me any idea how well I've been doing throughout the entire test (how likely I am to get a PR).

    Additional context

    Pace caret demo in Monkeytype. The underline caret moves at a consistent 130 WPM, but jumps when I miss a word.

    https://user-images.githubusercontent.com/62364808/166748602-748a802f-a758-4075-8918-af2dcf3a9568.mp4

    Reviewed by RomanHN at 2022-05-04 17:56
  • 12. implemented basic scrolling #6

    What

    This PR aims to address #6. It adds a scrolling functionality to the text field, so that the user isn't overwhelmed by having all the words displayed at once.

    Why

    Besides being a better user experience, rendering fewer words at a single time makes the application faster since there aren't as many characters to render/keep track of.

    How

    The difficult part was figuring out when the user is at the end of a line. I don't think there's a way to do this using rust-tui so I've had to do the math myself. This logic is present in the get_skip_count function. Once we have calculated the amount of characters to skip, the implementation is relatively straightforward.

    Checklist

    • [ ] Documentation added
    • [ ] Tests added
    • [ ] No linting errors / broken tests
    • [ ] Merge ready

    Once this is merged, I think it would be nice to increase the HORIZONTAL_MARGIN (dynamically) to center the text. It would result in a better UI in my opinion.

    Reviewed by TheTrio at 2022-05-01 19:43
  • 13. Change displayed words dynamically

    Problem

    Presently, when you pass -s to set a time limit, the test doesn't run for that amount of time. Instead, it runs until the you've typed all the words(which is 15 by default)

    Solution

    I really like 60 seconds typing tests and on something like monkeytype, the number of words isn't static - if you're typing fast, it increases the number of words automatically. There are 3 lines and as soon as you complete the 2nd line, a new line of words is added. So you never reach the last line.

    This makes more sense to me.

    Alternatives

    However, I have no clue if doing that is feasible in a terminal. If it isn't, I think doing something similar to →(but without resetting the timer) would be nice.

    Of course, I can do something like -s 60 -w 2000 but having so many words displayed at once makes it much more difficult for me to focus.

    Reviewed by TheTrio at 2022-04-30 10:42
A template for bootstrapping a Rust TUI application with tui-rs & crossterm
A template for bootstrapping a Rust TUI application with tui-rs & crossterm

rust-tui-template A template for bootstrapping a Rust TUI application with tui-rs & crossterm. tui-rs The library is based on the principle of immedia

Jun 1, 2022
Terminal-based typing test.
Terminal-based typing test.

ttyper Ttyper is a terminal-based typing test built with Rust and tui-rs. installation With Cargo: cargo install ttyper usage For usage instructions,

Jun 20, 2022
yet another typing test, but crab flavoured

toipe A trusty terminal typing tester for the tux. Usage Install cargo install toipe Run typing test toipe looks best on a nice terminal (such as Ala

Jun 21, 2022
Application microframework with command-line option parsing, configuration, error handling, logging, and shell interactions
Application microframework with command-line option parsing, configuration, error handling, logging, and shell interactions

Abscissa is a microframework for building Rust applications (either CLI tools or network/web services), aiming to provide a large number of features w

Jun 16, 2022
A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf.
A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf.

xplr A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf. [Quickstart] [Features] [Plugins] [Documentation] [Upgrade Guide] [

Jun 18, 2022
TUI for crate management like lazydocker and lazynpm
TUI for crate management like lazydocker and lazynpm

TUI for crate management like lazydocker and lazynpm. Shouldve named it as lazycargo but lazycrates sounded good at that time.

Jun 5, 2022
Rust TUI client for steamcmd
Rust TUI client for steamcmd

Steam TUI About Just a simple TUI client for steamcmd. Allows for the graphical launching, updating, and downloading of steam games through a simple t

Jun 15, 2022
Another TUI based system monitor, this time in Rust!
Another TUI based system monitor, this time in Rust!

Another TUI based system monitor, this time in Rust!

Jun 17, 2022
A user-friendly TUI client for Matrix written in Rust!

Konoha A user-friendly TUI client for Matrix written in Rust! Notice: The client is currently not usable and is only hosted on GitHub for version cont

Jan 5, 2022
TUI image viewer
TUI image viewer

Picterm TUI image viewer install $ cargo install picterm or $ git clone https://github.com/ksk001100/picterm $ cd picterm $ cargo install --path . usa

Jun 20, 2022
A cli prepared with TUI that facilitates your operations.
A cli prepared with TUI that facilitates your operations.

⚠️ For linux only ⚠️ Helper CLI A cli prepared with TUI that facilitates your operations. Click me to learn more about the theme system. If you just w

Feb 1, 2022
A tui to test regexes on the rust regex crate

regex-tui Structure src/ ├── app.rs -> holds the states and renders the widgets ├── event.rs -> handles the terminal events (key press, mouse cl

Oct 21, 2021
Parse hex colors to tui::style::Color

Color -> Tui Parse hex colors to tui rgb colors #c3f111 -> Color::Rgb(195,241,17) Note that the indexed colors are NOT HEX #142 -> Color::Indexed(142)

Nov 8, 2021
TUI input library supporting multiple backends
TUI input library supporting multiple backends

tui-input WARNING: Most of the functionality is only human tested. A TUI input library supporting multiple backends. This crate can be used with tui-r

Jun 16, 2022
2048 in `tui`, just for fun
2048 in `tui`, just for fun

TUI 2048 - Have a relax at anytime - ?? ^_^ How to run repo clone this repo, git clone https://github.com/WanderHuang/game-2048-tui.git cd game-2048-t

Jun 13, 2022
Tiny color conversion library for TUI application builders
Tiny color conversion library for TUI application builders

Definition of ANSI, RGB and HSL color types and all the conversions between them. There are many other color conversion crates. This one may be useful

Jan 27, 2022
FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config.
FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config.

Connect quickly to your services ?? FastSSH is a TUI that allows you to quickly connect to your services by navigating through your SSH config. Instal

Jun 14, 2022
Lemurs - A lightweight TUI display/login manager written in Rust 🐒
Lemurs - A lightweight TUI display/login manager written in Rust 🐒

Lemurs ?? A TUI Display/Login Manager written in Rust WIP: Whilst the project is working and installable, there are still a lot of bugs and limitation

Jun 7, 2022
Playground for 2D EKF-SLAM as TUI in Rust

SLAMme.RS Playground for 2D EKF-SLAM as TUI in Rust Installation $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # install RUST $ su

Jan 14, 2022