From 15e5ec9c186198b5857526de2199f47722cb715d Mon Sep 17 00:00:00 2001 From: Doman Date: Sat, 12 Feb 2022 22:03:01 +0100 Subject: [PATCH] added hide cursos option --- README.md | 6 +++++- fasttyper/__main__.py | 12 ++++++++++-- fasttyper/interface.py | 6 +++++- setup.cfg | 2 +- setup.py | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d5c6108..f9df22c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,11 @@ To exit you can either finish test, use `KeyboardInterrupt` (CTRL+C) or tap **ta # When backspace does wierd shiet -Some terminal emulators send different values for key presses of backspace and ctrl+backspace. To fix it, simply add `b` flag to `python3 -m fasttyper`. +Some terminal emulators send different values for key presses of backspace and ctrl+backspace. To fix it, simply add `b` flag like that: `python3 -m fasttyper -b`. + +# Hiding cursor + +To hide the cursor, simply add `n` flag like that: `python3 -m fasttyper -n`. ## Example scripts diff --git a/fasttyper/__main__.py b/fasttyper/__main__.py index 6836577..67f99a5 100644 --- a/fasttyper/__main__.py +++ b/fasttyper/__main__.py @@ -17,7 +17,7 @@ import argparse import json -def initialize(configmap, rbuffer, backspace_debug): +def initialize(configmap, rbuffer, backspace_debug, no_cursor): config = Config(configmap) reference_buffer = Buffer(rbuffer) @@ -39,6 +39,7 @@ def initialize(configmap, rbuffer, backspace_debug): stats_component, cursor_component, ], + no_cursor, ) wrapper(interface) @@ -68,6 +69,13 @@ def main(): help="unclutter backspace, when it raises ctrl+backspace instead", default=False, ) + parser.add_argument( + "--no-cursor", + "-n", + action="store_true", + help="disable cursos", + default=False, + ) args = parser.parse_args() if is_tty: @@ -87,7 +95,7 @@ def main(): except FileNotFoundError: configmap = {} - initialize(configmap, rbuffer, args.unclutter_backspace) + initialize(configmap, rbuffer, args.unclutter_backspace, args.no_cursor) if __name__ == "__main__": diff --git a/fasttyper/interface.py b/fasttyper/interface.py index 5889452..d957ce7 100644 --- a/fasttyper/interface.py +++ b/fasttyper/interface.py @@ -2,9 +2,10 @@ import curses class Interface: - def __init__(self, application, components): + def __init__(self, application, components, no_cursor=False): self.application = application self.components = components + self.no_cursor = no_cursor def init_colors(self): assert curses.has_colors() @@ -30,6 +31,9 @@ class Interface: self.init(screen) self.application.start() + if self.no_cursor: + curses.curs_set(0) + while self.application.running(): self.update(screen) self.application.action(screen) diff --git a/setup.cfg b/setup.cfg index a2a147d..c15cde7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.5.1 +current_version = 1.5.2 [wheel] universal = 1 diff --git a/setup.py b/setup.py index f9ec6f6..775f408 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setup( name="fasttyper", - version="1.5.1", + version="1.5.2", author="Piotr Domanski", author_email="pi.domanski@gmail.com", description="Minimalistic typing exercise",