On 05/12/2012 21:23, ik wrote:
Hello,

For a very long time now (7-8 years), that I wish to add Lazarus
possibility to split edit of my current edit (and other open files)
vertically and horizontally.
I understand that many people here don't like the idea, so I wish to
write an extension for, rather then adding it to the UI itself.
Actually, it is on my list too. But hasn't made priority yet.

Can you please give me some pointers in the matter on how to start
writing it, what should I be looking for etc... ?

Actually, you are looking at 2 things that you will need.

The first is in SynEdit. Though that depends, I will get to that in a moment.

The 2nd, is in the IDE (SourceEditor, project, ...). That is
- Adding a splitter (or rather, if the view is not yet splitted, it will just be a tiny bit on the right gutter/scrollbar) - Adding the ability to save and restore the layout, with the project session (this is not the window manager, as it is still seen as one editor, in one tab)


Back to SynEdit. There is a decision on functional issues.
Currently if you have 2 Editors in 2 windows, editing one file, then they are truly 2 editors. 2 - 2 carets (if the OS supports (GTK), and the option "Persistent caret" is set. Each has it's location, and each shows that location in the statusbar.
- 2 selections, and tey can be in different places
- 2 syncro edits
...

IMHO that is not what one expects from a split view. It should be one of each (one editor). - Except for each split it will remember (but not show, unless active) the caret pos. - But for example it is one selection. Changing the selection affects all splits (as they are views on the same editor).

***** SynEdit

*** "2 Edit approach"
Yet the first (2 edit) is already implemented. The 2nd still needs doing.
If chosen, it should be done in a way, that it can later be replaced.

*** "1 Edit approach"
If the 2nd is done, it raises the question, if each split should have a wincontrol (with a handle). The difference is, if you edit something in the upper split, that is also seen in the lomer split, the with ore wincontrol (on most OS) the invalidate is the minimum rectangle covering both lines.
This repaints a lot of text that has not changed (battery life on laptopts)

With the recent introduction of "TLazSynTextArea = class(TLazSynSurface)" the 2nd solution became a lot easier. (See ide/SourceSynEditor TopInfoHint). Looking at TopInfoHint would be the starting point for this. (And then to check for details with me)

***** Project
You need to discover that on your self. Its a while ago, and I can only give you bits and pieces.

Files, SourceEditor (do not add dopendencies in uses, add events), main.pp, project.pp (I think someone recently factored some code into a 4th file...)

procedure TSourceEditor.UpdateProjectFile;
begin
  if Assigned(Manager) and Assigned(Manager.OnEditorMoved)
    then Manager.OnEditorMoved(self);
end;

leads you to main.pp, line 2031
  SourceEditorManager.OnEditorMoved := @OnSrcNotebookEditorMoved;


procedure TMainIDE.OnSrcNotebookEditorMoved(Sender: TObject);
var
  p: TUnitEditorInfo;
  i: Integer;
  SrcEdit: TSourceEditor;
begin
  SrcEdit := TSourceEditor(Sender);
  p :=Project1.EditorInfoWithEditorComponent(SrcEdit);
  if p <> nil then begin
    p.PageIndex := SrcEdit.PageIndex;
p.WindowIndex := SourceEditorManager.IndexOfSourceWindow(SrcEdit.SourceNotebook);
    p.IsLocked := SrcEdit.IsLocked;
  end
  else if SrcEdit.IsNewSharedEditor then begin
    // attach to UnitInfo
    SrcEdit.IsNewSharedEditor := False;
    i := 0;
while (i < SrcEdit.SharedEditorCount) and (SrcEdit.SharedEditors[i] = SrcEdit) do
      inc(i);
    p := Project1.EditorInfoWithEditorComponent(SrcEdit.SharedEditors[i]);
    p := p.UnitInfo.GetClosedOrNewEditorInfo;
    p.EditorComponent := SrcEdit;
    p.SyntaxHighlighter := SrcEdit.SyntaxHighlighterType;
p.CustomHighlighter := p.SyntaxHighlighter <> p.UnitInfo.DefaultSyntaxHighlighter;
  end;
end;


Look at the UnitInfo stuff...




--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to