added hide cursos option

This commit is contained in:
Doman 2022-02-12 22:03:01 +01:00
parent a39b542b44
commit 15e5ec9c18
5 changed files with 22 additions and 6 deletions

View file

@ -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

View file

@ -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__":

View file

@ -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)

View file

@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.5.1
current_version = 1.5.2
[wheel]
universal = 1

View file

@ -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",