Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Colorize::Mode values #13725

Closed
HertzDevil opened this issue Aug 2, 2023 · 0 comments · Fixed by #13745
Closed

Missing Colorize::Mode values #13725

HertzDevil opened this issue Aug 2, 2023 · 0 comments · Fixed by #13745

Comments

@HertzDevil
Copy link
Contributor

HertzDevil commented Aug 2, 2023

As suggested in https://forum.crystal-lang.org/t/italic-mode-not-supported-in-colorize/5890, several SGR codes from ECMA 48 are not defined in the Colorize::Mode enum yet, presumably because they weren't widely supported. The flags that don't simply cancel other flags' effects are:

  • \e[3m: italicized
  • \e[6m: rapidly blinking (150 per minute or more)
  • \e[9m: crossed-out (characters still legible but marked as to be deleted)
  • \e[20m: Fraktur (Gothic)
  • \e[21m: doubly underlined
  • \e[51m: framed
  • \e[52m: encircled
  • \e[53m: overlined
  • \e[60m: ideogram underline or right side line
  • \e[61m: ideogram double underline or double line on the right side
  • \e[62m: ideogram overline or left side line
  • \e[63m: ideogram double overline or double line on the left side
  • \e[64m: ideogram stress marking

I tested those flags in various terminal emulators:

Terminal emulator \e[3m \e[6m \e[9m \e[21m \e[53m
Windows Terminal ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
GNOME Terminal ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
Konsole ✅ Yes ❌ No ✅ Yes ✅ Yes ✅ Yes
Visual Studio Code ✅ Yes ❌ No ✅ Yes ✅ Yes ✅ Yes
kitty ✅ Yes ❌ No ✅ Yes ✅ Yes ❌ No
xterm ✅ Yes ❌ No ✅ Yes ✅ Yes ❌ No
Alacritty ✅ Yes ❌ No ✅ Yes ❌ No ❌ No
iTerm2 ✅ Yes ❌ No ✅ Yes ❌ No ❌ No
Termux ✅ Yes ❌ No ✅ Yes ❌ No ❌ No
Terminal.app ✅ Yes ❌ No ❌ No ❌ No ❌ No
Linux virtual console ✅ Yes ❌ No ❌ No ✅ Yes ❌ No

(The Linux virtual console does not actually render those flags as such, instead it merely recolors text. Also it supports \e[12m (second alternative font) for some reason.)

The flags not shown in the table are not supported by any of these emulators, so I assume they are truly too obscure. For the flags that are shown we should define additional values in Colorize::Mode:

module Colorize
  enum Mode
    # ...
    Italic          # 3
    BlinkFast       # 6
    Strikethrough   # 9
    DoubleUnderline # 21
    Overline        # 53
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant