Recent

Author Topic: Where is completion demo/tutorial?  (Read 671 times)

Borneq

  • Full Member
  • ***
  • Posts: 238
Where is completion demo/tutorial?
« on: December 14, 2019, 12:26:29 am »
I search samples for Synedit completion and underscoring by redwavy line error words.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6674
  • Debugger - SynEdit - and more
    • wiki
Re: Where is completion demo/tutorial?
« Reply #1 on: December 14, 2019, 12:59:32 am »
There are examples for the completion. The Lazarus IDE has a folder examples in the main install dir.
See examples/synedit
Also read https://wiki.lazarus.freepascal.org/SynEdit#Completion_plugins




The wavy lines currently have no examples.

SynEdit has several ways to apply coloring (including style, and frames)
- Highlighter (only ONE per SynEdit)
- TSynEditMarkup (as many as you want)
   used by Selection (coloring the selection), mouse-link, "begin-end" brackets, () matches, word at caret, syncro edit, ......
- OnSpecialLine.... (actually this is a TSynEditMarkup too)

Note: SynEdit does not do any RichText or the like. There is no way to store or associate color directly to a chunk of text.
Color is only applied by the above methods

The highlighter is designed for structural info.

If you check words against a dictionary, then you probably want TSynEditMarkup,
though if you do not use any highlighter you could use something like the highlighter SynPosSyn. (the one that is included, is dead slow)


Look at TSynSelectedColor (or rather the base TSynHighlighterAttributesModifier)

The red zickzack is done as bottom only border.


More about highlighters here: https://wiki.lazarus.freepascal.org/SynEdit_Highlighter
Tutorial sample files in the example folder.


Markup is not currently documented...

A recent bit of discussion that involves markup: https://forum.lazarus.freepascal.org/index.php/topic,30122.0.html
I am not sure how helpful it is, if at all. It is rather very long....
So it was sufficient for Pascal to write the vertical-line-outline-begin-end-block-markup



Maybe have a look at unit SynEditMarkupBracket;

It gets the 2 coordinates for ( and ) in InvalidateBracketHighlight. You can ignore that method, as you get your own positions for where you want coloring.


General notes about synedit

1)  invalidation vs re-computing of the data:

While in a PaintLock, do as little as possible. You may get hundreds of invalidate calls.
(the bracket module simply sets a flag)

When leaving the paintlock, compute your data.

2) In any method that happens inside "Paint"
IIRC Those are
    Procedure PrepareMarkupForRow(aRow : Integer); virtual;
    Procedure FinishMarkupForRow(aRow : Integer); virtual;
    Procedure BeginMarkup; virtual;
    Procedure EndMarkup; virtual;
    Function  GetMarkupAttributeAtRowCol(const aRow: Integer;
    Procedure GetNextMarkupColAfterRowCol(const aRow: Integer;
    procedure MergeMarkupAttributeAtRowCol(const aRow: Integer;

Do as little as possible. (no time consuming calcs)
Again pre-calc data, when the paint lock ends. (Or in invalidate, if there is no paintlock)

Instead of invalidate, for you it may be any other notification that something has changed. (e.g. TextChanged, or any hook into SynEdit)
« Last Edit: December 14, 2019, 01:02:10 am by Martin_fr »

 

TinyPortal © 2005-2018