How can I bind on modified event to a specific view?
On my desperate last attempt what I came up is this:
Basically I want to get the input_view and output_view (output) into a variable and when input_view changes I want to update the output view. However the event listener - or the updates to the output view - should only be active when the plug in is toggled on.
The following code prints “modified” whenever ANY view is modified and not just the one I want… How can I make this work?
I appreciate the help!
class ToggleWatch(TextCommand):
def is_enabled(self):
return isCoffee(self.view)
def run(self, edit):
watch_mode = True
print "watch_mode " , watch_mode
Modified.inputview = self.view
Modified.inputself = self
Modified.output = self.view.window().new_file()
output = Modified.output
output.set_scratch(True)
output.set_syntax_file('Packages/JavaScript/JavaScript.tmLanguage')
no_wrapper = settings.get('noWrapper', True)
args = '-p']
if no_wrapper:
args = '-b'] + args
print "watch_mode yes"
#while True :
# time.sleep(1)
# print "refreshed"
res = brew(args, Text.get(self.view))
if res"okay"] is True:
output.insert(edit, 0, res"out"])
else:
output.insert(edit, 0, res"err"].split("\n")[0])
class Modified(sublime_plugin.EventListener):
def __init__(self):
pass
def on_modified(inputself, inputview ):
print "modified"