Hi all
Hi all,
Using the ToolsAPI, does anyone know how to get the current size of the .pas file (which may be different to the size on disk, due to unsaved changes)?
Using the ToolsAPI, does anyone know how to get the current size of the .pas file (which may be different to the size on disk, due to unsaved changes)?
Uwe Schuster Thomas Mueller Yeah, I didn't give much context around what I am trying to do but IOTAEditorContent.Content does look interesting. Yes, DXE or better :)
ReplyDeleteContext: At work, we have a standard on how the 'uses' clause is set out and within reviews if there is even one out of place, then people will jump on it like there is no tomorrow. So what I was thinking was to write a plug-in that on a save, checks the 'uses' clause (using Roman Yankovsky 's DelphiAST - gotta use it for something!!) and rewrite it accordingly - just the 'uses' clause, no source (re)formatting.
From the examples of DelphiAST I have seen, it needs either a string or a (T)stream (from memory).
Even if this project doesn't pan out, it will be a learning session on ToolsAPI and DelphiAST.
Roland Wind Thanks for the information, I will check it out to see how GExperts does that (you never know when something like that might be handy) :-D
ReplyDeleteHi Nicholas
ReplyDeleteWhen you want to use the GExperts part, you will find the Interface in GX_EditorChangeServices. Here is a small part of Code to use it:
TEditorNotifier = class(TInterfacedObject, IGxEditorNotification)
private
FChangeServiceNotifierIndex: Integer;
protected
// IGxEditorNotification
procedure NewModuleOpened(const Module: IOTAModule);
procedure SourceEditorModified(const SourceEditor: IOTASourceEditor);
procedure FormEditorModified(const FormEditor: IOTAFormEditor);
procedure ComponentRenamed(const FormEditor: IOTAFormEditor;
Component: IOTAComponent; const OldName, NewName: string);
function EditorKeyPressed(const SourceEditor: IOTASourceEditor; CharCode: Word; KeyData: Integer): Boolean;
procedure SourceEditorActivated(const SourceEditor: IOTASourceEditor);
function GetIndex: Integer;
protected
procedure Attach;
public
constructor Create(Owner: TComponent);
destructor Destroy; override;
procedure Detach;
end;
If you did not want to use GExperts, than you can use the Notifier from IOTAEditor. There you can attach an IOTANotifier.