From 0230ecfd204008b74bf4fb238bf55122b14619d8 Mon Sep 17 00:00:00 2001 From: coreylakey Date: Thu, 19 Aug 2021 08:19:57 -0700 Subject: [PATCH] Add constant for max message length --- ports/stm32/boards/Passport/modules/constants.py | 3 +++ ports/stm32/boards/Passport/modules/display.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ports/stm32/boards/Passport/modules/constants.py b/ports/stm32/boards/Passport/modules/constants.py index 8f22c3f..9554d6f 100644 --- a/ports/stm32/boards/Passport/modules/constants.py +++ b/ports/stm32/boards/Passport/modules/constants.py @@ -39,3 +39,6 @@ MAX_ACCOUNT_NAME_LEN = 20 MAX_MULTISIG_NAME_LEN = 20 DEFAULT_ACCOUNT_ENTRY = {'name': 'Primary', 'acct_num': 0} + +# Maximum amount of characters in a text entry screen +MAX_MESSAGE_LEN = 64 \ No newline at end of file diff --git a/ports/stm32/boards/Passport/modules/display.py b/ports/stm32/boards/Passport/modules/display.py index 948f3cf..ca7e614 100644 --- a/ports/stm32/boards/Passport/modules/display.py +++ b/ports/stm32/boards/Passport/modules/display.py @@ -195,10 +195,11 @@ class Display: def text_input(self, x, y, msg, font=FontSmall, invert=0, cursor_pos=None, visible_spaces=False, fixed_spacing=None, cursor_shape='line'): from ux import word_wrap from utils import split_by_char_size + from constants import MAX_MESSAGE_LEN - # Maximum message size is 64 characters - if len(msg) >= 64: - msg = msg[:64] + # Maximum message size is MAX_MESSAGE_LEN (64) characters + if len(msg) >= MAX_MESSAGE_LEN: + msg = msg[:MAX_MESSAGE_LEN] if hasattr(msg, 'readline'): lines = split_by_char_size(msg.getvalue(), font)