-
Notifications
You must be signed in to change notification settings - Fork 111
feat: wrap lines longer than the terminal width #364
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
base: master
Are you sure you want to change the base?
Conversation
I have added tests and snapshots for the wrapping behaviour, to demonstrate some aspects of it like the cursor taking up multiple lines, etc. but I haven't updated all the existing snapshots because there is a potentially controversial change: I opted to widen the "gutter" (where the cursor is displayed) to 2 columns, one for the cursor and one for the wrap indicator. From my perspective showing the wrap indicator is a much better user experience than showing nothing, because otherwise it feels like the cursor behaves inconsistently (since you can't always see what's a wrap without the indicator.) I wanted to indent the wrapped lines by 1, so that I could make the extra gutter space only when needed, but The problem is that this would require me to update all the other snapshots, and I wanted to get your opinion on this before going off and bloating the PR with all of those changes. |
As far as the implementation goes, I don't know if this is a good approach. I thought that using ratatui's
![]() Edit: I think there is a bug in |
04177a3
to
0aa0c2f
Compare
Previously long lines would be truncated, now instead they are wrapped and a wrap indicator displayed at the front of each line, after the first one. The wrap indicator and collapse indicators are configurable.
0aa0c2f
to
ee07e89
Compare
Text wrapping is a great addition! About adding an exta column to the gutter, I suppose it's possible.
Or even doing both?
One currently annoying thing though, if you double-click to select a whole word in a terminal, say you want to select and copy the commit hash:
Then this would be selected: TermwizI've been peeking at perhaps switching over and rewriting the rendering code to use Termwiz entirely instead. It's more low-level, but also feels more intuitive in that widgets can actually have a determined size (Ratatui seems to be all around deciding the size of containers first, and then the widget will have to make use of the size its given). NavigationI think there is the assumption in this module when it comes to navigation where it assumes an Item is always a single line. It might be that there's some weird behavior upon navigating if a lot of line-wrapping is in place.
Found here: Lines 235 to 256 in 6b9e124
|
Leaving the cursor/selection out for a continuation is a good idea.
Adding the extra gutter column seems to improve this, at least in my terminal.
The navigation seems to work okay, at least as far as I could tell. What could I try to produce a mismatched line issue? I figured that since the line wrapping is happening only at the render point, that what happens in effect is that the virtual lines (for items) are modelled as single lines (that can never wrap), but at the point they become characters in the terminal then they end up being wrapped, although the model logic doesn't know (or care) that the renderer does that. |
38016e3
to
afd3c4d
Compare
One example is when navigating below the visible view, the view should scroll along with the cursor. But if enough lines are wrapped, then it would be delayed. There is logic in the screen module that makes assumptions about navigation from the size of the view. The |
Previously long lines would be truncated, now instead they are wrapped and a wrap indicator displayed at the front of each line, after the first one.
The wrap indicator and collapse indicators are configurable.
Fixes #277