 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
abp Guest
|
Posted: Fri Feb 23, 2007 2:10 pm Post subject: For those who use Notepad++ (aka npp) |
|
|
in notepad++ there is a 'function list' plugin, which does not support AHK syntax.
but you can add user defined rules, so that view a list of functions or hotkeys.
here is my ini file.
| Code: |
[Function List]
Show all functions=0
Sort by names=0
showCmd=0
[User Languages]
Count User Languages=1
Name 1=AHK Autohotkey
KeyWBodyBeg 1=
KeyWBodyEnd 1=
MatchCase 1=0
Count Comment 1=0
Count Syntax 1=3
Syntax P1.1.1=
Syntax P2.1.1=\([a-zA-Z0-9_, \t]*\)
Syntax P3.1.1=[a-zA-Z0-9_]+
Syntax P4.1.1={
Syntax P5.1.1=}
Syntax P6.1.1=$
Syntax P1.2.1=
Syntax P2.2.1=
Syntax P3.2.1=[#!^+&*~$ -=\[\]\\;',./A-Za-z0-9]+[:][:]
Syntax P4.2.1=
Syntax P5.2.1=
Syntax P6.2.1=
Syntax P1.3.1=
Syntax P2.3.1=
Syntax P3.3.1=
Syntax P4.3.1=
Syntax P5.3.1=
Syntax P6.3.1=
[HEX-Editor]
Columns=16
Bits=1
Binary=0
Little=0
Capitel=0
Extensions=
|
Save it as insertExt.ini and move it into your notepad++ directory.(eg. c:\program files\notepad++)
make sure you set AHK as user defined language. it can be done by copying ahkdir\extras\notepad++\userDefineLang.xml into your notepad++ directory.
 |
|
| Back to top |
|
 |
HuBa
Joined: 24 Feb 2007 Posts: 172 Location: Budapest, Hungary
|
Posted: Sat Feb 24, 2007 6:25 pm Post subject: |
|
|
Great!
But sadly it has an annoying effect: it can't handle the standalone % characters.
example: | Code: | | DataPath := % A_ScriptDir "\Data\" ; This is a valid assignment | (EDIT: fixed syntax )
Every code appears in orange color after the % sign. Can you fix it?
Last edited by HuBa on Sun Feb 25, 2007 7:32 pm; edited 1 time in total |
|
| Back to top |
|
 |
abp Guest
|
Posted: Sun Feb 25, 2007 7:09 pm Post subject: |
|
|
Dear HuBa,
You're right. AHK highlighting with NPP is not perfect, because it's not so configurable.
If you don't mind, you can use my customized version.
it's not perfect neither, but i think it would be better.
http://www.playnow.co.kr/link/d78da0a4960/userDefineLang.xml
anyway,
| Quote: | example:
| Code: | | DataPath := % A_ScriptDir "\Data\ ; This is a valid assignment |
|
Is this a valid assignment?
p.s> Above ini doesn't recognize a function which has an optional parameters. This would work correctly. |
|
| Back to top |
|
 |
HuBa
Joined: 24 Feb 2007 Posts: 172 Location: Budapest, Hungary
|
Posted: Sun Feb 25, 2007 7:36 pm Post subject: |
|
|
| Quote: | | Is this a valid assignment? |
LOL, you are right, I forget the closing "
Thanx for the config files! The code is now beautiful!!!!  |
|
| Back to top |
|
 |
HuBa
Joined: 24 Feb 2007 Posts: 172 Location: Budapest, Hungary
|
Posted: Thu May 03, 2007 9:16 pm Post subject: Notepad++ 4.1 |
|
|
I made a modified version of userDefineLang.xml
- It includes 2 new variable: True and False
- And 3 new operator: And, Not, Or
- Light background color for comment.
- Changed text colors a bit.
Also there is a new version out there: Notepad++ 4.3
It features a new tabbed find dialog and url styling with dblclick handling.
Be careful with the %APPDATA% option in installer!
Last edited by HuBa on Sat Oct 13, 2007 8:15 am; edited 1 time in total |
|
| Back to top |
|
 |
mosaic
Joined: 25 Apr 2007 Posts: 20
|
Posted: Sun May 06, 2007 1:04 pm Post subject: Re: Notepad++ 4.1 |
|
|
| HuBa wrote: | I made a modified version of userDefineLang.xml
- It includes 2 new variable: True and False
- And 3 new operator: And, Not, Or
- Light background color for comment.
- Changed text colors a bit.
Also there is a new version out there: Notepad++ 4.1
It features a new tabbed find dialog and url styling with dblclick handling.
Be careful with the %APPDATA% option in installer! |
Nice. Thanks a lot HuBa.
By the way, I have a question on function list based on the definition in insertExt.ini
The following few examples will display incorrect function lists:
| Code: |
this_function_does_not_show_but_should_be_shown(help="default help string", test=){
} ; this the
if this_function_should_not_show_but_show(hello, haha) { ;if this is true
}
If (InStr(FirstWord,"::")) {
; this is shown as hotkey because of :: in the string, oops, another one
; so :: should not even appear in the comment
}
DLLCall(arg1, arg2) ; this one should not be listed as function but it is
; if you make lots of DllCall, guess what you will see
anothergoodfunction_not_shown( arg1, ; comment for arg1
arg2 ; comment for arg2
)
{
}
|
I have no knowledge of how to change insertExt.ini. Is there a documentation somewhere to explain the Syntax?
Thanks |
|
| Back to top |
|
 |
mosaic
Joined: 25 Apr 2007 Posts: 20
|
Posted: Sun May 06, 2007 5:04 pm Post subject: Modified insertExt.ini and some rules to display func list |
|
|
After spend a good few hours, I made some progress.(sort of). Here is what I find out and I thought might as well share back with all of you.
First of all, there are very few information available on insertExt.ini, however, in Notepad++, goto Plugins->Function List->User Rules, that's where you can define this insertExt.ini, when you open the gui, you can click help (underneath Remove Rule button), you can get a small help.
Secondly, I tried various way, but I think, mostly probably due to my limited knowledge, I can't get them work.
Thirdly, I found out that if I stick to certain rules in my coding, I got enlightened by the Auto-Syntax-Tidy.ahk script , I maybe more likely to succeed.
Here is my version insertExt.ini ( I started with abp's version, thanks for the clue)
| Code: |
[Function List]
Show all functions=1
Sort by names=0
showCmd=0
[User Languages]
Count User Languages=1
Name 1=AHK Autohotkey
KeyWBodyBeg 1=
KeyWBodyEnd 1=
MatchCase 1=0
Count Comment 1=1
Count Syntax 1=3
Syntax P1.1.1=^
Syntax P2.1.1=\([a-zA-Z0-9_,="; \t]*\)
Syntax P3.1.1=[a-zA-Z0-9_]+
Syntax P4.1.1={
Syntax P5.1.1=}
Syntax P6.1.1=$
Syntax P1.2.1=^
Syntax P2.2.1=
Syntax P3.2.1=[#!^+&*~$ -=\[\]\\;',./A-Za-z0-9]+[:][:][ \t]*$
Syntax P4.2.1=
Syntax P5.2.1=
Syntax P6.2.1=
Syntax P1.3.1=
Syntax P2.3.1=
Syntax P3.3.1=
Syntax P4.3.1=
Syntax P5.3.1=
Syntax P6.3.1=
Comment P1.1.1=/*
Comment P2.1.1=*/
[HEX-Editor]
Columns=16
Bits=1
Binary=0
Little=0
Capitel=0
Extensions=.exe .dll
|
As you can see, I added the requirement that all the function definition can't be indented or leave any spaces. If I stick to this rule, I simplied many problems I faced, as I listed in the previous post. But this still does not solve this:
| Code: | | DllCall(helo, helo) | or this
| Code: | If(true) {
;do something
}
|
So I made another rule, all function call (and anything resembling function definition) should be indented, in that way, they will not be listed in the function list.
The following is my test script, which shows the functions are listed correctly
| Code: |
/* Some Rules
If calling a function, make sure to indent the calling function
function definition should not be indented
In the function argument block, if there are comments, don't use any more ()
*/
weppp::
function2(arg1="::", arg2){
}
function(help="default help string", test=){
} ; this the
; make DllCall like this, leave some room in the begining
DLLCall(helo, helo)
; make if block like this, leave some room in the begining
if(true) { ; do something
}
if thisisnotfunction(hello, haha) { ;hello
}
functiongood(ha, ha) ; comment
{ ; more comment
}
functiongood2(arg1, arg2) { ; another good one """
} ; comment
Anothergoodfunct( arg1, ; some comment for arg1, *****
arg2 ; some comment for arg2, avoid using left parences in the comment section
)
{
}
|
Last edited by mosaic on Mon May 07, 2007 3:59 pm; edited 1 time in total |
|
| Back to top |
|
 |
mosaic
Joined: 25 Apr 2007 Posts: 20
|
Posted: Mon May 07, 2007 1:03 pm Post subject: |
|
|
I made some changes to insertExt.ini to include @ as valid character in function names as mentioned here.
I also greatly simplified the RegEx rule in the function argument block to not allow additional ( character. Even that could not happen if there are comments for argument as the following a legit function definition:
| Code: |
valid_function_heh(arg1, ; comment for arg1
arg2 ; comment for arg2, !@#$%^^&&**(()_+
)
{
}
|
But that will throw things off too much, here is the new insertExt.ini file:
| Code: |
[Function List]
Show all functions=1
Sort by names=1
showCmd=0
[User Languages]
Count User Languages=1
Name 1=AHK Autohotkey
KeyWBodyBeg 1=
KeyWBodyEnd 1=
MatchCase 1=0
Count Comment 1=1
Count Syntax 1=3
Syntax P1.1.1=^
Syntax P2.1.1=\([^(]*\)
Syntax P3.1.1=[a-zA-Z0-9@#?\[\]_]+
Syntax P4.1.1={
Syntax P5.1.1=}
Syntax P6.1.1=$
Syntax P1.2.1=
Syntax P2.2.1=
Syntax P3.2.1=[#!^+&*~$ -=\[\]\\;',./A-Za-z0-9]+[:][:][ \t]*$
Syntax P4.2.1=
Syntax P5.2.1=
Syntax P6.2.1=
Syntax P1.3.1=
Syntax P2.3.1=
Syntax P3.3.1=
Syntax P4.3.1=
Syntax P5.3.1=
Syntax P6.3.1=
Comment P1.1.1=/*
Comment P2.1.1=*/
[HEX-Editor]
Columns=16
Bits=1
Binary=0
Little=0
Capitel=0
Extensions=.exe .dll
|
If anyone is trying and running into problems, please let me know. Thanks. |
|
| Back to top |
|
 |
mosaic
Joined: 25 Apr 2007 Posts: 20
|
Posted: Mon May 07, 2007 3:34 pm Post subject: |
|
|
I updated the insertExt.ini to reflect the following:
| Quote: | Variable names: Variable names are not case sensitive (for example, CurrentDate is the same as currentdate). Variable names may be up to 254 characters long and may consist of letters, numbers and the following punctuation: # _ @ $ ? [ ]
|
This is in response to toralf's message Thanks toralf.
Using this new rule, the following extreme case function name could be picked up:
| Code: |
Is_This_Valid?#[@index](){
MsgBox, is this valid?
}
|
|
|
| Back to top |
|
 |
Avalon
Joined: 11 May 2007 Posts: 28
|
Posted: Fri May 11, 2007 10:11 pm Post subject: |
|
|
| I know it's a very lame question, but how can I install a userDefined language from that xml file linked above? |
|
| Back to top |
|
 |
mosaic
Joined: 25 Apr 2007 Posts: 20
|
Posted: Sat May 12, 2007 12:00 am Post subject: |
|
|
| Avalon wrote: | | I know it's a very lame question, but how can I install a userDefined language from that xml file linked above? |
Avalon,
No question is lame. To install the the XML file, just copy it (userDefined.xml) to your notepad++ directory (the same directory where your notepad++.exe resides), and afterwards, you probably need to restart your notepad++ program for it to take effect.
GL, and let me know if you ran into any problem. |
|
| Back to top |
|
 |
Avalon
Joined: 11 May 2007 Posts: 28
|
Posted: Sat May 12, 2007 7:42 am Post subject: |
|
|
| mosaic wrote: |
[...]
To install the the XML file, just copy it (userDefined.xml) to your notepad++ directory (the same directory where your notepad++.exe resides), and afterwards, you probably need to restart your notepad++ program for it to take effect.
[...]
|
This is exactly what I did, but somehow I had messed up my Npp, and did nothing. :S Now I overwrote it with a freshly downloaded, and it works perfectly.
Thanks for the kind help!  |
|
| Back to top |
|
 |
haichen
Joined: 05 Feb 2007 Posts: 110 Location: Osnabrück, Germany
|
Posted: Sat May 12, 2007 6:47 pm Post subject: |
|
|
| Quote: | To install the the XML file, just copy it (userDefined.xml) to your notepad++ directory (the same directory where your notepad++.exe resides), and afterwards, you probably need to restart your notepad++ program for it to take effect.
| I had to put the files in C:\Documents......r\Application Data\Notepad++
Then it worked. |
|
| Back to top |
|
 |
mosaic
Joined: 25 Apr 2007 Posts: 20
|
Posted: Sat May 12, 2007 9:02 pm Post subject: Updated insert.ini to support Subroutines |
|
|
I have updated the insertExt.ini to include support for subroutines.
Here it is:
| Quote: |
[Function List]
Show all functions=1
Sort by names=1
showCmd=0
[User Languages]
Count User Languages=1
Name 1=AHK Autohotkey
KeyWBodyBeg 1=
KeyWBodyEnd 1=
MatchCase 1=0
Count Comment 1=1
Count Syntax 1=4
Syntax P1.1.1=^
Syntax P2.1.1=\([^(]*\)
Syntax P3.1.1=[a-zA-Z0-9@?#\[\]_]+
Syntax P4.1.1={
Syntax P5.1.1=}
Syntax P6.1.1=$
Syntax P1.2.1=
Syntax P2.2.1=
Syntax P3.2.1=[#!^+&*~$ -=\[\]\\;',./A-Za-z0-9]+[:][:][ \t]*$
Syntax P4.2.1=
Syntax P5.2.1=
Syntax P6.2.1=
Syntax P1.3.1=^
Syntax P2.3.1=[ \t]*$
Syntax P3.3.1=[a-zA-Z0-9@?#\[\]_]+[:]
Syntax P4.3.1=
Syntax P5.3.1=^[Rr]eturn[ \t]*$
Syntax P6.3.1=$
Comment P1.1.1=/*
Comment P2.1.1=*/
Syntax P1.4.1=
Syntax P2.4.1=
Syntax P3.4.1=
Syntax P4.4.1=
Syntax P5.4.1=
Syntax P6.4.1=
[HEX-Editor]
Columns=16
Bits=1
Binary=0
Little=0
Capitel=0
Extensions=.exe .dll
|
As usual, some rules to use this insertExt.ini
| Quote: |
/* Some Rules
If calling a function, make sure to indent the calling function
Function definition should not be indented or leave any spaces in the front
In the function argument block, if there are comments, don't use any more ()
When making a subroutine label, make sure don't use any indentation or leave any spaces in the front, just like function definition, same with the return statement which end the subroutine.
For example:
Sub1:
; your code blocks here
; there could be more return statement in between
; you should indent those earlier return statement (usually under certain if conditioning statement
Return
Sub1 should be correctly picked up in the function lists now.
*/
|
I also went to the Notepad++ plugin developement forum asking for some help, as the parser for function list plugin will treat the following if statement (in C/C++) as functions:
| Quote: |
if(x>y) {
printf("x is bigger than y");
} else {
if(x<y) {
printf("x is smaller than y");
} else { // x=y
printf("x is the same as y");
}
}
|
This demonstrates the problem with function list displaying problem is not unique in ahk script. This enhances my belief that if you follow a strict rule of coding, you may more likely to succeed. As a matter of fact, since ahk support is not built in, we can succeed way faster than those built-in languages. The problem I mentioned above still exists in the newest version of NPP, however, if you use my insertExt.ini, and follow the rules I mentioned above, you eliminate the problem right away.
This is usually possible with your own code. However, what if you are reading other people's code. To quickly modify it, I recommend to use the toralf's Auto-Syntax-Tidy.ahk, pick a style you like.
This will usually solve majority of the problem. Except making function calls in the autoexec section of the code. I recommend the C/C++ approach. Convert your autoexec into a subroutine called Main, keep it on the stop of your script, so it will still be autoexecuted.
| Code: |
Main:
; your original autoexec code for ahk script
Return
; your other code
|
This works in 98% of the time, on some weird situations, Subroutine labels could be displayed in the function list twice for the same Subroutine, I tried in vain to fix it. I can produce examples here if some of you are interested and may want to help to find a solution.
Anyway, hope this is helpful for some of you who are using Notepad++ to do ahk scripting. ( I am a total newbie to Notepad++ as well )
There is a bug in the userLangDefine.xml which affecting the folding capability, I have no idea how to modify the userLangDefine.xml.
Use the following example, load into your Notepad++
| Code: |
If RadUpdateOnClick {
;dosomething
}Else { ; dosomethingelse
}
;;;add a whole bunch of code afterwards
string2 = {
string1 := "{"
;MsgBox % StrLen(string2) StrLen(string1)
If(string1=string2)
MsgBox, They are the same
}
|
What is going to happen is, the if block will include everything afterwards as if they are all on the same block. After many trial and error, I found out, if you leave a space between } and Else, the problem disappears. Go ahead and try it for yourself.
Anyway, these are my 2 cents for the community. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Sat May 12, 2007 9:22 pm Post subject: |
|
|
Thanks for your contribution,
I considering to use NPP. When that time comes, I will use your files. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|