2016-11-23 41 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) –