Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geany css color #1130

Open
82d opened this issue Nov 3, 2021 · 14 comments
Open

geany css color #1130

82d opened this issue Nov 3, 2021 · 14 comments

Comments

@82d
Copy link

82d commented Nov 3, 2021

is there a plugin in Geany capable of highlighting codes to display HEX and RGB colors with an appropriate marker? or is it possible to do this in the config syntax highlighting?

@elextr
Copy link
Member

elextr commented Nov 3, 2021

or is it possible to do this in the config syntax highlighting?

Not in Geany, the lexical entities are recognised by the lexer in the lexilla library which does not appear to identify colour values differently to other values.

Not aware of plugins that might, but I doubt it.

@xiota
Copy link
Contributor

xiota commented Nov 3, 2021

Supposing someone wanted to write a plugin to do what you want... What do you mean by:

... with an appropriate marker...

If you want to check the color of a value, Geany has a color chooser. There is also a "Send Selection to" command. There might be an external program that could display the colors you send it.

@elextr
Copy link
Member

elextr commented Nov 3, 2021

@xiota a plugin would have to use one of the Scintilla facilities not used by Geany/Lexilla for styling since it will simply be overwritten by the lexer if the plugin uses any of those, eg colour, font face, etc.

Some indicators (some are used by Geany for compiler errors, but that does not apply to CSS) or annotations are available for plugins (assuming they are not used by other plugins enabled at the same time).

@xiota
Copy link
Contributor

xiota commented Nov 3, 2021

@elextr Doesn't that depend on what "appropriate marker" means? A "marker" could be anything.

Would displaying a tooltip to show the color when the mouse hovers over a hex code (if it's possible) conflict with anything?

(It depends on what the goal is... Is it to have special syntax highlighting or to eventually see the color of the value? Someone could frame it in terms of syntax highlighting with the idea of making the highlight color match the hex value, but if the goal is to see the color, it could be achieved by other means.)

@elextr
Copy link
Member

elextr commented Nov 3, 2021

To make the conclusion I'm trying to convey clearer, no it can't be anything!!!

It can't be anything that Geany/Lexilla/another plugin uses, like changing the text colour to match the value, that would need a lot of styles since each colour would need its own, and a large CSS might run you out of styles (max 255 less already used). But also Geany and the lexer will simply re-write the style when its re-run on that piece of text.

If no build errors are used by the filetype Indicators are available AFAIK, and annotations are not used anywhere so thats what the OP has to choose from.

@xiota
Copy link
Contributor

xiota commented Nov 3, 2021

My question is for clarification about what OP means by "appropriate marker". It's not clear what qualifies as a "marker" to OP, except maybe that it "display HEX and RGB colors".

How important is the "highlighting" part? Maybe not at all, if the primary purpose is to show the color that's represented. But if highlighting is the primary purpose, numbers, including hex values, are already highlighted, and the secondary purpose of showing colors may not be possible.

But if showing the color is the primary purpose, a tooltip could accomplish that without changing any Scintilla or Geany styles. The plugin would just need to extract the hex code and screen location. Then it could use GTK to display the color independently of scintilla when the mouse cursor is the right position.

@elextr
Copy link
Member

elextr commented Nov 4, 2021

Almost all types of values including colours are one lexical entity type, so they all show the same.

Of course if the "anything" is a display separate from the Scintilla widget thats ok, although I'm not sure if Scintilla widget allows tooltips.

The sort of thing other IDEs do is and is likely what the OP is thinking of if given a choice of "anything" 😁, but thats the sort of thing that can only be done if its built into the Lexilla lexer which isn't Geany's code.

[Late edit: Although I just found indicators can have any colour, (I mean why would anyone not notice from the name that SETFLAGS sets colour? 😁), so maybe something similarish to VS code is actually possible with a Geany plugin if somebody wants to try it.]

@xiota
Copy link
Contributor

xiota commented Nov 4, 2021

The sort of thing other IDEs do...

That looks terrible. If it's ever introduced to Geany, I will promptly open a PR to add an option to disable it.

@elextr
Copy link
Member

elextr commented Nov 4, 2021

I will promptly open a PR to add an option to disable it.

I doubt it will be added to the Lexer without an option that you can disable, and that can go in your filetypes.css, but if it slips past Neil you can always PR Lexilla, its now in github.

If its a plugin, well the advantage of plugins is you don't need to load them :)

@xiota
Copy link
Contributor

xiota commented Nov 4, 2021

Although I just found indicators can have any colour, (I mean why would anyone not notice from the name that SETFLAGS sets colour? grin), so maybe something similarish to VS code is actually possible with a Geany plugin if somebody wants to try it.

That might even be doable with a Lua script since the GeanyLua plugin can send scintilla messages.

If its a plugin, well the advantage of plugins is you don't need to load them :)

I'm seeing why you seem to push some feature requests toward plugins...

@elextr
Copy link
Member

elextr commented Nov 4, 2021

Mentioning add-ons on geany/geany#2972 caused me to look at it, there is an option to make a coloured tooltip appear over some things that look like hex colour specs. (See what I mean by its a "catch all", its easy to miss things.) The capability is not CSS specific so it doesn't understand names or rgb() AFAICT but it may be sufficient for @82d or somebody could improve it.

@xiota
Copy link
Contributor

xiota commented Nov 4, 2021

Mentioning add-ons on geany/geany#2972 caused me to look at it, there is an option to make a coloured tooltip appear over some things that look like hex colour specs.

@elextr I don't understand most of the options in the addons plugin... but I also noticed them after you mentioned it. In case anyone has trouble finding them, they are:

  • Show a calltip when hovering over a color value
  • Open Color Chooser when double-clicking a color value

@82d
Copy link
Author

82d commented Nov 5, 2021

Mentioning add-ons on geany/geany#2972 caused me to look at it, there is an option to make a coloured tooltip appear over some things that look like hex colour specs. (See what I mean by its a "catch all", its easy to miss things.) The capability is not CSS specific so it doesn't understand names or rgb() AFAICT but it may be sufficient for @82d or somebody could improve it.

I beg your pardon for delaying the answer. there was a lot of work. the essence of the question is to display all the colors at once, and not when seeing. I want it to be like this plugin does.

@elextr
Copy link
Member

elextr commented Nov 5, 2021

The Vim plugin seems to display the background as the specified colour. Normal styling in Scintilla allows for only 255 styles, so thats not enough so AFAICT that may not be possible without Scintilla additions since it can only specify foreground (ie the text) colours with RGB for indicators, see here. Then a suitable Geany plugin could do it.

Scintilla is the editing widget, it is a separate project and any changes would have to be made there first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants