Browse Source

Add constant for max message length

PASS1-112
coreylakey 4 years ago
parent
commit
0230ecfd20
  1. 3
      ports/stm32/boards/Passport/modules/constants.py
  2. 7
      ports/stm32/boards/Passport/modules/display.py

3
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

7
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)

Loading…
Cancel
Save