Ticket #2697 (new enhancement)

Opened 13 years ago

Last modified 7 years ago

Filter as you type mode

Reported by: iwfmp Owned by:
Priority: major Milestone: Future Releases
Component: mc-core Version: master
Keywords: Cc: gotar@…, christopher.czyba@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

After using total commander, I'm kind of used to have a choice of what the keystrokes do - either filter as I type, find as I type etc...

In midnight commander I only seem to have the find-as-you-type feature (which is also great).
Since I usually prefer the filter as you type method, it would be great if it can be added to the midnight commander functionality, maybe as an option to choose from...

Attachments

quickfilter.patch (85.5 KB) - added by chris_c 8 years ago.
Implementation of quickfilter feature

Change History

comment:1 in reply to: ↑ description Changed 13 years ago by andrew_b

Replying to iwfmp:

After using total commander, I'm kind of used to have a choice of what the keystrokes do - either filter as I type, find as I type etc...

I never used TotalCommander and I don't understand what you want. Could you please describe in general terms what is 'filter as I type', 'find as I type' etc?

Last edited 13 years ago by andrew_b (previous) (diff)

comment:2 Changed 13 years ago by iwfmp

For example, a folder containing a few files:

abc.txt
abd.txt
bbd.txt
bbr.txt

when I press the keys "ab":
find-as-you-type will highlight the 1st item that starts with the keys "ab", thus showing (* is for selected):
*abc.txt
abd.txt
bbd.txt
bbr.txt

filter-as-you-type will show ONLY the items that starts with the keys "ab", thus showing:
*abc.txt
abd.txt

comment:3 Changed 13 years ago by andrew_b

Try use quick search.

comment:4 Changed 13 years ago by angel_il

press ctrl-s
type: *b*.txt
ctrl-s, ctrl-s...

comment:5 Changed 13 years ago by iwfmp

To angel_li -
I tried your suggestion, but it doesn't seem to be what I'm looking for.
The solution you gave just toggles around to all items with the mask given through ctrl-s.

What I'm looking for is a better overview of all the objects.

