Skip to content

Re-wrapping output when window is resized #6

@12Me21

Description

@12Me21

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions