]> Sergey Matveev's repositories - nnn.git/commitdiff
Middle click to visit parent dir
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 18 May 2019 05:25:17 +0000 (10:55 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 22 May 2019 03:18:44 +0000 (08:48 +0530)
README.md
src/nnn.c

index f131303329aefff3d57ac351948b1f1c2b17b2fe..047d977f69eff7004561ef70b9486d6b52266911 100644 (file)
--- a/README.md
+++ b/README.md
@@ -50,8 +50,8 @@ It runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows
 - [Quickstart](#quickstart)
 - [Usage](#usage)
   - [Cmdline options](#cmdline-options)
-  - [Keyboard shortcuts](#keyboard-shortcuts)
-  - [Leader key](#leader-key)
+  - [Keyboard and mouse](#keyboard-and-mouse)
+    - [Leader key](#leader-key)
   - [Contexts](#contexts)
     - [Context-specific color](#context-specific-color)
   - [Selection](#selection)
@@ -230,7 +230,7 @@ optional args:
  -h      show help
 ```
 
-#### Keyboard shortcuts
+#### Keyboard and mouse
 
 Press <kbd>?</kbd> in `nnn` to see the list anytime.
 
@@ -270,7 +270,13 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
 
 Note: Help & settings, file details, media info and archive listing are shown in the PAGER. Use the PAGER-specific keys in these screens.
 
-#### Leader key
+| Mouse click | Function |
+|:---:| --- |
+| Left single | Select context or entry |
+| Left double | Select context or open file/directory |
+| Middle single | Visit parent directory |
+
+##### Leader key
 
 The Leader key provides a powerful multi-functional navigation mechanism. It is case-sensitive and understands contexts, bookmarks and location shortcuts.
 
index 65c6562261973b87ad4c8536755730a75364e572..75df0e7f8a3de9b062ea49cb6876cc4ecc5131d2 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -874,7 +874,7 @@ static bool initcurses(void)
        nonl();
        //intrflush(stdscr, FALSE);
        keypad(stdscr, TRUE);
-       mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL);
+       mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED, NULL);
        curs_set(FALSE); /* Hide cursor */
        start_color();
        use_default_colors();
@@ -3116,24 +3116,28 @@ nochange:
                        presel = 0;
 
                switch (sel) {
+               case SEL_CLICK:
+                       if (getmouse(&event) != OK)
+                               goto nochange; // fallthrough
                case SEL_BACK:
-                       dir = visit_parent(path, newpath, &presel);
-                       if (!dir)
-                               goto nochange;
+                       // Handle right click to go to parent
+                       if ((sel == SEL_BACK)
+                           || (sel == SEL_CLICK && event.bstate == BUTTON2_CLICKED)) {
+                               dir = visit_parent(path, newpath, &presel);
+                               if (!dir)
+                                       goto nochange;
 
-                       /* Save last working directory */
-                       xstrlcpy(lastdir, path, PATH_MAX);
+                               /* Save last working directory */
+                               xstrlcpy(lastdir, path, PATH_MAX);
 
-                       /* Save history */
-                       xstrlcpy(lastname, xbasename(path), NAME_MAX + 1);
+                               /* Save history */
+                               xstrlcpy(lastname, xbasename(path), NAME_MAX + 1);
 
-                       xstrlcpy(path, dir, PATH_MAX);
+                               xstrlcpy(path, dir, PATH_MAX);
 
-                       setdirwatch();
-                       goto begin;
-               case SEL_CLICK:
-                       if (getmouse(&event) != OK)
-                               goto nochange;
+                               setdirwatch();
+                               goto begin;
+                       }
 
                        // Handle clicking on a context at the top:
                        if (event.y == 0) {