Compare commits

...

2 Commits
2.4 ... master

Author SHA1 Message Date
KikooDX 5e5f1bc9ef Fixed fmargin. 2019-11-16 16:18:27 +01:00
KikooDX 80cf133bbf Fancy margin.
Speed and size optimization.
2019-11-16 16:12:56 +01:00
1 changed files with 7 additions and 5 deletions

View File

@ -28,7 +28,7 @@ class Screen:
def fill(self, patern=" "):
self._mat = [[patern[0] for i in range(self._width)] for i in range(self._height)]
def refresh(self, ask_for_input=True, endl="\n", fancy=False):
def refresh(self, ask_for_input=True, endl="\n", fancy=False, fmargin=4):
to_print = str()
for line in self._mat[:-1] if fancy else self._mat:
for cell in line:
@ -38,9 +38,11 @@ class Screen:
print(to_print)
if ask_for_input or fancy:
line = ""
for cell in self._mat[-1][:-5]:
if fancy:
for cell in self._mat[-1][:-fmargin]:
line += cell
return input(line if fancy else "> ")
return input(line)
return input("> ")
else:
print("", end=endl)
return None
@ -70,7 +72,7 @@ class Screen:
class Pad(Screen):
def refresh(self, x=1, y=1, width=21, height=7, ask_for_input=True,\
endl="\n", fancy=True):
endl="\n", fancy=True, fmargin=4):
ogwidth = width
if width > self._width:
width = self._width
@ -95,7 +97,7 @@ class Pad(Screen):
to_print = to_print[:-1]
print(to_print[:-width], end="")
if ask_for_input or fancy:
return input(to_print[-width:-1]+ " " * (ogwidth - width - 4) if fancy else "> ")
return input(to_print[-width:-1]+ " " * (ogwidth - width - fmargin) if fancy else "> ")
else:
print(to_print[-width:], end=endl)
return None