Home Download Buy Blog Forum Support

Move cursor to click

Move cursor to click

Postby ericandrewlewis on Mon Sep 10, 2012 4:10 pm

Hi,

I'm writing a plugin to automatically search open files with the alt+clicked word.

Current code:

Code: Select all
import sublime, sublime_plugin

class QuickSearchCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        for region in self.view.sel():
            if region.empty():
                line = self.view.word(region)
                self.view.insert(edit, line.begin(), self.view.substr(line))
            else:
                self.view.insert(edit, region.begin(), self.view.substr(region))


This code grabs the word where the cursor was before the click, not the word you just clicked on. How would I move the cursor to the clicked word?
ericandrewlewis
 
Posts: 4
Joined: Mon Sep 10, 2012 4:09 pm

Re: Move cursor to click

Postby ericandrewlewis on Tue Sep 11, 2012 3:21 am

I've actually decided to go a different route.

I'm going to activate search by grabbing the word the cursor is currently within, or based on the selection of the user, and then triggered by a shortcut.
ericandrewlewis
 
Posts: 4
Joined: Mon Sep 10, 2012 4:09 pm

Re: Move cursor to click

Postby tito on Tue Sep 11, 2012 1:46 pm

There is the package Open-Include, doing something like that with the shorcut ALT+D.
I'm interested into see some examples of what are you trying to open, and where these files are located.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay


Return to Plugin Development

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests