def run(self, paths = [], confirmed = 'False'): if confirmed == 'False' and s.get('confirm_before_deleting', True): if sublime.platform() == 'osx': if sublime.ok_cancel_dialog('empty the content of the folder?'): self.run(paths, 'True') else: self.confirm([item.path() for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames()], [item.pathWithoutProject() for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames()]) else: try: for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames(): for content in os.listdir(item.path()): file = os.path.join(item.path(), content) if not SideBarSelection().isNone(file): send2trash(file) if s.get('close_affected_buffers_when_deleting_even_if_dirty', False): item.close_associated_buffers() except: pass SideBarProject().refresh();
def description(self, paths = []): items = [] for item in SideBarSelection(paths).getSelectedFiles(): items.append('*'+item.extension()) items = list(set(items)) if len(items) > 1: return 'In Files With Extensions '+(",".join(items))+u'…' elif len(items) > 0: return 'In Files With Extension '+(",".join(items))+u'…' else: return u'In Files With Extension…'
def run(self, paths = []): items = [] for item in SideBarSelection(paths).getSelectedFilesWithExtension('js'): items.append('<script type="text/javascript" src="'+item.pathAbsoluteFromProjectEncoded()+'"></script>') if len(items) > 0: sublime.set_clipboard("\n".join(items)); if len(items) > 1 : sublime.status_message("Items copied") else : sublime.status_message("Item copied")
def run(self, paths = [], confirmed = 'False'): if confirmed == 'False' and s.get('confirm_before_deleting', True): if sublime.platform() == 'osx': if sublime.ok_cancel_dialog('delete the selected items?'): self.run(paths, 'True') else: self.confirm([item.path() for item in SideBarSelection(paths).getSelectedItems()], [item.pathWithoutProject() for item in SideBarSelection(paths).getSelectedItems()]) else: try: for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems(): if s.get('close_affected_buffers_when_deleting_even_if_dirty', False): item.close_associated_buffers() send2trash(item.path()) SideBarProject().refresh(); except: import functools self.window.show_input_panel("BUG!", '', '', None, None) self.window.run_command('hide_panel'); self.window.show_input_panel("Permanently Delete:", SideBarSelection(paths).getSelectedItems()[0].path(), functools.partial(self.on_done, SideBarSelection(paths).getSelectedItems()[0].path()), None, None)
def run(self, paths = []): items = [] for item in SideBarSelection(paths).getSelectedFilesWithExtension('css'): items.append('<link rel="stylesheet" type="text/css" href="'+item.pathAbsoluteFromProjectEncoded()+'"/>') if len(items) > 0: sublime.set_clipboard("\n".join(items)); if len(items) > 1 : sublime.status_message("Items copied") else : sublime.status_message("Item copied")
def run(self, paths = []): items = [] for item in SideBarSelection(paths).getSelectedItems(): items.append('<a href="'+item.pathAbsoluteFromProjectEncoded()+'">'+item.namePretty()+'</a>') if len(items) > 0: sublime.set_clipboard("\n".join(items)); if len(items) > 1 : sublime.status_message("Items copied") else : sublime.status_message("Item copied")
def run(self, paths = []): items = [] for item in SideBarSelection(paths).getSelectedItems(): items.append(item.path()) if len(items) > 0: sublime.set_clipboard("\n".join(items)); if len(items) > 1 : sublime.status_message("Items copied") else : sublime.status_message("Item copied")
def run(self, paths=[]): items = [] for item in SideBarSelection( paths).getSelectedItemsWithoutChildItems(): items.append(SideBarProject().getDirectoryFromPath(item.path())) items = list(set(items)) if items: self.window.run_command('hide_panel') self.window.run_command("show_panel", { "panel": "find_in_files", "where": ",".join(items) })
def run(self): for repo in SideBarGit().getSelectedRepos( SideBarSelection([self.file_name]).getSelectedItems()): object = Object() object.item = repo.repository object.command = ['git', 'branch'] object.silent = True SideBarGit().run(object) sublime.set_timeout( lambda: self.on_done(SideBarGit.last_stdout.decode('utf-8')), 0) return
def run(self, paths = []): s = sublime.load_settings("SideBarEnhancements/Clipboard.sublime-settings") items = [] for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems(): items.append(item.path()) if len(items) > 0: s.set('cut', '') s.set('copy', "\n".join(items)) if len(items) > 1 : sublime.status_message("Items copied") else : sublime.status_message("Item copied")
def run(self, paths = [], application = "", extensions = ""): import sys application_dir, application_name = os.path.split(application) application_dir = application_dir.encode(sys.getfilesystemencoding()) application_name = application_name.encode(sys.getfilesystemencoding()) application = application.encode(sys.getfilesystemencoding()) if extensions == '*': extensions = '.*' if extensions == '': items = SideBarSelection(paths).getSelectedItems() else: items = SideBarSelection(paths).getSelectedFilesWithExtension(extensions) import subprocess for item in items: if sublime.platform() == 'osx': subprocess.Popen(['open', '-a', application, item.nameSystem()], cwd=item.dirnameSystem()) elif sublime.platform() == 'windows': subprocess.Popen([application_name, item.pathSystem()], cwd=expand_vars(application_dir), shell=True) else: subprocess.Popen([application_name, item.nameSystem()], cwd=item.dirnameSystem())
def run(self, paths = []): items = [] for item in SideBarSelection(paths).getSelectedImages(): try: image_type, width, height = self.getImageInfo(item.contentBinary()) items.append('<img src="'+item.pathAbsoluteFromProjectEncoded()+'" width="'+str(width)+'" height="'+str(height)+'" border="0"/>') except: items.append('<img src="'+item.pathAbsoluteFromProjectEncoded()+'" border="0"/>') if len(items) > 0: sublime.set_clipboard("\n".join(items)); if len(items) > 1 : sublime.status_message("Items copied") else : sublime.status_message("Item copied")
def on_done(self, paths, name): for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames(): item = SideBarItem(item.join(name), True) if item.exists(): sublime.error_message("Unable to create folder, folder or file exists.") self.run(paths, name) return else: item.create() if not item.exists(): sublime.error_message("Unable to create folder:\n\n"+item.path()) self.run(paths, name) return SideBarProject().refresh();
def run(self, paths=[]): items = [] for item in SideBarSelection(paths).getSelectedItems(): items.append('*' + item.extension()) items = list(set(items)) self.window.run_command('hide_panel') if int(sublime.version()) >= 2134: self.window.run_command("show_panel", { "panel": "find_in_files", "where": ",".join(items) }) else: self.window.run_command("show_panel", { "panel": "find_in_files", "location": ",".join(items) })
def run(self, paths=[]): items = [] project = SideBarProject() url = project.getPreference('url_production') if url: if url[-1:] != '/': url = url + '/' for item in SideBarSelection(paths).getSelectedItems(): if item.isUnderCurrentProject(): items.append(url + item.pathRelativeFromProjectEncoded()) if len(items) > 0: sublime.set_clipboard("\n".join(items)) if len(items) > 1: sublime.status_message("Items URL copied") else: sublime.status_message("Item URL copied")
def run(self, paths=[]): for item in SideBarSelection(paths).getSelectedItems(): if self.window.num_groups() == 1: self.window.run_command( 'set_layout', { "cols": [0.0, 0.5, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1]] }) #self.window.run_command('clone_file') view = self.window.new_file() view.set_name(item.name() + ".disasm") view.set_syntax_file("Packages/Disasma/Disasma.tmLanguage") view.run_command('disasmaentry', {"location": item.path()}) self.window.run_command('move_to_group', {"group": 1}) self.window.focus_view(view)
def run(self, paths = [], type = False): browser = s.get("default_browser") if browser == '': browser = 'firefox' if type == False or type == 'testing': type = 'url_testing' elif type == 'production': type = 'url_production' else: type = 'url_testing' for item in SideBarSelection(paths).getSelectedItems(): if item.projectURL(type): self.try_open(item.projectURL(type) + item.pathRelativeFromProjectEncoded(), browser) else: self.try_open(item.uri(), browser)
def on_done(self, paths, name): for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames(): 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()
def run(self, paths = [], type = False): import webbrowser try: browser = webbrowser.get(s.get("default_browser")) except: browser = webbrowser if type == False or type == 'testing': type = 'url_testing' elif type == 'production': type = 'url_production' else: type = 'url_testing' for item in SideBarSelection(paths).getSelectedItems(): if item.projectURL(type): browser.open_new_tab(item.projectURL(type) + item.pathRelativeFromProjectEncoded()) else: browser.open_new_tab(item.uri())
def run(self, paths = []): global sidebar_instant_search if paths == [] and SideBarProject().getDirectories(): paths = SideBarProject().getDirectories() else: paths = [item.path() for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames()] if paths == []: return view = self.window.new_file() view.settings().set('word_wrap', False) view.set_name('Instant File Search') view.set_syntax_file('Packages/SideBarEnhancements/SideBar Results.hidden-tmLanguage') view.set_scratch(True) edit = view.begin_edit() view.settings().set('sidebar_instant_search_paths', paths) view.replace(edit, sublime.Region(0, view.size()), "Type to search: ") view.end_edit(edit) view.sel().clear() view.sel().add(sublime.Region(16)) sidebar_instant_search += 1
def run(self, paths = []): import subprocess for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames(): if sublime.platform() == 'osx': try: subprocess.Popen(['subl', '.'], cwd=item.pathSystem()) except: try: subprocess.Popen(['sublime', '.'], cwd=item.pathSystem()) except: subprocess.Popen(['/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', '.'], cwd=item.pathSystem()) elif sublime.platform() == 'windows': try: subprocess.Popen(['subl', '.'], cwd=item.pathSystem(), shell=True) except: try: subprocess.Popen(['sublime', '.'], cwd=item.pathSystem(), shell=True) except: subprocess.Popen(['sublime_text.exe', '.'], cwd=item.pathSystem(), shell=True) else: try: subprocess.Popen(['subl', '.'], cwd=item.pathSystem()) except: subprocess.Popen(['sublime', '.'], cwd=item.pathSystem())
def run(self, paths = [], in_parent = 'False', test = 'True', replace = 'False'): s = sublime.load_settings("SideBarEnhancements/Clipboard.sublime-settings") cut = s.get('cut', '') copy = s.get('copy', '') already_exists_paths = [] if SideBarSelection(paths).len() > 0: if in_parent == 'False': location = SideBarSelection(paths).getSelectedItems()[0].path() else: location = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()[0].dirname() if os.path.isdir(location) == False: location = SideBarItem(os.path.dirname(location), True) else: location = SideBarItem(location, True) if cut != '': cut = cut.split("\n") for path in cut: path = SideBarItem(path, os.path.isdir(path)) new = os.path.join(location.path(), path.name()) if test == 'True' and os.path.exists(new): already_exists_paths.append(new) elif test == 'False': if os.path.exists(new) and replace == 'False': pass else: try: if not path.move(new, replace == 'True'): sublime.error_message("Unable to cut and paste, destination exists.") return except: sublime.error_message("Unable to move:\n\n"+path.path()+"\n\nto\n\n"+new) return if copy != '': copy = copy.split("\n") for path in copy: path = SideBarItem(path, os.path.isdir(path)) new = os.path.join(location.path(), path.name()) if test == 'True' and os.path.exists(new): already_exists_paths.append(new) elif test == 'False': if os.path.exists(new) and replace == 'False': pass else: try: if not path.copy(new, replace == 'True'): sublime.error_message("Unable to copy and paste, destination exists.") return except: sublime.error_message("Unable to copy:\n\n"+path.path()+"\n\nto\n\n"+new) return if test == 'True' and len(already_exists_paths): self.confirm(paths, in_parent, already_exists_paths) elif test == 'True' and not len(already_exists_paths): self.run(paths, in_parent, 'False', 'False') elif test == 'False': cut = s.set('cut', '') SideBarProject().refresh();
def is_enabled(self, paths=[]): return SideBarSelection(paths).hasFilesWithExtension( 'js') and SideBarSelection(paths).hasItemsUnderProject()
def is_enabled(self, paths=[]): return SideBarSelection(paths).len() > 0
def is_enabled(self, paths=[]): return SideBarSelection(paths).hasImages() and SideBarSelection( paths).hasItemsUnderProject()
def is_enabled(self, paths=[], in_parent=False): s = sublime.load_settings( "SideBarEnhancements/Clipboard.sublime-settings") return s.get('cut', '') + s.get('copy', '') != '' and len( SideBarSelection(paths).getSelectedDirectoriesOrDirnames()) == 1
def run(self, paths=[], in_parent='False', test='True', replace='False'): s = sublime.load_settings( "SideBarEnhancements/Clipboard.sublime-settings") cut = s.get('cut', '') copy = s.get('copy', '') already_exists_paths = [] if SideBarSelection(paths).len() > 0: if in_parent == 'False': location = SideBarSelection(paths).getSelectedItems()[0].path() else: location = SideBarSelection( paths).getSelectedDirectoriesOrDirnames()[0].dirname() if os.path.isdir(location) == False: location = SideBarItem(os.path.dirname(location), True) else: location = SideBarItem(location, True) if cut != '': cut = cut.split("\n") for path in cut: path = SideBarItem(path, os.path.isdir(path)) new = os.path.join(location.path(), path.name()) if test == 'True' and os.path.exists(new): already_exists_paths.append(new) elif test == 'False': if os.path.exists(new) and replace == 'False': pass else: try: if not path.move(new, replace == 'True'): sublime.error_message( "Unable to cut and paste, destination exists." ) return except: sublime.error_message("Unable to move:\n\n" + path.path() + "\n\nto\n\n" + new) return if copy != '': copy = copy.split("\n") for path in copy: path = SideBarItem(path, os.path.isdir(path)) new = os.path.join(location.path(), path.name()) if test == 'True' and os.path.exists(new): already_exists_paths.append(new) elif test == 'False': if os.path.exists(new) and replace == 'False': pass else: try: if not path.copy(new, replace == 'True'): sublime.error_message( "Unable to copy and paste, destination exists." ) return except: sublime.error_message("Unable to copy:\n\n" + path.path() + "\n\nto\n\n" + new) return if test == 'True' and len(already_exists_paths): self.confirm(paths, in_parent, already_exists_paths) elif test == 'True' and not len(already_exists_paths): self.run(paths, in_parent, 'False', 'False') elif test == 'False': cut = s.set('cut', '') SideBarProject().refresh()
def is_enabled(self, paths=[]): return SideBarSelection(paths).len() > 0 and SideBarSelection( paths).hasProjectDirectories() == False
def is_enabled(self, paths=[]): return SideBarSelection(paths).hasFiles()
def run(self, paths=[]): project = SideBarProject() if project.hasOpenedProject(): for item in SideBarSelection(paths).getSelectedDirectories(): project.rootAdd(item.path())
def is_enabled(self, paths=[]): return SideBarSelection(paths).hasDirectories()