Author Topic: How to get the cursor to toggle between the start and end of a selection  (Read 4002 times)

heckstein

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
I want to write a function that toggles the cursor from its current
position within a selection to the beginning of the selection, then to
the end, then back to its original location.

The function should detect if the current cursor position is already
on either the beginning or the end of the selection and toggle the
cursor appropriately.

Is there a function or a macro that returns the beginning and ending
line and column of the active selection, or, alternatively, the byte
offset of the cursor's current position within the selection?  Also, I
don't see how to identify the cursor's current position.  How can I
do that?

I suppose I could just create a bookmark then simply toggle to the
beginning then toggle to the end with _begin-select and _end-select,
without putting in any finer logic, because in most cases, I'm
somewhere in a large selection and want to get to the top.

Thanks for your interest and assistance.

Graeme

  • Senior Community Member
  • Posts: 2379
  • Hero Points: 314
Look at
_begin_select
_end_select
select_active
push_bookmark
pop_bookmark
p_col
p_line
save_pos
restore_pos
_save_pos2
_restore_pos2

all in the help index.