Home Download Buy Blog Forum Support

Function to return current cursor's position?

Function to return current cursor's position?

Postby Esente on Tue Aug 24, 2010 12:09 am

Hi,

Is there any function in the Plugin API that returns the current position of the cursor in the current view?
Esente
 
Posts: 26
Joined: Mon Aug 16, 2010 7:20 pm

Re: Function to return current cursor's position?

Postby guillermooo on Tue Aug 24, 2010 6:50 am

Maybe...

Code: Select all
# get selected regions as RegionSet
sels = view.sel()
# get 1st cursor as Region
cursor1 = sels[0]
# startPos, endPos = cursor1.begin(), cursor1.end()
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Function to return current cursor's position?

Postby Esente on Tue Aug 24, 2010 5:32 pm

Thanks guillermooo!

I haven't tested it yet (currently at work), but I'm wondering why cursor position has begin and end? I thought it only has one position.
Esente
 
Posts: 26
Joined: Mon Aug 16, 2010 7:20 pm

Re: Function to return current cursor's position?

Postby guillermooo on Wed Aug 25, 2010 8:27 am

Sublime has a powerful multi-selection mode. That means there isn't just the one selection. Selections are merely buffer regions that happen to be selected. Visually, you might see just the caret at times, but in actuality what you are seeing is an empty region (one starting and ending at the same point within the buffer).

If you can spare the time, read sublimator's guide (link above).
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests