The input panel doesn't support updating the text dynamically, but it might be possible to hack around this a little bit.
What you'd do is something like this:
Show input panel with initial selection when command is run
Set some variable indicating that you are "running" (probably class-level or module-level so that it stays after the command has been run)
Have an event listener which reacts to on_selection_modified and calls another input panel with the new word (thus discarding the first panel). Only do this while "running" is True
When the panel is selected or cancelled, set the "running" variable from step 2 to False
I tried implementing this, but it's pretty nasty. It kind of works, but i would personally stay far away from it, since it violates the way people are accustomed to interacting with the input panel:
from functools import partial
from sublime_plugin import WindowCommand, EventListener
is_running = False
def stop_running(*args, **kwargs):
Running.is_running = False
def noop(*args, **kargs):
Running.is_running = True
self.window.show_input_panel('test', '1', stop_running, noop, stop_running)
def on_selection_modified(self, view):
sublime.set_timeout(partial(self.update_input_panel, view, view.window()), 50)
def update_input_panel(self, view, window):
word = view.substr(view.sel())
if window and word:
window.show_input_panel('test', word, stop_running, noop, stop_running)
Note that you need to do some callbacks and stuff to make sure you manage when it's running and not, and you need to give the command enough time for the selection to change (i.e. if you double click - thats what the 50 ms are for).
But again... Please don't use it, at least not without THOROUGH testing.