summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/actions.py16
-rw-r--r--ranger/defaults/keys.py4
-rw-r--r--ranger/help/fileop.py6
3 files changed, 21 insertions, 5 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 911f5ca4..a298b304 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -542,8 +542,9 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		self.env.cut = False
 		self.ui.browser.main_column.request_redraw()
 
-	def copy(self, narg=None, dirarg=None):
-		"""Copy the selected items"""
+	def copy(self, mode='set', narg=None, dirarg=None):
+		"""Copy the selected items.  Modes are: 'set', 'add', 'remove'."""
+		assert mode in ('set', 'add', 'remove')
 		cwd = self.env.cwd
 		if not narg and not dirarg:
 			selected = (f for f in self.env.get_selection() if f in cwd.files)
@@ -559,12 +560,17 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 					pagesize=self.env.termsize[0], offset=offset)
 			cwd.pointer = pos
 			cwd.correct_pointer()
-		self.env.copy = set(selected)
+		if mode == 'set':
+			self.env.copy = set(selected)
+		elif mode == 'add':
+			self.env.copy.update(set(selected))
+		elif mode == 'remove':
+			self.env.copy.difference_update(set(selected))
 		self.env.cut = False
 		self.ui.browser.main_column.request_redraw()
 
-	def cut(self, narg=None, dirarg=None):
-		self.copy(narg=narg, dirarg=dirarg)
+	def cut(self, mode='set', narg=None, dirarg=None):
+		self.copy(mode=mode, narg=narg, dirarg=dirarg)
 		self.env.cut = True
 		self.ui.browser.main_column.request_redraw()
 
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index ce595be6..75f6eb2e 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -168,7 +168,11 @@ map('u<C-V><dir>', fm.mark_in_direction(val=False))
 
 # ------------------------------------------ file system operations
 map('yy', 'y<dir>', fm.copy())
+map('ya', fm.copy(mode='add'))
+map('yr', fm.copy(mode='remove'))
 map('dd', 'd<dir>', fm.cut())
+map('da', fm.cut(mode='add'))
+map('dr', fm.cut(mode='remove'))
 map('pp', fm.paste())
 map('po', fm.paste(overwrite=True))
 map('pl', fm.paste_symlink())
diff --git a/ranger/help/fileop.py b/ranger/help/fileop.py
index 53ce9ff8..f8401800 100644
--- a/ranger/help/fileop.py
+++ b/ranger/help/fileop.py
@@ -60,6 +60,9 @@ The "highlighted file", or the "current file", is the one below the cursor.
 	yy	copy the selection
 	dd	cut the selection
 
+	ya, da	add the selection to the copied/cut files
+	yr, dr	remove the selection from the copied/cut files
+
 	pp	paste the copied/cut files. No file will be overwritten.
 		Instead, a "_" character will be appended to the new filename.
 	po	paste the copied/cut files. Existing files are overwritten.
@@ -75,6 +78,9 @@ If renaming is not possible because the source and the destination are
 on separate devices, it will be copied and eventually the source is deleted.
 This implies that a file can only be cut + pasted once.
 
+The files are either copied or cut, never mixed even if you mix "da" and "ya"
+keys (in which case the last command is decisive about whether they are copied
+or cut.)
 
 ==============================================================================
 4.4. Task View