plasma-applet-commandoutput icon indicating copy to clipboard operation
plasma-applet-commandoutput copied to clipboard

Parse Terminal Colors

Open RaitaroH opened this issue 7 years ago • 5 comments

Not sure how to do it. The color itself simply ends up as the color code instead. Would be nice to have this to get some nice visual. I want my update icons for ex to change color so is more visible.

echo "$(tput setaf 1)Red text $(tput setab 7)and white background$(tput sgr 0)"
echo '\e[1;34m%-6s\e[m' "This is text"

RaitaroH avatar Jan 30 '19 20:01 RaitaroH

<font color="#a94d37">This text is orange</font>

AndydeCleyre avatar Mar 16 '19 01:03 AndydeCleyre

Unfortunately coloring the text this way mangles the spacing, as discussed in #12. So this issue should remain open until coloring the text preserves the text being colored.

AndydeCleyre avatar Jun 07 '19 20:06 AndydeCleyre

To https://www.pling.com/u/rumcho/, the widget does not parse terminal colors, but it can use an HTML subset:

https://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop

Zren avatar Sep 21 '20 22:09 Zren

You can use &nbsp; to re add spacing.

joickle avatar Jan 10 '22 04:01 joickle

Git master should now parse:

  • \033[m Reset
  • \033[0m Reset
  • \033[1m Bold
  • \033[30m - \033[37m FG Normal Colors
  • \033[90m - \033[97m FG Bright Colors
  • \033[1;30m Bold Normal Colors are automagically converted to Bright Colors (30 + 60 = 90)
  • \033[38;2;255m 8-Bit Preset Colors (Only Tested a couple colors in journalctl)
  • \033[38;5;255;255;255m RGB Color (Untested)

I've tested:

  • git -C ~/Code/plasma-applet-commandoutput log --oneline
  • git -C ~/Code/plasma-applet-commandoutput log --color --oneline
  • SYSTEMD_COLORS=1 journalctl -q -b0 -n20
    • \033[0;1;38;5;185m
    • \033[0;1;39m

Todo:

  • 39, which should not reset boldness (slightly annoying to implement).

Edit: Now should support 8-bit and RGB color mode.

Zren avatar Apr 29 '22 03:04 Zren