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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Restoring cursor position

IlyaYeroshenko
1-Newbie

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

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

Thank you for this trick, it works fine.

Top Tags