Recent

Author Topic: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}  (Read 111428 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
Quote
Code: Pascal  [Select]
  1.  
  2. Procedure First (n : longint); forward;

I just checked. "forward" is already handled. It closes the fold, so the next proc is not affected.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
from your code
Code: Pascal  [Select]
  1. //avoid bug of IncludeOpeningOnLine := False;
  2.     not ((sfaOpen in TmpNode.FoldAction)  and (TmpNode.LineIndex + 1 = aRow)) then

How to reproduce this bug?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
Code: Pascal  [Select]
  1.                      sfaOutlineNoColor,     // Node will not painted by nested-coloring, but may increase color (e.g. any "procedure")
  2.                      sfaOutlineNoLine,      // Node doesn't want to have vertical line. (e.g. "then")
  3.  

Should those be in the node?

I would imagine it is better if
Code: Pascal  [Select]
  1. TSynCustomFoldConfigMode = (fmFold, fmHide, fmMarkup, fmOutline);
would *instead* of fmOutline have
  fmOutlineLine
  fmOutlineColor

Then it can be userconfigured for each node.

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
@Martin_fr,
unfortunately I am very busy now doing something else (daily job) fyi.
I will back on it perhaps next week. sorry 8)
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
from your code
Code: Pascal  [Select]
  1. //avoid bug of IncludeOpeningOnLine := False;
  2.     not ((sfaOpen in TmpNode.FoldAction)  and (TmpNode.LineIndex + 1 = aRow)) then

How to reproduce this bug?
That happened when loading included file {$I including.pas} that has no unit, no program, just direct functions.
But I tried using your last changes, its not a bug.
Try this:



1.
Code: Pascal  [Select]
  1.  
  2. constructor TSynEditMarkupFoldColors.Create(ASynEdit: TSynEditBase);
  3. begin
  4.   FNestList.IncludeOpeningOnLine := False;//// True; //False; //
  5.  


2.

Code: Pascal  [Select]
  1.  
  2.     if (sfaOutline in TmpNode.FoldAction )
  3.     //avoid bug of IncludeOpeningOnLine := False;
  4. //    and not ((sfaOpen in TmpNode.FoldAction)  and (TmpNode.LineIndex + 1 = aRow)) then
  5.  


3. open a pascal file that has no "unit", no "interface"/"implementation", not "program".
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
from your code
Code: Pascal  [Select]
  1. //avoid bug of IncludeOpeningOnLine := False;
  2.     not ((sfaOpen in TmpNode.FoldAction)  and (TmpNode.LineIndex + 1 = aRow)) then

How to reproduce this bug?
That happened when loading included file {$I including.pas} that has no unit, no program, just direct functions.
But I tried using your last changes, its not a bug.

You mean the  procedure(s) at the top, do not get outlined (nor folded)?

This is intention. And important.

And if you plan (which I do not advice) to do some workaround, then make it optional (i.e. provide a boolean property to enable this only if the user wants it.

In such an include file the parser can not know if it is in interface or implementation.
There are many include files that go into the interface part of a unit. All they do is list procedures, that are "exported". So they read like:
Code: Pascal  [Select]
  1.   procedure foo(..);
  2.   procedure bar(..);
  3.   procedure abc(..);
  4.   .... // many hundred more.
  5.  

I don't think, that in this case you want to start an outline for each of them ?

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
You mean the  procedure(s) at the top, do not get outlined (nor folded)?
Even worst, there were fatal error such "could not read memory address nyah nyah nya.."
That was the reason I avoid them.
But nowadays, you've changed the classes of nestednodelist, which in turn solves this problem.


Quote
This is intention. And important.
put the situation in unit test maybe enough.
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Code: Pascal  [Select]
  1.                      sfaOutlineNoColor,     // Node will not painted by nested-coloring, but may increase color (e.g. any "procedure")
  2.                      sfaOutlineNoLine,      // Node doesn't want to have vertical line. (e.g. "then")
  3.  

Should those be in the node?

I would imagine it is better if
Code: Pascal  [Select]
  1. TSynCustomFoldConfigMode = (fmFold, fmHide, fmMarkup, fmOutline);
would *instead* of fmOutline have
  fmOutlineLine
  fmOutlineColor

Then it can be userconfigured for each node.


How can user configure OutlineLine/OutlineColor if there are no fmOutlineLine/fmOutlineColor?
I do understand the reason, but I can't understand the technical implementation.

When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
How can user configure OutlineLine/OutlineColor if there are no fmOutlineLine/fmOutlineColor?
I do understand the reason, but I can't understand the technical implementation.

When you retrieve the node from the foldednestlist, then it contains the FoldType. (e.g. ord(cbftTryExcept)).
Your markup code can then get the foldconfig for this FoldType, and check the FoldConfig.Modes. That way you know if to color the keyword and/or outline.

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com

Oh! so...
Now I completely agree that the markup should be TComponent.
... OI should be able to show and configure FoldConfig, and markups should be components that can be added like a HL. But that will be some work to get there.
I try this : componentize the markup
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
But please keep it in a separate branch.

I don't want to separate the changes again.
In order to merge your code, the outlining, and the component-izing are 2 entirely separate and unrelated changes. And if they are mixed in one branch that creates lots of extra work for me.

--
Also I may have a couple of ideas, but I will write them down later.
« Last Edit: April 19, 2016, 04:46:19 am by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
There may be several ways to make the Markup designer ready.
(Note: publishing required HL properties, is a different issue/branch again)

1) just make them components.
This will also make the MarkupMgr a component, but that one must not be registered.

Also Markups then need a publisher read/write SynEdit property, but the MarkupMgr MUST NOT have that.

A Markup then is kind of owned by the SynEdit and/or the form.
Owner = form, but that means form is responsible for destroying, yet old code assumes SynEdit is, and that also needs to be kept, for compatibility. (SynEdit needs to check, if owner = form)

2) Make SynEdit the owner even in design. (like frames).
SynEdit afaik already has the attributes. It just needs to accept the markup and drop (and forms must reject it).
Investigate gutter parts. they are owned by the SynEdit. (look at an lfm)

3) Similar to 2, but do not add Markup to the component palette.
Instead have a special property editor. (like gutterparts.)

--------
I prefer 2 and 3 over 1.


x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
okay, I sum up: how the markup owned by synedit is just similar mechanism as
TAction (and TCutAction, TPasteAction, TBoldAction) owned by TActionManager.
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5705
    • wiki
I havent looked at TAciton.

But I was thinking more like any TComponent on a TFrame. When streamed, they are nested into the frame, instead of the form.

SynEdit already does this with Gutter parts.

---
Btw arent we getting ahead of ourselves.

Shouldnt the markup first be finished, before starting to add new features?


Pascal

  • Hero Member
  • *****
  • Posts: 832
Shouldnt the markup first be finished, before starting to add new features?

Yes, of course! I am looking forward of seeing this implemented.  ;)
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)