In other words, think of the Filter option in the left/right panel, activated "as you type", and not only after being prompted for a mask.
Just like the "find as you type" feature when you disable the command-prompt view (maybe you didn't know about it, as I can only assume from your comments)
It's just a matter of convenience really, but it does save a lot of keystrokes and enables me to have a quick and very good view of all the files with the given mask, and make actions with them easily.

comment:6 Changed 12 years ago by gotar

  • Cc gotar@… added

Quick search works well if you know exactly what you search, and you search for single item, while filtering directory listing might have much more use patterns - it's more like dynamic Menu->{Left,Right}->Filter, so internally it requires only:

  • keybinding that calls quick search in filter mode,
  • calling existing filter function on every keystroke on quick search in filter mode.

Why this might be better? In quick search one ctrl-s too much makes you cycle all again, especially when searching for *.jpg or so.

comment:7 Changed 12 years ago by slavazanko

Why this might be better? In quick search one ctrl-s too much makes you cycle all again, especially when searching for *.jpg or so.

Can helps 'file search' by filemask and then 'panelize' action? Actually, it's exactly what you want, but realized in few steps.
Probably, we need for keyboard binding, which call the dialog with input field for entering filemask, and then call 'search&panelize' action (as one).

comment:8 Changed 11 years ago by Nowaker

The thing is, we don't want any other windows and keystrokes - we just want a filter-as-I-type feature, which is a standard in all file explorers, and lots of other software (e.g. IntelliJ IDEA). Any chance to get it implemented as iwfmp and gotar suggested?

I am aware that lots of people are now used to entering a command. In such case, filter-as-I-type should be a configuration option off by default.

Changed 8 years ago by chris_c

Implementation of quickfilter feature

comment:9 follow-up: ↓ 10 Changed 8 years ago by chris_c

  • Cc christopher.czyba@… added

Since I also wish to use this feature I went and implemented it myself. I just called it quickfilter instead of filter-as-you-type though. I designed it in the way that what you type is prefixed by * and suffixed by * to match the string as an infix.

The behavior is thus like this:

Dir contents:

".." bar.tgz faa.tgz foo.tgz

Assuming you have all options set(See notes), typing 'f' will will result in the filter "*f*" and the directory will only contain faa.tgz and foo.tgz. By typing 'a' the filter will be "*fa*" and the directory will only contain "faa.tgz".

A few notes about the implementation:

  • Adds an option to use quickfilter instead of quicksearch when the commandline is hidden.
  • The implementation mostly resembles the implementation of the quicksearch feature.
  • It uses "WPanel.filter" to filter directories.
    • Setting a filter via the menu overrides the quickfilter as I gave it higher priority.
  • Also adds an option for a case insensitive filter.
  • Since the feature is by itself not as useful if it doesn't filter directories as well I have also added an option to filter directories.
  • Similarly I have added an option for filtering the ".." directory.
  • Uses the same mini_info the quicksearch uses to display the actual filter string since the filter, since the filter will be "*foo*.tgz*" while the typed string is just "foo*.tgz", resulting in a mismatch between what the user typed and what he expects to see.
  • Entering a directory deletes the filter, since we are switching contexts.
  • Similarly to quicksearch the filter first checks if there is a match. If there isn't the typed letter is not added to the filter.
  • Backspace deletes the last typed letters.
  • The name and the option pages where I incorporated the options were chosen by my understanding of where they belong. You may change or remove them as you see fit.

Issues that may result from my decisions:

  1. Setting a filter via the menu can result in an empty directory if the filter is too tight and both directories and the ".." dir are filtered as well. I addressed this issue by adding the ".." dir if the filter would result in an empty list.
  2. I do not know which parts of the code only work if the ".." dir exists. During my use cases I have not noticed any issues with this, but I just wanted to mention it.
  3. The implementation is not the most efficient since it reloads the whole directory instead of just checking the already filtered parts when typing a new letter. A backspace needs the reload or some kind of caching mechanism.

If there are some issues I do not see yet and are crucial for this patch the be applied, please tell me and I will address them.

comment:10 in reply to: ↑ 9 Changed 8 years ago by mooffie

I think #405 is a duplicate.

comment:11 Changed 8 years ago by mooffie

Just for the record: mc2 has two similar features:

  1. filter-as-you-type: unlike @chris_c's solution, it of course doesn't modify MC's C code, so it suffers from MC's inherent filter limitation of not being able to filter directories.

Replying to chris_c:

I designed it in the way that what you type is prefixed by * and suffixed by * to match the string as an infix.
[...]
Uses the same mini_info the quicksearch uses to display the actual filter string since [...] mismatch between what the user typed and what he expects to see.

(In mc2 I use a conventional input widget and the "**" is entered there automatically for the user so there are no surprises.)

Replying to chris_c:

The implementation is not the most efficient since it reloads the whole directory instead of just checking the already filtered parts when typing a new letter

(In mc2 I solve this by debouncing (100 ms by default; 1000 ms on sh://). In Lua it's just two lines of code. In C it'd be hundreds.)

But I actually don't use filter-as-you-type. I very frequently use the superior:

  1. Visual Panelize (it uses the UI of Visual Rename, hence the link points there). It doens't suffer from any of MC's filter limitations (efficiency; directories are filtered). Unlike a filter, you can run it repeatedly to narrow down the selection further. Very useful. And, of course, the pattern you type is highlighted in the file names, so you instantly see why a file matches (i.e., whether it matches "tar" because it has this extension or because it's titled "A frightening Tarantula!.jpg").

comment:12 Changed 7 years ago by andrew_b

Ticket #3854 has been marked as a duplicate of this ticket.

Note: See TracTickets for help on using tickets.