]> git.wh0rd.org Git - nano.git/commitdiff
add the ability to move to the first and last file in the file browser
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Sat, 6 May 2006 15:07:26 +0000 (15:07 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Sat, 6 May 2006 15:07:26 +0000 (15:07 +0000)
via Meta-\ (Meta-|) and Meta-/ (Meta-?)

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

ChangeLog
src/browser.c
src/global.c
src/nano.h

index d10f9d82e97c16abe8afcfdce10c3ad121cc0529..f6105ef916227f793f1fc5ff73e0599dfcff4158 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -66,9 +66,14 @@ CVS code -
          do_unindent_marked_void(); changes to shortcut_init(). (Chris
          and DLR)
        - Add the ability to move to the first and last line of the help
-         text via Meta-\ (Meta-|) and Meta-/ (Meta-?).  Changes to
-         shortcut_init() and do_help(). (DLR)
+         text and the first and last file in the file browser via
+         Meta-\ (Meta-|) and Meta-/ (Meta-?).  Changes to do_browser(),
+         shortcut_init(), and do_help(). (DLR)
 - browser.c:
+  do_browser()
+       - Reference NANO_GOTODIR_(ALT|F)?KEY instead of
+         NANO_GOTOLINE_(ALT|F)?KEY for the "Go to Directory" shortcut.
+         (DLR)
   parse_browser_input()
        - Remove redundant key checks. (DLR)
 - files.c:
@@ -113,6 +118,10 @@ CVS code -
        - Tweak the descriptions of some shortcut keys to make them more
          uniform. (Benno Schulenberg, minor tweaks by DLR)
        - Change the shortcut to find the matching bracket to ^]. (DLR)
+       - Shorten the "Where is Next" shortcut name to fit on the screen
+         after adding Meta-\ (Meta-|) and Meta-/ (Meta-?). (DLR)
+       - Lengthen the "UnCut Txt" shortcut name to "UnCut Text", as
+         there's enough room to display it unabbreviated. (DLR)
   toggle_init()
        - In the global toggle list, move the "Constant cursor position
          display" toggle up to after the "Use more space for editing"
index 19b479bfba7ec21722883d10f4f777a187880ea0..bbb5d611bb8fc4c070f29b6712d9d34abfa382ae 100644 (file)
@@ -39,7 +39,8 @@ static int width = 0;
 static int longest = 0;
        /* The number of columns in the longest filename in the list. */
 static size_t selected = 0;
-       /* The currently selected filename in the list. */
+       /* The currently selected filename in the list.  This variable
+        * is zero-based. */
 static bool search_last_file = FALSE;
        /* Have we gone past the last file while searching? */
 
@@ -149,26 +150,27 @@ char *do_browser(char *path, DIR *dir)
                }
 
                break;
-#endif
-
-           case NANO_PREVLINE_KEY:
-               if (selected >= width)
-                   selected -= width;
-               break;
+#endif /* !DISABLE_MOUSE */
 
-           case NANO_BACK_KEY:
-               if (selected > 0)
-                   selected--;
+           case NANO_HELP_KEY:
+#ifndef DISABLE_HELP
+               do_browser_help();
+               curs_set(0);
+#else
+               nano_disabled_msg();
+#endif
                break;
 
-           case NANO_NEXTLINE_KEY:
-               if (selected + width <= filelist_len - 1)
-                   selected += width;
+           /* Search for a filename. */
+           case NANO_WHEREIS_KEY:
+               curs_set(1);
+               do_filesearch();
+               curs_set(0);
                break;
 
-           case NANO_FORWARD_KEY:
-               if (selected < filelist_len - 1)
-                   selected++;
+           /* Search for another filename. */
+           case NANO_WHEREIS_NEXT_KEY:
+               do_fileresearch();
                break;
 
            case NANO_PREVPAGE_KEY:
@@ -187,86 +189,18 @@ char *do_browser(char *path, DIR *dir)
                    selected = filelist_len - 1;
                break;
 
