✨Sleek typing tui written in rust

Overview

thokr

sleek typing tui written in rust

GitHub Build Workflow GitHub Deploy Workflow License Crate Version Github Stars

demo

Installation

Cargo

$ cargo install thokr

Docker

$ docker run -it coloradocolby/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

Comments
  • Add AUR package

    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
    opened by crstian19 10
  • Added wikipedia support

    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! 😄

    opened by margual56 6
  • ctrl+backspace to delete last word

    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

    enhancement blocked 
    opened by RomanHN 3
  • Adds sentence functionality. Allows the -f <number_of_sentences> flag…

    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.
    opened by merelymyself 3
  • Fix unwrap() causing panic at exit on Windows.

    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
    opened by dmitr101 3
  • Log results to platform specific location

    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
    enhancement 
    opened by nickwanninger 3
  • (t)weet doesn't work in Docker container

    (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
    bug 
    opened by amorriscode 3
  • Multi-byte codepoints cause panic

    Multi-byte codepoints cause panic

    Description

    When a multiple-byte codepoint is rendered in the prompt, thokr panics and dies.

    To Reproduce

    Run thokr -p "ä" Observe the panic.

    Expected behavior

    Thokr should render the character properly, without panicking.

    Environment

    • OS: Devuan GNU/Linux Ceres on amd64
    • Terminal Emulator: gnome-terminal
    • Font: JetBrains Mono Nerd Font
    • Crate version: 0.3.0

    Additional context

    I suspect the source of the panic can be found on line 64 in thok.rs. https://github.com/thatvegandev/thokr/blob/9453468032cae753570b660146103abd55609df2/src/thok.rs#L64

    bug 
    opened by bluelhf 2
  • Fresh warp terminal bug

    Fresh warp terminal bug

    Description

    When I start a fresh terminal and run thokr for the first time it doesn't load any graphic until I run it again

    To Reproduce

    Run thokr in a fresh warp terminal.

    Expected behavior

    It's expected that it shows some graphics, isn't it?

    Screenshots

    first run in a fresh terminal: image after retry: image

    video:

    https://user-images.githubusercontent.com/39351332/175514836-d22ee8f4-8641-4ca4-83cb-bdaa07ecdcca.mov

    Environment

    • OS: macOS Monterey 12.4 (21F79)
    • Terminal Emulator: warp
    • Font: hack (warp default)
    • Thokr Version: 0.4.0

    Additional context

    I'm not an English speaker so sorry for any language mistake...

    In iTerm it runs normally...

    bug 
    opened by junque1r4 2
  • Problem with custom prompt

    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
    bug 
    opened by SamDc73 1
  • fix: remove tweet functionality if no browser available

    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
    opened by jrnxf 0
  • Add basic multi-language support

    Add basic multi-language support

    This PR attempts to support multiple languages by implementing grapheme cluster inputs and comparison using the unicode-segmentation crate. I've tested it with Finnish prompts (which can contain letters with diacritical marks, such as ä and ö), and they seem to work fine (under fish-shell on tmux, anyways).

    opened by bluelhf 2
  • Caret customization

    Caret customization

    Hi ! Thanks for creating thokr, i'm having fun playing it in random terminals :)

    My only issue is that I struggle noticing where my caret is sometimes (when i'm trying to see whether the key i hit registered or not); the underline is not always visible enough to me.

    It would be cool to see an option to use different caret types (block, beam), perhaps even following current terminal settings ! (That could perhaps expand into cool fluff like pace carets like the other issue describes as well).

    enhancement 
    opened by KaniDev 0
  • visualize historical test results

    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

    enhancement 
    opened by RomanHN 2
  • pace caret

    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

    enhancement 
    opened by RomanHN 1
  • implemented basic scrolling #6

    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.

    opened by TheTrio 10
  • Change displayed words dynamically

    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.

    enhancement performance 
    opened by TheTrio 5
Releases(v0.4.1)
Owner
Colby Thomas
should probably be sleeping
Colby Thomas
Sleek is a CLI tool for formatting SQL. It helps you maintain a consistent style across your SQL code, enhancing readability and productivity.

Sleek: SQL Formatter ✨ Sleek is a CLI tool for formatting SQL. It helps you maintain a consistent style across your SQL code, enhancing readability an

Nick Rempel 40 Apr 20, 2023
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

Orhun Parmaksız 72 Dec 31, 2022
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,

Max Niederman 527 Dec 17, 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

Samyak Sarnayak 431 Dec 20, 2022
This CLI will help you improve your typing accuracy and speed

This CLI will help you improve your typing accuracy and speed! Improve your personal bests and look back on your previous records in a graph. All in the convenience of your own terminal!

Mitchel Wijt 8 May 25, 2023
Typing accuracy practice app.

booktyping booktyping is a simple commandline tool for practicing typing accuracy while reading a book. installation booktyping has only been tested o

null 3 Dec 10, 2023
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

L3af 9 Jan 5, 2022
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

Gijs Burghoorn 136 Jan 1, 2023
TUI interface for LLMs written in Rust 🔥

Tenere TUI interface for LLMs written in Rust ?? Demo ?? Supported LLMs Only ChatGPT is supported for the moment. But I'm planning to support more mod

BADR 22 Apr 22, 2023
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

Dylan Madisetti 599 Jan 9, 2023
Another TUI based system monitor, this time in Rust!

Another TUI based system monitor, this time in Rust!

Caleb Bassi 2.1k Jan 3, 2023
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

null 1 Oct 21, 2021
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

Thore Goll 1 Jan 14, 2022
Rust TUI library - Clipping region is a set of min/max x/y values applied to the existing region

TinyBit Clipping region is a set of min/max x/y values applied to the existing region A TUI lib This is not yet production ready T O D O TODO: bugs: T

Togglebit 13 May 3, 2022
An easy-to-use TUI crate for Rust, based off of the Elm architecture.

Rustea An easy-to-use TUI crate for Rust, based off of the Elm architecture. This is a re-implementation of Go's Tea, created by TJ Holowaychuk. Featu

Laz 82 Dec 21, 2022
Demo Rust Cursive crate for terminal user interface (TUI)

Demo Rust Cursive Demonstration of the Rust programming language and Cursvie crate for terminal user interface (TUI). Setup Create: cargo new demo Add

Joel Parker Henderson 5 Dec 27, 2022
A TUI for your todos built in Rust with full CLI support.

todui TUI Features This app allows for almost anythig you would need when dealing with todos: Create, edit, and delete tasks Add links to tasks Add du

Daniel Melchor 14 Apr 1, 2023
HTTP client/libcurl TUI front end in Rust, with request + key storage

Rust TUI HTTP Client with API Key Management This project is still in active development and although it is useable, there may still be bugs and signi

Preston Thorpe 23 Nov 9, 2023
A simple TUI password manager made in Rust.

IronKey IronKey is a Terminal User Interface (TUI) based password generator written in Rust. It leverages the power of Rust's performance and safety f

Kekma 3 Feb 23, 2024