Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-02

Editor File Manager in Windows menu

14 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

I implemented a new feature: an Editor File Manager. It can be found as the first item in Windows menu. It becomes very useful when you have lots of files open. Please check out and give comments.

Juha

Reply by email

Martin
to Juha Manninen
Juha Manninen wrote 5 lines
I implemented a new feature: an Editor File Manager. It can be found as the first item in Windows menu. It becomes very useful when you have lots of files open. Please check out and give comments.

Nice.

Sorting would be nice. By either file or full name. Often I know in which directory a file is, so if they were sorted....

Maybe multiply columns: folder / file / which window(s) / tab-index ...

Maybe allow to specify the sort order for the menu too.

Reply by email

Martin
to Martin
Martin wrote 14 lines
On 17/02/2012 12:59, Juha Manninen wrote: > I implemented a new feature: an Editor File Manager. > It can be found as the first item in Windows menu. > It becomes very useful when you have lots of files open. Please check > out and give comments. > Nice. Sorting would be nice. By either file or full name. Often I know in which directory a file is, so if they were sorted.... Maybe multiply columns: folder / file / which window(s) / tab-index ... Maybe allow to specify the sort order for the menu too.

Why is it modal?

Reply by email

Juha Manninen
to Martin: Why is it modal?

2012/2/17, Martin :

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?

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. 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.
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.
If there is a good notification API for it, please tell me.

The manager window is very useful even when it is modal.

I took a similar challenge when I changed the TabOrder dialog from modal to modeless some time ago. It required lots of synchronization with the form designer. The notification mechanism was already there so it was not very hard after all.

Juha

Reply by email

Martin
to Juha Manninen
Juha Manninen wrote 13 lines
2012/2/17, Martin: 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 (AnUnitInfonil) and (AnUnitInfo.OpenEditorInfoCount > 0) then
         DoSaveEditorFile(ASrcEdit, [sfCheckAmbiguousFiles]);
     end else if (Sender is TObjectInspectorDlg) then begin
       GetObjectInspectorUnit(ASrcEdit,AnUnitInfo);
       if (AnUnitInfonil) 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.

Show quoted text 7 lines
> 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.

Show quoted text 9 lines
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))

Show quoted text 6 lines
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.

Reply by email

Juha Manninen
to Juha Manninen

SrcEdit.EditorComponent.CommandProcessor(ecSave, '', nil) did not really work, but this did:
LazarusIDE.DoSaveEditorFile(SrcEdit, [])

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

Now these 2 things are mixed. You can use a single selection to activate and close a file (there is a popup menu). But, you must use checkboxes for multiple file operations. I understand it could be done with selections, too.
Maybe I must rethink it...

Martin, one more question if you don't mind: How to change editor tab order? If you don't remember the answer by hart, I can study the code later and find out myself.

Thanks for all the info. I will look at it later.

Juha

2012/2/17, Juha Manninen :

Show quoted text 10 lines
2012/2/17, Mattias Gaertner : > Caption needs a resourcestring. > The file list needs scrollbars. > While loading IDEImages: Resource "laz_close" not found I fixed the caption and image. A vertical scrollbar is there automatically. I didn't find a way to set a horizontal scrollbar in TChecklistBox. Juha

Reply by email

Martin
to Juha Manninen
Juha Manninen wrote 5 lines
Martin, one more question if you don't mind: How to change editor tab order? If you don't remember the answer by hart, I can study the code later and find out myself.
procedure TSourceNotebook.MoveEditor(OldPageIndex, NewPageIndex: integer);

If you allow sorting tabs, how do you display files, that are open in several windows?

Reply by email

zeljko
to Martin: Nice. Sorting would be nice. By either file or full name. Often I know in which directory…
Martin wrote 10 lines
On 17/02/2012 12:59, Juha Manninen wrote: > I implemented a new feature: an Editor File Manager. > It can be found as the first item in Windows menu. > It becomes very useful when you have lots of files open. Please check > out and give comments. Nice. Sorting would be nice. By either file or full name. Often I know in which directory a file is, so if they were sorted....

+1

Maybe multiply columns: folder / file / which window(s) / tab-index ...

tab index / unit name + (filename without path)/ changed-not changed (can be just asterisk) / full path

+1

Maybe allow to specify the sort order for the menu too.

Sort order for the menu ?

zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120218/8723af20/attachment.html>

Reply by email

zeljko
to Juha Manninen: 2012/2/17, Mattias Gaertner : I fixed the caption and image. A vertical scrollbar is…
Juha Manninen wrote 7 lines
2012/2/17, Mattias Gaertner : > Caption needs a resourcestring. > The file list needs scrollbars. > While loading IDEImages: Resource "laz_close" not found I fixed the caption and image. A vertical scrollbar is there automatically. I didn't find a way to set a horizontal scrollbar in TChecklistBox.

Why don't you use TListView + Checkable ?

zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120218/0bc80960/attachment.html>

Reply by email

Juha Manninen
to Martin: procedure TSourceNotebook.MoveEditor(OldPageIndex, NewPageIndex: integer); If you allow…

2012/2/17, Martin :

procedure TSourceNotebook.MoveEditor(OldPageIndex, NewPageIndex: integer);

TSourceNotebook.MoveEditor(...)
is protected, so I used:
TSourceNotebook.NotebookPages.Move(...)

If you allow sorting tabs, how do you display files, that are open in several windows?

Now it lists all windows in all editor windows and allows moving them inside the same window. If you try to move over the boundary, you get a "List index out bounds" error.
I will look at it later.

Zeljan, a future version will use TListView + Checkable. It may take some time though. I would like to implement the filter edit control for TListView at the same go.

Juha

Reply by email

Martin
to Juha Manninen
Juha Manninen wrote 5 lines
2012/2/17, Martin: > procedure TSourceNotebook.MoveEditor(OldPageIndex, NewPageIndex: integer); TSourceNotebook.MoveEditor(...) is protected, so I used: TSourceNotebook.NotebookPages.Move(...)
That is dangerous, yuo must also do
   UpdatePageNames;
   UpdateProjectFiles;

At least the 2nd is needed or changes do not go into the session (and maybe other problems...

But more so, yours is not future save....

Feel free to make MoveEditors public
(Note there is a version with window-index too. best keep them together)

General rule here is.
Things are added and kept none public, if not needed. Helps future refactoring.
If needed, then most methods can be made public

Show quoted text 21 lines
> If you allow sorting tabs, how do you display files, that are open in > several windows? Now it lists all windows in all editor windows and allows moving them inside the same window. If you try to move over the boundary, you get a "List index out bounds" error. I will look at it later. Zeljan, a future version will use TListView + Checkable. It may take some time though. I would like to implement the filter edit control for TListView at the same go. Juha -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Juha Manninen
to Martin

2012/2/19, Martin :

Feel free to make MoveEditors public (Note there is a version with window-index too. best keep them together)

Done.
The EditorFileManager behaves quite well now.

Juha

Reply by email