termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
36.94k stars 3.88k forks source link

Fixed: Implement colon separated CSI parameters #4154

Closed fornwall closed 1 month ago

fornwall commented 2 months ago

Colon separated escape sequences for setting colors

It seems that more and more terminal emulators and terminal programs supports colon (:) as well as semicolon (;) to specify colors:

red=255 green=100 blue=0 
printf "\x1b[38;2;${red};${green};${blue}m TRUECOLOR\n" # Semicolon separated, works in Termux
printf "\x1b[38:2:${red}:${green}:${blue}m TRUECOLOR\n" # Colon separated, implemented in this PR

See https://github.com/termstandard/colors?tab=readme-ov-file#truecolor-support-in-output-devices, where it can be seen that multiple terminal emulators also support using a colon as delimiter nowadays:

This is now implemented in Termux as well. Fixes https://github.com/termux/termux-packages/issues/20655, escape sequence issues with vtm.

See https://github.com/alacritty/vte/issues/22 for a discussion when this was implemented in alacritty/vte.

Colored and styled underlines parsing

We also here start to parse Colored and styled underlines as initially proposed by Kitty:

To set the underline style:

[4:0m # no underline [4:1m # straight underline [4:2m # double underline [4:3m # curly underline [4:4m # dotted underline [4:5m # dashed underline [4m # straight underline (for backwards compat) [24m # no underline (for backwards compat) To set the underline color (this is reserved and as far as I can tell not actually used for anything): [58...m This works exactly like the codes 38, 48 that are used to set foreground and background color respectively. To reset the underline color (also previously reserved and unused): [59m

In this initial step we currently don't support straight/double/curly/dotted/dashed nor colored underlines, but parse them and map them to normal underlines. Fixes https://github.com/termux/termux-packages/issues/20620, escape sequences showing up at the start of neovim. Future follow up work is actually respecting them when rendering, which is (at least IMHO) a nice touch when using code editors with support for it such as neovim.