Hello friends,
I have the folowing scenario:
My program wants to be a simple debugger for serial data. I receive some data, most of them strings and display with nice colours in edit1. The same data I load also in edit2 but converted in hex digits.
Now the lines of edit1 and edit2 are not exact the same because I use edit1 also as system info, for display some button states on change, or some program parameters.
The problem is I need when I put cursor in edit1 (the text one) I want to select the corresponding hex (2 chars) in edit2 and viceversa.
I noticed goto(line,col) is missing and I quite understand why by reading some old posts in this forum.
I tried with AddCheckpoint but no success so far. Someone can give me a hint for my project or I miss something?
Thanks very much in advance,
go to character, sync 2 richviewedit
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
TRichView document consists of items, indexed from 0 to ItemCount-1.
If the i-th item is a text item, then GetItemStyle(i) >= 0.
If the i-th item starts is a new line (paragraph), then IsFromNewLine(i) = True.
You can get text of the i-th item using GetItemText(i).
You can set the selection using SetSelectionBounds.
Knowing this information, you can implement GoTo.
First, you need to find the proper line (paragraph). Iterate from the beginning of document, checking IsFromNewLine (or IsParaStart). There is an example: http://www.trichview.com/forums/viewtopic.php?t=7
Next, when you found the item starting the proper paragraph, use GetItemText to get text and to determine if the caret should be placed in this item. If not, take the next item and so on.
If the i-th item is a text item, then GetItemStyle(i) >= 0.
If the i-th item starts is a new line (paragraph), then IsFromNewLine(i) = True.
You can get text of the i-th item using GetItemText(i).
You can set the selection using SetSelectionBounds.
Knowing this information, you can implement GoTo.
First, you need to find the proper line (paragraph). Iterate from the beginning of document, checking IsFromNewLine (or IsParaStart). There is an example: http://www.trichview.com/forums/viewtopic.php?t=7
Next, when you found the item starting the proper paragraph, use GetItemText to get text and to determine if the caret should be placed in this item. If not, take the next item and so on.