【问题标题】:Get path of folder on right click in sidebar by Sublime API通过 Sublime API 在侧边栏中右键单击获取文件夹路径
【发布时间】:2016-10-01 18:39:28
【问题描述】:

如何通过 Sublime API 在侧边栏中右键单击获取文件夹路径?我可以通过 sublime.view.file_name() 获取文件路径,但文件夹没有。

【问题讨论】:

  • os.path.dirname(view.file_name())

标签: sublimetext2 sublimetext3 sublimetext sublime-text-plugin


【解决方案1】:

简而言之,创建一个带有命令定义的Side Bar.sublime-menu 文件:

[
    { "caption": "Side Bar Test Dirs",  "command": "side_bar_test_dirs",  "args": {"dirs": []} },
    { "caption": "Side Bar Test Paths", "command": "side_bar_test_paths", "args": {"paths": []} },
    { "caption": "Side Bar test Files", "command": "side_bar_test_files", "args": {"files": []} },
]

然后是命令:

import sublime
import sublime_plugin

class SideBarTestDirsCommand(sublime_plugin.WindowCommand):
    def run(self, dirs):
        print(dirs)

class SideBarTestPathsCommand(sublime_plugin.WindowCommand):
    def run(self, paths):
        print(paths)

class SideBarTestFilesCommand(sublime_plugin.WindowCommand):
    def run(self, files):
        print(files)

Sublime Text Unofficial Documentaion 中有更详细的文档。

【讨论】:

    猜你喜欢
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 2018-08-08
    • 2011-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    相关资源
    最近更新 更多