Script formatter

is anyone aware of any script formatters that can be used / plugged in and used with the source memo controls?

Hi Stuart, not sure what you mean? Syntax styles? You have the Pascal and Basic syntax stylers with TScrMemo. If you use the TAdvMemo component you have much more syntaxes (SQL, C, etc.)

I don't mean syntax highlighting.



I mean the ability to format or beautify the entered script / code, like we can perform within the Delphi code editor (Format Source - Ctrl+d).



I appreciate that this is not directly available within the TxxxMemo components and the reason why I asked about other plug ins that may be available.

Ah ok. None that I'm aware of. Maybe other users know something about it?

The code formatter in GExperts (which I think shares a lot of code with DelForEx) is here:

https://sourceforge.net/p/gexperts/code/HEAD/tree/trunk/Source/Formatter/

It uses ToolsAPI to grab the instance of the delphi IDE editor, and registers itself as an expert in the IDE.

It has a "format file" option too.

If someone was really ambitious, it might be possible to use most of this - create a new wrapper that instead takes a string (or stream) and formats it, returning the results to the ScrMemo or AdvMemo.

Might be a LOT of work: I'm just wondering if the non-standard syntax would break the parser (not requiring var types, etc).

(Actually, I just tried it on fSnake.psc - copied and pasted the code into a new unit in RX10.1. It formatted just fine).

There's also formatter experts in cnPack and JCL.


Cheers,
EdB