Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Auto-Syntax-Tidy v12


  • Please log in to reply
88 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i tried v10 and that was on my laptop... now i'm usig my desktop and v11, and there's no error... i'll let you know if i can find something, though i don't think it matters now as it seems to be gone (atleast on this machine!)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I just shortened the code by 150 lines, but that's not worth an update.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
An update to version 12. First post is updated.

changes since version 11:
- tray icon allows to toggle show/hide of GUI and to exit script
- added progressbar if identation is done inside an editor and blockinput is used to limit interference
- shortend code with functions, with new features the line numbers stay equal
- log text is scrolled to the end
- on /hidden, gui is created but hidden, tray icon is visible in both cases.
- on "/watch hwnd" , gui is hidden and closes itself when hwnd closes
- on /toggle, script checks if another instance is running and closes both scripts
- improved possibilty to find path of AHK
- added warning message if syntax files do not exist
- OwnHotkey is stored in INI file and has a control in the GUI


Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Demokos
  • Members
  • 105 posts
  • Last active: Jan 20 2011 06:28 PM
  • Joined: 28 Dec 2005
For me the link in the first page is out.

mosaic
  • Members
  • 29 posts
  • Last active: Nov 04 2009 04:57 AM
  • Joined: 25 Apr 2007
What's the newest version? is v14 out there? I only managed to get v13.

I am interested in this script. Thank you for the wonderful work, toralf. I am a autohotkey newbie (used for several weeks now, loved it), I am learning how to use Notepad++ to edit ahk script, with syntax hightlighting and function list, to my dismay, the insertExt.ini fails quite frequently, I spend at least 4 hours today trying to fix up. After did many research and readings, I came to the conclusion that with my own retricted syntax, I could make it out. See my posting in this thread for details.

However, I would like to hear any expert's opinion here on how to make it work better. One thing I would like to improve is function call such as:

DllCall(arg1, arg2)

Should not be listed as function even if it is not indented, but I have no idea how to do that.

Thank you all in advance.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Hi mosaic,

I do not know where you got version 13 from. My latest version is number 12. :)

Regarding NotePad++ I can't help you since I'm not using it and this is off topic in this thread. Sorry, you'll have to try to fing help somewhere else, since I doubt that people that use NotePad++ will look here frequently.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

mosaic
  • Members
  • 29 posts
  • Last active: Nov 04 2009 04:57 AM
  • Joined: 25 Apr 2007

Hi mosaic,

I do not know where you got version 13 from. My latest version is number 12. :)

Regarding NotePad++ I can't help you since I'm not using it and this is off topic in this thread. Sorry, you'll have to try to fing help somewhere else, since I doubt that people that use NotePad++ will look here frequently.


toralf,

Thanks for your reply.

I got it in a zip file some where in this forum. the name of the zip file is PSPad_AHK_Toolbar_v1a.zip (in there, there is a v13, dated Aug 23, 2006)

The reason I am asking v14 is in the screen shot you posted in the very first message, it says v14.

I personally like the rajat style in the syntax tidy choice (after I tried both BoBo/Toralf style). However, it is slight off for function definition(for my own tast anyway). I am not so sure it's intentional or not. The following is the function definition iff from Auto-Syntax-Tidy.ahk

iif(exp,a,b=""){
		If exp
			Return a
		Return b
	}

