New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination for sign/verify message #1384
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Your render_text
is much more readable. UI diff looks legit.
this is now ready for review, modulo passing CI checks. @prusnak you're tagged for reviewing the C rendering code changes for @mmilata: I implemented the "mock out There is also a proper UI test for the paginated signmessages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!! Left some comments inline.
Went through the UI diff, the changes are either barely perceptible or a clear improvement to the previous state.
core/src/trezor/ui/text.py
Outdated
def next_line(self) -> bool: | ||
"""Advance the span to point to contents of the next line. | ||
|
||
Returns True if the rendered should make newline afterwards, False if this is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo - rendered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in a83f110
core/src/trezor/ui/text.py
Outdated
the first character of the indicated item which should be considered. | ||
The purpose is to allow rendering different "pages" of text, using the same `items` | ||
argument (slicing the list could be expensive in terms of memory). | ||
The item selected by `item_offset` must be a string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: paginate_lines
violates this statement (item_offset
is font) though I don't think it poses a problem, maybe just remove the sentence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a problem actually, it reveals a bug: font instructions that precede item_offset
are going to be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 02ca00d
core/src/trezor/ui/text.py
Outdated
if isinstance(word, int): | ||
if word is BR or word is BR_HALF: | ||
if isinstance(item, int): | ||
if item is BR or item is BR_HALF: | ||
# line break or half-line break | ||
if offset_y > offset_y_max: | ||
ui.display.text(offset_x, offset_y, "...", ui.BOLD, ui.GREY, bg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this also be conditional on render_page_overflow
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in a83f110
message_read = "" | ||
message += "End." | ||
|
||
def input_flow(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope for this PR but I'm wondering how to generalize this for other tests to use. Would be nice to record fixtures for all the pageable screens in tests that have them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, we'd need a debuglink indication that a screen is paginated, and ideally a page position as well.
relatively easy to implement, but i'm thinking maybe the redesign of ButtonRequests will solve this too?
a83f110
to
2cb10ce
Compare
rebased on master, added changelogs. ping @prusnak for C review, otherwise ready to merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use const char *
instead of char *
to indicate we are not modifying the contents of the string, just slicing it.
Feel free to cherry-pick 1c9e247 with the suggested changes. |
cherry-pick applied |
* use less memory due to copy-less rendering * implement linebreaking on embedded \n
6541908
to
ebc67c9
Compare
based on and supersedes #1337
The biggest part of this PR is actually a refactor of the
render_text
function, which adds three new outward-facing features:Span
class can be used to count lines in a stringIncludes @mmilata's patch to modtrezordisplay that allows rendering substrings, and takes advantage of this in
render_text
to avoid slicing passed-in strings. This causes rather solid savings in memory allocations: 114k allocs in text.py vs master's ~147k (i don't have a link to an artifact with this :( )notably, there are zero allocations in calling
render_text
the newlines rendering means that we can use the following going forward
old:
new:
which is an important step in #1005