Forum > SynEdit

Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}

(1/66) > >>

A-M:
Hi Dear FPC/Lazarus Developers
The idea is so simple , colorizing code blocks start and ending keywords for helping on perception while developing and browsing the source code
like what the CNPack add-on do on delphi IDE

its specially important when you are developing a complex algorithm with multi level code blocks inside ...
and even i can say it will be effective for choosing lazarus/fpc over other languages and IDEs for programming newcomers.



i'm ready to start the job ,
if you know what the class or method is suitable for adding this feature
or you want help doing this  ;)
or even you have any comment about , i will be happy to know.


Best Regards.

Martin_fr:
Hi

I am the current maintainer of SynEdit in Lazarus.

   Welcome.

Nice to have someone interested in helping.


This should be done as a new subclass of TSynEditMarkup.

Colors can be added to TSynSelectedColor. look at frames and frame boundaries. Then the drawer will deal with them. (It needs testing for drawing in the middle of chars, which can happen if the line goes through a tab)

Look at SynEditMarkupWordGroup to see how to find Begin and end of blocks efficiently.


I will gladly add more help later.

-----------------
Things to start with

You need to understand:

http://wiki.lazarus.freepascal.org/SynEdit_Highlighter
How "ranges" are used in folding, and how they "level" can help finding blocks

Basics about what tokens are (this is how the HL splits the line). You probably will not need details.

http://wiki.lazarus.freepascal.org/SynEdit
logical and physical caret. this is essential.

Have a look at TSynSelectedColor and what it already provides

Martin_fr:
this is also good http://wiki.lazarus.freepascal.org/Redesign_of_the_SynEdit_component

Not 100% up to date, and not 100% related, but an overview how things connect.

Martin_fr:
SynEditMarkupWordGroup  really is the start point. It is the code that highlights matching begin / end, if the cursor is on it

When you write your code, you will need to find all begin/end (try finally / repeat until / ...) pairs (iirc you can even find if/then this way).

Of course in

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---while adobegin  //...end; you then get a line for begin end, not starting at the while (same as code folding does).

So the first task is to find all those blocks in the current display. And it must be efficient, with folding there can be 1000 lines between top and bottom line.
For that you use the HL level info. (and later tricks like caching, but not to worry now)

When you have all the blocks surrounding the current line, then you know where to draw the lines. (Also when you have all blocks for line N, remember them, and if the next line is N+1 you can check which ones to re-use.)

There is a method PrepareMarkupForRow in which you should prepare this list.
--------------------

There will be calls to
    Procedure GetNextMarkupColAfterRowCol(const aRow: Integer;
                                          const aStartCol: TLazSynDisplayTokenBound;
                                          const AnRtlInfo: TLazSynDisplayRtlInfo;
                                          out   ANextPhys, ANextLog: Integer); virtual; abstract;


Find the first pos after aStartCol on which you need to draw a line, in your list of blocks  and return it.

and in GetMarkupAttributeAtRowCol
wait until that column is due. then return a markup with a frame on the left side only (and set the frameStartBound (search examples in other markup)


Alextp:
Martin Fr.

Look at your msg.

You write each sentence, almost each, on new line.

Even not new line.
Even on new paragraf.

This is irritating for usual reader. IMHO.

Navigation

[0] Message Index

[#] Next page

Go to full version