wtee icon indicating copy to clipboard operation
wtee copied to clipboard

Support for ANSI escape sequences

Open 3lo1i opened this issue 7 years ago • 5 comments

Many applications use ANSI escape codes extensively for styling text in output. Currently Wtee is not aware of escape codes and prints them as is, which makes logs in some cases look like this: [0m[1;31madmin[0m[1m@[0m[0m[1;31madmin[0m.

This pull request adds two options:

  • Don't show escape sequences in log view. Hides anything that matches \x1b\[[0-9;]*[a-zA-Z]
  • Enable colors in output. Interprets Select Graphic Rendition for text styling: 1 - lighter than normal 2 - darker than normal 3 - italic 4 - underline 5 - blinking (fast blinking (6) has no effect, as in GNOME Terminal) 7 - reverse 8 - hide 9 - cross-out Only 3/4 bit type of color sequence is supported: 30-37 - foreground colors (black, red, green, yellow, blue, purple, cyan, white) 40-47 - background colors. The color scheme is similar to Tango of GNOME Terminal.

Both options are enabled by default.

3lo1i avatar Jun 03 '18 09:06 3lo1i

Thanks - this looks great. I'll try having a closer look during the week :+1:

One thing - can you drop the commit with the frontend dependencies? I don't really need them under version control as long as they can be reproduced during the frontend-build step.

gvalkov avatar Jun 03 '18 21:06 gvalkov

Commit 81f1fb5 also adds .bowerrc file:

{
  "directory": "wtee/assets/vendor"
}

That way bower install saves dependencies directly to wtee/assets/vendor, not bower_components.

3lo1i avatar Jun 04 '18 17:06 3lo1i

I've cleaned up first 3 commits. "Install frontend dependencies" is dropped, "Don't show ANSI escape codes" is also dropped because changes in this commit are not present in final file, following frontend compilation is also dropped. I also edited eaf147b because I accidentally removed lines:

// TODO: Need a css only solution.
if (line === '') {
  line = '‌';
}

It all should be hunky-dory now. .bowerrc file clearly does not belong to this pull request, but I suggest to add it in some commit later.

3lo1i avatar Jun 05 '18 19:06 3lo1i

Haven't seen any continuation of this ANSI escape handling pull. Does this mean colorized output if merged? Is there a way I can build your changes myself? When I do a "make", I seem to always get back the original wtee.

ntlug avatar Jul 25 '22 23:07 ntlug

I used "pip install wtee" to install the latest version of WTee, how to I get the Ansi Colors to work? :)

jasgot avatar Jun 20 '24 19:06 jasgot