I applied rajat style with Indentation 1xTab and Indentation of Method 1 continuation Lines: 1 Tab. As you can see, the last parances } is lined up with (, instead, I want it to line up with iif, in this case, should be the very first character in the line, like the following:


iif(exp,a,b=""){
		If exp
			Return a
		Return b
}

Is it easy to make this customization?

Finally, in terms of Notepad++'s insetExt.ini, I am sorry it is off-topic to this thread, I actually started to think about that after I read this thread. I do have a small question to ask, just bear with me. It's obviously doing some RegEx checking to get the function name. I just noticed Laszlo used the following function in this thread:

[email protected](Ptr, Type="Int") { ; Extract Type binary value pointed to by Ptr
   VarSetCapacity(Value,99)
   DllCall("RtlMoveMemory", Type . "*",Value, UInt,Ptr, UInt ; #Bytes:
   , InStr("UChar",Type) ? 1 : InStr("UShort",Type) ? 2 : InStr("UIntFloat",Type) ? 4 : 8)
   Return Value
}

So obviously @ is an acceptable character in function names, 'cause my insertExt.ini won't be able to pick it up. As it is using the following RegEx to pick up function names (the ^ in the first line is a pre-condition that the function name should appear in the beginning of the line, is this an acceptable practice to rely on this to pick up function names?, it works for me for now, well, with one exception):

^
[a-zA-Z0-9_]+

So, I made the change to include the @ character:

^
[[email protected]_]+


Now, it can pick up [email protected] as function names as well. What other character you or others can think of which are allowed in function names? Also in the same thread, Lazslo's example code made lots of DllCall without indentation, my function definition "successfull" picked them up as function names. Bummer.

Thanks a lot.

mosaic
  • Members
  • 29 posts
  • Last active: Nov 04 2009 04:57 AM
  • Joined: 25 Apr 2007
Ok, by experiment, I have found a bug:

The following code could not be Syntax-Tidied, because they use special characters(?, @) in the function, however, they are valid function names (I just tested):

isthisvalid?(){
MsgBox, is this valid?
}

[email protected](Ptr, Type="Int") { ; Extract Type binary value pointed to by Ptr
VarSetCapacity(Value,99)
DllCall("RtlMoveMemory", Type . "*",Value, UInt,Ptr, UInt ; #Bytes:
	, InStr("UChar",Type) ? 1 : InStr("UShort",Type) ? 2 : InStr("UIntFloat",Type) ? 4 : 8)
Return Value
}


mosaic
  • Members
  • 29 posts
  • Last active: Nov 04 2009 04:57 AM
  • Joined: 25 Apr 2007
I also have a feature request for your next version:

Could you add a feature that I can highlight a piece of code and press a key (say F3) to insert tabs in the front)???

Thanks.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
True there has been a special version for AHK toolbar, that I forgot about. I do not knwo if I have a version 14 somewhere. Maybe it was a mistake. I have version 13 in the AHK toolbar script. I'll have to sort it out.

Regrading your RegEx, the manual says:

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: # _ @ $ ? [ ]

Thus a RegEx would be:

identifierRE = ][#@$?\w                  ; Legal characters for AHK identifiers (variables and function names)
parameterListRE = %identifierRE%,=".\s-  ; Legal characters in function definition parameter list
RegExMatch(CurrLine, "^\s*(?P<Name>[" . identifierRE . "]+)"
                              . "\((?P<Parameters>[" . parameterListRE . "]*)"
                              . "(?P<ClosingParen>\)\s*(?P<OpeningBrace>\{)?)?"
                              . lineCommentRE, function)
taken from PhiLho
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

mosaic
  • Members
  • 29 posts
  • Last active: Nov 04 2009 04:57 AM
  • Joined: 25 Apr 2007
Thanks toralf,

I will make change in the insertExt.ini to use this new rule.

Could you confirm whether there is indeed a bug in auto-syntax-tidy.ahk when function names having those special characters in it?

Thanks for your help.

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
Hi,
I viewed and tried your script and it's great!
But I have discovered one bug with menus:

Original script menu bar:

Posted Image

Tidy-ed script menu bar:

Posted Image

The case is incorrect in "Ayuda" ("help" in english) menu and in the "Herramientas" (tools) menu the item "Calculadora" (calculator) appears in lowercase (and the item "Acerca de..." (about) in the "Ayuda" menu).

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Sorry, that the script screwed up the cases. If this happens to you, you have to turn off the case correction.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Have you ever thought about converting the script to a function so it can be reused?

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


urlwolf
  • Members
  • 150 posts
  • Last active: Feb 26 2012 07:56 PM
  • Joined: 16 Mar 2006
Another feature request:
Could you add an option to covert functions to the K&R format, i.e. function (params) { ? That's OTB for functions.

This would be handy to make this script complement this solution for editor-independent function lists:

<!-- m -->http://www.autohotke... ... ight=ctags<!-- m -->

Thanks