From 4d66aff45c036d085d09cdcfb03c3f51e1641b19 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 15 Jul 2018 23:01:47 +0200 Subject: Add the filter stack docs --- doc/ranger.1 | 29 ++++++++++++++++++++++++++++- doc/ranger.pod | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/ranger.1 b/doc/ranger.1 index 5b3afa73..509fc53c 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "2018-06-07" "ranger manual" +.TH RANGER 1 "ranger-1.9.1" "2018-07-15" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -657,6 +657,33 @@ Close the current tab. The last tab cannot be closed this way. A key chain that allows you to quickly change the line mode of all the files of the current directory. For a more permanent solution, use the command \&\*(L"default_linemode\*(R" in your rc.conf. +.IP ".n" 14 +.IX Item ".n" +Apply a new filename filter. +.IP ".d" 14 +.IX Item ".d" +Apply the typefilter \*(L"directory\*(R". +.IP ".f" 14 +.IX Item ".f" +Apply the typefilter \*(L"file\*(R". +.IP ".l" 14 +.IX Item ".l" +Apply the typefilter \*(L"symlink\*(R". +.IP ".|" 14 +Combine te two topmost filters from the filter stack in the \*(L"\s-1OR\*(R"\s0 +relationship, instead of the \*(L"\s-1AND\*(R"\s0 used implicitly. +.IP ".!" 14 +Negate the topmost filter. +.IP ".c" 14 +.IX Item ".c" +Clear the filter stack. +.IP ".*" 14 +Decompose the topmost filter combinator (e.g. \f(CW\*(C`.!\*(C'\fR, \f(CW\*(C`.|\*(C'\fR). +.IP ".p" 14 +.IX Item ".p" +Pop the topmost filter from the filter stack. +.IP ".." 14 +Show the current filter stack state. .SS "READLINE-LIKE \s-1BINDINGS IN THE CONSOLE\s0" .IX Subsection "READLINE-LIKE BINDINGS IN THE CONSOLE" .IP "^B, ^F" 14 diff --git a/doc/ranger.pod b/doc/ranger.pod index fcee60aa..6d7d5a00 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -620,6 +620,47 @@ A key chain that allows you to quickly change the line mode of all the files of the current directory. For a more permanent solution, use the command "default_linemode" in your rc.conf. +=item .n + +Apply a new filename filter. + +=item .d + +Apply the typefilter "directory". + +=item .f + +Apply the typefilter "file". + +=item .l + +Apply the typefilter "symlink". + +=item .| + +Combine te two topmost filters from the filter stack in the "OR" +relationship, instead of the "AND" used implicitly. + +=item .! + +Negate the topmost filter. + +=item .c + +Clear the filter stack. + +=item .* + +Decompose the topmost filter combinator (e.g. C<.!>, C<.|>). + +=item .p + +Pop the topmost filter from the filter stack. + +=item .. + +Show the current filter stack state. + =back =head2 READLINE-LIKE BINDINGS IN THE CONSOLE -- cgit 1.4.1-2-gfad0 From 712ec67e1426fe601e99c63ac078d215378299c7 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 19 Aug 2018 15:48:45 +0200 Subject: Implement the filter stack rotation Tested to work both ways, so one can rotate by negative number to undo the previous positive rotation. --- doc/ranger.1 | 6 +++++- doc/ranger.pod | 7 ++++++- ranger/config/commands.py | 7 +++++++ ranger/config/rc.conf | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/ranger.1 b/doc/ranger.1 index 4ed1e584..8423d068 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -670,10 +670,14 @@ Apply the typefilter \*(L"file\*(R". .IX Item ".l" Apply the typefilter \*(L"symlink\*(R". .IP ".|" 14 -Combine te two topmost filters from the filter stack in the \*(L"\s-1OR\*(R"\s0 +Combine the two topmost filters from the filter stack in the \*(L"\s-1OR\*(R"\s0 relationship, instead of the \*(L"\s-1AND\*(R"\s0 used implicitly. .IP ".!" 14 Negate the topmost filter. +.IP ".r" 14 +.IX Item ".r" +Rotate the filter stack by N elements. Just confirm with enter to +rotate by 1, i.e. move the topmost element to the bottom of the stack. .IP ".c" 14 .IX Item ".c" Clear the filter stack. diff --git a/doc/ranger.pod b/doc/ranger.pod index 849acbb2..6e7075a7 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -638,13 +638,18 @@ Apply the typefilter "symlink". =item .| -Combine te two topmost filters from the filter stack in the "OR" +Combine the two topmost filters from the filter stack in the "OR" relationship, instead of the "AND" used implicitly. =item .! Negate the topmost filter. +=item .r + +Rotate the filter stack by N elements. Just confirm with enter to +rotate by 1, i.e. move the topmost element to the bottom of the stack. + =item .c Clear the filter stack. diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 35aa3ffb..c136db56 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1554,6 +1554,7 @@ class filter_stack(Command): filter_stack add FILTER_TYPE ARGS... filter_stack pop filter_stack decompose + filter_stack rotate [N=1] filter_stack clear filter_stack show """ @@ -1577,6 +1578,12 @@ class filter_stack(Command): self.fm.thisdir.filter_stack.extend(inner_filters) elif subcommand == "clear": self.fm.thisdir.filter_stack = [] + elif subcommand == "rotate": + rotate_by = int(self.arg(2) or 1) + self.fm.thisdir.filter_stack = ( + self.fm.thisdir.filter_stack[-rotate_by:] + + self.fm.thisdir.filter_stack[:-rotate_by] + ) elif subcommand == "show": stack = map(str, self.fm.thisdir.filter_stack) pager = self.fm.ui.open_pager() diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 4d8f1f54..14706dce 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -564,6 +564,7 @@ map .f filter_stack add type f map .l filter_stack add type l map .| filter_stack add or map .! filter_stack add not +map .r console filter_stack rotate map .c filter_stack clear map .* filter_stack decompose map .p filter_stack pop -- cgit 1.4.1-2-gfad0 From 7d2e57b7a693dd7e8dfc00cb1e52116108b60e9a Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 19 Aug 2018 21:40:13 +0200 Subject: Add an explicit "AND" filter combinator Closes #1268. --- doc/ranger.1 | 4 ++++ doc/ranger.pod | 6 ++++++ ranger/config/rc.conf | 1 + ranger/core/filter_stack.py | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+) (limited to 'doc') diff --git a/doc/ranger.1 b/doc/ranger.1 index 8423d068..060686b8 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -672,6 +672,10 @@ Apply the typefilter \*(L"symlink\*(R". .IP ".|" 14 Combine the two topmost filters from the filter stack in the \*(L"\s-1OR\*(R"\s0 relationship, instead of the \*(L"\s-1AND\*(R"\s0 used implicitly. +.IP ".&" 14 +Explicitly combine the two topmost filters in the \*(L"\s-1AND\*(R"\s0 +relationship. Usually not needed though might be useful in more +complicated scenarios. .IP ".!" 14 Negate the topmost filter. .IP ".r" 14 diff --git a/doc/ranger.pod b/doc/ranger.pod index 6e7075a7..48e6a41e 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -641,6 +641,12 @@ Apply the typefilter "symlink". Combine the two topmost filters from the filter stack in the "OR" relationship, instead of the "AND" used implicitly. +=item .& + +Explicitly combine the two topmost filters in the "AND" +relationship. Usually not needed though might be useful in more +complicated scenarios. + =item .! Negate the topmost filter. diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 14706dce..b112dc2c 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -563,6 +563,7 @@ map .d filter_stack add type d map .f filter_stack add type f map .l filter_stack add type l map .| filter_stack add or +map .& filter_stack add and map .! filter_stack add not map .r console filter_stack rotate map .c filter_stack clear diff --git a/ranger/core/filter_stack.py b/ranger/core/filter_stack.py index f5b00014..ff9f4080 100644 --- a/ranger/core/filter_stack.py +++ b/ranger/core/filter_stack.py @@ -98,6 +98,26 @@ class OrFilter(BaseFilter): return self.subfilters +@filter_combinator("and") +class AndFilter(BaseFilter): + def __init__(self, stack): + self.subfilters = [stack[-2], stack[-1]] + + stack.pop() + stack.pop() + + stack.append(self) + + def __call__(self, fobj): + return accept_file(fobj, self.subfilters) + + def __str__(self): + return "".format(" and ".join(map(str, self.subfilters))) + + def decompose(self): + return self.subfilters + + @filter_combinator("not") class NotFilter(BaseFilter): def __init__(self, stack): -- cgit 1.4.1-2-gfad0