ranger-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ranger-users] explorer mode


From: Eduardo Suarez-Santana
Subject: Re: [Ranger-users] explorer mode
Date: Tue, 30 Oct 2012 17:59:47 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.7) Gecko/20120824 Thunderbird/10.0.7

On 26/10/12 19:53, Joshua Landau wrote:
On 25 October 2012 11:08, Eduardo Suarez-Santana <address@hidden> wrote:
Is there a classic explorer mode? That is, I type the first letters of the filename and then it gets selected. 'Enter' to go forward, 'Backspace' to go back.

'f' does something similar, but it's not the same.

I've implemented and often use something almost as good - not quite, but close - called "travel".

It's a little old, so it doesn't do quite what it used to in a few circumstances. However, it works thusly:

  • Press key-binding to enter travel mode
  • Type to filter dynamically
    • When there is only exactly one file left:
      • If it is a directory, enter it
      • Else, run it (default mode)
    • Press TAB to move forward one file
    • Press ENTER to run current file, or enter directory
    • Press ESC to quit
    • If the filter is "..", go back a directory
Entering directories does not quit, but just resets the filter.
This is almost the same, but using 'startswith' instead of 'count'. I also changed the dot behavior to '..'.

In rc.conf (very important whitespace at the end):
map e console explorer

In commands.py:
class explorer(Command):
    """ 
    :explorer <string>
   
    Enters Explorer Mode. Press Esc or Ctrl-C to exit Explorer Mode
    """
   
    special = False
   
    def execute(self):
        self.fm.set_filter("")
        self.fm.reload_cwd()
            
        if self.special:
            self.fm.cd(self.special)
            if self.special != "..":
                self.fm.block_input(0.5)
            self.special = False
        else:
            self.fm.move(right=1)
            
        self.fm.open_console('explorer ')
            
    def cancel(self):
        self.fm.set_filter("")
        self.fm.reload_cwd()

    def quick(self):
        arg = self.rest(1)
        self.fm.set_filter(arg)
        self.fm.reload_cwd()

        if arg == ".":
            self.special = ".."
            return self.execute()

        filtered_files = [d for d in self.fm.env.cwd.files if d.basename.startswith(arg)]
        if len(filtered_files)==1:
            self.special = filtered_files[0].basename
            return self.execute()

    def tab(self):
        if self.fm.env.cwd.files[-1] is not self.fm.env.cf:
            self.fm.move(down=1)
        else:
            self.fm.move(to=0)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]