Visual Filters, extended patterns and more in donnatella
Freshly pushed to the branch next
on donnatella's
github are a few commits,
some fixes and other improvements here and there of course, and a few things
worth spending a few more words about.
First of all, you could use patterns in a few places in donna, such as when filtering via names (or any text property) or to define arrangements. A pattern was a string that could contain wildchars in a glob-like manner. They've now become a bit more powerful...
Patterns are more than just patterns
A pattern is now a string that can start with one of the following, to specify which mode to use :
- a double quote (
"
) for glob-like pattern mode, the only thing originally supported: the given string can use*
and?
as wildchars with similar semantics as the standard glob() function - a single-quote (
'
) for search mode: the given string will be searched (case sensitive) in the matched against string - a caret (
^
) for begin mode: the matched against string must begin with the given string to match - a dollar sign (
$
) for end mode: the matched against string must end with the given string to match - a tilde sign (
~
) for case-insensitive matching mode: the matched against string and the given string must be the same (case insensitively) - an equal sign (
=
) for case-sensitive matching mode: the matched against string and the given string must be the exact same - a greater than sign (
>
) for regex mode: the given string must be Perl-compatible regular expression to be matched against
If the string doesn't start with any of those, search mode will be used unless there is at least one wildchar, then pattern mode is used.
Additionally, if the string first starts with a pipe character (|
) then any
other pipe character will be used as a separator (i.e. it cannot be used in any
pattern definition), allowing you to specify more than one possible patterns to
match.
Note that each time the prefix rule apply, e.g. to match strings that end either
with "foo" or "bar" use |$foo|$bar
Of course you can use different types, e.g:
|this file|*.pdf|>report [0-9]{4}\.xml
This makes every feature using patterns much more powerfull than before. One thing worth mentionning though, is that the columntype name used to support using the pipe character to specify more than one pattern. It was a oddity (in that it was alone to support it), but now that this is part of the general pattern syntax, a change of syntax is in order: the pattern string must start with a pipe character, to enable it.
Filter by node type
Columntype name only allowed to filter using patterns, matched against the
node's name. You can now also filter by node type, using +
or -
followed by
either c
(or d
) to match only containers (directories), or i
(or f
) to
match only items (files).
So using +f
will match only files, just like -d
would. So if you're looking
to filter only directories modified yesterday, you could use:
name:"+d" and time:A1d
Visual Filters
Another addition is that of visual filters (VF). Filtering capabilities have been part of donna from day one, but until now you couldn't use them to filter what is visible on list: now you can!
Two new commands have been added to do so: tv_set_visual_filter()
to set a
visual filter, and tv_get_visual_filter()
to get the current one. Unsetting a
VF is simply done by not specifying a new one (or using an empty string as VF).
An option toggle
also allows to unset the VF if trying to set a VF that is
already set.
How to use some VF
Some default keys allow you to use VF easily: pressing f
followed by a letter
will apply said filter, which is simply defined as a configuration option under
category "filters" For example, "fv" to only show videos, "fi" for images, "ft"
for rows modified today, "fw" for ones modified this week...
And using F
instead will work the same, but allowing you to edit the filter
before applying it. As a nice trick, keeping filters/f
an option set to an
empty string will allow to press "ff" to unset any current VF.
Dynamic VFs
Some other nice things can be done, for example typing a size followed by either
lesser than (<
) or greater than (>
) will filter by the specified size (in
MiB).
Pressing q
will only show rows modified today. Of course, you can prefix it
with a number of days, e.g. 1q
to show rows from yesterday, 2q
from two
days ago, etc.
You can even prefix this with &
followed by a time unit, e.g. &Vq
for
modified this week, &V2q
for two weeks ago, etc
Lastly, using Q
works similarly, but where q
resolves to time:A<NB><UNIT>
using Q
will resolves to time:A<=<NB><UNIT>
so e.g. &V2Q
means modified
anytime from two weeks ago (i.e. includes last week and this week as well).
Those are only examples of course, since as always, you can define things how you like/want/need them to be. (And don't hesitate to share your cool tricks!)
Filter files only
One last note: if you only ever want your VF to apply to files, but mean for all
directories to always all remain visible, no need to specify it on each & every
filter you use: simply set treeview option vf_items_only
to true.
Better status info
Some changes in the possibilities of the status area from a treeview. A few
variables were added: %f
for the focused row, %F
for the current VF, %h
and %H
for the number/size of hidden rows respectively.
All of "avhsF" also supports an extra (in between brackets), which is itself a string parsed the same way and supporting the same variables (If you need recursion, any backslash or closing braquet must be escaped via backslash).
The parsed string will then be shown instead of what the variable usually resolves to. However, there's a twist:
- for
%F
it will only be shown when a VF is set (else resolves to nothing/empty string) - for the others, the string will also be splitted using comma as separator (if you need to use commas, you then need to use %,), so you can specify up to 3 strings.
With only 1 string, it will be shown unless the reference (i.e. the number of items the variable refers to) is zero. With 2 strings, nothing is shown if the reference is zero, the first one is shown if it is one, else the second one is shown. Lastly, with 3 strings, the first one is shown is reference is zero, the second one if it's one, else the last one is shown.
%a
behaves a little differently, in that instead of not showing anything (or
the first of the 3 specified strings) when the reference (i.e. number of all
rows) is zero, it does so when it is the same as the number of visible rows.
This is to make it easy to show e.g. "23 rows" when all are visible, and "23/42
rows" when some are hidden, using: %{%v/}a%a rows
And option key_modes_colors
was renamed to simply colors
and isn't a boolean
anymore, but can take values "off", "keys" or "vf" The later case being used
when a VF is set.
Finally, the same variables are supported in option format_tooltip
, used for
the tooltip of the statusbar area (no color support there).
Updating your config to benefit from all of this
Now, there's still work to do when it comes to upgrades in donna. Specifically,
there isn't currently a way to update/import new defaults, so that is a manual
operation. Archers, think of this as some king of .pacnew
handling! ;)
Here's the patch to update your donnatella.conf (from last time) :
- diff --git a/misc/donnatella.conf b/misc/donnatella.conf
- index d45fd98..e58b10b 100644
- --- a/misc/donnatella.conf
- +++ b/misc/donnatella.conf
- @@ -92,8 +92,11 @@ expand=false
- [statusbar/active]
- source=:active
- expand=false
- -format=%v/%a files (%V) %N
- +{% raw %}format=%{%s/}s%{no rows,1 row,%v rows}v(%{%S / }s%V)%{ %h hidden (%H)}h
- +{% endraw %}format_tooltip=%{Current VF: %F}F
- size_format=%R
- +colors:tree-st-colors=vf
- +foreground=blue
- [statusbar/log]
- source=:app
- @@ -112,7 +115,7 @@ source=:focused
- format=%o %K
- width=100
- expand=false
- -key_modes_colors=true
- +colors:tree-st-colors=keys
- key_mode_select_background-rgba=rgba(0,42,200,0.8)
- key_mode_select_foreground=white
- @@ -191,6 +194,7 @@ sort_groups:sg=first
- select_highlight:highlight=column-underline
- focusing_click=true
- goto_item_set:tree-set=scroll,focus
- +vf_items_only=false
- history_max=100
- context_menu_menus=context
- context_menu=@go:tree,marks,-,add_to_tree<add_as_root>,-,!new_nodes,-,@register,-,@selection,-,column_edit<!column_edit>,-,:refresh<@refresh>
- @@ -201,7 +205,7 @@ context_menu_colheader=columns<!columns>,-,:sort_order<!sort_order>,:second_sort
- # some color filters
- [defaults/lists/arrangement/color_filters/]
- -filter=*.tar.*|*.tgz|*.zip|*.rar
- +filter=|*.tar.*|*.tgz|*.zip|*.rar
- column=name
- foreground=green
- @@ -775,6 +779,36 @@ trigger=command:node_trigger(@ask_text(Enter FL to trigger))
- [key_modes/donna/key_slash]
- trigger=command:tv_start_interactive_search (%o)
- +# Visual Filters
- +[key_modes/donna/key_f]
- +type:key=spec
- +spec:spec=lower,upper
- +trigger=command:tv_set_visual_filter (%o, @config_get_string (filters/%k), 1)
- +[key_modes/donna/key_F]
- +type:key=spec
- +spec:spec=lower,upper
- +trigger=command:tv_set_visual_filter (%o, @config_set_string (filters/%k, @ask_text (Enter filter %k,,@config_try_get_string (filters/%k, @tv_get_visual_filter (%o)))), 1)
- +
- +# VF: by age
- +[key_modes/donna/key_ampersand]
- +type:key=combine
- +spec:spec=custom
- +custom_chars=HMSdmVY
- +combine=age_unit
- +[key_modes/donna/key_q]
- +combine=age_unit
- +trigger=command:tv_set_visual_filter (%o, time:A%m%c)
- +[key_modes/donna/key_Q]
- +combine=age_unit
- +trigger=command:tv_set_visual_filter (%o, time:A<=%m%c)
- +
- +# VF: by size
- +[key_modes/donna/key_less]
- +trigger=command:tv_set_visual_filter (%o, size:<=%mM)
- +[key_modes/donna/key_greater]
- +trigger=command:tv_set_visual_filter (%o, size:>=%mM)
- +
- +
- # F2 to rename
- [key_modes/donna/key_F2]
- trigger=command:tv_column_edit (%o, %n, name)
- @@ -1155,4 +1189,25 @@ node=config:/
- box=box-orange
- +#
- +# FILTERS
- +#
- +
- +[filters]
- +# used to unset current VF (via ff)
- +f=
- +# today
- +t=time:A0
- +# yesterday
- +y=time:A1d
- +# this week
- +w=time:A0V
- +# videos
- +v=desc:* video
- +# images
- +i=desc:* image
- +# archives
- +a=desc:* archive*
- +
- +
- # EOF
Where to get it?
For Arch Linux users, you can use donnatella-git in the AUR to easilly get it. Or simply clone the git repo from github and compile things yourself.
For a a complete list of all changes/bug fixes please refer to the git log.
And in case you read all that and are wondering what donnatella is, or are looking for more information, download links, etc please refer to donnatella.
As always, bug reports, suggestions or any other form of constructive criticism is very much welcome. You can open issues on github, use the thread on Arch Linux forums, or simply email me.