From 1cbd7546273c08ec72215a37d8dad8b3d6fdb543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Mon, 13 Jul 2020 11:47:28 +0200 Subject: [PATCH] Fixed table rendering (close #94) --- CB/__init__.py | 2 +- CurseBreaker.py | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CB/__init__.py b/CB/__init__.py index 82d3d4d..fe31ea5 100644 --- a/CB/__init__.py +++ b/CB/__init__.py @@ -2,7 +2,7 @@ import random from rich.terminal_theme import TerminalTheme -__version__ = '3.5.0' +__version__ = '3.5.1' __license__ = 'GPLv3' __copyright__ = '2019-2020, Paweł Jastrzębski ' __docformat__ = 'restructuredtext en' diff --git a/CurseBreaker.py b/CurseBreaker.py index 2ed94c6..709dcf7 100644 --- a/CurseBreaker.py +++ b/CurseBreaker.py @@ -13,6 +13,7 @@ from pathlib import Path from datetime import datetime from rich import box +from rich.text import Text from rich.rule import Rule from rich.table import Table from rich.console import Console @@ -290,8 +291,8 @@ def setup_completer(self): def setup_table(self): self.table = Table(box=box.SQUARE) self.table.add_column('Status', header_style='bold white', no_wrap=True, justify='center') - self.table.add_column('Name', header_style='bold white', no_wrap=True) - self.table.add_column('Version', header_style='bold white', no_wrap=True) + self.table.add_column('Name', header_style='bold white') + self.table.add_column('Version', header_style='bold white') def c_install(self, args): if args: @@ -308,9 +309,11 @@ def c_install(self, args): for addon in addons: installed, name, version = self.core.add_addon(addon, optignore) if installed: - self.table.add_row('[green]Installed[/green]', name, version) + self.table.add_row('[green]Installed[/green]', Text(name, no_wrap=True), + Text(version, no_wrap=True)) else: - self.table.add_row('[bold black]Already installed[/bold black]', name, version) + self.table.add_row('[bold black]Already installed[/bold black]', + Text(name, no_wrap=True), Text(version, no_wrap=True)) progress.update(task, advance=1, refresh=True) self.console.print(self.table) else: @@ -335,9 +338,11 @@ def c_uninstall(self, args): for addon in addons: name, version = self.core.del_addon(addon) if name: - self.table.add_row(f'[bold red]Uninstalled[/bold red]', name, version) + self.table.add_row(f'[bold red]Uninstalled[/bold red]', + Text(name, no_wrap=True), Text(version, no_wrap=True)) else: - self.table.add_row(f'[bold black]Not installed[/bold black]', addon, '') + self.table.add_row(f'[bold black]Not installed[/bold black]', + Text(addon, no_wrap=True), Text('', no_wrap=True)) progress.update(task, advance=1, refresh=True) self.console.print(self.table) else: @@ -372,17 +377,22 @@ def c_update(self, args, addline=False, update=True, force=False): if versionold: if versionold == versionnew: if modified: - self.table.add_row('[bold red]Modified[/bold red]', name, versionold) + self.table.add_row('[bold red]Modified[/bold red]', + Text(name, no_wrap=True), Text(versionold, no_wrap=True)) else: - self.table.add_row('[green]Up-to-date[/green]', name, versionold) + self.table.add_row('[green]Up-to-date[/green]', + Text(name, no_wrap=True), Text(versionold, no_wrap=True)) else: if modified or blocked: - self.table.add_row('[bold red]Update suppressed[/bold red]', name, versionold) + self.table.add_row('[bold red]Update suppressed[/bold red]', + Text(name, no_wrap=True), Text(versionold, no_wrap=True)) else: self.table.add_row(f'[yellow]{"Updated" if update else "Update available"}' - f'[/yellow]', name, f'[yellow]{versionnew}[/yellow]') + f'[/yellow]', Text(name, no_wrap=True), + Text(versionnew, style='yellow', no_wrap=True)) else: - self.table.add_row(f'[bold black]Not installed[/bold black]', addon, '') + self.table.add_row(f'[bold black]Not installed[/bold black]', + Text(addon, no_wrap=True), Text('', no_wrap=True)) except Exception as e: exceptions.append(e) progress.update(task, advance=1 if args else 0.5, refresh=True)