Sublime Forum

Help on TextInputHandler

#1

The documentation references Packages/Default/arithmetic.py as an example of taking input from the command palette, but I can’t find the file anywhere, neither on my system nor on the tubes.

Otherwise, I found this, which purports to take input by using a TextInputHandler, but I get an error when I try using it.

Code:

class SampleCommand(sublime_plugin.TextCommand):
    def run(self, edit, text):
        print(text)

    def input(self, args):
        print("input(%s)" % args)
        return sublime_plugin.TextInputHandler()

Error:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 460, in is_visible_
    ret = self.is_visible()
TypeError: is_visible() missing 1 required positional argument: 'paths'
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 556, in run_
    return self.run(edit)
TypeError: run() missing 1 required positional argument: 'text'
0 Likes

#2

Turns out my /opt/sublime_text/ directory was running 3083. I think this is the problem.

0 Likes

#3

Indeed the ability for a command to collect input from the Command Palette is a recent innovation in the latest dev builds and isn’t officially released yet, so all else being equal the code won’t work in older versions, including the currently released version.

0 Likes

#4

I installed the latest dev build and everything is working as expected.

0 Likes