【问题标题】:Modify title of SublimeREPL in tab修改选项卡中 SublimeREPL 的标题
【发布时间】:2021-08-13 20:25:51
【问题描述】:

我正在使用SublimeREPL 包。运行代码的选项卡中的标题很长,使导航选项卡很麻烦:

REPL 选项卡中显示的标题可以一起修改和/或隐藏吗?

【问题讨论】:

标签: sublimetext3 sublime-text-plugin sublimerepl


【解决方案1】:

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.
    }
},

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-17
    • 1970-01-01
    相关资源
    最近更新 更多