ansi-regex icon indicating copy to clipboard operation
ansi-regex copied to clipboard

No support for the newer colon (":") seperated SGR sequences

Open Mani4D46 opened this issue 1 year ago • 1 comments

from wezterm docs:

SGR sequences are of the form CSI DIGITS [; DIGITS ]+ m. That is, any number of semicolon separated numbers, terminated by the m codepoint. There are a handful of slightly more modern sequences that use colon : codepoints to encode additional context.

The colon is also used as an alternative to the semicolon separation method, take a look at this example on wezterm docs.

Mani4D46 avatar Nov 29 '24 07:11 Mani4D46

Some tests done in python to replace every escape sequence to '[ESC]':

Using colons

>>> pattern = "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
>>> re.sub(pattern, '[ESC]', '\x1b[1:2m')
'[ESC]:2m'

Using semicolons

>>> re.sub(pattern, '[ESC]', '\x1b[1;2m')
'[ESC]'

Mani4D46 avatar Nov 29 '24 07:11 Mani4D46