• 大小: 39KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: 其他
  • 标签: sidebar  sublime  插件  

资源简介

SideBarEnhancements插件一个增强侧边栏文件夹浏览功能的插件,比较不错,具有很多对于文件列表进行操作的功能。

资源截图

代码片段和文件信息

# coding=utf8
import sublime sublime_plugin
import os

import threading time

from sidebar.SideBarItem import SideBarItem
from sidebar.SideBarSelection import SideBarSelection
from sidebar.SideBarProject import SideBarProject

from send2trash import send2trash

# needed for getting local app data path on windows
if sublime.platform() == ‘windows‘:
import _winreg

def expand_vars(path):
for k v in os.environ.iteritems():
# dirty hack this should be autofixed in python3
try:
k = unicode(k.encode(‘utf8‘))
v = unicode(v.encode(‘utf8‘))
path = path.replace(‘%‘+k+‘%‘ v).replace(‘%‘+k.lower()+‘%‘ v)
except:
pass
return path
#NOTES
# A “directory“ for this plugin is a “directory“
# A “directory“ for a user is a “folder“

s = sublime.load_settings(‘Side Bar.sublime-settings‘)

def check_version():
version = ‘11.13.2012.1305.0‘;
if s.get(‘version‘) != version:
SideBarItem(sublime.packages_path()+‘/SideBarEnhancements/messages/‘+version+‘.txt‘ False).edit();
s.set(‘version‘ version);
sublime.save_settings(‘Side Bar.sublime-settings‘)

sublime.set_timeout(lambda:check_version() 3000);

class SideBarNewFile2Command(sublime_plugin.WindowCommand):
def run(self paths = [] name = ““):
import functools
self.window.run_command(‘hide_panel‘);
self.window.show_input_panel(“File Name:“ name functools.partial(SideBarNewFileCommand(sublime_plugin.WindowCommand).on_done paths True) None None)

class SideBarNewFileCommand(sublime_plugin.WindowCommand):
def run(self paths = [] name = ““):
import functools
self.window.run_command(‘hide_panel‘);
self.window.show_input_panel(“File Name:“ name functools.partial(self.on_done paths False) None None)

def on_done(self paths relative_to_project name):
if relative_to_project and s.get(‘new_files_relative_to_project_root‘):
paths = SideBarProject().getDirectories()
if paths:
paths = [SideBarItem(paths[0] False)]
if not paths:
paths = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()
else:
paths = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()
if not paths:
paths = SideBarProject().getDirectories()
if paths:
paths = [SideBarItem(paths[0] False)]
if not paths:
sublime.active_window().new_file()
else:
for item in paths:
item = SideBarItem(item.join(name) False)
if item.exists():
sublime.error_message(“Unable to create file file or folder exists.“)
self.run(paths name)
return
else:
try:
item.create()
item.edit()
except:
sublime.error_message(“Unable to create file:\n\n“+item.path())
self.run(paths name)
return
SideBarProject().refresh();

class SideBarNewDirectoryCommand(sublime_plugin.WindowCommand):
def run(self paths = [] name = ““):
import functools
self.window.run_command(‘hide_panel‘);
self.window.show_input_panel(“Folder Name:“ name functools.partial(self.on_done paths) None None)

def on_done(self path

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-02-05 16:14  SideBarEnhancements\
     文件          33  2013-10-22 00:40  SideBarEnhancements\.gitignore
     文件        2247  2013-10-22 00:40  SideBarEnhancements\Commands.sublime-commands
     文件         220  2013-10-22 00:40  SideBarEnhancements\Default.sublime-keymap
     目录           0  2014-02-05 16:14  SideBarEnhancements\disable_default\
     文件         146  2013-10-22 00:40  SideBarEnhancements\disable_default\Side Bar Mount Point.sublime-menu.txt
     文件         673  2013-10-22 00:40  SideBarEnhancements\disable_default\Side Bar.sublime-menu.txt
     目录           0  2014-02-05 16:14  SideBarEnhancements\hurry\
     文件        2166  2013-10-22 00:40  SideBarEnhancements\hurry\filesize.py
     文件        2055  2013-10-22 00:40  SideBarEnhancements\hurry\PKG-INFO
     文件        1113  2013-10-22 00:40  SideBarEnhancements\hurry\README.txt
     文件           0  2013-10-22 00:40  SideBarEnhancements\hurry\__init__.py
     文件         924  2013-10-22 00:40  SideBarEnhancements\license.txt
     文件        2584  2013-10-22 00:40  SideBarEnhancements\Main.sublime-menu
     目录           0  2014-02-05 16:14  SideBarEnhancements\messages\
     文件         571  2013-10-22 00:40  SideBarEnhancements\messages\11.13.2012.1305.0.txt
     文件         155  2013-10-22 00:40  SideBarEnhancements\readme.md
     目录           0  2014-02-05 16:14  SideBarEnhancements\send2trash\
     文件        1634  2013-10-22 00:40  SideBarEnhancements\send2trash\plat_osx.py
     文件        5288  2013-10-22 00:40  SideBarEnhancements\send2trash\plat_other.py
     文件        1586  2013-10-22 00:40  SideBarEnhancements\send2trash\plat_win.py
     文件         468  2013-10-22 00:40  SideBarEnhancements\send2trash\__init__.py
     文件       10845  2013-10-22 00:40  SideBarEnhancements\Side Bar.sublime-menu
     文件        1051  2013-10-22 00:40  SideBarEnhancements\Side Bar.sublime-settings
     目录           0  2014-02-05 16:14  SideBarEnhancements\sidebar\
     目录           0  2014-02-05 16:14  SideBarEnhancements\sidebar\desktop\
     文件       17223  2013-10-22 00:40  SideBarEnhancements\sidebar\desktop\dialog.py
     文件        8000  2013-10-22 00:40  SideBarEnhancements\sidebar\desktop\windows.py
     文件        8910  2013-10-22 00:40  SideBarEnhancements\sidebar\desktop\__init__.py
     文件       13740  2013-10-22 00:40  SideBarEnhancements\sidebar\SideBarItem.py
     文件        4036  2013-10-22 00:40  SideBarEnhancements\sidebar\SideBarProject.py
............此处省略6个文件信息

评论

共有 条评论