diff --git a/README.md b/README.md index 96be6e5..53e4667 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,96 @@ # typos + Typing speed test in terminal written in C++ using ncurses. -> made by tmaluh a.k.a _ipal a.k.a MrChebys a.k.a ... + +> made by tmaluh a.k.a \_ipal a.k.a MrChebys a.k.a ... ## Features: - - You can move across already typped characters with Arrow Keys. - - Deleting input of current word by pressing Ctrl+Backspace, or if you at the start of the word - this shortcut will move the cursor to begin of the previous word. - - When words are ended, but time still ticking - you will start typing the same words from the beginning again. (Statistic will not be reset until the time is over) - - You can reset the current test with Tab, or on the Stats Screen with Enter. - - Under all the words displaying also prints previous, current, and next word to type with the current character always at the center of the screen. - - Displaying the timer. - - Detailed statistics. +- You can move across already typped characters with Arrow Keys. +- Deleting input of current word by pressing Ctrl+Backspace, or if you at the start of the word - this shortcut will move the cursor to begin of the previous word. +- When words are ended, but time still ticking - you will start typing the same words from the beginning again. (Statistic will not be reset until the time is over) +- You can reset the current test with Tab, or on the Stats Screen with Enter. +- Under all the words displaying also prints previous, current, and next word to type with the current character always at the center of the screen. +- Displaying the timer. +- Detailed statistics. + +*** - *** #### Statistics: - - **WPM**: The correct way of calculating WPM including corrected typos. Net WPM - - **RAW WPM**: WPM without any typos calculations. Gross WPM - - **REAL WPM**: Calculating Net WPM, but with all typos what you ever made in your life ... Net WPM v2 - - **TYPED**: Count of all typed characters. - - **CPS**: Characters Per Second. - - **TYPOS**: Corrected typos. - - **REAL TYPOS**: All typos that you made. - - **ACC**: Accuracy with corrected typos. - - **REAL ACC**: Accuracy with all typos. - - *** + +- **WPM**: The correct way of calculating WPM including corrected typos. Net WPM +- **RAW WPM**: WPM without any typos calculations. Gross WPM +- **REAL WPM**: Calculating Net WPM, but with all typos what you ever made in your life ... Net WPM v2 +- **TYPED**: Count of all typed characters. +- **CPS**: Characters Per Second. +- **TYPOS**: Corrected typos. +- **REAL TYPOS**: All typos that you made. +- **ACC**: Accuracy with corrected typos. +- **REAL ACC**: Accuracy with all typos. + +*** + #### Flags: - `-h`: Prints this help message. - `-t `: Number of maximum time to type in seconds. Accepts only positive integer in range: 10 - 240; Default: 60. - `-w `: Number of maximum words to type. Accepts only positive integer in range: 10 - 150; Default: 42; - `-a`: Words sorted in alphabetical order. Default: false; - `-m`: Monochrome mode. Default: false; + - `-f`: Free typing mode. The timer will not start. Default: false; + +*** - *** #### Keybindigs: - - Welcome Screen: - - Ctrl+C, Ctrl+D, and Esc: Now closing the `typos`. - - Any other key will start the `typos`. - - - While typing: - - Tab: Fully resetting current typing test(Already typed stats, words, and even timer will be reset). And you will start the test from the beginning. - - Ctrl+C, Ctrl+D, and Esc: Now closing the `typos`. - - Ctrl+Backspace: Removing current word, or goes to start of the previous. - - Backspace: Removing current character. - - : Moves to the previously typed character. - - : Moves to the next character. Works only for already typed characters. - - Only printable characters will be prompt to the test (see `man 3 isprint`). - - Any other input will be ignored. - - - Stats Screen: - - Ctrl+C, Ctrl+D, and Esc: Now closing the `typos`. - - Ctrl+S: Saves your typing test result to `./typos.log` file. By appending new test data to the end of the file and with the current local date at the top of each result. - - Enter: Restart the test. + +- Welcome Screen: + - Ctrl+C, Ctrl+D, and Esc: Now closing the `typos`. + - Any other key will start the `typos`. + +- While typing: + - Tab: Fully resetting current typing test(Already typed stats, words, and even timer will be reset). And you will start the test from the beginning. + - Ctrl+C, Ctrl+D, and Esc: Now closing the `typos`. + - Ctrl+Backspace: Removing current word, or goes to start of the previous. + - Backspace: Removing current character. + - : Moves to the previously typed character. + - : Moves to the next character. Works only for already typed characters. + - Only printable characters will be prompt to the test (see `man 3 isprint`). + - Any other input will be ignored. + +- Stats Screen: + - Ctrl+C, Ctrl+D, and Esc: Now closing the `typos`. + - Ctrl+S: Saves your typing test result to `./typos.log` file. By appending new test data to the end of the file and with the current local date at the top of each result. + - Enter: Restart the test. > !! IMPORTANT !!; Because of reasons of handling the "Escape Sequences" the Esc-key by itself has a delay in 1 sec. My advice is to use Ctrl+C, and Ctrl+D keybindgds instead of Esc whatever it's possible. The Esc is not removed because for some peoples the Esc-key may be a more comfortable way to close the program. - *** +*** + #### Debug mode - Will show you some additional information about current input with some stats if you need it. - - To active this you must rebuild `typos` with: - ```bash - make debug_all - ``` +Will show you some additional information about current input with some stats if you need it. +To active this you must rebuild `typos` with: + +```bash +make debug_all +``` ## Installation the deps.: + ```bash sudo apt-get install libncurses5-dev libncursesw5-dev clang ``` Most of the other tools is already pre-installed in most of Linux distros. but if u still have troubles when building the app: + ```bash sudo apt-get install build-essential ``` ## Building: + Just make it working: + ```bash make ``` @@ -85,17 +98,21 @@ make More options for Makefile are described [here](https://github.com/Iipal/MakeMeBetter). ## Using the typos: + After successful installation you can run it like this: + ```bash ./typos ``` To see the help info about some options: + ```bash ./typos -h ``` - + If you wanted globally access to the `typos`: + ```bash mkdir -p ~/.bin; git clone https://github.com/Iipal/typos/ ~/.bin/typos; diff --git a/includes/Flags.hpp b/includes/Flags.hpp index 1c6eacd..035eb2f 100644 --- a/includes/Flags.hpp +++ b/includes/Flags.hpp @@ -9,6 +9,7 @@ class Flags { static unsigned int max_words; static bool is_monochrome; static bool is_alphabetic; + static bool is_free_mode; private: Flags(); diff --git a/srcs/Flags.cpp b/srcs/Flags.cpp index 7ffdcb6..6b6783b 100644 --- a/srcs/Flags.cpp +++ b/srcs/Flags.cpp @@ -7,8 +7,9 @@ #define FLAG_T 't' #define FLAG_M 'm' #define FLAG_A 'a' +#define FLAG_F 'f' -#define FLAGS_OPT "hw:t:ma" +#define FLAGS_OPT "hw:t:maf" #define FLAGS_USAGE "Usage: ./typos [" FLAGS_OPT "]" @@ -29,8 +30,8 @@ "Default: 60." #define FLAG_M_DEFAULT false - #define FLAG_A_DEFAULT false +#define FLAG_F_DEFAULT false #define FLAG_H_DESC \ FLAGS_USAGE \ @@ -39,12 +40,15 @@ " -w [number] : " FLAG_W_DESC "\n" \ " -t [seconds]: " FLAG_T_DESC "\n" \ " -m : Monochrome mode. Default: false;\n" \ - " -a : Words sorted in alphabetical order. Default: false;\n" + " -a : Words sorted in alphabetical order. Default: false;\n" \ + " -f : Free typing mode. The timer will not start. Default: " \ + "false; \n" unsigned int Flags::max_time = FLAG_T_DEFAULT; unsigned int Flags::max_words = FLAG_W_DEFAULT; bool Flags::is_monochrome = FLAG_M_DEFAULT; bool Flags::is_alphabetic = FLAG_A_DEFAULT; +bool Flags::is_free_mode = FLAG_F_DEFAULT; Flags::Flags() {} @@ -94,6 +98,10 @@ void Flags::parse(int argc, char *argv[]) { Flags::is_alphabetic = true; break; + case FLAG_F: + Flags::is_free_mode = true; + break; + case '?': fprintf(stderr, "%s\n", FLAGS_USAGE); exit(EXIT_FAILURE); @@ -104,6 +112,7 @@ void Flags::parse(int argc, char *argv[]) { exit(EXIT_SUCCESS); default: + printf("%s\n", FLAG_H_DESC); exit(EXIT_FAILURE); } } diff --git a/srcs/Print.cpp b/srcs/Print.cpp index 31ba397..1dac2ea 100644 --- a/srcs/Print.cpp +++ b/srcs/Print.cpp @@ -109,6 +109,10 @@ void Print::clean_input(void) { } void Print::timer(int seconds) { + if (Flags::is_free_mode) { + return; + } + curs_set(0); int min = seconds / 60; diff --git a/srcs/Timer.cpp b/srcs/Timer.cpp index 0454a9d..204393a 100644 --- a/srcs/Timer.cpp +++ b/srcs/Timer.cpp @@ -18,6 +18,10 @@ void Timer::init(int seconds, Typing *typing) { Timer::_typing = typing; } + if (Flags::is_free_mode) { + return; + } + struct sigaction act; act.sa_handler = Timer::timer_handler; act.sa_flags = SA_NOCLDWAIT;