-
Notifications
You must be signed in to change notification settings - Fork 11
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
Some functions are not being colored properly. #11
Comments
Are you using AHK v2 or v1? The extension is currently written primarily for v1, I am working on improving support for v2, I will look into this over the weekend |
Thanks for the response. The version is v1.1.30.03 64-bit Unicode according to the following code:
|
Thanks for confirming. This will take some looking into. Just to confirm: |
My initial assumptions might have been wrong regarding the intended colors. Are function calls supposed to be white? I thought they were supposed to be blue because the other functions calls were. Are they blue because keys names are blue and that takes precedence over the fact that they are also function calls? If this is the case, the only issue I see in the coloring of my code is that Pause should be blue because it is a key name and that should take precedence over it also being a function. |
in my vscode, function calls are yellow, since these are all function calls (Except for AltTab), I would make them all yellow. how to do this: nested stuff (click to expand)"match": "\\b(?!MsgBox)(?i:new|__New|__Delete|shift|lshift|rshift|alt|lalt|ralt|control|lcontrol|rcontrol|ctrl|lctrl|rctrl|lwin|rwin|appskey|altdown|altup|shiftdown|shiftup|ctrldown|ctrlup|lwindown|lwinup|rwindown|rwinup|lbutton|rbutton|mbutton|wheelup|wheelleft|wheelright|wheeldown|xbutton1|xbutton2|joy1|joy2|joy3|joy4|joy5|joy6|joy7|joy8|joy9|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy30|joy31|joy32|joyx|joyy|joyz|joyr|joyu|joyv|joypov|joyname|joybuttons|joyaxes|joyinfo|space|tab|enter|escape|esc|backspace|bs|delete|del|insert|ins|pgup|pgdn|home|end|up|down|left|right|printscreen|ctrlbreak|pause|scrolllock|capslock|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadmult|numpadadd|numpadsub|numpaddiv|numpaddot|numpaddel|numpadins|numpadclear|numpadup|numpaddown|numpadleft|numpadright|numpadhome|numpadend|numpadpgup|numpadpgdn|numpadenter|f1|f2|f3|f4|f5|f6|f7|f8|f9|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f20|f21|f22|f23|f24|browser_back|browser_forward|browser_refresh|browser_stop|browser_search|browser_favorites|browser_home|volume_mute|volume_down|volume_up|media_next|media_prev|media_stop|media_play_pause|launch_mail|launch_media|launch_app1|launch_app2|vk\\d+|sc\\d+)(?!\\()\\b\\b(?!MsgBox)(?i:new|__New|__Delete|shift|lshift|rshift|alt|lalt|ralt|control|lcontrol|rcontrol|ctrl|lctrl|rctrl|lwin|rwin|appskey|altdown|altup|shiftdown|shiftup|ctrldown|ctrlup|lwindown|lwinup|rwindown|rwinup|lbutton|rbutton|mbutton|wheelup|wheelleft|wheelright|wheeldown|xbutton1|xbutton2|joy1|joy2|joy3|joy4|joy5|joy6|joy7|joy8|joy9|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy30|joy31|joy32|joyx|joyy|joyz|joyr|joyu|joyv|joypov|joyname|joybuttons|joyaxes|joyinfo|space|tab|enter|escape|esc|backspace|bs|delete|del|insert|ins|pgup|pgdn|home|end|up|down|left|right|printscreen|ctrlbreak|pause|scrolllock|capslock|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadmult|numpadadd|numpadsub|numpaddiv|numpaddot|numpaddel|numpadins|numpadclear|numpadup|numpaddown|numpadleft|numpadright|numpadhome|numpadend|numpadpgup|numpadpgdn|numpadenter|f1|f2|f3|f4|f5|f6|f7|f8|f9|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f20|f21|f22|f23|f24|browser_back|browser_forward|browser_refresh|browser_stop|browser_search|browser_favorites|browser_home|volume_mute|volume_down|volume_up|media_next|media_prev|media_stop|media_play_pause|launch_mail|launch_media|launch_app1|launch_app2|vk\\d+|sc\\d+)(?!\\s*\\()\\b",
note: this will not only match "func()" , but it will also match "func ()" key names take precedence over custom functions next time, please paste the code in the images, so someone else won't have to retype it |
I'm curious, is there any way to make if you want, you can make all functions blue: or you can remove |
As @FuPeiJiang mentioned, all function calls should be function color, as they are not being used as keywords when they are function calls. The function color depends on your VS Code theme: in @nmpsyntax's screenshots, function color is white. Key names (AKA keywords) should not take precedence over function calls, and I will update the extension to make all function calls function color.
I will look into that.
Re-iterating this point. Here is the code in the original screenshots, both screenshots contained in one code snippet: <#Tab:: AltTab
<#c:: CenterActiveWindow()
$LAlt:: LAlt()
$*Pause:: Pause()
$AppsKey:: AppsKey()
$CapsLock:: CapsLock() |
Sorry about the code snippet, I've edited the original issue to include the code. I was trying to color the text like yours @mark-wiemer but wasn't sure how. |
No worries. You can color code in markdown by adding the language name to the end of the "fence" (the set of three backticks)
becomes Tab:: DoTabThing() |
@FuPeiJiang can you help me understand your reasoning for the changes to the regexes? For while (x > 0) ; "while" should be keyword color, not function color
{
x--
} |
reasoning: I only added if you are talking about I was talking about changing |
is there a way to match (syntax highlighting) without using regex ? |
My mistake, I had copied your code wrong. Works fine, makes sense, merged to dev.
Gotcha, my mistake again. How is this change related to the original issue?
I'm not sure what you mean, could you provide some more details? |
how it's related: here, "LAlt (" is not a keyword, but it is not a function either are there other ways to do syntax highlighting than using ahk.tmLanguage.json ? in ahk.tmLanguage.json, |
Gotcha, I will change line 282 as you mentioned. RE syntax highlighting without regex: yep, the other core way is to compile the code and analyze the abstract syntax tree (AST). I have experience with compilers, but I have limited time to dedicate to this project. I know regex matching isn't great, but it gets the job done OK for now. You're more than welcome to search how to create a VS Code Language Support extension and see what you find, I'm sure there's plenty of documentation. But switching to AST analysis is no easy feat :). Let's not discuss alternative syntax highlighting methods on this issue anymore, it's a big enough discussion for its own thread. |
I must thank both of you for investigating this issue, but after reading the comment thread, I'm none the wiser as the how you intend to conclude this. Is Pause() going to be recognized as a keyword rather than a function call? |
@nmpsyntax No worries. All function calls will be "function color" regardless of their name. In your screenshots, "function color" looks white, the same color as When you write
|
Some of my functions are not being colored correctly.
Here is the code in the images:
The text was updated successfully, but these errors were encountered: