From c12a43a29d0987b233dc2d26a23a2aaefb99226a Mon Sep 17 00:00:00 2001 From: Stanislav Arnaudov Date: Sun, 24 Feb 2019 16:19:14 +0100 Subject: Implementing destination argument for the built in paste command --- ranger/core/actions.py | 13 +++++++++---- ranger/core/loader.py | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index ddb98d9b..a9e01b79 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1559,12 +1559,17 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m link(source_path, next_available_filename(target_path)) - def paste(self, overwrite=False, append=False): + def paste(self, overwrite=False, append=False, dest=None): """:paste - - Paste the selected items into the current directory. + + Paste the selected items into the current directory or in dest + if given. """ - loadable = CopyLoader(self.copy_buffer, self.do_cut, overwrite) + if dest is not None: + if not exists(dest) and not isdir(dest): + self.notify('Failed to paste. The given path is invalid.', bad=True) + return + loadable = CopyLoader(self.copy_buffer, self.do_cut, overwrite, dest=dest) self.loader.add(loadable, append=append) self.do_cut = False diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 9f32535f..96d000ac 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -51,11 +51,11 @@ class Loadable(object): class CopyLoader(Loadable, FileManagerAware): # pylint: disable=too-many-instance-attributes progressbar_supported = True - def __init__(self, copy_buffer, do_cut=False, overwrite=False): + def __init__(self, copy_buffer, do_cut=False, overwrite=False, dest=None): self.copy_buffer = tuple(copy_buffer) self.do_cut = do_cut self.original_copy_buffer = copy_buffer - self.original_path = self.fm.thistab.path + self.original_path = dest if dest is not None else self.fm.thistab.path self.overwrite = overwrite self.percent = 0 if self.copy_buffer: @@ -102,7 +102,7 @@ class CopyLoader(Loadable, FileManagerAware): # pylint: disable=too-many-instan tag = self.fm.tags.tags[path] self.fm.tags.remove(path) self.fm.tags.tags[ - path.replace(fobj.path, self.original_path + '/' + fobj.basename) + path.replace(fobj.path, path.join(self.original_path, fobj.basename)) ] = tag self.fm.tags.dump() n = 0 -- cgit 1.4.1-2-gfad0 From 5253b3992f76251c1daf954b3282eec7a31e1412 Mon Sep 17 00:00:00 2001 From: Stanislav Arnaudov Date: Tue, 26 Feb 2019 22:22:38 +0100 Subject: Clearing up some whitespaces --- ranger/core/actions.py | 2 +- ranger/core/loader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index a9e01b79..618170a4 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1561,7 +1561,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def paste(self, overwrite=False, append=False, dest=None): """:paste - + Paste the selected items into the current directory or in dest if given. """ diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 96d000ac..3935e2aa 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -398,8 +398,8 @@ class Loader(FileManagerAware): else: break except IndexError: - return + return item.unpause() self.rotate() -- cgit 1.4.1-2-gfad0 From b39bde2d86575a75481cdf953c57555bd26ba1e4 Mon Sep 17 00:00:00 2001 From: Stanislav Arnaudov Date: Wed, 27 Feb 2019 23:04:01 +0100 Subject: Fixing the dumb clearing mistake --- ranger/core/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 3935e2aa..96d000ac 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -398,8 +398,8 @@ class Loader(FileManagerAware): else: break except IndexError: - return + item.unpause() self.rotate() -- cgit 1.4.1-2-gfad0 From 9326536e0fb12ead0b5f40e509e9a2e7153f083a Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 28 Feb 2019 13:15:58 +0100 Subject: Minor docstring rephrasing --- ranger/core/actions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 618170a4..3868d102 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1562,8 +1562,8 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def paste(self, overwrite=False, append=False, dest=None): """:paste - Paste the selected items into the current directory or in dest - if given. + Paste the selected items into the current directory or to dest + if provided. """ if dest is not None: if not exists(dest) and not isdir(dest): -- cgit 1.4.1-2-gfad0 From 51e7383ad5ebdf35374d62b44ca57ad58ce339cb Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 28 Feb 2019 13:16:06 +0100 Subject: New keybindings for paste to destination pd opens up the console to allow pasting to a path. p' and p` allow for pasting to a bookmark. --- ranger/config/rc.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 98a059d4..4a182f69 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -476,6 +476,9 @@ map pl paste_symlink relative=False map pL paste_symlink relative=True map phl paste_hardlink map pht paste_hardlinked_subtree +map pd console paste dest= +map p` paste dest=%any_path +map p' paste dest=%any_path map dD console delete -- cgit 1.4.1-2-gfad0