Sublime Forum

onIdle callback

#1

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

[code]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)[/code]

0 Likes

#2

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.

0 Likes

#3

I’m planning on adding an onSelectionModified callback for plugins in the next beta, btw

0 Likes