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
Question: highlight-API: is loading/querying of individual styles possible? #2331
Comments
Yep, thats the approved method for users to specify colours. The sequence is:
If a user wants different colours for the same syntactic entity in different filetypes they can create new named styles and only use them in some filetypes files, or replace the mapping in the filetype files between entities and style names with a literal style if they only want to change one filetype. There is no API because setting it programatically would break this configuration scheme. |
@LarsGit223 can you elaborate on what you're trying to do in your plugin? |
@codebrainz: I saw an issue for the pairtaghighlighter plugin asking to make the highlihgt color/style configurable. Then I thought let's quickly add a new key/value pair to a color scheme and use that values. But then I stumbled across the API. |
I only want to read a value, preferably by key name. There is a function for it, but it's static. |
Ahh, probably the best would be to use indicators for that, they are independent of the highlighting styles so easy for plugins to apply, see scintilla docs https://www.scintilla.org/ScintillaDoc.html#Indicators. |
My question is not about how highlighting itself can be implemented. The highlighting is already implemented in the plugin, see the code below and yes it's using indicators:
The issue is that the colors are fixed coded into the plugin. And as always this can just be fine for some themes and for others it's causing bad readability because the color/style cannot be adjusted to the theme. So I wondered if there is an already implemented, re-usable way to read in color/style values. Colorschemes does not seem to add a new key and access it somehow. I would prefer to define a key explicitly for the pairtaghighlighter plugin. But colorschemes seem to be bound to predefined meanings/styles. |
Ahh, they followed my advice before I gave it, excellent 😁
Ok, then I strongly suggest just making it manually configurable. Trying to automatically adjust to the theme is tricky because the plugin is highlighting the whole tag and that has different styles for element name, attribute names, and attribute values, so its quite likely that part of a tag will clash unless you somehow consider all the tag styles. I guess you would need to consider the actual colours for SCE_H_TAG, SCE_H_TAGUNKNOWN, SCE_H_ATTRIBUTE, SCE_H_ATTRIBUTEUNKNOWN, SCE_H_NUMBER, SCE_H_DOUBLESTRING, SCE_H_SINGLESTRING, SCE_H_OTHER, SCE_H_COMMENT, SCE_H_ENTITY, SCE_H_TAGEND all of which can occur in a tag IIUC.
Not that I'm aware of any way, but highlighting[mappings].[hc] is @b4n's baby and maybe its hidden away there somewhere. But plugins can read the styles from Scintilla eg foreground. |
I like to find the best way to let the user specify colors, e.g. by config, theme or whatever (I am talking about colors for text highlighting here not the UI parts outside the editor widget). The colorschemes seem to do the job.
Looking at
highlight.c
it seems that every style specified in a colorscheme is loaded to the hashnamed_style_hash
. How can a plugin access a style by its key name?I only found this API call for querying a style but it does not look like it is allowing individual styles:
Thanks for all answers in advance.
The text was updated successfully, but these errors were encountered: