Repository navigation
text/tabwriter: add ANSI Graphics Rendition format - #35017
kindermoumoute wants to merge 2 commits into
Conversation
|
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 What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
@googlebot I signed it! |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
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 |
|
Message from Brad Fitzpatrick: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/202257. |
|
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/202257. |
|
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 |
|
Message from olivier cano: Patch Set 2: (2 comments)
Please don’t reply on this GitHub thread. Visit golang.org/cl/202257. |
|
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. |
|
Message from olivier cano: Patch Set 2:
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. |
|
Message from Robert Griesemer: Patch Set 2:
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. |
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
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
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
|
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/202257. |
Updates #12073