It’s not really hard to make the indent-while-you-type part…
I just wrote 1 way to do it below. I hope it won’t scare you off…
Actually, making the “clean indent” tool might even be easier.
I guess there’s an event to catch when a user types something. Just make it react when n opening brace ( ‘{’ ), closing brace ( ‘}’ ) or a newline ( enter key, be it numpad or large return key ) is entered in the text field.
(Note: allso check if the length of the inserted text is larger then 1 token, in that case he’s pasting and you won’t want to indent at that moment)
Then you got to write those events. Entering ‘{’ will set a flag ‘indent’. As soon a new-line is entered after that, a new line will be made having more tabs then the previous line. (You’d need a function to count tab characters then from a given line of text. It will allso need some work to extract the previous line from the script itself.)
If the user doesn’t press “enter” or clicks somewhere else in the text field, the flag is set off.
Now nearly the same happens when you press ‘}’. Here you should check if the cursor was on an empty line. (Save for tabs) In that case, you would check how many tabs there are on the previous line, and place one less on this line.
In case of a newline, it should create a new line but allso insert as many tabs as there were on the previous line.
I might be able to write the code for this myself, but I know that the project wouldn’t get finished without some pressure.