我需要从剪贴板中获取字符串,然后使用它进行一些操作,运行默认的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')
答案 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)