def _execute_delete_file(self, filepath):
        if IS_ST3 and self._side_bar_enhancements_installed():
            import Default.send2trash as send2trash

            send2trash.send2trash(filepath)
        else:
            self.window.run_command("delete_file", {"files": [filepath]})
Exemple #2
0
 def run(self, edit, group=-1, index=-1):
     targetView = self.getTargetView(group, index)
     targetFilePath = targetView.file_name()
     if targetFilePath:
         send2trash(targetFilePath)
         targetView.set_scratch(True)
         targetView.close()
Exemple #3
0
 def run(self, dirs):
     if sublime.ok_cancel_dialog("Delete Folder?", "Delete"):
         import Default.send2trash as send2trash
         try:
             for d in dirs:
                 send2trash.send2trash(d)
         except:
             sublime.status_message("Unable to delete folder")
Exemple #4
0
 def run(self, dirs):
     if sublime.ok_cancel_dialog("Delete Folder?", "Delete"):
         import Default.send2trash as send2trash
         try:
             for d in dirs:
                 send2trash.send2trash(d)
         except:
             sublime.status_message("Unable to delete folder")
Exemple #5
0
    def run(self, files):
        # Import send2trash on demand, to avoid initialising ctypes for as long as possible
        import Default.send2trash as send2trash
        for f in files:
            v = self.window.find_open_file(f)
            if v is not None and not v.close():
                return

            send2trash.send2trash(f)
Exemple #6
0
    def run(self, files):
        # Import send2trash on demand, to avoid initialising ctypes for as long as possible
        import Default.send2trash as send2trash
        for f in files:
            v = self.window.find_open_file(f)
            if v != None and not v.close():
                return

            send2trash.send2trash(f)
 def _sender(files, event_for_wait, event_for_set):
     for filename in files:
         event_for_wait.wait()
         event_for_wait.clear()
         if event_for_wait is remove_event:
             send2trash.send2trash(join(path, filename))
         else:
             _status(filename)
         event_for_set.set()
     _status(done=True)
Exemple #8
0
    def do_delete(self, path):

        # Reset FileNavigatorCommand
        self.cls.reset()

        # Save source name
        source_name = os.path.basename(path)

        if sublime.ok_cancel_dialog("Delete %s?" % source_name, "Delete"):
            send2trash(path)
            sublime.status_message("%s deleted" % source_name)
	def do_delete(self, path):

		# Reset FileNavigatorCommand
		self.cls.reset()

		# Save source name
		source_name = os.path.basename(path)

		if sublime.ok_cancel_dialog("Delete %s?" % source_name, "Delete"):
			send2trash(path)
			sublime.status_message("%s deleted" % source_name)
Exemple #10
0
    def run(self, group, index):
        name = os.path.basename(self.path).center(64)
        delete = sublime.ok_cancel_dialog(
            "Are you sure you want to delete?\n\n" + name, "Delete")

        if delete and self.view.close():
            import Default.send2trash as send2trash
            try:
                send2trash.send2trash(self.path)
            except:
                msg = "Unable to delete file: " + self.path
                sublime.status_message(msg)
Exemple #11
0
 def run(self):
     view = self.window.active_view()
     if view is None:
         file_name = self.window.extract_variables().get('file')
     else:
         file_name = view.file_name()
     if file_name is None or not os.path.exists(file_name):
         return
     if sublime.ok_cancel_dialog("Delete %s?" % file_name, "Delete"):
         if not view.close():
             return
         import Default.send2trash as send2trash
         send2trash.send2trash(file_name)
Exemple #12
0
    def run(self, group=-1, index=-1):
        """Delete the tab's file."""

        if group >= 0 and index >= 0:
            view = get_group_view(self.window, group, index)
            if view is not None:
                file_name = view.file_name()
                if file_name is not None and os.path.exists(file_name):
                    if sublime.ok_cancel_dialog("Delete %s?" % file_name, "Delete"):
                        if not view.close():
                            return
                        import Default.send2trash as send2trash
                        send2trash.send2trash(file_name)
Exemple #13
0
    def run(self, paths):
        if len(paths) == 1:
            message = "Delete %s?" % paths[0]
        else:
            message = "Delete %d items?" % len(paths)

        if sublime.ok_cancel_dialog(message, "Delete"):
            import Default.send2trash as send2trash
            try:
                for path in paths:
                    send2trash.send2trash(path)
            except:
                self.window.status_message("Unable to delete")
Exemple #14
0
    def run(self, group=-1, index=-1):
        """Delete the tab's file."""

        if group >= 0 and index >= 0:
            view = get_group_view(self.window, group, index)
            if view is not None:
                file_name = view.file_name()
                if file_name is not None and os.path.exists(file_name):
                    if sublime.ok_cancel_dialog("Delete %s?" % file_name, "Delete"):
                        if not view.close():
                            return
                        import Default.send2trash as send2trash
                        send2trash.send2trash(file_name)
Exemple #15
0
    def run(self, dirs):

        if len(dirs) == 1:
            message = "Delete Folder %s?" % dirs[0]
        else:
            message = "Delete %d Folders?" % len(dirs)

        if sublime.ok_cancel_dialog(message, "Delete"):
            import Default.send2trash as send2trash
            try:
                for d in dirs:
                    send2trash.send2trash(d)
            except:
                sublime.status_message("Unable to delete folder")
