moe icon indicating copy to clipboard operation
moe copied to clipboard

Hex color editing mode

Open tobimensch opened this issue 5 years ago • 2 comments
trafficstars

In CSS files and the like, even in moe's own configuration, color codes are often encoded in this format: #RRGGBB

It's pretty hard to accurately predict what those hex values will end up looking like when viewed as color on the screen, therefore I suggest to add a special hex color editing mode.

When the cursor is over a hex color in normal mode, and you type ':hexcolor' into the command mode, then a special color editing mode should appear with three or four columns. The fourth column would be for the alpha channel, if needed.

We already have a table of 256 color names in the source we can use for this. But of course this isn't enough for modern web design or game design or theme design or anything like it, you want precision. This feature will make even more sense, once moe has true color support.

An example without the alpha column could look like this:

Darker              Red                    Green                     Blue
                   68%                      28%                      18%
                   69%                      29%                      19%
Current            70%                      30%                      20%   
                   71%                      31%                      21%
                   72%                      32%                      22%
Lighter            73%                      33%                      23%

The current line represents the current color setting in color editing mode. The red green and blue columns represent possible changes that can be made, for example the 18% Blue value represents the change of the current line to 18% blue, so if the user goes to 18% blue with the cursor and hits enter, current will change to 70% red, 30% and 18% blue. The whole current line should be written with the currently selected color as foreground. While the other columns of the other lines should be written with the color the current line would change into, once the users selects that line/column. With this the user would always have a preview.

Instead of current, the approximated name of the color should be written.

When searching in this mode with / and entering a color name like cyan, the current color selection should be changed to that color. Then you should be able to edit it.

When the cursor is above one of the RGB values in the current line and the user edits that percentage (or 0-255 value) manually, this change should also be applied to the color editing mode, and the color should be represented.

I'm not exactly sure how to apply a change to the original buffer based on this mode, maybe when doing a :w. But I'm not sure if that's consistent, because we're not actually writing to disk.

Or when using ESC to go back to the original buffer, maybe then the change should also be applied?

tobimensch avatar Jul 07 '20 17:07 tobimensch

Sorry, I've just seen that you already opened an issue for this:

https://github.com/fox0430/moe/issues/326

Well, I provided some of my own ideas on this topic.

tobimensch avatar Jul 07 '20 17:07 tobimensch

@tobimensch

Ok. Thank you good idea.

fox0430 avatar Jul 07 '20 17:07 fox0430