files.c:do_insertfile() - Add some more checks and fix recursion when toggling multibuffer (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1416 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
0eab236580
commit
434d686ee4
|
@ -48,6 +48,9 @@ CVS Code -
|
||||||
- Fix goto directory operating dir check and tilde expansion
|
- Fix goto directory operating dir check and tilde expansion
|
||||||
(David Benbennick).
|
(David Benbennick).
|
||||||
- Even more checks and operating dir fixes (David Benbennick).
|
- Even more checks and operating dir fixes (David Benbennick).
|
||||||
|
do_insertfile()
|
||||||
|
- Add some more checks and fix recursion when toggling
|
||||||
|
multibuffer (David Benbennick).
|
||||||
open_file()
|
open_file()
|
||||||
- Fix FD leak with file load error (David Benbennick).
|
- Fix FD leak with file load error (David Benbennick).
|
||||||
add_open_file()
|
add_open_file()
|
||||||
|
|
3
TODO
3
TODO
|
@ -22,6 +22,9 @@ For version 1.4:
|
||||||
- Remindable keys?
|
- Remindable keys?
|
||||||
- Keystroke to implement "Add next sequence as raw" like vi's ^V.
|
- Keystroke to implement "Add next sequence as raw" like vi's ^V.
|
||||||
- Spell check selected text only.
|
- Spell check selected text only.
|
||||||
|
- Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their
|
||||||
|
parent menu when their keystroke is entered a second time (^W^T^T and
|
||||||
|
(^R^X^X)(requires figuring out when to keep cursor pos and when not to).
|
||||||
|
|
||||||
Old requests:
|
Old requests:
|
||||||
|
|
||||||
|
|
75
files.c
75
files.c
|
@ -427,6 +427,10 @@ int do_insertfile(int loading_file)
|
||||||
|
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
|
|
||||||
|
#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
|
||||||
|
start_again: /* Goto here when the user cancels the file browser. */
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||||
currshortcut = insertfile_list;
|
currshortcut = insertfile_list;
|
||||||
#endif
|
#endif
|
||||||
|
@ -473,55 +477,46 @@ int do_insertfile(int loading_file)
|
||||||
fprintf(stderr, _("filename is %s\n"), answer);
|
fprintf(stderr, _("filename is %s\n"), answer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
realname = real_dir_from_tilde(answer);
|
|
||||||
|
|
||||||
#ifndef DISABLE_BROWSER
|
|
||||||
if (i == NANO_TOFILES_KEY) {
|
|
||||||
char *tmp = do_browse_from(realname);
|
|
||||||
|
|
||||||
#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
|
||||||
currshortcut = insertfile_list;
|
|
||||||
#endif
|
|
||||||
#ifdef DISABLE_TABCOMP
|
|
||||||
realname = NULL;
|
|
||||||
#endif
|
|
||||||
if (tmp != NULL) {
|
|
||||||
free(realname);
|
|
||||||
realname = tmp;
|
|
||||||
} else
|
|
||||||
return do_insertfile(loading_file);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
|
||||||
if (operating_dir != NULL && check_operating_dir(realname, 0)) {
|
|
||||||
statusbar(_("Can't insert file from outside of %s"),
|
|
||||||
operating_dir);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
if (i == TOGGLE_LOAD_KEY) {
|
if (i == TOGGLE_LOAD_KEY) {
|
||||||
/* don't allow toggling if we're in both view mode and
|
/* Don't allow toggling if we're in view mode. */
|
||||||
multibuffer mode now */
|
if (!ISSET(VIEW_MODE))
|
||||||
if (!ISSET(VIEW_MODE) || !ISSET(MULTIBUFFER))
|
|
||||||
TOGGLE(MULTIBUFFER);
|
TOGGLE(MULTIBUFFER);
|
||||||
return do_insertfile(ISSET(MULTIBUFFER));
|
loading_file = ISSET(MULTIBUFFER);
|
||||||
|
goto start_again;
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_MULTIBUFFER */
|
#endif /* ENABLE_MULTIBUFFER */
|
||||||
|
|
||||||
if (i == NANO_EXTCMD_KEY) {
|
if (i == NANO_EXTCMD_KEY) {
|
||||||
int ts;
|
int ts = statusq(TRUE, extcmd_list, "", NULL,
|
||||||
ts = statusq(1, extcmd_list, "", 0, _("Command to execute "));
|
_("Command to execute"));
|
||||||
if (ts == -1 || answer == NULL || answer[0] == '\0') {
|
if (ts == -1 || answer == NULL || answer[0] == '\0') {
|
||||||
statusbar(_("Cancelled"));
|
statusbar("Cancelled");
|
||||||
UNSET(KEEP_CUTBUFFER);
|
UNSET(KEEP_CUTBUFFER);
|
||||||
display_main_list();
|
display_main_list();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !NANO_SMALL */
|
#endif /* !NANO_SMALL */
|
||||||
|
#ifndef DISABLE_BROWSER
|
||||||
|
if (i == NANO_TOFILES_KEY) {
|
||||||
|
char *tmp = do_browse_from(answer);
|
||||||
|
|
||||||
|
if (tmp != NULL)
|
||||||
|
answer = tmp;
|
||||||
|
else
|
||||||
|
goto start_again;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
|
if (i != NANO_EXTCMD_KEY && check_operating_dir(answer, FALSE)) {
|
||||||
|
statusbar(_("Can't insert file from outside of %s"),
|
||||||
|
operating_dir);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
if (loading_file) {
|
if (loading_file) {
|
||||||
|
@ -536,11 +531,15 @@ int do_insertfile(int loading_file)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (i == NANO_EXTCMD_KEY)
|
if (i == NANO_EXTCMD_KEY) {
|
||||||
|
realname = mallocstrcpy(realname, "");
|
||||||
i = open_pipe(answer);
|
i = open_pipe(answer);
|
||||||
else
|
} else
|
||||||
#endif /* NANO_SMALL */
|
#endif /* NANO_SMALL */
|
||||||
|
{
|
||||||
|
realname = real_dir_from_tilde(answer);
|
||||||
i = open_file(realname, 1, loading_file);
|
i = open_file(realname, 1, loading_file);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
if (loading_file) {
|
if (loading_file) {
|
||||||
|
|
Loading…
Reference in New Issue