diff --git a/fasttyper/__main__.py b/fasttyper/__main__.py index b46aa41..d1652cc 100644 --- a/fasttyper/__main__.py +++ b/fasttyper/__main__.py @@ -6,6 +6,7 @@ from .components import ( ReferenceText, StatsComponent, TextBox, + TopMargin, ) from .listener import Listener from .buffer import UserBuffer, Buffer @@ -24,6 +25,7 @@ def initialize(configmap, rbuffer): reference_buffer = Buffer(rbuffer) user_buffer = UserBuffer() + top_margin = TopMargin(config) cursor_component = CursorComponent(config) text_box = TextBox(config, cursor_component) user_input = UserInput(config, text_box) @@ -35,7 +37,14 @@ def initialize(configmap, rbuffer): interface = Interface( application, - [user_input, reference_text, text_box, stats_component, cursor_component], + [ + top_margin, + user_input, + reference_text, + text_box, + stats_component, + cursor_component, + ], ) wrapper(interface) diff --git a/fasttyper/components.py b/fasttyper/components.py index 3759156..2d809f4 100644 --- a/fasttyper/components.py +++ b/fasttyper/components.py @@ -44,6 +44,18 @@ class StatsComponent(TextComponent): self.paint_text(screen, text, self.color) +class TopMargin(Base): + def __init__(self, config): + super().__init__() + self.height = config.get("top_margin_percentage") / 100 + + def paint(self, screen, application): + maxy, _ = screen.getmaxyx() + lines = int(self.height * maxy) + for line in range(lines): + screen.addstr("\n") + + class TextBox(TextComponent): """ Wraps lines of text elements writing to it nicely diff --git a/fasttyper/config.py b/fasttyper/config.py index 50b840a..a375730 100644 --- a/fasttyper/config.py +++ b/fasttyper/config.py @@ -21,6 +21,7 @@ class Config: "accuracy: {stats.accuracy:0.2f}%" ), "summary_datafile": "~/.cache/fasttyper/datafile.csv", + "top_margin_percentage": 30, } def __init__(self, configmap): diff --git a/setup.cfg b/setup.cfg index bdaa886..c85bb8f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.0 +current_version = 1.3.3 [wheel] universal = 1 diff --git a/setup.py b/setup.py index eff7dd2..1271e0b 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.3.2", + version="1.3.3", author="Piotr Domanski", author_email="pi.domanski@gmail.com", description="Minimalistic typing exercise",