Page 1 of 1

resynchronizing

Posted: Thu May 15, 2008 5:20 pm
by Cosmin3
Hi.
In my application I scan the text (from ScaleRichView) and then I write in a listbox a few lines that look like this: "Line x Col y: Some problem". Each line in listbox is associated with a TPoint in which x is ItemNo and y is Offs (in item). When the user double clicks on that line in listbox then with SetSelectionBounds the cursor is moved to that position.
Problem is that the user sometimes is deleting text, inserting something or using Undo/Redo. So some items in listbox may become unusable and some may have to be resynchronized.
For this I need a method that is fast (so the user doesn't wait seconds when is modifying the text). So I understand that can't be 100% precise...
I tried to store the cursor position and selection length at OnChanging event but it's not working. Even if it would work it would not helped me with Undo/Redo.

Any ideas?
Thank you in advance.

Posted: Thu May 15, 2008 6:50 pm
by Sergey Tkachenko
How do you fill this listbox initially? Do each paragraph in ScaleRichView correspond to one listbox item, or how?

Posted: Sat May 17, 2008 9:58 am
by Cosmin3
For example: I scan the text and if I found this "It's a beautifull day ;!" then I place a line in listbox saying "Line 3 Col 20: you must remove ';' character". It's just an example - the messages in my language are more sofisticated..
The user may start fixing the text or may start doing something else. My application has to try to resynchronize this lines (from listbox). ItemNo and Offs at least but it would be great also with "Line x Col y"...

Posted: Sat May 17, 2008 10:46 am
by Sergey Tkachenko
May be it makes sense to mark these places with Checkpoints?

Posted: Sat May 17, 2008 11:22 am
by Cosmin3
It's a good idea. Thank you.
Just a problem: checkpoints are associated with items not with a specific position inside items. So if there are several problems in a text item how can I assign a checkpoint to each of them?

Let's say that I will use SetCheckpointInfo to add a invisible checkpoint to a item. The ATag parameter will be the index of the message from the listbox. With GetItemCheckpoint I have to check every item from text (slow). Is there a way to access the "checkpoint array" to find the specific checkpoint (when I double click on a line in listbox)?

Posted: Sat May 17, 2008 12:09 pm
by Sergey Tkachenko
The method InsertCheckpoint inserts the checkpoint at the caret position. If it is in the middle of the item, the item will be splitted.

The methods GetFirstCheckpoint and GetNextCheckpoint allow to enumerate checkpoints without enumerating all items. But they ignore checkpoints in table cells.

Posted: Sat May 17, 2008 12:19 pm
by Cosmin3
The method InsertCheckpoint inserts the checkpoint at the caret position. If it is in the middle of the item, the item will be splitted.
So you say that when i scan the text I have to move the caret to each problem? Isn't this slow (especially on ScaleRichView which in slow)?
Plus I have to scan again the text from editor because if the item is splitted then all position of the items (that are stored in an integer array) after this item will be no longer valid...

Posted: Sat May 17, 2008 1:27 pm
by Sergey Tkachenko
Well, if you need I can post code for for fast splitting text item (not as an editing operation).

But all stored positions become invalid after editing...

Posted: Sun May 18, 2008 12:32 pm
by Cosmin3
I have implemented checkpoints and it works fine. Thank you very much for your help.
Just 2 things:
1. I noticed that you can find checkpoints inserted as bookmarks in Word but you can't use their CheckpointData to find, for example, item number. The code gives error "Invalide CheckpointData".
2. In help at GetLineNo you say "There is an idea how to make it lightning-fast in future, but it will be implemented later". Maybe you'll implement a faster GetLineColNo (with a TPoint as result for example) in the near future. This would help me to resynchronize "Line x Col y" from that listbox. For now I can't use it (or make one myself) because it's slow on large texts...