Skip to content

Commit

Permalink
Added clear function in Home class
Browse files Browse the repository at this point in the history
  • Loading branch information
sexfrance committed Oct 25, 2024
1 parent f1e40f6 commit 7b39966
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ home_screen = Home(
align="center",
adinfo1="discord.cyberious.xyz",
adinfo2="v1.0",
credits="Developed by sexfrance"
credits="Developed by sexfrance",
clear = False, # To clear the console, default is True
)

home_screen.display()
Expand Down Expand Up @@ -154,7 +155,8 @@ home_screen = Home(
align="center",
adinfo1="discord.cyberious.xyz",
adinfo2="v1.0",
credits="Developed by sexfrance"
credits="Developed by sexfrance",
clear = False
)

home_screen.display()
Expand Down
11 changes: 9 additions & 2 deletions logmagix/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ def stop(self):
print(self.end, flush=True)

class Home:
def __init__(self, text, align="left", adinfo1=None, adinfo2=None, credits=None):
def __init__(self, text, align="left", adinfo1=None, adinfo2=None, credits=None, clear=True):
self.text = text
self.align = align
self.adinfo1 = adinfo1
self.adinfo2 = adinfo2
self.credits = credits
self.clear = clear
self.username = getpass.getuser()

def _get_char_art(self):
Expand Down Expand Up @@ -141,6 +142,9 @@ def _align_text(self, lines, terminal_width, alignment, block_width):
aligned_result.append(aligned_line)
return aligned_result

def _clear(self):
os.system('cls' if os.name == 'nt' else 'clear')

def display(self):
char_arts, max_height = self._get_char_art()
result = [""] * max_height
Expand All @@ -155,8 +159,11 @@ def display(self):
terminal_width = os.get_terminal_size().columns
except OSError:
terminal_width = 80

aligned_result = self._align_text(result, terminal_width, self.align, max_line_width)
if self.clear:
self._clear()

for line in aligned_result:
Write.Print(line + "\n", Colors.red_to_blue, interval=0.000)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="logmagix",
version="1.0.3",
version="1.0.4",
packages=find_packages(),
install_requires=["colorama"],
author="Sexfrance",
Expand Down

0 comments on commit 7b39966

Please sign in to comment.