(Main home page - http://www.bigfoot.com/~davidsont/astyle)
Artistic Style is a C++ port of the Java-based JStyle.
When indenting source code, we as programmers have a tendency to use both spaces and tab characters to create the wanted indentation. Moreover, some editors by default insert spaces instead of tabs when pressing the tab key, and other editors (Emacs for example) have the ability to "pretty up" lines by automatically setting up the white space before the code on the line, possibly inserting spaces in a code that up to now used only tabs for indentation.
Since the NUMBER of space characters showed on screen for each tab character in the source code changes between editors (until the user sets up the number to his liking...), one of the standard problems facing programmers when moving from one source code editor to another is that code containing both spaces and tabs that was up to now perfectly indented, suddently becomes a mess to look at when changing to another editor. Even if you as a programmer take care to ONLY use spaces or tabs, looking at other peoples source code can still be problematic.
To address this problem I have created Artistic Style - a series of filters, written in C++, that automatically reindent & reformat C/C++/Java source files. These can be used from a command line, or it can be incorporated as classes in another C++ program.
Artistic Style is distributed under the "Artistic License" - the same used by the Perl programming language.
1) Unzip astyle.zip and compile 'astyle' (read README.txt for instructions).
2) Either place the resulting executable file's directory in your PATH system-variable, or move the executable to a directory that appears in your PATH system-variable.
3) Run it with the following syntax:
astyle [options]< OriginalSourceFile > BeautifiedSourceFile
OR
astyle [options]Foo.java Bar.javaAnotherBar.java [ . . . ]
The < and > characters are used to redirect the files into standard input and out of standard output - don't forget them!!!
The following indentation options are currently avaiable:
-j - Indent a Java file.
-t - Indent using a tab characters.
-s# - Indent using # spaces per indent (i.e. -s2).
-m# - Indent a maximal # spaces in a continuous statement, relatively to the previous line(i.e. -m40)
-ib - Add extra indentation to brackets.
-fs - Flush (i.e. don't indent) 'switch' blocks..
-h - print help message and quit
The following formatting options are currently avaiable:
-bb - Break brackets from their pre-block statements ( i.e. ANSI C, C++ style ).
-ab - Attach brackets to their pre-block statements ( i.e. Java style ).
-p - Insert space padding around operators.
Not specifying any option will bring to C/C++ style indentation, with a default of 4 spaces per indent, and NO formatting.
Reach me at davidsont@bigfoot.com
- If you find a bug, please send me a bug-report including an example source code that generates the bug, and I will try to fix it as fast as possible.
- If you find a bug and find a fix for it in the source code, please send me a bug-report together with an example source-code that generates the bug PLUS the corrected ASBeautifier.java file, so that I can learn from it and publish it.
-Thanks to Jim Watson for creating the help message option !!!
-Thanks to all the dedicated beta-testers and bug notifiers!!!