I’ve had no response to my previous post as yet but, nevertheless, I’m pursuing this subject. The following opens the input panel beginning with the term ‘Not found:’. If I eventually type ‘bob’ then the beginning text is replaced with 'Found: '. It then reverts to ‘Not found:’ until ‘bob’ appears again. It should be easy to replace ‘bob’ with the result of a file/path search.
[code]class AndyOutput(sublime_plugin.WindowCommand):
ignore = False
the_input = None
def run(self):
self.the_input = self.window.show_input_panel(‘Andy>’,‘Not found:’, self.on_done,
self.on_change, None)
self.ignore = False
def on_done(self, text):
pass
def on_change(self, text):
if self.ignore:
return
try:
if text == '':
return
sel = self.the_input.sel()[0] ######### AttributeError
sel_line =self.the_input.line(sel)
if text-3:] == 'bob' and text[0:3] == 'Not':
edit = self.the_input.begin_edit()
self.the_input.replace(edit, sublime.Region(sel_line.begin(),
sel_line.begin()+10), 'Found: ')
self.ignore = True
self.the_input.end_edit(edit)
self.ignore = False
elif text[0:5] == 'Found':
edit = self.the_input.begin_edit()
self.the_input.replace(edit, sublime.Region(sel_line.begin(),
sel_line.begin()+10), 'Not Found:')
self.ignore = True
self.the_input.end_edit(edit)
self.ignore = False
except ValueError:
pass[/code]
I do get an AttributeError: ‘NoneType’ object has no attribute ‘sel’ - at the line indicated, but the code still works (oddly). But… I’m new to Python