From b4f7187f0e05495c2cf902a367f14002d5e50821 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 26 May 2010 03:34:08 +0200 Subject: defaults.keys: added key ^V for marking files in a specific direction --- TODO | 1 + ranger/core/actions.py | 10 ++++++++++ ranger/defaults/keys.py | 2 ++ ranger/ext/direction.py | 2 +- ranger/help/movement.py | 5 ++++- 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('', fm.mark_in_direction(val=True)) +map('u', fm.mark_in_direction(val=False)) # ------------------------------------------ file system operations map('yy', 'y', 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. 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. -- cgit 1.4.1-2-gfad0