SublimeANSI icon indicating copy to clipboard operation
SublimeANSI copied to clipboard

Make default color mapping support OSX Clang

Open kavika13 opened this issue 9 years ago • 6 comments

Clang on OSX outputs escape sequences that look like this:

<ESC>[0;1;31m

I don't know escape sequences well enough to know if clang is just flat out wrong, or if it is expecting more complete ANSI support. Either way, the default settings only match color escape sequences with two values.

Here's a mapping that seemed to work for me:

{"scope": "black", "code": "\\x1b\\[(0;(0;)?)?30m", "color": "#000000"},
{"scope": "black_light", "code": "\\x1b\\[(0;)?1;30m", "color": "#686868"},
{"scope": "red", "code": "\\x1b\\[(0;(0;)?)?31m", "color": "#c71e12"},
{"scope": "red_light", "code": "\\x1b\\[(0;)?1;31m", "color": "#ff6f6b"},
{"scope": "green", "code": "\\x1b\\[(0;(0;)?)?32m", "color": "#00c120"},
{"scope": "green_light", "code": "\\x1b\\[(0;)?1;32m", "color": "#67f86f"},
{"scope": "yellow", "code": "\\x1b\\[(0;(0;)?)?33m", "color": "#c7c327"},
{"scope": "yellow_light", "code": "\\x1b\\[(0;)?1;33m", "color": "#fffa72"},
{"scope": "blue", "code": "\\x1b\\[(0;(0;)?)?34m", "color": "#0a2fc4"},
{"scope": "blue_light", "code": "\\x1b\\[(0;)?1;34m", "color": "#6a76fc"},
{"scope": "magenta", "code": "\\x1b\\[(0;(0;)?)?35m", "color": "#c839c5"},
{"scope": "magenta_light", "code": "\\x1b\\[(0;)?1;35m", "color": "#ff7cfd"},
{"scope": "cyan", "code": "\\x1b\\[(0;(0;)?)?36m", "color": "#01c5c6"},
{"scope": "cyan_light", "code": "\\x1b\\[(0;)?1;36m", "color": "#68fdfe"},
{"scope": "white", "code": "\\x1b\\[(0;(0;)?)?(37)?m", "color": "#c7c7c7"},
{"scope": "white_light", "code": "\\x1b\\[(0;)?1;37m", "color": "#ffffff"},
{"scope": "_bold", "code": "\\x1b\\[(0;(0;)?)?1m", "color": "#ffffff", "font_style": "bold"}

kavika13 avatar Aug 16 '16 05:08 kavika13

This file is not perfect though :) I think it has problems with bold/unbold. I can upload a sample clang output if that is useful.

kavika13 avatar Aug 16 '16 06:08 kavika13

If someone is interested, I made a fork without regular expressions but with a really simple ANSI parser. It solves problem with clang output. You can find it here https://github.com/PurplePowder/SublimeANSI

PurplePowder avatar Aug 19 '16 07:08 PurplePowder

It works pretty well out of the box. This also looks like way less of a headache to understand and configure.

I had user settings already, and it puked on them, even if I emptied the file and saved it. Is there something you can do to make error recovery on a bad user (not default) settings file slightly better? It seems to default to an "all grey" theme when it dies on user configuration, instead of falling back.

Of course, once I copied the default settings to the user settings path it worked :)

I have about 3 feature requests now, but I think it makes more sense to focus on verifying if your branch is stable before worrying about that.

kavika13 avatar Aug 19 '16 08:08 kavika13

I had user settings already, and it puked on them, even if I emptied the file and saved it. Is there something you can do to make error recovery on a bad user (not default) settings file slightly better?

Fixed. Now when plugin founds out that some required color isn't described in settings, it simply doesn't colorize it, so default color is used

PurplePowder avatar Aug 19 '16 09:08 PurplePowder

This is still an issue.

heyer2 avatar Jul 15 '20 16:07 heyer2

You can file a PR or use https://packagecontrol.io/packages/Terminus instead nowadays.

jfcherng avatar Jul 15 '20 16:07 jfcherng