zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.03k stars 1.17k forks source link

Enhancement: complementary foreground color when using background color (not only) in 16-color terminals #428

Open ghost opened 7 years ago

ghost commented 7 years ago

It would be nice to have the editor use complementary colors for foreground (text).

If we use, for instance 'brightblack' as background color for cursor-line and we are on a line that has elements with 'brightblack' as text color, practically, we don't see any text in that area since the foreground and background are the same.

In this case, a complementary color should be used for the text, to make sure it's visible to the user.

See the screenshot, line 19, on the right view. It's the same file from the left view, with current editor line being 19.

image

\ I think the current editor line should have some special treatment for text, for better readability (not only when overlapping with same color text but also when using colors that are close to it). See line 8 on the right: image

ghost commented 7 years ago

Actually, this would apply to any terminal, regardless of color depth. This is a (really neat) text editor, so, readability must have priority 0 over anything else.

ghost commented 7 years ago

This will require an HSL (hue-saturation-light) complimentary color calculator function (RGB->HSL->opposite H->RGB).

ghost commented 7 years ago

In 16 color terminals, we could hardcode the readable combinations like suggested here: https://dev.yorhel.nl/dump/nccolour

ghost commented 7 years ago

FYI: I have stumbled upon this: http://terminal.sexy/ It seems very useful for building / exporting color schemes.

GeigerCounter commented 7 years ago

Ahoy there! I'm working on improving the syntax highlighting and color themes presently. When I've got that sufficiently done, I'm putting in a pull request that's related to that. This should help/resolve this. I could probably also give a look into inverting the color if the current line contains text that's the color of the current line highlight as well.