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
toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Auto-Syntax-Tidy is for all those people like me and Hajos who get lazy with adjusting the indentation manually as it should be (for readability of the script).

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
New features in v11:
- Command line options
- New style "BoBo"
New features in v10:
- 2 bug fixes (thanks philoh)
New features in v9:
- commands directly after Else are supported
- case correction of directives
New features in v8:
- OTB, so it is up to date with AHK 1.0.41.02
- special indentations for GUI,Tab

!!! caution !!! case correction is dangerous, since WinTitles in commands are case sensitive

This script features:

; What it does:
; It takes a AHK script and changes the indentation and case of commands according to syntax.
;
; Known limitations:
; - a space is required after the last ":" for hotkeys, hotstrings and subroutine
; - comments might not have the right indentation in certain strongly
; encapsulated block-structures, due to not knowing what the next line will bring.
; - case correction only works for words longer than 4 characters,
; (except: (in all cases) If, Loop, Else
; (optional) Goto, Gui, Run, Exit, Send, Sort, Menu
; Parse, Read, Mouse, SendAndMouse, Default, Permit, Screen, Relative
; Pixel, Toggle, UseErrorLevel, AlwaysOn, AlwaysOff
; !!! caution !!! case correction is dangerous, since WinTitles in commands are case sensitive
;
; - after doing indentation in an editor the cursor jumps
; to the first position in the last line
; - Indentation might fail, if a "{" is the last character of a Loop or If statement that
; doesn't support OTB. E.g. "If x = {" or "Loop, Parse, Var, {"
;
; Functionality:
; - Gui: For drag&drop of files, setting of options and feedback
; - command line option "/in" for file and "/log" for log file
; - command line option "/hidden" to start script with hidden GUI
; - command line option "/watch hwnd" to start script with hidden GUI, closes itself when hwnd closes
; - command line option "/toggle" checks if another instance is running and closes both scripts
; - command line option "/hidden" to start script without GUI
; - Options:
; - custom hotkey for indenation
; - custom file extension (overwrites old file if nothing is specified)
; - custom indentation (one tab or a number of spaces)
; - different indentation styles (Rajat, Toralf or BoBo)
; - indentation of continuation lines (a number of tabs or spaces)
; - indentation preservation of block continuation lines (round brackets) On/Off
; - indentation preservation of block comments (/* ... */) On/Off
; - case correction for syntax words with more than 4 characters (thanks Rajat)
; - statistics for script (lines of code, comments, total and empty an time needed)
; - Dropped Files: Contents will be indented and copied to a new file with a user
; defined extension (overwrites old file if nothing is specified).
; - Hotkey (F2): Highlighted syntax in an editor will be indented, if nothing is
; highlighted all text will be indented. (thanks ChrisM)
; - Gui remembers last position and settings between sessions (thanks Rajat)
; - The case of subroutine calls and function calls is adjusted to the case
; of their respective definitions
; - Ctrl-d toggles debug mode
; - 12% faster then version 7 (due to shortened loop cycles) but 90 lines longer
;
; !!! Not heavily tested !!!! ---- !!!!!! Backup your data !!!!!
;
; Suggestions are appreciated

ScreenShot of GUI
Posted Image

The scripts own code has been indented with itself. So you get a nice impression on how it would look like if you use the settings of the GUI.

Since the code is now 1546 lines long (1098 command lines), I only provide the code as download:AHK source code

The script started to grow in a different but now old topic. It became too long, so I opened this new one.
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.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Great user interface and documentation.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Thanks
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
A new version v9 in the first post:

New features in v9:
- commands directly after Else are supported
- case correction of directives

!!! caution !!! case correction is dangerous, since WinTitles in commands are case sensitive

Please test your complicated scripts and report any wrongly indented code. Thanks
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
New version v10 in first post:
- 2 bug fixes (thanks philoh)
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.

AHKnow*
  • Guests
  • Last active:
  • Joined: --
Great Work!!! :D

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
I know this might be tricky to impliment but since you've made such a comprehensive parser I'll ask anyway. Would it be possible to add an optimization section - in here there could be things like comment and indentation removers.. ?

autohotkey.com/net Site Manager

 

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


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Why would you want to do that? I remember that I had this discussion before, and I think the result was, that it doesn't improve much, besides some kB on your harddrive for the scripts. Compiled scripts will not have it anyway.

BTW: To remove indentation can already be done.
Removing of comments and empty lines should be easy to implement, but would again add more controls to 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.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Ah ok. Well here's something else... the GUI looks very uninviting, here's my suggestion on the frontend UI:

Posted Image

Download Static GUI Script
(< 3kb)

autohotkey.com/net Site Manager

 

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


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Titan: this is nice, but:
- this is just a guess, but maybe toralf prefers a compact GUI that matches his style of coding...
- you loose the "extension for files" functionnality, which is nice IMHO. I don't like the read-only edit fields for file path, like we see in the AHK compiler, because it doesn't allow pasting, and you have to open a dialog for the target where a simple "paste and correct name" could be enough.
- There is a regression on the placement of the edit box indicating the number of Tabs or Spaces to be used in continuation lines. With the style you used, we would believe it is a multiplier for spaces only. I was confused in the old version of Auto-Syntax-Tidy and toralf was kind enough to change that.

In both cases, I am not fan of the "Rajat vs. Toralf" style names... Those unfamiliar with these eminent members of our community would be confused, and "See the website for more details" isn't satisfying...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

- this is just a guess, but maybe toralf prefers a compact GUI that matches his style of coding...

It's standard programming/design practice to make something easy to use. It also needs to be simple and fool proof (KIS). At a glance toralf's GUI looks quite cryptic and it does not address either points in my opinion.

- you loose the "extension for files" functionnality

Remember that GUI is static. Toralf could make the save as field update with an extension automatically when the original file field is changed.

I don't like the read-only edit fields for file path

Me too, I should have made it editable.

- There is a regression on the placement of the edit box indicating the number of Tabs or Spaces to be used in continuation lines. With the style you used, we would believe it is a multiplier for spaces only. I was confused in the old version of Auto-Syntax-Tidy and toralf was kind enough to change that.

To be honest I don't even know what that does so I left it the way I saw fit.

In both cases, I am not fan of the "Rajat vs. Toralf" style names... Those unfamiliar with these eminent members of our community would be confused, and "See the website for more details" isn't satisfying...

I agree, I think it's horrible. My GUI is just a remake of the original, so it still has room for improvement.

autohotkey.com/net Site Manager

 

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


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Please advice names for the two different styles.
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

Please advice names for the two different styles.

I would if I knew what they were... :?

autohotkey.com/net Site Manager

 

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


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
test both and you'll see the difference.
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

test both and you'll see the difference.

I did and I noticed no difference :?

autohotkey.com/net Site Manager

 

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