2
如何通过Sublime API右键点击侧边栏获取文件夹路径?我可以通过sublime.view.file_name()获取文件路径,但对文件夹没有任何影响。通过Sublime API在右侧点右键点击文件夹获取路径
如何通过Sublime API右键点击侧边栏获取文件夹路径?我可以通过sublime.view.file_name()获取文件路径,但对文件夹没有任何影响。通过Sublime API在右侧点右键点击文件夹获取路径
概括地说,创建一个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详细的文档。
os.path.dirname(view.file_name()) – OdatNurd