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

color priority/precedence #3860

Open
osergioabreu opened this issue Apr 27, 2024 · 13 comments
Open

color priority/precedence #3860

osergioabreu opened this issue Apr 27, 2024 · 13 comments

Comments

@osergioabreu
Copy link

osergioabreu commented Apr 27, 2024

An identifier_1 (php/bash variables: $example) inside a string should be colored as identifier_1, not as string.

Probably it's related to the execution order applying the colors.
Now the string scheme has more importance than identifier, and it should be the opposite.
An example:

"Here is a $variable inside a string"

The ideal in this case I believe is firstly applying the string color, and then, applying the identifier color which would let the identifier with a different color even it is inside the string, the point is to call the attention to it.
In my editor, it is using the string color, ignoring the identifier color. Outside a string the identifier_1 color is OK, but when inside a string, the priority color used is the string color, not identifier_1's color.

@b4n
Copy link
Member

b4n commented Apr 28, 2024

That's not how things work here, the identifier id either recognized as such anf given a separate style (which we might or might not draw the same as a string), or it's not recognized and thus is considered a string.

Which language do you have issue with?

@elextr
Copy link
Member

elextr commented Apr 28, 2024

Bash and PHP are mentioned.

AFAICT bash needs property lexer.bash.styling.inside.string set but the default is unset.

Php styles $word inside strings as SCE_HPHP_HSTRING_VARIABLE so it depends on what it maps to and what the theme set it to.

@osergioabreu
Copy link
Author

osergioabreu commented Apr 28, 2024 via email

@osergioabreu
Copy link
Author

osergioabreu commented Apr 28, 2024

I thank the lexer.bash.styling.inside.string information. How to set it ?

In php vim does equal geany, using preprocessor color, not string color.
But in shellscript, it is different.

The problem in shell is that before a variable is "dollared" (identifier_1) it was a simple identifier, without dollar sign. And identifier color is default, but you can set identifier_1 to be magenta in a green string as I do.

   # Shell, bash, sh syntax:

   # Below it has no "$", geany sees a "identifier" NOT "identifier_1":      
   variable="value"
   
   #After the attribution, it has the "$", it becomes "identifier_1", magenta in my case.  
   echo $variable    
   
   # Geany now ignores identifier_1 color for sh/bash, painting it green (string):
   echo "a string with $variable" 

How can we have lexer.bash.styling.inside.string working ?

ashel
aphp

See the sh correct syntax (identifier_1 priority) done by vim:
ashell2

@osergioabreu
Copy link
Author

An important observation:

For single quoted string 'Single quoted string kills $dollar $vars' it is OK as they kill dollar variables. In this case, the string color is used.

But double quotes "Double quotation keeps the $dollar $variables" they should be colored as identifier_1 as geany does outside the string.

@osergioabreu
Copy link
Author

osergioabreu commented Apr 28, 2024

PHP uses "preprocessor" color for the dollar variables, not identifier_1 ( that sh/bash use )

The question is: Why geany can draw php dollar variables interpolated in string correctly, but not for shellscript ?

@b4n
Copy link
Member

b4n commented Apr 28, 2024

Try adding this in filetypes.sh (you can open it from Tools → Configuration files → Filetypes configuration files → Scripting languages):

[lexer_properties]
lexer.bash.styling.inside.string=1
lexer.bash.styling.inside.backticks=1
lexer.bash.styling.inside.parameter=1
lexer.bash.styling.inside.heredoc=1

We probably should use all or some by default, we'd just need to check what defaults make more sense, and what the limitations might be.

@osergioabreu
Copy link
Author

The bad news is that it doesn't work too.
I have added it, closed geany, reopen and all is the same.

@osergioabreu
Copy link
Author

One question: what is the correct: altering via Geany Tools, ... or editing directly in the file /usr/share/geany/file...
Because opening in Tools, all lines appear commented and is is different from the same file in /usr/share/geany/file...
What is actually used ?

@b4n
Copy link
Member

b4n commented Apr 28, 2024

The bad news is that it doesn't work too.
I have added it, closed geany, reopen and all is the same.

WFM, looks like that:

Default:
default

Adding lexer.bash.styling.inside.string=1
strings

Adding lexer.bash.styling.inside.backticks=1
backticks

Adding lexer.bash.styling.inside.heredoc=1
heredoc

One question: what is the correct: altering via Geany Tools, ... or editing directly in the file /usr/share/geany/file...
Because opening in Tools, all lines appear commented and is is different from the same file in /usr/share/geany/file...
What is actually used ?

Both are used together. If something is not defined in the user's configuration, the value is looked up in the /usr/share one (or whatever the Geany installation path is).

All you need to do is go through Tools… and replace the whole content with literally what I mentioned above. Or add it (uncommented) somewhere.

@osergioabreu
Copy link
Author

osergioabreu commented Apr 28, 2024

Have done that, opened via Tools, replaced all the file content with the configs you suggested and still not working.
I closed geany, reopened, and even think that bash is taken by geany as sh too ?

So we do have a bug here.

@osergioabreu
Copy link
Author

osergioabreu commented Apr 28, 2024

if the software draws the string colors AFTER scalar and identifier_1 color, these colors are ovewritten by string color, and that seems to be the deep problem.

@elextr
Copy link
Member

elextr commented Apr 28, 2024

WFM.

if the software draws the string colors AFTER scalar and identifier_1 color, these colors are ovewritten by string color, and that seems to be the deep problem.

No it doesn't work like that. What version of Geany are you using?

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