From adb9fe0c2e6338c5228da2d5fd3356570a10b05c Mon Sep 17 00:00:00 2001 From: Gino D Date: Sat, 7 Jan 2023 21:24:37 +0100 Subject: [PATCH] Fixed terminal tab columns bugs --- src/picowatch.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/picowatch.py b/src/picowatch.py index 93d0c12..c25efd5 100644 --- a/src/picowatch.py +++ b/src/picowatch.py @@ -53,7 +53,7 @@ class Tab(): if nb_columns > 0 and auto_size > 0: terminal_size = os.get_terminal_size() - column_size = int((terminal_size.columns - sum(self.colsize)) / auto_size) + column_size = int((terminal_size.columns - sum(self.colsize) - 1) / auto_size) for i in range(len(self.colsize), nb_columns): self.colsize.append(column_size) @@ -608,12 +608,12 @@ class Picowatch(object): def __init__(self, pyboard: Pyboard): self.filesystem = FileSystem(pyboard) - signal.signal(signal.SIGINT, lambda a, b: self.interupt()) + signal.signal(signal.SIGINT, lambda a, b: self.interrupt()) def boot(self): self.filesystem.pyboard.boot() - def interupt(self): + def interrupt(self): self.filesystem.pyboard.send_ctrl_c() self.filesystem.pyboard.until_nothing_in_waiting() @@ -656,7 +656,7 @@ class Picowatch(object): def listing(self, filepath: str = '/'): filepath = filepath.strip('./') - tab = Tab(4, 30, 15, 100) + tab = Tab(4, 30, 15, nb_columns=4) tab.head('[ ]', 'Filename', 'Size (kb)', 'Exception') status, output, exception = self.filesystem.ls(filepath) @@ -678,7 +678,7 @@ class Picowatch(object): print(ln) def upload(self, filepath: str): - tab = Tab(4, 30, 15, 15, 100) + tab = Tab(4, 30, 15, nb_columns=4) tab.head('[ ]', 'Filename', 'Size (kb)', 'Checksum', 'Exception') for source, size in self.internal_ls(filepath): @@ -690,7 +690,7 @@ class Picowatch(object): tab.line('[?]', destination, '', '', str(e)) def download(self, filepath: str): - tab = Tab(4, 30, 15, 100) + tab = Tab(4, 30, 15, nb_columns=4) tab.head('[ ]', 'Filename', 'Checksum', 'Exception') status, output, exception = self.filesystem.ls(filepath.strip('./').strip('/')) @@ -711,7 +711,7 @@ class Picowatch(object): tab.line('[?]', filepath, '', exception) def delete(self, filepath: str): - tab = Tab(4, 30, 100) + tab = Tab(4, 30, nb_columns=3) tab.head('[ ]', 'Filename', 'Exception') status, output, exception = self.filesystem.rm(filepath.strip('./')) @@ -762,7 +762,7 @@ class Picowatch(object): if return_output: return changes - tab = Tab(4, 8, 40) + tab = Tab(4, 8, nb_columns=3) tab.head('[ ]', 'Status', 'Filename') for status, filename in changes: @@ -772,7 +772,7 @@ class Picowatch(object): tab.line('[+]', 'DELETED', filename) def push(self): - tab = Tab(4, 30, 15, 100) + tab = Tab(4, 30, 15, nb_columns=4) tab.head('[ ]', 'Filename', 'Size (kb)', 'Checksum', 'Exception') changes = self.status(return_output=True) @@ -846,7 +846,7 @@ except: print(str(e)) print('-' * 50) -picowatch.interupt() +picowatch.interrupt() while True: try: @@ -857,7 +857,7 @@ while True: match message.strip().split(' '): case ['?' | 'help']: print('These are common Picowatch keywords:\n') - tab = Tab(35, 70) + tab = Tab(35, nb_columns=2) tab.head('Keywords', 'Description') tab.line('uname', 'Pyboard name and version') tab.line('exit | ctrl + c', 'Exit Picowatch Terminal')