resynchronizing

General TRichView support forum. Please post your questions here
Post Reply
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

resynchronizing

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

How do you fill this listbox initially? Do each paragraph in ScaleRichView correspond to one listbox item, or how?
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post 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"...
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be it makes sense to mark these places with Checkpoints?
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post 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)?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post 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...
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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...
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post 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...
Post Reply