2016-11-23 46 views
0

我需要从剪贴板中获取字符串,然后使用它进行一些操作,运行默认的查找面板并将字符串粘贴到此处。崇高的插件。显示查找面板和粘贴文本

class ExampleCommand(sublime_plugin.TextCommand): 
    def run(self, edit): 
     s = sublime.get_clipboard() 
     try: 
      s = s[:s.index('\n')] 
     except: 
      pass 
     self.view.run_command('show_panel', *args*) 
     self.view.run_command('paste') 

ARGS我试图写这个片段的各种不同的解释:

"args": {"panel": "find", "reverse": false} }, 

回答

2

show_panel命令是WindowCommand,所以它不能使用view.run_command执行。

相反,你必须使用窗口参考:

window.run_command('show_panel', { 'panel': 'find' }) 

即从您的观点得到窗口:

self.view.window().run_command('show_panel') 

的参数参数需要的参数的字典。

args = dict() 
args['panel'] = 'find' 

args = {"panel": "find", "reverse": False} 

self.view.window().run_command('show_panel', args) 
+0

是的!这是完美的工作。谢谢! (false - > False) –