Exemple #16
0
    def run(self, dirs):

        if len(dirs) == 1:
            message = "Delete Folder %s?" % dirs[0]
        else:
            message = "Delete %d Folders?" % len(dirs)

        if sublime.ok_cancel_dialog(message, "Delete"):
            import Default.send2trash as send2trash
            try:
                for d in dirs:
                    send2trash.send2trash(d)
            except:
                sublime.status_message("Unable to delete folder")
 def _sender(files, event_for_wait, event_for_set):
     for filename in files:
         event_for_wait.wait()
         event_for_wait.clear()
         if event_for_wait is remove_event:
             try:
                 send2trash.send2trash(join(path, filename))
             except OSError as e:
                 errors.append(u'{0}:\t{1}'.format(e, filename))
         else:
             _status(filename)
         event_for_set.set()
     if event_for_wait is remove_event:
         _status(done=True)
Exemple #18
0
 def _sender(files, event_for_wait, event_for_set):
     for filename in files:
         event_for_wait.wait()
         event_for_wait.clear()
         if event_for_wait is remove_event:
             try:
                 send2trash.send2trash(join(path, filename))
             except OSError as e:
                 errors.append(u'{0}:\t{1}'.format(e, filename))
         else:
             _status(filename)
         event_for_set.set()
     if event_for_wait is remove_event:
         _status(done=True)
    def run(self,
            edit,
            prompt_before_delete=None,
            auto_close_buffer=None,
            move_to_trash=None):

        global settings

        if prompt_before_delete is None:
            prompt_before_delete = settings.get('prompt_before_delete', False)

        if auto_close_buffer is None:
            auto_close_buffer = settings.get('auto_close_buffer', True)

        if move_to_trash is None:
            move_to_trash = settings.get('move_to_trash', False)

        window = sublime.active_window()
        view = sublime.Window.active_view(window)
        file_name = view.file_name()
        message = "Are you sure you want to " + \
            "move '{}' to the trash?" if move_to_trash else "delete '{}'?"
        message = message.format(file_name)

        if prompt_before_delete:
            if not sublime.ok_cancel_dialog(message):
                return

        if view.is_dirty():
            view.set_scratch(True)

        if auto_close_buffer:
            window.run_command('close_file')

        if (file_name is not None and os.path.isfile(file_name)):
            if move_to_trash:
                # Import send2trash on demand, to avoid initialising ctypes
                # for as long as possible
                from Default.send2trash import send2trash
                send2trash(file_name)
            else:
                os.remove(file_name)
Exemple #20
0
def delete_override(window, pkg_name, override):
    """
    Delete the provided override from the given package name.
    """
    # Import send2trash on demand; see Default/side_bar.py.
    import Default.send2trash as send2trash

    confirm = oa_setting("confirm_deletion")

    relative_name = os.path.join(pkg_name, override)
    full_name = os.path.join(sublime.packages_path(), relative_name)
    if os.path.isfile(full_name):
        if confirm:
            msg = "Confirm deletion:\n\n{}".format(
                override_display(relative_name))

        if (confirm is False
                or sublime.yes_no_cancel_dialog(msg) == sublime.DIALOG_YES):
            send2trash.send2trash(full_name)
            log("Deleted %s", relative_name, status=True)
Exemple #21
0
 def run(self, edit, trash=False):
     files = self.get_marked() or self.get_selected()
     if files:
         # Yes, I know this is English.  Not sure how Sublime is translating.
         if len(files) == 1:
             msg = "Delete {0}?".format(files[0])
         else:
             msg = "Delete {0} items?".format(len(files))
         if trash and not send2trash:
             msg = "Cannot send to trash.\nPermanently " + msg[0].lower() + msg[1:]
             trash = False
         if trash or sublime.ok_cancel_dialog(msg):
             for filename in files:
                 fqn = join(self.path, filename)
                 if trash and send2trash:
                     send2trash.send2trash(fqn)
                 elif isdir(fqn):
                     shutil.rmtree(fqn)
                 else:
                     os.remove(fqn)
             self.view.run_command('dired_refresh')
    def run(self, edit, prompt_before_delete=None, auto_close_buffer=None,
            move_to_trash=None):

        global settings

        if prompt_before_delete is None:
            prompt_before_delete = settings.get('prompt_before_delete', False)

        if auto_close_buffer is None:
            auto_close_buffer = settings.get('auto_close_buffer', True)

        if move_to_trash is None:
            move_to_trash = settings.get('move_to_trash', False)

        window = sublime.active_window()
        view = sublime.Window.active_view(window)
        file_name = view.file_name()
        message = "Are you sure you want to " + \
            "move '{}' to the trash?" if move_to_trash else "delete '{}'?"
        message = message.format(file_name)

        if prompt_before_delete:
            if not sublime.ok_cancel_dialog(message):
                return

        if view.is_dirty():
            view.set_scratch(True)

        if auto_close_buffer:
            window.run_command('close_file')

        if (file_name is not None and os.path.isfile(file_name)):
            if move_to_trash:
                # Import send2trash on demand, to avoid initialising ctypes
                # for as long as possible
                from Default.send2trash import send2trash
                send2trash(file_name)
            else:
                os.remove(file_name)
 def run(self, files):
     # Import send2trash on demand, to avoid initialising ctypes for as long as possible
     import Default.send2trash as send2trash
     for f in files:
         send2trash.send2trash(f)
 def _execute_delete_file(self, filepath):
     if IS_ST3 and self._side_bar_enhancements_installed():
         import Default.send2trash as send2trash
         send2trash.send2trash(filepath)
     else:
         self.window.run_command("delete_file", {"files": [filepath]})