Rewrap ConsoleUI textbox for scrollbar and resize #3514
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problems
Noticed while testing RP-1 express install in ConsoleUI for #3512, because a Mac user asked about RP-1 on the forum.
Causes
ConsoleTextBox
performs word wrap on each line as it is added, using the full width without the scrollbar. Words longer than the textbox width are split at the width of the textbox at the time they are added. If that width later changes, by either the addition of a scrollbar or the resizing of the window, the old wrapping is retained as-is.Changes
Now we store the original full strings in
lines
and the word-wrapped strings indisplayLines
.AddLine
appends its raw input to the former and word-wraps it into the latter. A scrollbar-awarerewrapLines()
function re-does this word wrapping as needed, and we call this function when we first add the scrollbar as well as anytime the textbox size changes. This will ensure that the scrollbar never overwrites characters, and the word wrap always fits the box properly.