zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
2.72k stars 187 forks source link

Implement color preview #659

Closed Matteo-Nigro closed 1 year ago

Matteo-Nigro commented 1 year ago

Hi @zufuliu! I wanted to offer you this implementation... In Notepad3 I find the possibility of opening links directly from the text (Ctrl+Click) and being able to preview the colors (Hex or RGB, etc.) simply by passing the mouse over them, very convenient. When writing code with lots of colors it is especially useful. Talking about the colors with (Ctrl+Click) the window with the color palettes opens... this is also very useful...

Record

What do you think we could work on it? 😉

zufuliu commented 1 year ago

Open link is implemented for Markdown, other schemes will need to wait issue #52.

zufuliu commented 1 year ago

An alternative way to implement color preview is show calltips (change text and background color), open color picker when calltip clicked (similar to VSCode). This seems is easy to implemented than using indicators.

image

Matteo-Nigro commented 1 year ago

Hello @zufuliu. Great! 😀 It seems to be an interesting solution anyway. Do you think it can be implemented in the next release?

zufuliu commented 1 year ago

Do you think it can be implemented in the next release?

Not sure, but could do some experiments.

zufuliu commented 1 year ago

Implemented by 9492cf8afcc34aee3e85d674ac688127a7e282be: ColorCallTip

Matteo-Nigro commented 1 year ago

Hi @zufuliu very good, seems to be quite practical. I only report one bug... Upon closer examination I think the problem actually occurs only if the text begins with a color code... as seen in my second screenshot. Regardless of the lexer chosen.

In this case an error is returned which can potentially crash the program. Here is the error message and screenshot of the text that generated it.

image

image

zufuliu commented 1 year ago

The stack overrun is fixed by 98a70ca6985795e8a7e890a802ad55e5af504b47, it caused by: https://github.com/zufuliu/notepad2/blob/98a70ca6985795e8a7e890a802ad55e5af504b47/src/Styles.c#L5348-L5349

meteorquake commented 1 year ago

That looks good, I'm sure I'll use it! There may perhaps be some advantages in having it only activate when a modifier eg shift is held down whilst passing over but I'm not sure.

zufuliu commented 1 year ago

shift is held down whilst passing over

I think it would make the feature hard to use (something like "Color Preview" right-click menu).