Home Download Buy Blog Forum Support

onIdle callback

onIdle callback

Postby gpfsmurf on Mon Oct 19, 2009 10:46 pm

Is there a better way to have some kind of onIdle callback?

Code: Select all
import sublime, sublimeplugin

class IdleCommand(sublimeplugin.Plugin):
   def onActivated(self, view):
      sublime.setTimeout(self.onIdle, 200)
   def onIdle(self, view):
      # Do something
      sublime.setTimeout(self.onIdle, 200)
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: onIdle callback

Postby gpfsmurf on Tue Oct 20, 2009 8:02 pm

Ah that solves my problem... a Pending counter.

What I would actually need is an event to fire whenever the user changes the selection. An Idle event does the job, though.

I was playing with the region highlighting to do something like Eclipse: when you select a word, it'll highlight all the occurences of the same word (without changing the selection)

http://pastie.org/private/rv34calt6rzr9xv0hew5q

Seems pretty fast but I haven't tried with a big file yet.
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: onIdle callback

Postby jps on Tue Oct 20, 2009 8:17 pm

I'm planning on adding an onSelectionModified callback for plugins in the next beta, btw
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests