崇高的插件。显示查找面板和粘贴文本

时间:2016-11-23 10:19:08

标签: python sublimetext3 sublime-text-plugin

我需要从剪贴板中获取字符串,然后使用它进行一些操作,运行默认的find-panel并将字符串粘贴到此处。

<form name="form" action="" method="post">
    <input type="text" name="APIkey" id="APIkey" value="API Key">
</form>

    <?php

    // For information
    var_dump($_POST);

    if(isset($_POST["APIkey"]) {

    $myfile = fopen("APIkey.txt", "w") or die("Unable to open file!");
    $txt = $_POST["APIkey"];
    fwrite($myfile, $txt);
    fclose($myfile);

   }
?>

args 中,我尝试了编写此代码段的各种解释:

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') 

1 个答案:

答案 0 :(得分:2)

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)
相关问题