Increase word wrap with auto-detected terminal width#109
Merged
Conversation
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
5eb75f1 to
e20a532
Compare
maxatome
reviewed
Nov 29, 2025
internal/display/display.go
Outdated
| wordWrap := 80 | ||
| termFd := os.Stdout.Fd() | ||
| if term.IsTerminal(termFd) { | ||
| termWidth, _, _ := term.GetSize(os.Stdout.Fd()) |
Member
There was a problem hiding this comment.
style: could be more compact
Suggested change
| termWidth, _, _ := term.GetSize(os.Stdout.Fd()) | |
| if termWidth, _, _ := term.GetSize(termFd); termWidth > 0 { |
Contributor
Author
There was a problem hiding this comment.
Good point, I also missed using termFd here. I've changed that.
internal/display/display.go
Outdated
| // Use 80 characters by default, or the terminal width if available. | ||
| wordWrap := 80 | ||
| termFd := os.Stdout.Fd() | ||
| if term.IsTerminal(termFd) { |
Member
There was a problem hiding this comment.
Limit the scope of termFd:
Suggested change
| if term.IsTerminal(termFd) { | |
| if termFd := os.Stdout.Fd(); term.IsTerminal(termFd) { |
Contributor
Author
There was a problem hiding this comment.
Also changed this.
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
0cdf2d4 to
5a58a2e
Compare
amstuta
approved these changes
Dec 3, 2025
Collaborator
amstuta
left a comment
There was a problem hiding this comment.
Thank you for your contribution @TheoBrigitte ! This is a nice improvement :)
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.
Description
I found it quite difficult to read through some of the output of some commands sometimes, notably the
domain-zone getmight be quite long, with many entries and very wide entries sometimes, like with the Let's Encrypt and other kind of TXT records. I though this could be improved by making use of the full width available in the terminal window rather than being constrained to 80 columns.This PR proposes a changes in the way the output is rendered when displaying some markdown content. It does so by trying to read the terminal width and if found use it as word wrap limit, otherwise keep the current behavior of 80 word wrap.
Before
note that the table does not end here and continues afterward
After
here I can see the entire records table in one go
Type of change
Checklist:
make docgo mod tidy