Closed Alexey-T closed 9 years ago
OK, it could be. I don't understand yet, how one adapter works.
Now I'm updating the SynFacilSyn with some patchs and documentation, before to take the AtSynEdit version.
adapter: don't do adapter. First do OnCalcHilite event. If u ll do it--I ll help to make adapter
I've checking the OnCalcHilite event on the \app\demo_editor. And can see that the key for highlighting, is to fill the AParts[] table with information about the tokens. The questions are:
I think the information on the Wiki for highlighting must be clarified:
== How to highlight syntax? == Ther are two ways: === Using Adpter === ... === Using the event OnCalcHilite === ...
hi.. --The questions are:1. Why you use copy in Str:= Copy(ed.Strings. Becaus Line can be 300 chars, and you need to get only ~~80 from it (wordwrap On)
--How do you implement highlighting for multi-line tokens As always for all lines. OnCalcHilite must work for all lines. if comment is 3 lines, OnCalchilite must give hilite for each of 3 lines
information on the Wiki changed: thankx..
Logic of OnCalchilite isnot simple. then.
Good. But on multiline tokens, it's needed to know the state of the previous lines, for to work. One way would be to create an special structure for to save the state of every line. But I'm not sure it's the best way. Questions:
Q1.: what data? TATStrings cannot have more data Q2. from top line to bottom skipped fully folded lines
So I need to create my own structure for to save the state of the edit. I don't know how EControl works.
I wanted to include this data (state of the scanner for to highlight) on ATSynEdit, like SynEdit do, using the Object part of TSTrings.
"from top line to bottom" I don't think so. I don't think that for every key pressed, all the text is scanned.
U have file 200 lines. top scroll pos is 10, height 30 lines. u get indexes from 10 to 10+30..31
--own structure for to save the state Yes (don't see EControl- no need)
Let me know if I understand: "For every time you press a key (no control key), ATSynEdit call OnCalchilite, for every visible line on the editor".
Yes
OK. A simple, an efective way to refresh. Questions: Why you make this verification: if npart>High(AParts) then exit; ? Is the size of AParts limited? How many "parts" can a I use?
yep: limited; it is array! High(var) gets last index. Low()=0
I know it's an array. I will change the question: In which situations I would have npart>High(AParts)?
in case I set loo small AParts len in my code. and editor line has many tokens.
There is a first test of using SynFacilSyn here: https://github.com/t-edson/SynFacilSyn/tree/1.11/_demoSynFacilonATSynEdit Like it's expected, It cann't process mutil-line tokens, because have non information of previous lines. There is a dependency of the packet SynEdit.
good. WIll test!
good:keywords, comments ok hilited. :) not others. My notes.
need/ changed to
function GetTokenKind: PtrInt; reintroduce;
btw. EControl has all parse-ressults in memory. adapter calls it to get tokens multiline. U need to save results. And call em later..
The demo is only a simple test. I will check the case of the paths, but I work on windows.
GetTokenKind is a virtual method defined on the Base class. Using casting for to obtain th attribute is not the best way. I will consider to include a special function for to do it.
==special function for to do it.= Ok english "function to do it", no "for"
Thank for the english correction. I was thinking, It would be better to have a space into ATSynEdit, for to storage the highlighting information. Have an external structure could be slower.
"for to storage" again. (Wrong lang.) I don't get an idea. what storage..
You know highlighter needs to have information of the state of previous line to right proccess the multiline tokens. This needs to have some structure (like an array) to save the state of every line. And I said ATSynEdit would have this structure.
Having an external structure would make necessary to synchronize the size, every time the editor adds or removes lines. This is totally possible, but could be slower than have the storage internally in ATSynEdit.
hm. atSynEdit also needs to remake structure on each change. And sync its size. no? it ll be same slower. Why i dont like idea? because much work for me. And u didn't say what struct- Pointer for each line?
i try to have small ATStrings. some users tell Cudatext gets 300Mb on big 10M file. Reason: many items in TATStrings
300Mb for a 10M file? You really have a design problem. That's not efficient. Maybe you need to redesign.
For highlighting, it's only necessary a pointer for each line. Do you maintain an array (TATLineParts) for each line? Using an array of static data for highlighting, is bad for memory.
200M for 10M file maybe or 150M. I have record: see
TATStringItem = class
public
ItemString: atString;
ItemEnd: TATLineEnds;
ItemState: TATLineState;
ItemSeparator: TATLineSeparator;
ItemHidden: array[0..cMaxStringsClients-1] of smallint;
//0: line visible,
//-1: line hidden,
//>0: line hidden from this char-pos
ItemBm: byte;
ItemBmColor: TColor;
Sorry. I don't understand what you say. I said I prefer ATSynEdit have an internal storage for highlighters.
Why i donot want Pointer for each ATStrings line: it is 4 byte per line, 100000lines- 400K memory. 400K memory which not needed for almost all apps. can you make your 'storage'?
It will be probably slower, but it's possible. I need you to give me a detail of events to catch, in order to have a synchronized list with the size of the total editor lines.
Okey:event is procedure
TATAdapterHilite = class(TComponent)
public
procedure OnEditorChange(Sender: TObject); virtual;
can you make adapter from OnCalcHilite? if yes, add to adapter this procedure
procedure OnEditorChange(Sender: TObject); override;
if no, I make adapter
I guess you are saying: "No. There is not events defined to capture changes on the editor. You need to use adapters for that." This confused me. "can you make adapter from OnCalcHilite?" I don't know exactly, how an adapter works. Do you have an basic sample of that? What is the relation between adapters and OnCalcHilite?
hm, wait a patch from me. i try making adapter
Accepted, but the directories was reordered. I'm still waiting the responses to my questions:
responces 1.U can use both adapter and nonadapter. In adapter use procedure-i added 'showmessage'. in non adapter use OnChange(OnChanged?) 1b.Cannot detect which lines changed 2.ATsynedit first calls Adapter if it assigned, then calls OnCalcHilite if assigned
I see you have the type TATLineParts as a fixed Array, until 1000 elements. How many instances of TATLineParts do you have normally in ATSynEdit?
IMO, one instance if i correct
IMHO, that array is information of the highlighter too, it must not be stored at the editor. It seems to me your design doesn't separate well the function of the highlighter and the editor.
I dont say it is stored. It is calced, then ed painted, then array deleted (array here only when needed)
How do I know the index of the first line of TATSynEdit.Strings, that is visible on the screen? And the the last line?
Is it possible to know the first and the last line modified, after an operation like "Paste text" or a multi-line edition?
index of the first line: prop LineTop, visible at btm: LineBottom. NN lines may be hidden in range (folded)
ATStrings- property ListUpdates: TList, has indexes of lines chged. Maybe list clears before u get OnChange? need check..
Feel free to ask more:if wiki misses txt, I write more or tell here...