summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-05-26 03:34:08 +0200
committerhut <hut@lavabit.com>2010-05-26 03:34:08 +0200
commitb4f7187f0e05495c2cf902a367f14002d5e50821 (patch)
tree2fbfc200e9eed48a470e3e528a47b797667a7fde
parent1e5adcd713e5c0ed960a924e49958af7aec34759 (diff)
downloadranger-b4f7187f0e05495c2cf902a367f14002d5e50821.tar.gz
defaults.keys: added key ^V for marking files in a specific direction
-rw-r--r--TODO1
-rw-r--r--ranger/core/actions.py10
-rw-r--r--ranger/defaults/keys.py2
-rw-r--r--ranger/ext/direction.py2
-rw-r--r--ranger/help/movement.py5
5 files changed, 18 insertions, 2 deletions
diff --git a/TODO b/TODO
index d2aac406..1e02251c 100644
--- a/TODO
+++ b/TODO
@@ -87,6 +87,7 @@ Bugs
    (X) #87  10/05/10  files are not properly closed after previewing
    ( ) #88  10/05/10  race conditions for data loading from FS
    (X) #90  10/05/11  no link target for broken links
+   ( ) #94  10/05/26  "pressed keys" text cut off when chaining ctrl-XYZ keys
 
 
 Ideas
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 69fbf32f..14f862c7 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -273,6 +273,16 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		if hasattr(self.ui, 'status'):
 			self.ui.status.need_redraw = True
 
+	def mark_in_direction(self, val=True, dirarg=None):
+		cwd = self.env.cwd
+		direction = Direction(dirarg)
+		pos, selected = direction.select(lst=cwd.files, current=cwd.pointer,
+				pagesize=self.env.termsize[0])
+		cwd.pointer = pos
+		cwd.correct_pointer()
+		for item in selected:
+			cwd.mark_item(item, val)
+
 	# --------------------------
 	# -- Searching
 	# --------------------------
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 59b45f8e..c95baed9 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -163,6 +163,8 @@ map('T', fm.tag_remove())
 map(' ', fm.mark(toggle=True))
 map('v', fm.mark(all=True, toggle=True))
 map('V', 'uv', fm.mark(all=True, val=False))
+map('<C-V><dir>', fm.mark_in_direction(val=True))
+map('u<C-V><dir>', fm.mark_in_direction(val=False))
 
 # ------------------------------------------ file system operations
 map('yy', 'y<dir>', fm.copy())
diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py
index b9fbcac9..f36e22a6 100644
--- a/ranger/ext/direction.py
+++ b/ranger/ext/direction.py
@@ -134,7 +134,7 @@ class Direction(dict):
 			pos += current
 		return int(max(min(pos, maximum + offset - 1), minimum))
 
-	def select(self, lst, override, current, pagesize, offset=1):
+	def select(self, lst, current, pagesize, override=None, offset=1):
 		dest = self.move(direction=self.down(), override=override,
 			current=current, pagesize=pagesize, minimum=0, maximum=len(lst))
 		selection = lst[min(current, dest):max(current, dest) + offset]
diff --git a/ranger/help/movement.py b/ranger/help/movement.py
index 3287e9bb..3abec359 100644
--- a/ranger/help/movement.py
+++ b/ranger/help/movement.py
@@ -96,7 +96,10 @@ of the file you're pointing at.
 
 	<Space> mark a file
 	v	toggle all marks
-	V	remove all marks
+	V, uv	remove all marks
+	^V	mark files in a specific direction
+		e.g. ^Vgg marks all files from the current to the top
+	u^V	unmark files in a specific direction
 
 By "tagging" files, you can highlight them and mark them to be
 special in whatever context you want.  Tags are persistent across sessions.