如何通过Sublime API右键单击侧栏中的文件夹路径?我可以通过sublime.view.file_name()获取文件路径,但不能获取文件夹。
答案 0 :(得分:2)
简而言之,使用命令定义创建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中有更详细的文档。