-           case NANO_HELP_KEY:
-#ifndef DISABLE_HELP
-               do_browser_help();
-               curs_set(0);
-#else
-               nano_disabled_msg();
-#endif
-               break;
-
-           case NANO_ENTER_KEY:
-               /* You can't move up from "/". */
-               if (strcmp(filelist[selected], "/..") == 0) {
-                   statusbar(_("Can't move up a directory"));
-                   beep();
-                   break;
-               }
-
-#ifndef DISABLE_OPERATINGDIR
-               /* Note: the selected file can be outside the operating
-                * directory if it's ".." or if it's a symlink to a
-                * directory outside the operating directory. */
-               if (check_operating_dir(filelist[selected], FALSE)) {
-                   statusbar(
-                       _("Can't go outside of %s in restricted mode"),
-                       operating_dir);
-                   beep();
-                   break;
-               }
-#endif
-
-               if (stat(filelist[selected], &st) == -1) {
-                   /* We can't open this file for some reason.
-                    * Complain. */
-                   statusbar(_("Error reading %s: %s"),
-                       filelist[selected], strerror(errno));
-                   beep();
-                   break;
-               }
-
-               if (!S_ISDIR(st.st_mode)) {
-                   retval = mallocstrcpy(retval, filelist[selected]);
-                   abort = TRUE;
-                   break;
-               }
-
-               dir = opendir(filelist[selected]);
-               if (dir == NULL) {
-                   /* We can't open this dir for some reason.
-                    * Complain. */
-                   statusbar(_("Error reading %s: %s"),
-                       filelist[selected], strerror(errno));
-                   beep();
-                   break;
-               }
-
-               path = mallocstrcpy(path, filelist[selected]);
-
-               /* Start over again with the new path value. */
-               free_chararray(filelist, filelist_len);
-               goto change_browser_directory;
-
-           /* Redraw the screen. */
-           case NANO_REFRESH_KEY:
-               total_redraw();
-               break;
-
-           /* Search for a filename. */
-           case NANO_WHEREIS_KEY:
-               curs_set(1);
-               do_filesearch();
-               curs_set(0);
+           case NANO_FIRSTFILE_ALTKEY:
+               if (meta_key)
+                   selected = 0;
                break;
 
-           /* Search for another filename. */
-           case NANO_WHEREIS_NEXT_KEY:
-               do_fileresearch();
+           case NANO_LASTFILE_ALTKEY:
+               if (meta_key)
+                   selected = filelist_len - 1;
                break;
 
            /* Go to a specific directory. */
-           case NANO_GOTOLINE_KEY:
+           case NANO_GOTODIR_KEY:
                curs_set(1);
 
                i = do_prompt(TRUE,
@@ -340,6 +274,83 @@ char *do_browser(char *path, DIR *dir)
                free_chararray(filelist, filelist_len);
                goto change_browser_directory;
 
+           case NANO_PREVLINE_KEY:
+               if (selected >= width)
+                   selected -= width;
+               break;
+
+           case NANO_BACK_KEY:
+               if (selected > 0)
+                   selected--;
+               break;
+
+           case NANO_NEXTLINE_KEY:
+               if (selected + width <= filelist_len - 1)
+                   selected += width;
+               break;
+
+           case NANO_FORWARD_KEY:
+               if (selected < filelist_len - 1)
+                   selected++;
+               break;
+
+           case NANO_ENTER_KEY:
+               /* You can't move up from "/". */
+               if (strcmp(filelist[selected], "/..") == 0) {
+                   statusbar(_("Can't move up a directory"));
+                   beep();
+                   break;
+               }
+
+#ifndef DISABLE_OPERATINGDIR
+               /* Note: the selected file can be outside the operating
+                * directory if it's ".." or if it's a symlink to a
+                * directory outside the operating directory. */
+               if (check_operating_dir(filelist[selected], FALSE)) {
+                   statusbar(
+                       _("Can't go outside of %s in restricted mode"),
+                       operating_dir);
+                   beep();
+                   break;
+               }
+#endif
+
+               if (stat(filelist[selected], &st) == -1) {
+                   /* We can't open this file for some reason.
+                    * Complain. */
+                   statusbar(_("Error reading %s: %s"),
+                       filelist[selected], strerror(errno));
+                   beep();
+                   break;
+               }
+
+               if (!S_ISDIR(st.st_mode)) {
+                   retval = mallocstrcpy(retval, filelist[selected]);
+                   abort = TRUE;
+                   break;
+               }
+
+               dir = opendir(filelist[selected]);
+               if (dir == NULL) {
+                   /* We can't open this dir for some reason.
+                    * Complain. */
+                   statusbar(_("Error reading %s: %s"),
+                       filelist[selected], strerror(errno));
+                   beep();
+                   break;
+               }
+
+               path = mallocstrcpy(path, filelist[selected]);
+
+               /* Start over again with the new path value. */
+               free_chararray(filelist, filelist_len);
+               goto change_browser_directory;
+
+           /* Redraw the screen. */
+           case NANO_REFRESH_KEY:
+               total_redraw();
+               break;
+
            /* Abort the browser. */
            case NANO_EXIT_KEY:
                abort = TRUE;
@@ -512,7 +523,7 @@ void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
                break;
            case 'G':
            case 'g':
-               *kbinput = NANO_GOTOLINE_KEY;
+               *kbinput = NANO_GOTODIR_KEY;
                break;
            case 'S':
            case 's':
index 1e2d97e32ac0e123ae8124f00feb085215ebeca6..63b6353ffc84ce3785acae469390f4e3815f88f7 100644 (file)
@@ -267,8 +267,8 @@ void shortcut_init(bool unjustify)
     /* TRANSLATORS: Try to keep this and previous strings at most 10 characters. */
     const char *replace_msg = N_("Replace");
 #ifndef NANO_TINY
-    /* TRANSLATORS: Try to keep this at most 16 characters. */
-    const char *whereis_next_msg = N_("Where Is Next");
+    /* TRANSLATORS: Try to keep this at most 12 characters. */
+    const char *whereis_next_msg = N_("WhereIs Next");
 #endif
     /* TRANSLATORS: Try to keep this and following strings at most 10 characters. */
     const char *first_line_msg = N_("First Line");
@@ -525,7 +525,7 @@ void shortcut_init(bool unjustify)
                NANO_NO_KEY, NOVIEW, NULL);
     else
     /* TRANSLATORS: Try to keep this at most 10 characters. */
