to its own flag, --disable mouse. The --tiny option defines
this automatically, but now just mouse support can be disabled
if desired.
+ - File Browser supports the "Goto Directory"
- configure.in:
- New option, --enable-nanorc which currently does nothing but
sets a define. Will do more later...
+- files.c:
+ do_browser()
+ - Minor fixes to the processing of SELECT function (Rocco)
+ - Added the "Goto Directory" code (Rocco)
+- global.c:
+ - Updated some of the lists for the "Goto Directory" code (Rocco)
+- nano.c:
+ main()
+ - Code to silently process "-g" and "-j" (Rocco)
+- nano.h:
+ - Updated the BROWSER_LIST_LEN for the "Goto Directory" code (Rocco)
+- proto.h:
+ - New shortcut list added: gotodir_list (Rocco).
nano 1.1 tree forked here 04/07/2001
/* Loop invariant: Microsoft sucks. */
do {
- blank_edit();
- blank_statusbar();
+ DIR *test_dir;
+
+ blank_statusbar_refresh();
+
editline = 0;
col = 0;
case 'S':
/* You can't cd up from / */
- if (!strcmp(filelist[selected], "/..") && !strcmp(path, "/"))
+ if (!strcmp(filelist[selected], "/..") && !strcmp(path, "/")) {
statusbar(_("Can't move up a directory"));
- else
- path = mallocstrcpy(path, filelist[selected]);
+ break;
+ }
+
+ path = mallocstrcpy(path, filelist[selected]);
st = filestat(path);
if (S_ISDIR(st.st_mode)) {
- if (opendir(path) == NULL) {
+ if ((test_dir = opendir(path)) == NULL) {
/* We can't open this dir for some reason. Complain */
statusbar(_("Can't open \"%s\": %s"), path, strerror(errno));
- striponedir(path);
+ striponedir(path);
align(&path);
break;
}
+ closedir(test_dir);
if (!strcmp("..", tail(path))) {
/* They want to go up a level, so strip off .. and the
abort = 1;
}
break;
+ /* Goto a specific directory */
+ case 'g': /* Pico compatibility */
+ case 'G':
+ case NANO_GOTO_KEY:
+
+ curs_set(1);
+ j = statusq(0, gotodir_list, GOTODIR_LIST_LEN, "", _("Goto Directory"));
+ bottombars(browser_list, BROWSER_LIST_LEN);
+ curs_set(0);
+
+ if (j < 0) {
+ statusbar(_("Goto Cancelled"));
+ break;
+ }
+
+ if (answer[0] != '/') {
+ char *saveanswer = NULL;
+
+ saveanswer = mallocstrcpy(saveanswer, answer);
+ answer = realloc(answer, strlen(path) + strlen(saveanswer) + 2);
+ sprintf(answer, "%s/%s", path, saveanswer);
+ free(saveanswer);
+ }
+
+ if ((test_dir = opendir(answer)) == NULL) {
+ /* We can't open this dir for some reason. Complain */
+ statusbar(_("Can't open \"%s\": %s"), answer, strerror(errno));
+ break;
+ }
+ closedir(test_dir);
+
+ /* Start over again with the new path value */
+ path = mallocstrcpy(path, answer);
+ return do_browser(path);
+
/* Stuff we want to abort the browser */
case 'q':
case 'Q':
if (abort)
break;
+ blank_edit();
+
if (width)
i = width * editwinrows * ((selected / width) / editwinrows);
else
shortcut replace_list[REPLACE_LIST_LEN];
shortcut replace_list_2[REPLACE_LIST_LEN]; /* 2nd half of replace dialog */
shortcut goto_list[GOTO_LIST_LEN];
+shortcut gotodir_list[GOTODIR_LIST_LEN];
shortcut writefile_list[WRITEFILE_LIST_LEN];
shortcut help_list[HELP_LIST_LEN];
shortcut spell_list[SPELL_LIST_LEN];
#ifndef NANO_SMALL
char *nano_tofiles_msg = "";
+ char *nano_gotodir_msg = "";
nano_help_msg = _("Invoke the help menu");
nano_writeout_msg = _("Write the current file to disk");
nano_case_msg =
_("Make the current search or replace case (in)sensitive");
nano_tofiles_msg = _("Go to file browser");
+ nano_gotodir_msg = _("Goto Directory");
nano_cancel_msg = _("Cancel the current function");
#endif
nano_nextpage_msg,
0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, 0);
- sc_init_one(&browser_list[2], NANO_EXIT_KEY, _("Exit"),
+ sc_init_one(&browser_list[2], NANO_GOTO_KEY, _("Goto"),
+ nano_gotodir_msg, 0, NANO_GOTO_FKEY, 0, VIEW, 0);
+
+ sc_init_one(&browser_list[3], NANO_EXIT_KEY, _("Exit"),
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, 0);
+ sc_init_one(&gotodir_list[0], NANO_CANCEL_KEY, _("Cancel"),
+ nano_cancel_msg, 0, 0, 0, VIEW, 0);
+
#endif
#endif
#ifdef HAVE_GETOPT_LONG
- while ((optchr = getopt_long(argc, argv, "?T:RVbcefhiklmpr:s:tvwxz",
+ while ((optchr = getopt_long(argc, argv, "?T:RVbcefghijklmpr:s:tvwxz",
long_options, &option_index)) != EOF) {
#else
while ((optchr =
- getopt(argc, argv, "h?T:RVbcefiklmpr:s:tvwxz")) != EOF) {
+ getopt(argc, argv, "h?T:RVbcefgijklmpr:s:tvwxz")) != EOF) {
#endif
switch (optchr) {
case 'b':
case 'e':
case 'f':
+ case 'g':
+ case 'j':
/* Pico compatibility flags */
break;
case 'c':
#define REPLACE_LIST_LEN 6
#define REPLACE_LIST_2_LEN 3
#define GOTO_LIST_LEN 3
+#define GOTODIR_LIST_LEN 1
#define HELP_LIST_LEN 3
#define SPELL_LIST_LEN 1
#ifndef DISABLE_BROWSER
#define WRITEFILE_LIST_LEN 2
-#define BROWSER_LIST_LEN 3
+#define BROWSER_LIST_LEN 4
#else
#define WRITEFILE_LIST_LEN 1
#endif
extern shortcut writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN];
extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
#ifndef DISABLE_BROWSER
-extern shortcut browser_list[BROWSER_LIST_LEN];
+extern shortcut browser_list[BROWSER_LIST_LEN], gotodir_list[GOTODIR_LIST_LEN];
#endif
extern shortcut *currshortcut;