【问题标题】:sublime plugin. show find-panel and paste text崇高的插件。显示查找面板并粘贴文本
【发布时间】:2016-11-23 10:19:07
【问题描述】:

我需要从剪贴板中获取字符串,然后对其进行一些操作,运行默认的查找面板并将字符串粘贴到其中。

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中我尝试了各种不同的解释来写这个sn-p:

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

【问题讨论】:

    标签: python sublimetext3 sublime-text-plugin


    【解决方案1】:

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

    相反,您必须使用窗口引用:

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

    即从您的视图中获取窗口:

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

    arguments 参数需要是一个参数字典。

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

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

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

    【讨论】:

    • 是的!这是完美的工作。谢谢! (假 -> 假)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多