cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Restoring cursor position

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.

Tags (2)
2 REPLIES 2

Restoring cursor position

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

RE: Restoring cursor position

Thank you for this trick, it works fine.

Announcements