如何解决修改标签页中 SublimeREPL 的标题
我正在使用 SublimeREPL 包。运行代码的选项卡中的标题很长,使导航选项卡变得很麻烦:
解决方法
在 answer you linked 中,其中一个步骤是创建一个自定义插件来运行您的 virtualenv REPL。您可以通过更改 repl_open
方法以传递 "external_id"
键和值来自定义选项卡的标题。这是修改后的插件代码:
import sublime_plugin
class ProjectVenvReplCommand(sublime_plugin.TextCommand):
"""
Starts a SublimeREPL,attempting to use project's specified
python interpreter.
"""
def run(self,edit,open_file='$file',name='Python'):
"""Called on project_venv_repl command"""
cmd_list = [self.get_project_interpreter(),'-i','-u']
if open_file:
cmd_list.append(open_file)
self.repl_open(cmd_list=cmd_list,name=name)
def get_project_interpreter(self):
"""Return the project's specified python interpreter,if any"""
settings = self.view.settings()
return settings.get('python_interpreter','/usr/bin/python')
def repl_open(self,cmd_list,name):
"""Open a SublimeREPL using provided commands"""
self.view.window().run_command(
'repl_open',{
'encoding': 'utf8','type': 'subprocess','cmd': cmd_list,'cwd': '$file_path','syntax': 'Packages/Python/Python.sublime-syntax','external_id': name
}
)
在这里您可以修改发送给插件的参数以定义选项卡的名称(默认为 Python
):
{
"keys": ["f6"],"command": "project_venv_repl","args": {
"open_file": null,"name": "My Project Name" // insert name of choice here.
}
},
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。