From 2b33c6b6c245ff669a59f9e16779b5d218a2877b Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 6 Apr 2010 22:42:10 +0200 Subject: core.actions: move dummy function to an extra section --- ranger/core/actions.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 7da38162..b64ef316 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -27,6 +27,15 @@ class Actions(EnvironmentAware, SettingsAware): search_method = 'ctime' search_forward = False + # -------------------------- + # -- Backwards Compatibility + # -------------------------- + + def dummy(self, *args, **keywords): + """For backwards compatibility only.""" + + handle_mouse = resize = dummy + # -------------------------- # -- Basic Commands # -------------------------- @@ -49,11 +58,6 @@ class Actions(EnvironmentAware, SettingsAware): cwd.unload() cwd.load_content() - def dummy(self, *args, **keywords): - """For backwards compatibility only.""" - - handle_mouse = resize = dummy - def notify(self, text, duration=4, bad=False): if isinstance(text, Exception): if ranger.arg.debug: -- cgit 1.4.1-2-gfad0 From 4fb4b1a80e519d106b5ab384678f882846142f11 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 6 Apr 2010 22:53:36 +0200 Subject: defaults.keys: removed duplicate key definition --- ranger/defaults/keys.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 96491633..2e0e1eb7 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -64,8 +64,6 @@ def initialize_commands(map): map(KEY_UP, fm.move_pointer(relative=-1)) map(KEY_RIGHT, KEY_ENTER, ctrl('j'), fm.move_right()) map(KEY_LEFT, KEY_BACKSPACE, DEL, fm.move_left(1)) - map(KEY_HOME, fm.move_pointer(absolute=0)) - map(KEY_END, fm.move_pointer(absolute=-1)) map(KEY_HOME, fm.move_pointer(absolute=0)) map(KEY_END, fm.move_pointer(absolute=-1)) -- cgit 1.4.1-2-gfad0 From 98843e4667ace86d666813fae03b677aa0333de9 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 7 Apr 2010 00:01:59 +0200 Subject: defaults.keys: fixed hint for c-key --- ranger/defaults/keys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 2e0e1eb7..bfc84f01 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -182,7 +182,7 @@ def initialize_commands(map): map('cc', fm.search(order='ctime')) map('cm', fm.search(order='mimetype')) map('cs', fm.search(order='size')) - map('c', hint='//c//time //m//imetype //s//ize') + map('c', hint='//c//time //m//imetype //s//ize //t//agged') # ------------------------------------------------------- bookmarks for key in ALLOWED_BOOKMARK_KEYS: -- cgit 1.4.1-2-gfad0 From 90416a694b8126f5a0c8ade05edb797d61a5e89b Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 7 Apr 2010 00:57:26 +0200 Subject: make clean: fixed --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f3e00ee8..05c565e6 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ cleandoc: test -d $(DOCDIR) && rm -f -- $(DOCDIR)/*.html clean: - find . -regex \*.py[co]\$$ -exec rm -f -- {} \; + find . -regex .\*.py[co]\$$ -exec rm -f -- {} \; test: ./all_tests.py 1 -- cgit 1.4.1-2-gfad0 From add8bb3c38a95f7a696b5cde757ef168ab72d257 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 7 Apr 2010 13:46:40 +0200 Subject: defaults.keys: removed duplicate key definition --- ranger/defaults/keys.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index bfc84f01..1aef94ad 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -160,7 +160,6 @@ def initialize_commands(map): map('gr', 'g/', fm.cd('/')) map('gm', fm.cd('/media')) map('gn', fm.cd('/mnt')) - map('gt', fm.cd('/tmp')) map('gs', fm.cd('/srv')) map('gR', fm.cd(RANGERDIR)) -- cgit 1.4.1-2-gfad0 From 27451fceeb0fdade34c51ef0b26e91bf50bae52a Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 7 Apr 2010 16:04:17 +0200 Subject: defaults.keys: corrected docstring --- ranger/defaults/keys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 1aef94ad..623cd53f 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -26,7 +26,7 @@ fnc is a function which is called with the CommandArgument object. The CommandArgument object has these attributes: arg.fm: the file manager instance -arg.wdg: the widget or ui instance +arg.wdg: the current widget arg.n: the number typed before the key combination (if allowed) arg.keys: the string representation of the used key combination arg.keybuffer: the keybuffer instance -- cgit 1.4.1-2-gfad0 From d6e2900a1c900a5224a3cadec5c0562ad174d0ef Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 8 Apr 2010 00:06:24 +0200 Subject: made accumualtor use ext.directory.Directory --- ranger/api/keys.py | 4 ++-- ranger/core/actions.py | 2 +- ranger/defaults/commands.py | 2 +- ranger/ext/accumulator.py | 42 +++++++++++++------------------------ ranger/fsobject/directory.py | 2 +- ranger/gui/widgets/browsercolumn.py | 8 +++---- ranger/gui/widgets/pager.py | 2 +- ranger/gui/widgets/taskview.py | 4 ++-- 8 files changed, 26 insertions(+), 40 deletions(-) diff --git a/ranger/api/keys.py b/ranger/api/keys.py index 87186378..5f12e75d 100644 --- a/ranger/api/keys.py +++ b/ranger/api/keys.py @@ -54,9 +54,9 @@ class Wrapper(object): # If the method has an argument named "narg", pressing a number before # the key will pass that number as the narg argument. If you want the # same behaviour in a custom lambda function, you can write: -# bind('gg', fm.move_pointer(absolute=0)) +# bind('gg', fm.move(to=0)) # as: -# bind('gg', lambda arg: narg(arg.n, arg.fm.move_pointer, absolute=0)) +# bind('gg', lambda arg: narg(arg.n, arg.fm.move, to=0)) fm = Wrapper('fm') wdg = Wrapper('wdg') diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6910871b..0f8b74e5 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -167,7 +167,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): maximum=len(self.env.cwd), current=self.env.cwd.pointer, pagesize=self.ui.browser.hei) - self.env.cwd.move(absolute=newpos) + self.env.cwd.move(to=newpos) def history_go(self, relative): """Move back and forth in the history""" diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py index f653168f..89b1a3cb 100644 --- a/ranger/defaults/commands.py +++ b/ranger/defaults/commands.py @@ -227,7 +227,7 @@ class find(Command): if arg in filename: self.count += 1 if self.count == 1: - cwd.move(absolute=(cwd.pointer + i) % len(cwd.files)) + cwd.move(to=(cwd.pointer + i) % len(cwd.files)) self.fm.env.cf = cwd.pointed_obj if self.count > 1: return False diff --git a/ranger/ext/accumulator.py b/ranger/ext/accumulator.py index c65370d5..2e599c85 100644 --- a/ranger/ext/accumulator.py +++ b/ranger/ext/accumulator.py @@ -13,41 +13,27 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from ranger.ext.direction import Direction + class Accumulator(object): def __init__(self): self.pointer = 0 self.pointed_obj = None - def move(self, relative=0, absolute=None, pages=None, narg=None): - i = self.pointer + def move(self, narg=None, **keywords): + direction = Direction(keywords) lst = self.get_list() if not lst: return self.pointer - length = len(lst) - - if isinstance(absolute, int): - if isinstance(narg, int): - absolute = narg - if absolute < 0: # wrap - i = absolute + length - else: - i = absolute - - if relative != 0: - if isinstance(pages, int): - relative *= pages * self.get_height() - if isinstance(narg, int): - relative *= narg - i = int(i + relative) - - if i >= length: - i = length - 1 - if i < 0: - i = 0 - - self.pointer = i + pointer = direction.move( + direction=direction.down(), + maximum=len(lst), + override=narg, + pagesize=self.get_height(), + current=self.pointer) + self.pointer = pointer self.correct_pointer() - return self.pointer + return pointer def move_to_obj(self, arg, attr=None): if not arg: @@ -77,10 +63,10 @@ class Accumulator(object): test = obj if test == good: - self.move(absolute=i) + self.move(to=i) return True - return self.move(absolute=self.pointer) + return self.move(to=self.pointer) def correct_pointer(self): lst = self.get_list() diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index 79e32bff..bf626004 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -215,7 +215,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): if self.pointed_obj is not None: self.sync_index() else: - self.move(absolute=0) + self.move(to=0) else: self.filenames = None self.files = None diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 0d46ee06..4e93ed3e 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -358,11 +358,11 @@ class BrowserColumn(Pager): self.scroll_begin = self._get_scroll_begin() self.target.scroll_begin = self.scroll_begin - def scroll(self, relative): - """scroll by n lines""" + def scroll(self, n): + """scroll down by n lines""" self.need_redraw = True - self.target.move(relative=relative) - self.target.scroll_begin += 3 * relative + self.target.move(down=n) + self.target.scroll_begin += 3 * n def __str__(self): return self.__class__.__name__ + ' at level ' + str(self.level) diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index 49a1df7e..91383a18 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -187,7 +187,7 @@ class Pager(Widget): n = event.ctrl() and 1 or 3 direction = event.mouse_wheel_direction() if direction: - self.move(relative=direction) + self.move(down=direction * n) return True def _get_line(self, n, attempt_to_read=True): diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py index 6e86465c..6d025048 100644 --- a/ranger/gui/widgets/taskview.py +++ b/ranger/gui/widgets/taskview.py @@ -90,11 +90,11 @@ class TaskView(Widget, Accumulator): self.fm.loader.remove(index=i) - def task_move(self, absolute, i=None): + def task_move(self, to, i=None): if i is None: i = self.pointer - self.fm.loader.move(_from=i, to=absolute) + self.fm.loader.move(_from=i, to=to) def press(self, key): try: -- cgit 1.4.1-2-gfad0 From 37899948600f73c014ea6e933b2cbb85e07d9f5e Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 8 Apr 2010 00:13:16 +0200 Subject: ext.direction: bugfix --- ranger/ext/direction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index 417f3add..0b3f55f7 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -132,4 +132,4 @@ class Direction(dict): pos += maximum else: pos += current - return int(max(min(pos, maximum + offset), minimum)) + return int(max(min(pos, maximum + offset - 1), minimum)) -- cgit 1.4.1-2-gfad0 From e02d47edf8ef8ed3dda680e1e78aae779cb4e053 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 8 Apr 2010 01:27:59 +0200 Subject: todo: update --- TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO b/TODO index a0c7f03a..d715c991 100644 --- a/TODO +++ b/TODO @@ -49,6 +49,8 @@ General (X) #66 10/02/28 explain how colorschemes work (X) #70 10/03/14 mouse handler for titlebar (X) #71 10/03/21 previews: black/whitelist + read file + ( ) #79 10/04/08 tab number zero + ( ) #80 10/04/08 when closing tabs, avoid gaps? Bugs -- cgit 1.4.1-2-gfad0