Restoring cursor position
Jan 17, 2013
08:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jan 17, 2013
08:48 AM
Restoring cursor position
Good day!
Let us mark cursor position in the form of "|" sign.
For example, we have the following node in Arbortext Editor 5.2.
<node1>This is a sim|ple text.</node1>
Then my Java plugin encloses part of text with a "b" and "i" nodes:
<node1>This is a sim|ple text.</node1>
I want to restore the cursor position relatively to "node1", but the following code will not help me:
pos = oid_caret_pos(oid) // oid of the node1
...
goto_oid(oid, pos)
oid_caret_pos treats each non-text object (that is, markup, equations, tables, graphics) as one character.
2 REPLIES 2
Jan 17, 2013
11:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jan 17, 2013
11:29 AM
Hi Ilya--
Right, oid_caret() and oid_caret_pos() won't help in this instance,
since you are modifying the content after storing the location, which
will throw the pointers off.
Probably the easiest way to manage this would be to use some kind of
marker like a PI to take the place of the caret, and then using that to
find the caret position after modifying the content, something like
this:
# insert caret marker
insert(");
local caretoid = oid_caret();
# make changes
mark_up_text(oid1);
# restore caret
goto_oid(caretoid);
oid_delete(caretoid);
HTH.
--Clay
Clay Helberg
Senior Consultant
TerraXML
1380 Forest Park Circle, Suite 100
Lafayette, CO 80027
Right, oid_caret() and oid_caret_pos() won't help in this instance,
since you are modifying the content after storing the location, which
will throw the pointers off.
Probably the easiest way to manage this would be to use some kind of
marker like a PI to take the place of the caret, and then using that to
find the caret position after modifying the content, something like
this:
# insert caret marker
insert(");
local caretoid = oid_caret();
# make changes
mark_up_text(oid1);
# restore caret
goto_oid(caretoid);
oid_delete(caretoid);
HTH.
--Clay
Clay Helberg
Senior Consultant
TerraXML
1380 Forest Park Circle, Suite 100
Lafayette, CO 80027
Jan 30, 2013
10:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jan 30, 2013
10:04 AM
Thank you for this trick, it works fine.
