diff options
author | hut <hut@lavabit.com> | 2009-12-27 16:43:12 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-27 16:43:12 +0100 |
commit | 0b8a9d79273a91787eb4f373989d85e7a93e673b (patch) | |
tree | 17c9d982cd089d45fc6cfae8a0686241067d6b5b /ranger/actions.py | |
parent | d309f218d7d00405d5bca2f8c77344ce0c33a0bb (diff) | |
download | ranger-0b8a9d79273a91787eb4f373989d85e7a93e673b.tar.gz |
implemented customized cycling through the directory
Diffstat (limited to 'ranger/actions.py')
-rw-r--r-- | ranger/actions.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ranger/actions.py b/ranger/actions.py index 9ccbc93f..968aae4f 100644 --- a/ranger/actions.py +++ b/ranger/actions.py @@ -5,7 +5,7 @@ from ranger.shared import EnvironmentAware, SettingsAware from ranger import fsobject class Actions(EnvironmentAware, SettingsAware): - search_method = None + search_method = 'ctime' search_forward = False def search(self, order=None, forward=True): @@ -33,8 +33,23 @@ class Actions(EnvironmentAware, SettingsAware): return self.env.pwd.search_fnc(fnc=fnc, forward=forward) + elif order in ('size', 'mimetype', 'ctime'): + pwd = self.env.pwd + if not pwd.cycle_list: + lst = list(pwd.files) + if order == 'size': + fnc = lambda item: item.size + elif order == 'mimetype': + fnc = lambda item: item.mimetype + elif order == 'ctime': + fnc = lambda item: -int(item.stat and item.stat.st_ctime) + lst.sort(key=fnc) + pwd.set_cycle_list(lst) + + return pwd.cycle(forward=forward) + def set_search_method(self, order, forward=True): - if order in ('search', 'tag', 'size', 'type', 'time'): + if order in ('search', 'tag', 'size', 'mimetype', 'ctime'): self.search_method = order self.search_forward = forward |