1.4.0 - added padding

This commit is contained in:
doman 2022-02-10 14:21:48 +01:00
parent 5e63da1d31
commit 21eef90307
4 changed files with 14 additions and 6 deletions

View file

@ -77,6 +77,8 @@ class TextBox(TextComponent):
self.maxy, self.maxx = None, None
self.usedy, self.usedx = None, None
self.left_margin = config.get("left_margin_percentage")
def clear(self):
self.elements = []
@ -105,7 +107,11 @@ class TextBox(TextComponent):
@property
def max_line_x(self):
return self.maxx - 1
return int(self.maxx * (100 - self.left_margin - self.left_margin) / 100) - 1
@property
def padding(self):
return " " * int(1 + self.left_margin * self.maxx / 100)
def prepare_text_element(self, element):
lines = []
@ -150,11 +156,10 @@ class TextBox(TextComponent):
lines[-1] = lines[-1][: -len(next_word)]
lines = lines[: self.maxy - self.usedy]
return "\n".join(lines)
return ("\n" + self.padding).join(lines)
def pain_element(self, screen, element):
self.usedy, self.usedx = screen.getyx()
self.maxy, self.maxx = screen.getmaxyx()
text = self.prepare_text_element(element)
self.paint_text(screen, text, element.color)
@ -162,6 +167,8 @@ class TextBox(TextComponent):
self.cursor_component.update(screen)
def paint(self, screen, application):
self.maxy, self.maxx = screen.getmaxyx()
self.paint_text(screen, self.padding, 0)
for element in self.elements:
self.pain_element(screen, element)

View file

@ -21,7 +21,8 @@ class Config:
"accuracy: {stats.accuracy:0.2f}%"
),
"summary_datafile": "~/.cache/fasttyper/datafile.csv",
"top_margin_percentage": 0,
"top_margin_percentage": 30,
"left_margin_percentage": 10,
}
def __init__(self, configmap):

View file

@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.3.4
current_version = 1.4.0
[wheel]
universal = 1

View file

@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setup(
name="fasttyper",
version="1.3.4",
version="1.4.0",
author="Piotr Domanski",
author_email="pi.domanski@gmail.com",
description="Minimalistic typing exercise",