Recent

Author Topic: ATSynEdit -- A bit more info please :)  (Read 3946 times)

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
ATSynEdit -- A bit more info please :)
« on: January 18, 2017, 02:34:07 am »
I'm looking for a bit more information on highlighting and folding for ATSynEdit.

Highlighting

  • procedure OnEditorChange(Sender: TObject); virtual; When does it make sense to override this method? For which change?
  • procedure OnEditorCalcPosColor(Sender: TObject; AX, AY: integer; var AColor: TColor); virtual; Is this for when the color of an attribute changes? Is tihs related to Markers? Not sure what to do with this one.
  • procedure OnEditorCaretMove(Sender: TObject); virtual; Do I use this in conjunction with Dynamic Highlighting? If not, what do I use this for?
  • procedure OnEditorScroll(Sender: TObject); virtual; Same question
  • procedure OnEditorBeforeCalcHilite(Sender: TObject); virtual; This method sounds interesting but I'm not clear on when it is called. Suppose the user deletes a character on a line which would require that line to be highlighted again. Is this event called before the character has been deleted or after? If so, how is this method different from OnEdtiorCalcHilite?
  • property DynamicHiliteEnabled: boolean -- Is there a performance hit here?
  • property DynamicHiliteMaxLines: integer -- How is this property used?
  • property DynamicHiliteSupportedInCurLexer: boolean -- Which current lexer? What's the implication of setting this one to true?
  • function DynamicHiliteActiveNow: boolean; -- I take it this is a toggle to enable and disable dynamic highlighting. Perhaps this can be set from the OnEditorCaretMove and OnEditorScroll?
  • property EditorLineCount: integer write FEditorLineCount; Why does the adapter need this line count here? Can't it get it from the editor's lines?



Folding
I get that the TATSynRange and TATSynRanges manage the ranges for folding purposes, but I would have expected to see a number of logical event handlers to help us manage the folds. Presumably, this is done differently, and that's what I'm trying to understand:
  • OnBeforeJoinTwoLines: When a user backspaces one line into the preceding one. This event can affect multiple ranges.
  • OnBeforeSplitLine: Occurs when the user hits return in the middle of a line. This event can affect multiple ranges
  • OnInsertNewLine: occurs when the user inserts an empty line. This will affect the size of ranges
  • OnBeforeDeleteLine: occurs when the user is about to remove a line.
  • OnBeforeCutTextBlock: occurs when the user cuts a selected block of text.Knowing the start and end of this block would allow us to update the existing ranges.
  • OnBeforePasteTextBlock: occurs before the user inserts a seletected block of text. This also would allow us to update the existing ranges.
All these events relate to commands so I could I suppose catch the event before it occurs and act on it accordingly. I want to confirm this is how that's intended to work?


AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: ATSynEdit -- A bit more info please :)
« Reply #1 on: January 22, 2017, 11:30:16 pm »
property DynamicHiliteEnabled: boolean -- the global-enable-flag for Dyna hilting. Dyna hiliting is hilites of tokens which is caret pos dependant. e.g. HTML lexer has tokens < > which hilite with green if caret near <>

property DynamicHiliteMaxLines: integer -- How is this property used?
app must set it, from app's options. My app has opt=5000

property DynamicHiliteSupportedInCurLexer: boolean -
current lexer from EControl set. e.g. HTML or C++.
U dont set it. U only read this.

function DynamicHiliteActiveNow: boolean; -- 
its result of global-enable-flag plus MaxLines plus others. See code for this prop.

property EditorLineCount: integer write FEditorLineCount; Why does the adapter need this line count here? Can't it get it from the editor's lines?
I dont remember why adapter dont read count of lines. I made it for reason, maybe to not loop all editors for adapter (adapter has 2 editors if split tab active).
« Last Edit: January 22, 2017, 11:36:11 pm by Alextp »

AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: ATSynEdit -- A bit more info please :)
« Reply #2 on: January 22, 2017, 11:43:26 pm »
>procedure OnEditorCalcPosColor
called when editor calculates color of x/y pos, x/y is some text pos.
>procedure OnEditorCaretMove 
it is event, to see that user moved caret.
>procedure OnEditorScroll
event, to see when user scrolls memo.

>procedure OnEditorBeforeCalcHilite  This method sounds interesting but I'm not clear on when it is called.
Before calculating colors for entire line for all its chars

>Is this event called before the character has been deleted or after?
after.

> If so, how is this method different from OnEdtiorCalcHilite?
one of them makes hilite. Other dont. Other is event.
« Last Edit: January 22, 2017, 11:46:27 pm by Alextp »


McClane

  • New Member
  • *
  • Posts: 44
Re: ATSynEdit -- A bit more info please :)
« Reply #4 on: September 26, 2017, 06:30:50 am »
Hi, I've read the wiki but I can't understand how to highlight text.
How can I define parts? What are them? (var AParts: TATLineParts;)
Thanks in advance.

AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: ATSynEdit -- A bit more info please :)
« Reply #5 on: September 27, 2017, 07:27:56 am »
Parts: is array, type TATLineParts. First items of this array define colored parts of whole string. Parts in array parsed until next part has Len=0.
you can see declaration of TATLinePart. parts have:

- length
- offset from string begin
- color of backgnd
- color of font
etc

 

TinyPortal © 2005-2018