]> git.wh0rd.org Git - nano.git/commitdiff
in do_browser(), refactor and simplify the mouse support, modeling it
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 28 Jun 2006 22:38:11 +0000 (22:38 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 28 Jun 2006 22:38:11 +0000 (22:38 +0000)
after do_mouse() for consistency

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3687 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/browser.c

index 41e009d1adc4205db00b519a6010fd309a210738..8fcfc13466e37530b32844cf8528fec9712919b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@ CVS code -
        - Fix mouse support so that it really ignores everything except
          releases of button 1 (i.e, left clicks).  Changes to
          enable_mouse_support() and get_mouseinput(). (DLR)
+- browser.c:
+  do_browser()
+       - Refactor and simplify the mouse support, modeling it after
+         do_mouse() for consistency. (DLR)
 - doc/syntax/c.nanorc:
        - Since .i and .ii are preprocessed C and C++ output, colorize
          them here. (Mike Frysinger)
index d1b206f5d77d9d0237090fb75ce92a22a5d2acb6..2eae6bae0c310f333d56263984372fb6c1a4c016 100644 (file)
@@ -96,9 +96,6 @@ char *do_browser(char *path, DIR *dir)
        size_t fileline;
        char *new_path;
            /* Used by the "Go To Directory" prompt. */
-#ifndef DISABLE_MOUSE
-       MEVENT mevent;
-#endif
 
        /* Compute the line number we're on now, so that we don't divide
         * by zero. */
@@ -109,42 +106,45 @@ char *do_browser(char *path, DIR *dir)
        switch (kbinput) {
 #ifndef DISABLE_MOUSE
            case KEY_MOUSE:
-               if (getmouse(&mevent) == ERR)
-                   break;
-
-               /* If we clicked in the edit window, we probably clicked
-                * on a file. */
-               if (wenclose(edit, mevent.y, mevent.x)) {
-                   size_t old_selected = selected;
-
-                   /* Subtract out the size of topwin. */
-                   mevent.y -= 2 - no_more_space();
-
-                   /* longest is the width of each column.  There are
-                    * two spaces between each column. */
-                   selected = (fileline / editwinrows) * (editwinrows *
-                       width) + (mevent.y * width) + (mevent.x /
-                       (longest + 2));
-
-                   /* If they clicked beyond the end of a row, select
-                    * the end of that row. */
-                   if (mevent.x > width * (longest + 2))
-                       selected--;
-
-                   /* If we're off the screen, reset to the last item.
-                    * If we clicked the same place as last time, select
-                    * this name! */
-                   if (selected > filelist_len - 1)
-                       selected = filelist_len - 1;
-                   else if (old_selected == selected)
-                       /* Put back the "Select" key, so that the file
-                        * is selected. */
-                       unget_kbinput(NANO_ENTER_KEY, FALSE, FALSE);
-               } else {
-                   /* We must have clicked a shortcut.  Put back the
-                    * equivalent shortcut key. */
+               {
                    int mouse_x, mouse_y;
-                   get_mouseinput(&mouse_x, &mouse_y, TRUE);
+                   bool retval = get_mouseinput(&mouse_x, &mouse_y,
+                       TRUE);
+
+                   if (!retval) {
+                       /* We can click in the edit window to select a
+                        * file. */
+                       if (wenclose(edit, mouse_y, mouse_x)) {
+                           size_t old_selected = selected;
+
+                           /* Subtract out the size of topwin. */
+                           mouse_y -= 2 - no_more_space();
+
+                           /* longest is the width of each column.
+                            * There are two spaces between each
+                            * column. */
+                           selected = (fileline / editwinrows) *
+                               (editwinrows * width) + (mouse_y *
+                               width) + (mouse_x / (longest + 2));
+
+                           /* If they clicked beyond the end of a row,
+                            * select the file at the end of that
+                            * row. */
+                           if (mouse_x > width * (longest + 2))
+                               selected--;
+
+                           /* If we're off the screen, select the last
+                            * file.  If we clicked the same place as
+                            * last time, read in the file there. */
+                           if (selected > filelist_len - 1)
+                               selected = filelist_len - 1;
+                           else if (old_selected == selected)
+                               /* Put back the "Select" key, so that
+                                * the file is read in. */
+                               unget_kbinput(NANO_ENTER_KEY, FALSE,
+                                       FALSE);
+                       }
+                   }
                }
                break;
 #endif /* !DISABLE_MOUSE */