From ad9375cf53f53b7fe5c6ac4b15da7bdea388c752 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Thu, 26 May 2022 09:43:00 -0500 Subject: [PATCH 1/3] Allow `PSBTOverviewScreen` to truncate "self-transfer" Fixes #215 --- src/seedsigner/gui/screens/psbt_screens.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/seedsigner/gui/screens/psbt_screens.py b/src/seedsigner/gui/screens/psbt_screens.py index 89bef6b1..b25fad79 100644 --- a/src/seedsigner/gui/screens/psbt_screens.py +++ b/src/seedsigner/gui/screens/psbt_screens.py @@ -118,7 +118,7 @@ class PSBTOverviewScreen(ButtonListScreen): # max_destination_col_width += curve_width # Now let's maximize the actual destination col by adjusting our addr truncation - def calculate_destination_col_width(truncate_at: int): + def calculate_destination_col_width(truncate_at: int = 0): def truncate_destination_addr(addr): return f"{addr[:truncate_at]}..." @@ -129,7 +129,7 @@ class PSBTOverviewScreen(ButtonListScreen): destination_column.append(truncate_destination_addr(addr)) for i in range(0, self.num_self_transfer_outputs): - destination_column.append(f"self-transfer") + destination_column.append(truncate_destination_addr("self-transfer")) else: # destination_column.append(f"{len(self.destination_addresses)} recipients") destination_column.append(f"recipient 1") @@ -151,7 +151,7 @@ class PSBTOverviewScreen(ButtonListScreen): if len(self.destination_addresses) + self.num_self_transfer_outputs > 3: # We're not going to display any destination addrs so truncation doesn't matter - (destination_text_width, destination_column) = calculate_destination_col_width(truncate_at=0) + (destination_text_width, destination_column) = calculate_destination_col_width() else: # Steadliy widen out the destination column until we run out of space for i in range(6, 13): From fc988418e68ed3768cb498edc784b485a19fce5c Mon Sep 17 00:00:00 2001 From: kdmukai Date: Thu, 26 May 2022 09:52:49 -0500 Subject: [PATCH 2/3] Update psbt_screens.py Ensure that regular displays that don't have space constraints aren't unnecessarily truncated. --- src/seedsigner/gui/screens/psbt_screens.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/seedsigner/gui/screens/psbt_screens.py b/src/seedsigner/gui/screens/psbt_screens.py index b25fad79..17c1eb04 100644 --- a/src/seedsigner/gui/screens/psbt_screens.py +++ b/src/seedsigner/gui/screens/psbt_screens.py @@ -120,6 +120,9 @@ class PSBTOverviewScreen(ButtonListScreen): # Now let's maximize the actual destination col by adjusting our addr truncation def calculate_destination_col_width(truncate_at: int = 0): def truncate_destination_addr(addr): + if len(addr) <= truncate_at + len("..."): + # No point in truncating + return addr return f"{addr[:truncate_at]}..." destination_column = [] @@ -154,7 +157,7 @@ class PSBTOverviewScreen(ButtonListScreen): (destination_text_width, destination_column) = calculate_destination_col_width() else: # Steadliy widen out the destination column until we run out of space - for i in range(6, 13): + for i in range(6, 14): (new_width, new_col_text) = calculate_destination_col_width(truncate_at=i) if new_width > max_destination_col_width: break From 6f6062254a2ae9cd52fe224ac3aa515f03901304 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Thu, 26 May 2022 09:54:58 -0500 Subject: [PATCH 3/3] Note for upcoming issue with translations --- src/seedsigner/gui/screens/psbt_screens.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/seedsigner/gui/screens/psbt_screens.py b/src/seedsigner/gui/screens/psbt_screens.py index 17c1eb04..053d47e5 100644 --- a/src/seedsigner/gui/screens/psbt_screens.py +++ b/src/seedsigner/gui/screens/psbt_screens.py @@ -120,6 +120,7 @@ class PSBTOverviewScreen(ButtonListScreen): # Now let's maximize the actual destination col by adjusting our addr truncation def calculate_destination_col_width(truncate_at: int = 0): def truncate_destination_addr(addr): + # TODO: Properly handle the ellipsis truncation in different languages if len(addr) <= truncate_at + len("..."): # No point in truncating return addr