[Lazarus] Code Structure / SourceEdit and SyneEdit [Re: Mouse Link in SynEdit (only link-able items)]

Martin Friebe lazarus at mfriebe.de
Sat Dec 13 14:49:21 CET 2008


Hans-Peter Diettrich wrote:
> Martin Friebe schrieb:
>   
>> Well I am in the process of breaking it up into smaller bits.
>> - The gutter drawing moved to its own class.
>> - Folding is partly abstracted
>> - Trim Trailing spaces has been abstracted into a class of its own. (a 
>> view of SynEditLines)
>> - Caret and block have been started
>>     
> I've a TCharGrid component, developed in the time when the SynEdit was 
> too instable and unreliable. It handles all cursor moves, scrolling, 
> selecting text (also in columns), tab widths, (syntax) coloring, and 
> also has provisions for both vertical and horizontal gutters. It was 
> intended as a more reliable base for e.g. SynEdit, in general for 
> representing text in a monospaced font, as is convenient for source 
> code. It was developed and tested with Delphi 7, i.e. for Windows, but 
> should be widely platform independent. If somebody is interested in the 
> source code...
>
> DoDi
>   
Looking at your signature, you are the Author of 
http://wiki.lazarus.freepascal.org/Redesign_of_the_SynEdit_component ?

A couple of remarks:
-Individual drawer objects fro Gutter and TextArea (I will avoid Grid in 
the name, Grid is a specialization)

This has been started for the Gutter. It does need a lot of clean up still.
It would also benefit from the Os-Handle and canvas being moved into a 
wrapper class. This would:
- avoid the need  to callback synedit for Invalidates
- allow a Handle/Canvas of another Component being passed to SynEdit, 
and SynEdit painting the other component (e.g. SourceEditor)

Similar considerations for the Textarea. However the textdrawer will 
have to access a lot of other objects, and need ways to merge the 
result. there are
- the highlighter
- the MarkUpManager
- The TextLines itself (e.g. Highlighter token will return a tab as a 
tab, but the TestLines need to translate this into displayable chars. Either
  -- spaces
  -- "show special chars" >" (and if tab is only one char, then maybe 
there is only one ">" followe by spaces?
 This can only be done by the Lines, as they know the layout/tabwidth 
(see concept of Views/ TabView below)


The storage and view of the TextLines:
I think TSynEditCodeBuffer is a good start for this. Yet tabs are a 
specialisation, that should go into a ViewClass.
ViewClasses TSynEditStrings themself, that will modify how the stored 
text is seen. (TrimTrailingSpaces is an example. FoldedView too, so 
FoldedFiew does not yet fully follow the concept)

The following Views (and others) can apply to the text

- WordWrapView
- FoldView
- TabView or ElasticTabView (http://bugs.freepascal.org/view.php?id=9650)
   modifies Logical(byte) to Phisical (char on screen) calculations.
   probably still returns tabs, but offers conversation methods.
   - replacing tabs with spaces in the Strings[] property, may 
complicate Highlighting and MarkUp and show special chars
     It would also impact the ability of keeping the caret from being 
placed in the middle of a tab (which currently can be done)
- TrimSpaceView
- TSynEditStringBuffer (holding the actual text)

Martin






More information about the Lazarus mailing list