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