Skip to content

Conversation

@hawkw
Copy link
Member

@hawkw hawkw commented Dec 18, 2021

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.

Screenshots

On the main branch, we don't wrap. Here's a wide enough terminal:
image
...and here's one that's too narrow:
image

After this change, when the terminal is wide enough, it looks the same:
image
...but if the terminal is too narrow, it wraps:
image

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 more
work than just wrapping on whitespace, and the current thing is better
than it was before!

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.
Copy link
Collaborator

@zaharidichev zaharidichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@hawkw hawkw merged commit ef41507 into main Dec 18, 2021
@hawkw hawkw deleted the eliza/word-wrap-controls branch December 18, 2021 22:25
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants