-
-
Notifications
You must be signed in to change notification settings - Fork 163
fix(console): wrap controls line when the terminal is too narrow #231
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, the controls line for table views is never wrapped, even if it's too long to fit on a single line in the current terminal width. This isn't great...especially since PR #223 is adding more controls, and will make the line even longer. This branch allows wrapping the controls paragraph if it doesn't fit in the current area. The code for this was surprisingly complex: while `tui` supports wrapping text, layout area sizes are determined _before_ text wrapping. So, we can't just say "use as many lines as are necessary to fit this text in the current terminal width", we have to implement that logic ourselves, and pass the required number of lines to the `Layout::constraints` method.
zaharidichev
approved these changes
Dec 18, 2021
Collaborator
zaharidichev
left a comment
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!
hawkw
added a commit
that referenced
this pull request
Jan 18, 2022
<a name=""></a> ## (2022-01-18) #### Features * feature-flag `tracing-journald` dependency (#250) ([24f25db](24f25db)) * add vi style keybinds for tables (#223) ([1845c99](1845c99)) #### Bug Fixes * fix task lookup in async ops view (#257) ([9a50b63](9a50b63)) * don't make details requests with rewritten IDs (#251) ([4ec26a8](4ec26a8)) * fix build error with journald enabled ([a931b7e](a931b7e)) * increase default event buffer capacity a bit (#235) ([0cf0aee](0cf0aee)) * wrap controls line when the terminal is too narrow (#231) ([ef41507](ef41507)) * don't enable crossterm mouse capture (#222) ([e020d66](e020d66), closes [#167](167))
hawkw
added a commit
that referenced
this pull request
Jan 18, 2022
<a name=""></a> ## (2022-01-18) #### Features * feature-flag `tracing-journald` dependency (#250) ([24f25db](24f25db)) * add vi style keybinds for tables (#223) ([1845c99](1845c99)) #### Bug Fixes * fix task lookup in async ops view (#257) ([9a50b63](9a50b63)) * don't make details requests with rewritten IDs (#251) ([4ec26a8](4ec26a8)) * fix build error with journald enabled ([a931b7e](a931b7e)) * increase default event buffer capacity a bit (#235) ([0cf0aee](0cf0aee)) * wrap controls line when the terminal is too narrow (#231) ([ef41507](ef41507)) * don't enable crossterm mouse capture (#222) ([e020d66](e020d66), closes [#167](167))
hawkw
added a commit
that referenced
this pull request
Jan 18, 2022
<a name=""></a> ## (2022-01-18) #### Features * feature-flag `tracing-journald` dependency (#250) ([24f25db](24f25db)) * add vi style keybinds for tables (#223) ([1845c99](1845c99)) #### Bug Fixes * fix task lookup in async ops view (#257) ([9a50b63](9a50b63)) * don't make details requests with rewritten IDs (#251) ([4ec26a8](4ec26a8)) * fix build error with journald enabled ([a931b7e](a931b7e)) * increase default event buffer capacity a bit (#235) ([0cf0aee](0cf0aee)) * wrap controls line when the terminal is too narrow (#231) ([ef41507](ef41507)) * don't enable crossterm mouse capture (#222) ([e020d66](e020d66), closes [#167](167))
hawkw
added a commit
that referenced
this pull request
Jan 18, 2022
<a name=""></a> ## (2022-01-18) #### Features * feature-flag `tracing-journald` dependency (#250) ([24f25db](24f25db)) * add vi style keybinds for tables (#223) ([1845c99](1845c99)) #### Bug Fixes * fix task lookup in async ops view (#257) ([9a50b63](9a50b63)) * don't make details requests with rewritten IDs (#251) ([4ec26a8](4ec26a8)) * fix build error with journald enabled ([a931b7e](a931b7e)) * increase default event buffer capacity a bit (#235) ([0cf0aee](0cf0aee)) * wrap controls line when the terminal is too narrow (#231) ([ef41507](ef41507)) * don't enable crossterm mouse capture (#222) ([e020d66](e020d66), closes [#167](167))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, the controls line for table views is never wrapped, even if
it's too long to fit on a single line in the current terminal width.
This isn't great...especially since PR #223 is adding more controls, and
will make the line even longer.
This branch allows wrapping the controls paragraph if it doesn't fit in
the current area. The code for this was surprisingly complex: while
tuisupports wrapping text, layout area sizes are determined beforetext wrapping. So, we can't just say "use as many lines as are necessary
to fit this text in the current terminal width", we have to implement
that logic ourselves, and pass the required number of lines to the
Layout::constraintsmethod.Screenshots
On the main branch, we don't wrap. Here's a wide enough terminal:


...and here's one that's too narrow:
After this change, when the terminal is wide enough, it looks the same:


...but if the terminal is too narrow, it wraps:
It might be nice to change this code to only wrap on commas, so each
<keys> = <description>isn't broken...but that seems like a lot morework than just wrapping on whitespace, and the current thing is better
than it was before!