Export the current output width to watched program as COLUMNS environment variable#140
Draft
ilyagr wants to merge 3 commits intoblacknon:masterfrom
Draft
Export the current output width to watched program as COLUMNS environment variable#140ilyagr wants to merge 3 commits intoblacknon:masterfrom
COLUMNS environment variable#140ilyagr wants to merge 3 commits intoblacknon:masterfrom
Conversation
COLUMNS environment variable
Contributor
Author
|
It's also worth noting that there is a more heavy-weight potential solution of running the program in a pty, as in sachaos/viddy#8. However, I don't think that would work on Windows unless there's a cross-platform library. Just for reference, https://github.com/Watfaq/PowerSession-rs probably includes similar functionality for Windows. However, somebody else would have to be interested in researching it further. |
68b4592 to
03a9111
Compare
ilyagr
added a commit
to ilyagr/dotfiles
that referenced
this pull request
Jul 8, 2024
f5fb20e to
86dfa3d
Compare
COLUMNS is part of the [POSIX standard](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03).
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
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.
This is WIP, but I'll put it here since it's:
Now that borders and scroll bars are implemented, commands I use often wrap to the wrong number of columns. This has always been the case when the history window is open. This is because they get the full terminal width from the terminal and don't know that
hwatchis using some columns for the UI.There is, in fact, at least one standard way to address this: set the
COLUMNSvariable. Many programs, e.g.git diff --statand Git in general, already support it.COLUMNS is part of POSIX (apparently, the 2017 edition of the standard is freely available on that site).
My implementation works, but has one problem: COLUMNS is not set at the first program invocation, resulting in the user seeing a badly wrapped screen until the first update. Fixing this might require a bit of a refactor, I'm thinking about how best to do it.
A good way to test this is:
and then play with toggling UI/border/etc.