refactor(core): no implicit spaces in render_text

pull/1533/head
Martin Milata 3 years ago
parent 2a5f5c1c20
commit b1e38fe382

@ -47,9 +47,8 @@ async def require_confirm_verify_message(
ctx: wire.Context, address: str, coin: str, message: bytes
) -> None:
header = "Verify {} message".format(coin)
text = Text(header, new_lines=False)
text = Text(header)
text.bold("Confirm address:")
text.br()
text.mono(*split_address(address))
await require_confirm(ctx, text)

@ -20,7 +20,7 @@ async def require_confirm_tx(ctx, to_bytes, value, chain_id, token=None, tx_type
to_str = "new contract?"
text = Text("Confirm sending", ui.ICON_SEND, ui.GREEN, new_lines=False)
text.bold(format_ethereum_amount(value, token, chain_id, tx_type))
text.normal(ui.GREY, "to", ui.FG)
text.normal(ui.GREY, " to ", ui.FG)
for to_line in split_address(to_str):
text.br()
text.mono(to_line)
@ -33,9 +33,9 @@ async def require_confirm_fee(
):
text = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN, new_lines=False)
text.bold(format_ethereum_amount(spending, token, chain_id, tx_type))
text.normal(ui.GREY, "Gas price:", ui.FG)
text.normal(" ", ui.GREY, "Gas price:", ui.FG)
text.bold(format_ethereum_amount(gas_price, None, chain_id, tx_type))
text.normal(ui.GREY, "Maximum fee:", ui.FG)
text.normal(" ", ui.GREY, "Maximum fee:", ui.FG)
text.bold(format_ethereum_amount(gas_price * gas_limit, None, chain_id, tx_type))
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)

@ -99,9 +99,9 @@ async def _continue_dialog(ctx: wire.Context, msg: RecoveryDevice) -> None:
text.br_half()
text.normal("By continuing you agree")
text.br()
text.normal("to")
text.normal("to ")
text.bold("https://trezor.io/tos")
else:
text = Text("Seed check", ui.ICON_RECOVERY, new_lines=False)
text.normal("Do you really want to", "check the recovery", "seed?")
text.normal("Do you really want to check the recovery seed?")
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)

@ -9,9 +9,8 @@ from .helpers import NEM_MAX_DIVISIBILITY
async def require_confirm_text(ctx, action: str):
content = action.split(" ")
text = Text("Confirm action", ui.ICON_SEND, ui.GREEN, new_lines=False)
text.normal(*content)
text.normal(action)
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)

@ -243,8 +243,6 @@ def render_text(
else:
fg = item
SPACE = ui.display.text_width(" ", font)
for item_index in range(item_offset, len(items)):
# load current item
item = items[item_index]
@ -261,7 +259,6 @@ def render_text(
elif item in _FONTS:
# change of font style
font = item
SPACE = ui.display.text_width(" ", font)
else:
# change of foreground color
fg = item
@ -278,7 +275,7 @@ def render_text(
):
offset_y += TEXT_LINE_HEIGHT
ui.display.text(INITIAL_OFFSET_X, offset_y, item, font, fg, bg)
offset_x = INITIAL_OFFSET_X + item_width + SPACE
offset_x = INITIAL_OFFSET_X + item_width
continue
span.reset(
@ -320,7 +317,7 @@ def render_text(
offset_y += TEXT_LINE_HEIGHT
elif span.width > 0:
# only advance cursor if we actually rendered anything
offset_x += span.width + SPACE
offset_x += span.width
if __debug__:
@ -415,7 +412,7 @@ class TextBase(ui.Component):
parts = format_string.split("{}", len(params))
for i in range(len(parts)):
self.content.append(font)
self.content.append(parts[i].strip(" "))
self.content.append(parts[i])
if i < len(parts) - 1 and i < len(params):
param = params[i]
self.content.append(param_font)

@ -132,7 +132,7 @@ async def confirm_reset_device(ctx: wire.GenericContext, prompt: str) -> bool:
text.br_half()
text.normal("By continuing you agree")
text.br()
text.normal("to")
text.normal("to ")
text.bold("https://trezor.io/tos")
return is_confirmed(
await interact(

@ -46,7 +46,7 @@ def set_autolock_delay(device_handler, delay_ms):
debug.input("1234")
layout = debug.wait_layout()
assert f"auto-lock your device after {delay_ms // 1000} seconds" in layout.text
assert f"auto-lock your device after {delay_ms // 1000} seconds" in layout.text
debug.click(buttons.OK)
layout = debug.wait_layout()

@ -67,20 +67,20 @@
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[withdrawal_amount_is_too_large]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[withdrawal_has_non_staking_path]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
"cardano-test_sign_tx.py::test_cardano_sign_tx_with_multiple_chunks[large_transaction_to_be_-377cb9ff": "4a46dd8ac42295d853646a55ca1b85023b2235af6155be663b1de10a6c98def2",
"test_autolock.py::test_apply_auto_lock_delay": "de8ddc62320c82938920fa6b7d95cb571bd7fa766b192549971a975e24cc0b34",
"test_autolock.py::test_apply_auto_lock_delay": "d6b79c89a21e8979a6cede0715ea3d83a5c786ae7445dad797cf668ed6bf6180",
"test_autolock.py::test_apply_auto_lock_delay_out_of_range[0]": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_autolock.py::test_apply_auto_lock_delay_out_of_range[1]": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_autolock.py::test_apply_auto_lock_delay_out_of_range[4194304]": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_autolock.py::test_apply_auto_lock_delay_out_of_range[536871]": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_autolock.py::test_apply_auto_lock_delay_out_of_range[9]": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_autolock.py::test_apply_auto_lock_delay_valid[10]": "1c4d26c24483449997b79f385e2a6eab000dfca98bfe8f3c08e7f007370fca1c",
"test_autolock.py::test_apply_auto_lock_delay_valid[123]": "8c9f07104463543083dfb461810a5fc8727e3a2c09644b4b3e423a43970a72c7",
"test_autolock.py::test_apply_auto_lock_delay_valid[3601]": "941179a4f674b1c3d7004cc7073a29b327c70246eb853aa29f31e2e261f329e6",
"test_autolock.py::test_apply_auto_lock_delay_valid[536870]": "dd430048994310dee37453ae03dfe9c1e15c2fc2ce952dd755bf5df27730907f",
"test_autolock.py::test_apply_auto_lock_delay_valid[60]": "a0e602c8c04eae2dc6dd0768f0a627bcc0327b69d6a9645ecbc3e02f0e4c7908",
"test_autolock.py::test_apply_auto_lock_delay_valid[7227]": "f9e78f3bf23f4808d105da5ae1abc4f25ee550b7590aec0c15fcfb041eeb4413",
"test_autolock.py::test_autolock_cancels_ui": "a63bbf50bb612a87c459b27fe87b38f7b3e984b46c9d68b7604e40667072adc6",
"test_autolock.py::test_autolock_default_value": "e3e6a55dae2c8b152477080002d8b734e1bafe00f26e138294969e2dfd9c596e",
"test_autolock.py::test_apply_auto_lock_delay_valid[10]": "f720426dd1f7038af5af0a96e4bcf60498aab1414f2f2828b57bfdb0e3d9a73e",
"test_autolock.py::test_apply_auto_lock_delay_valid[123]": "0362fad4d8a7aec2d0227f78f8b919a903343a3397a8442ad73bc8665a51bac8",
"test_autolock.py::test_apply_auto_lock_delay_valid[3601]": "50672aa321fbde95e976f00ae8bb329712a828af4d1121563a25a57593fc4cea",
"test_autolock.py::test_apply_auto_lock_delay_valid[536870]": "1184da463fcb4210f7fb7421332d980dad73374902b3bfc5e03e0054ff99c09b",
"test_autolock.py::test_apply_auto_lock_delay_valid[60]": "f6a45cc230422d938b1f47a7f3ffa3cbff5809b79d8f009860a28caa37b4d0bc",
"test_autolock.py::test_apply_auto_lock_delay_valid[7227]": "aec1624c900d995f114515b72a1dbcd4aea46345f0ac4bedeaf647875b063b44",
"test_autolock.py::test_autolock_cancels_ui": "cd8018fe8a79cdb701ff6468a7c43d5dd12ff1d47804320244a414061e805263",
"test_autolock.py::test_autolock_default_value": "8e4e95d6b18440bf42712c667ba3b88b55f66d02a6205bb28bb2e01b64c96377",
"test_basic.py-test_device_id_different": "bc6acd0386b9d009e6550519917d6e08632b3badde0b0cf04c95abe5f773038a",
"test_basic.py-test_device_id_same": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_basic.py-test_features": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
@ -106,11 +106,11 @@
"test_msg_applysettings.py-test_apply_homescreen_toif_fail[TOIf\\x80\\x00\\x80\\x00~\\x00\\x00\\x00-fefdb3aa": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_msg_applysettings.py-test_apply_homescreen_toif_fail[TOIf\\x90\\x00\\x90\\x00~XXXf\\x90\\x00-4f4d817c": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_msg_applysettings.py-test_apply_homescreen_toif_fail[TOIg\\x90\\x00\\x90\\x00~\\x00\\x00\\x00-63ffc926": "6badfcdd682ecaf16311749ef7a6c07c6a4d0df402427c8dd5a48d476751ed77",
"test_msg_applysettings.py-test_apply_settings": "9394ea770233a5679c6292c7afe75f4d3528f1b1576f47e6bef8ede6276eec8b",
"test_msg_applysettings.py-test_apply_settings": "63f5bb37fce2d6bafee3d55bdb78eb38409605e0f603d3987465d2c4903f9ddb",
"test_msg_applysettings.py-test_apply_settings_passphrase": "40de0143b32b5d06ece43d47be27bb91499f0c2417754ddb8e9e03ff41a7f6d4",
"test_msg_applysettings.py-test_apply_settings_passphrase_on_device": "3e6527e227bdde54f51bc9c417b176d0d87fdb6c40c4761368f50eb201b4beed",
"test_msg_applysettings.py-test_apply_settings_rotation": "5789f4a9274b8a37af5b279296cf13a95be6e528738474a1c64d36bb0692e216",
"test_msg_applysettings.py-test_experimental_features": "388d5f0ee2e8c521fd82bf8687bd5bdba26ed34695d2a1aecb28f6a72df8df4c",
"test_msg_applysettings.py-test_apply_settings_rotation": "b4983c819399cc837b3634e1de7638b6c31c72354fe097ebd0abeebb5cadbea9",
"test_msg_applysettings.py-test_experimental_features": "e92e61f71380804323835b062e328834e9450e86d99aa7be6678edc4e971ebdf",
"test_msg_applysettings.py-test_label_too_long": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_msg_applysettings.py-test_safety_checks": "4d37de3654678b7f16643cf4ef912a0bced545e0e0526e41ea0c9b820560344e",
"test_msg_authorize_coinjoin.py::test_cancel_authorization": "d8a608beb6165f5667cc44dcff6bdc17ebb4638ddd3bd09e7f0e1e75d1e21135",
@ -588,7 +588,7 @@
"test_msg_verifymessage_segwit_native.py-test_message_verify": "3aeca0b02254b83988008b5129812a749f320add09146d189fa294f2b5c80c34",
"test_msg_verifymessage_segwit_native.py-test_verify_utf": "62d12291ee0f0d4639d861ea61d55c9944c37aad24bd70dd35877e9d12a2b731",
"test_msg_webauthn.py::test_add_remove": "a9cdefeb089f197427257e097d07179b23de4fcad4ee91af0191ed767f80577c",
"test_msg_wipedevice.py::test_autolock_not_retained": "b07784bf0739fcc5d5877f2a1670b88e10019346c56f9864b48d5cb56944b07b",
"test_msg_wipedevice.py::test_autolock_not_retained": "74e2b2af49f2153886519108b4e11e250a6a5ff76d27da333066af7afc76bb5f",
"test_msg_wipedevice.py::test_wipe_device": "bc6acd0386b9d009e6550519917d6e08632b3badde0b0cf04c95abe5f773038a",
"test_multisig.py-test_15_of_15": "9d1799a199b45785ac69ae6af715c251b10aebb60f981c9b73d78e53e1a91374",
"test_multisig.py-test_2_of_3": "2be92556edf4ff8eed340d535f379ee6915eae34fef25d669ce865848e7b4705",

Loading…
Cancel
Save