-       sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
+       sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Text"),
                IFHELP(nano_uncut_msg, FALSE), NANO_NO_KEY,
                NANO_UNCUT_FKEY, NANO_NO_KEY, NOVIEW, do_uncut_text);
 
@@ -556,7 +556,6 @@ void shortcut_init(bool unjustify)
        NANO_REPLACE_FKEY, NANO_NO_KEY, NOVIEW, do_replace);
 
 #ifndef NANO_TINY
-    /* TRANSLATORS: Try to keep this at most 16 characters. */
     sc_init_one(&main_list, NANO_MARK_KEY, N_("Mark Text"),
        IFHELP(nano_mark_msg, FALSE), NANO_MARK_ALTKEY, NANO_MARK_FKEY,
        NANO_NO_KEY, VIEW, do_mark);
@@ -1106,6 +1105,14 @@ void shortcut_init(bool unjustify)
        IFHELP(nano_exitbrowser_msg, FALSE), NANO_NO_KEY,
        NANO_EXIT_FKEY, NANO_NO_KEY, VIEW, NULL);
 
+    sc_init_one(&browser_list, NANO_WHEREIS_KEY, whereis_msg,
+       IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
+       NANO_NO_KEY, VIEW, NULL);
+
+    sc_init_one(&browser_list, NANO_NO_KEY, whereis_next_msg,
+       IFHELP(nano_whereis_next_msg, FALSE), NANO_WHEREIS_NEXT_KEY,
+       NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, NULL);
+
     sc_init_one(&browser_list, NANO_PREVPAGE_KEY, prev_page_msg,
        IFHELP(nano_prevpage_msg, FALSE), NANO_NO_KEY,
        NANO_PREVPAGE_FKEY, NANO_NO_KEY, VIEW, NULL);
@@ -1114,18 +1121,18 @@ void shortcut_init(bool unjustify)
        IFHELP(nano_nextpage_msg, FALSE), NANO_NO_KEY,
        NANO_NEXTPAGE_FKEY, NANO_NO_KEY, VIEW, NULL);
 
-    sc_init_one(&browser_list, NANO_WHEREIS_KEY, whereis_msg,
-       IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
-       NANO_NO_KEY, VIEW, NULL);
+    sc_init_one(&browser_list, NANO_NO_KEY, first_file_msg,
+       IFHELP(nano_firstfile_msg, FALSE), NANO_FIRSTFILE_ALTKEY,
+       NANO_NO_KEY, NANO_FIRSTFILE_ALTKEY2, VIEW, NULL);
 
-    sc_init_one(&browser_list, NANO_NO_KEY, whereis_next_msg,
-       IFHELP(nano_whereis_next_msg, FALSE), NANO_WHEREIS_NEXT_KEY,
-       NANO_WHEREIS_NEXT_FKEY, NANO_NO_KEY, VIEW, NULL);
+    sc_init_one(&browser_list, NANO_NO_KEY, last_file_msg,
+       IFHELP(nano_lastfile_msg, FALSE), NANO_LASTFILE_ALTKEY,
+       NANO_NO_KEY, NANO_LASTFILE_ALTKEY2, VIEW, NULL);
 
     /* TRANSLATORS: Try to keep this at most 22 characters. */
-    sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
-       IFHELP(nano_gotodir_msg, FALSE), NANO_GOTOLINE_ALTKEY,
-       NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
+    sc_init_one(&browser_list, NANO_GOTODIR_KEY, N_("Go To Dir"),
+       IFHELP(nano_gotodir_msg, FALSE), NANO_GOTODIR_ALTKEY,
+       NANO_GOTODIR_FKEY, NANO_NO_KEY, VIEW, NULL);
 
     free_shortcutage(&whereis_file_list);
 
index 46302c778c3625b39d66047c9f97c59d524cd9c7..2a0e9c3c20ac6adc29acc322367919405f0f4a4c 100644 (file)
@@ -482,6 +482,9 @@ typedef struct rcoption {
 #define NANO_GOTOLINE_KEY              NANO_CONTROL_7
 #define NANO_GOTOLINE_FKEY             KEY_F(13)
 #define NANO_GOTOLINE_ALTKEY           NANO_ALT_G
+#define NANO_GOTODIR_KEY               NANO_CONTROL_7
+#define NANO_GOTODIR_FKEY              KEY_F(13)
+#define NANO_GOTODIR_ALTKEY            NANO_ALT_G
 #define NANO_TOGOTOLINE_KEY            NANO_CONTROL_T
 #define NANO_HELP_KEY                  NANO_CONTROL_G
 #define NANO_HELP_FKEY                 KEY_F(1)