Skip to content
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

Re-wrapping output when window is resized #6

Open
12Me21 opened this issue Sep 14, 2021 · 1 comment
Open

Re-wrapping output when window is resized #6

12Me21 opened this issue Sep 14, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@12Me21
Copy link
Owner

12Me21 commented Sep 14, 2021

Basically i guess how this would work is,
each line has a flag for whether it ended in a wrap or a newline (and where the newline was, since there could be trailing whitespace)

when the window is resized, we take the array of lines, and combine all the consecutive lines which ended in a wrap (i.e. undoing the wrapping which happened when they were printed). then take these L O N G lines and split them based on the new terminal width
(this can be optimized to be done in one pass without extra memory usage, but that's the basic idea)

There may be other considerations to consider, but generally this seems to work fine across the terminals that support it so I doubt it's very complicated.
Of course this will only work for simple text output (and not graphical TUI programs etc.), but this will only apply to the main screen so that doesn't matter.

The main trouble seems to come from the shell prompt fighting with the re-wrapper, but I'm pretty sure I've seen terminals which don't have this issue so it's probably possible to fix.

@12Me21 12Me21 added the enhancement New feature or request label Sep 14, 2021
@y-ack
Copy link

y-ack commented Aug 10, 2023

this is a pretty important feature imo. i tend to snap windows around depending on the references i have open next to them.
wrap/newline tracking is also important for copying rectangular text selections and not getting like a bunch of spaces or other Bad Characters..

(it only has to apply to the main screen because the alt buffer programs self-repaint on resize anyway)

wt calls it "reflow" and has test cases here: https://github.com/microsoft/terminal/blob/main/src/buffer/out/ut_textbuffer/ReflowTests.cpp
they also have a long-standing issue called "the exact wrap bug" that may be a special concern(doesn't know) microsoft/terminal#3088
i think wt may also have some trouble with cursor position/re-printing/not clearing prompts after reflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants