Skip to content

text/tabwriter: add ANSI Graphics Rendition format - #35017

Closed
kindermoumoute wants to merge 2 commits into
golang:masterfrom
kindermoumoute:master
Closed

kindermoumoute wants to merge 2 commits into
golang:masterfrom
kindermoumoute:master

Conversation

@kindermoumoute

Copy link
Copy Markdown

Updates #12073

@googlebot

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no Used by googlebot to label PRs as having an invalid CLA. The text of this label should not change. label Oct 20, 2019
@kindermoumoute

Copy link
Copy Markdown
Author

@googlebot I signed it!

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change. and removed cla: no Used by googlebot to label PRs as having an invalid CLA. The text of this label should not change. labels Oct 20, 2019
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: e67952e) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/202257 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Brad Fitzpatrick:

Patch Set 1:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/202257.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Gobot Gobot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
Within the next week or so, a maintainer will review your change and provide
feedback. See https://golang.org/doc/contribute.html#review for more info and
tips to get your patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11, it means that this CL will be reviewed as part of the next development
cycle. See https://golang.org/s/release for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/202257.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 8891f48) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/202257 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot

Copy link
Copy Markdown
Contributor

Message from olivier cano:

Patch Set 2:

(2 comments)

Patch Set 1:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/202257.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Robert Griesemer:

Patch Set 2:

Except for the (general) issue #12073, has this change been discussed somewhere? Why should we allow this specific escape sequence and not others? Where does it stop?


Please don’t reply on this GitHub thread. Visit golang.org/cl/202257.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from olivier cano:

Patch Set 2:

Patch Set 2:

Except for the (general) issue #12073, has this change been discussed somewhere? Why should we allow this specific escape sequence and not others? Where does it stop?

The general issue is that text/tabwriter cannot work with ANSI SGR formatting. This affect mostly CLI developers that want to display colors/format in a terminal.


Please don’t reply on this GitHub thread. Visit golang.org/cl/202257.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Robert Griesemer:

Patch Set 2:

Patch Set 2:

Patch Set 2:

Except for the (general) issue #12073, has this change been discussed somewhere? Why should we allow this specific escape sequence and not others? Where does it stop?

The general issue is that text/tabwriter cannot work with ANSI SGR formatting. This affect mostly CLI developers that want to display colors/format in a terminal.

Sorry, I dropped the ball here - and now it's too late for 1.14.

That said, while this change is mostly innocuous, I'm not comfortable with it because it opens the door to other escape sequences that we may want to filter - so we end up with a list of flags for all kinds of variations. A better solution would be a more general mechanism instead (I'm imagining some kind of filter function that one could install).

But since this package is effectively frozen, there shouldn't be too much harm in making a copy and adjust it as you see fit. There's unlikely going to be a lot of work to keep it in sync with this one.

If you like to pursue this still, please bring it up early in the Go 1.15 release cycle and we can try to find a more general mechanism, perhaps.

Thanks.


Please don’t reply on this GitHub thread. Visit golang.org/cl/202257.
After addressing review feedback, remember to publish your drafts!

martymichal added a commit to martymichal/toolbox that referenced this pull request Jul 8, 2020
The rewritten Toolbox did not highlight running containers because the
code uses a special table writter from 'text/tabwriter' that does not
support ANSI color codes[0]. The solution used here is to use color
codes on _every_ lines of the output (including headers) and make the
color codes use the same number of characters.

In my terminals (Tilix, GNOME Terminal) the output looks alright.

[0] golang/go#35017
debarshiray pushed a commit to martymichal/toolbox that referenced this pull request Jul 22, 2020
The rewritten Toolbox did not highlight running containers because the
code uses a special table writter from 'text/tabwriter' that does not
support ANSI color codes[0]. The solution used here is to use color
codes on _every_ lines of the output (including headers) and make the
color codes use the same number of characters.

In my terminals (Tilix, GNOME Terminal) the output looks alright.

[0] golang/go#35017

containers#494
debarshiray pushed a commit to martymichal/toolbox that referenced this pull request Jul 22, 2020
The Go implementation did not highlight running containers because it
uses a special table writer from 'text/tabwriter' that does not
support colored output [0].

The trick used here is to use ANSI SGR terminal escape sequences [1]
on every line output by the table writer, including headers, and make
the escape sequences use the same number of characters. eg., even
though it's idiomatic to use "\033[0m" to reset the SGR attributes,
such as color; each non-colored line is prefixed with "\033[0;00m" to
ensure that it has the same number of characters as "\033[1;32m", which
is used for bold green output.

Therefore, not only are the non-colored lines wrapped in a redundant
pair of ANSI SGR terminal escape sequences, they are carefully crafted
to match the escape sequences for colored output.

Tested on VTE and xterm.

[0] golang/go#35017
[1] https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters

containers#494
@gopherbot

Copy link
Copy Markdown
Contributor

Message from Go Bot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
Within the next week or so, a maintainer will review your change and provide
feedback. See https://golang.org/doc/contribute.html#review for more info and
tips to get your patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11, it means that this CL will be reviewed as part of the next development
cycle. See https://golang.org/s/release for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/202257.
After addressing review feedback, remember to publish your drafts!

@heschi heschi closed this Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants