[Lazarus] Editor File Manager in Windows menu

Martin lazarus at mfriebe.de
Fri Feb 17 15:26:39 CET 2012


On 17/02/2012 13:56, Juha Manninen wrote:
> 2012/2/17, Martin<lazarus at mfriebe.de>:
>
> I am happy you answered, Martin. I wanted to ask you about saving files.
> If you look at the source, there is
>    SrcEdit: TSourceEditor;
> I can do
>    SrcEdit.Activate;
> which is very intuitive. I can also do:
>    SrcEdit.SourceNotebook.CloseFile(SrcEdit.PageIndex);
> which is ok, too. But I cannot do:
>    SrcEdit.Save;
> or anything similar.
> So the question is how to save the files?

SrcEditor is display, save etc, is done in main.pp.

You can always track back the UserCommandEvet (send by synedit to src edit for keypress, and src-edit to main)

     procedure ProcessCommand(Sender: TObject;
        var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: 
pointer);
     procedure ProcessUserCommand(Sender: TObject;
        var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: 
pointer);


at the end of the 2nd:
         
TSourceNotebook(FaOwner).ProcessParentCommand(self,Command,aChar,Data,
                         Handled);

It either goes to
     IDECmd:=IDECommandList.FindIDECommand(Command);

Otherwise there is
     Manager.OnProcessUserCommand(Self,Command,Handled);
which is set in main.pp
   SourceEditorManager.OnProcessUserCommand := @OnProcessIDECommand;


in

procedure TMainIDE.OnProcessIDECommand(Sender: TObject;
   Command: word;  var Handled: boolean);
   ecSave:
     if (Sender is TDesigner) then begin
       GetDesignerUnit(TDesigner(Sender),ASrcEdit,AnUnitInfo);
       if (AnUnitInfo<>nil) and (AnUnitInfo.OpenEditorInfoCount > 0) then
         DoSaveEditorFile(ASrcEdit, [sfCheckAmbiguousFiles]);
     end else if (Sender is TObjectInspectorDlg) then begin
       GetObjectInspectorUnit(ASrcEdit,AnUnitInfo);
       if (AnUnitInfo<>nil) and (AnUnitInfo.OpenEditorInfoCount > 0) then
         DoSaveEditorFile(ASrcEdit, [sfCheckAmbiguousFiles]);
     end else if Sender is TSourceNotebook then
       mnuSaveClicked(Self);

---------------------------------
so much for theory

easiest is (EditorComponent  is synedit)

SrcEdit.EditorComponent.CommandProcessor(ecSave, '', nil)

acts exactly like as if triggered by keys.



>> Sorting would be nice. By either file or full name. Often I know in
>> which directory a file is, so if they were sorted....
> Can be done.
>
>> Maybe multiply  columns: folder / file / which window(s) / tab-index ...
> It should use TListView then. It can be done but requires lots of changes.
> The checkboxes must be dumped and selections used instead.
Selection is easier anyway IMHO.

If I want a single file (saved or closed), then checkbox is rather annoying.


> I don't have a FilterEdit control for TListView yet although it can be
> implemented. The filter is a very nice thing to have with any GUI
> container.
> It means I will not implement columns very soon but maybe later, yes.
>
>
>> Maybe allow to specify the sort order for the menu too.
> Do you mean changing the editor tab order from the manager window? I
> am planning to do it.
I meant the order in the list (like click on column header (if there 
were any))

> Maybe I have ask you again about how to do it best using the editor interface.
>
>> Why is it modal?
> Because a modeless window would require lots of synchronizing between
> other parts of Lazarus. Editor windows can be opened, closed, renamed
> and modified in many ways.
SrcEditor has some events, but probably not enough

   TsemChangeReason = (
     semWindowCreate,    // Called after creation of a Window
     semWindowDestroy,   // Called after removal of a Window
     semWindowActivate,  // Window is now ActiveSourceWindow (does not 
vave to be focused)
     semWindowFocused,   // The window became the active win of the 
application
     semEditorCreate,
     semEditorDestroy,
     semEditorActivate,  // Editor is ActiveEditor
     semEditorStatus     // any status change of the editor (Caret, 
Selection, topline, ...)
   );

TSourceEditorManagerInterface (base class of SrcNotebook)
     procedure RegisterChangeEvent(AReason: TsemChangeReason; AHandler: 
TNotifyEvent); virtual; abstract;
     procedure UnRegisterChangeEvent(AReason: TsemChangeReason; 
AHandler: TNotifyEvent); virtual; abstract;


semEditorStatus      goes for EVERY keypress, so only fast handlers
   it has synedits modified flag, which equals saved/modified
   To avoid slow down, there should be a filtered wersion, for the 
desired flags only

- rename can probably be added

> If there is a good notification API for it, please tell me.
>
>





More information about the Lazarus mailing list