-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Syntax highlighting colors for PHP are not informative #2842
Comments
Reviewed. Moving to low priority just because PHP itself isn't a primary focus of Brackets, but I agree it's worth looking at soon. One issue might be that we might specifically want some of these colors to be the same as the default text color for JS (due to the XD design for the default theme). Is there a way we can change the colors per mode? Or, perhaps you could make the case that we want them to be different colors in JS as well. Feel free to research and make a recommendation :) |
@njx I agree that "low priority" is probably right. I marked it as medium because a prof at Stanford is evaluating using Brackets in his intro HCI course and reported this bug to me. It'd be great to have them use it -- about 200 young, impressionable students each year. :-) Anyway, I think it's a relatively easy fix, and I'm happy to do the lifting next sprint. |
Removed sprint 21 milestone. I'm still going to try to do this during sprint 21, though. |
@joelrbrandt Are you still working on this? If not, I'd happily pick up where you left it off. |
@albertxing I haven't started on this yet (so picking up where I left off will be easy 😃). It'd be great to get your help, and I'd be happy to review your pull request. Thanks! |
If we were to leave the thirdparty CodeMirror definitions alone, we would have to redefine Any thoughts on this? |
@albertxing Right now In JavaScript it seems to be used for the color of object identifiers in property expressions. So, in In CSS it seems to be used for some literals in CSS property values. In @GarthDB -- Any input on this? Another option would be to enable per-mode CSS rules. @DennisKehrig -- In your language extensibility work, did you do any thinking about supporting different CSS files (for syntax highlighting) for different languages? I can imagine that we'd want, for example, @albertxing -- Sorry that isn't a direct answer to your question. @GarthDB and @DennisKehrig are probably the right people to help out. |
@joelrbrandt I also thought that adding language classes somewhere in the DOM was the right way to go. This shouldn't be too hard as we already have code that inserts the language into the status bar - we just need to add this to another element. Perhaps add an attribute like |
I'll look into it. |
I was thinking the same, and it gets even worst in PHP, where you could have HTML, JavaScript, and CSS internal modes, which is what we want to fix. If we want to use classes, we might even need 1 per line and we would need to parse the document to add this, so it might not be great. Would it be ok to just change the PHP mode? We could change the functions names to def (this would require to change the clike mode too) and some of the variables or all to def. Although I know that this would change lots of other CodeMirror themes too, so we might need to check the impact of this change. Changing the functions names to def, would make it more like JavaScript, so that might not be a problem, but the variables, might be depending on the change since it can add a lot more color, which might not always be wanted. |
Correct me if I'm wrong, but isn't the PHP mode part of CodeMirror and not Brackets? |
Experimented a little bit. In CodeMirror's
The resulting span would then have the class Obviously this would increase the size of CodeMirror's output. Rendering might also be impacted because one additional CSS class has to be considered for each span. |
@DennisKehrig Can't seem to get it to work on mine. Which file/line did you insert into? |
There are two places with the call to mode.token, make sure to at least alter the one in function |
@DennisKehrig Still doesn't work. I'm in
The idea seems plausible, we just need to get @marijnh to agree. |
@albertxing Ah, alright. I was referring to |
@DennisKehrig It's working now, thanks. |
@albertxing Glad to hear it! |
@DennisKehrig There doesn't seem too big a difference with performance. It works if you add
Or the like to |
@albertxing Thanks for checking! If that is true for most modes and even more complex files (many lines, long lines, maybe a minified file) and we make sure that the other places that call |
@DennisKehrig The only other instance of I don't think we should change this, because a lot of functions that rely on the return would break (they would have to use So unless we have to change the code in other files like |
@albertxing Could be! I hope somebody with more CodeMirror experience will pick this up and work it out. |
@albertxing More experience than I have, I mean. :) |
@DennisKehrig Nah, it's fine. I don't have much experience anyway. |
It is, and it is still a problem that one mode declares function names as definitions and another doesn't, so that might be something that could be fixed in the mode. In the same way, PHP could declare some variables as definition, maybe just those that are assigned to but not for arrays/hashmaps, since those are definitions too, and differ from JavaScript to. By doing changes like this, the modes classes/tokens became more compatible. |
We have PHP mode enabled, but we don't have good color mappings for the token types.
For example, variables get the token type
cm-variable-2
which is just the default text color.The text was updated successfully, but these errors were encountered: