diff --git a/ChangeLog b/ChangeLog index bcf1d4ac15257eb0dabcaa3fc737e199320a21d6..2bf8b2181c374ed5b62b8e01c489a3c6e5f58d08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,11 @@ CVS code - inaccuracy in the description of -Q/--quotestr. (DLR) - Set REG_EXTENDED in all regcomp() calls. (DLR) - Minor cosmetic code cleanups. (DLR) + - Changed do_insertfile to (a) report multibuffer status at the + prompt and allowing it to be toggled, taking into account the + need to keep the translatable strings, and (b) added a + variable inspath to keep track of what the string was before + toggling. I'm sure there's bugs, have at it. - configure.ac: - Added pt_BR to ALL_LINGUAS (Jordi). - Changed --enable-color warning to be slightly less severe. diff --git a/files.c b/files.c index e0ef48256a86dca2f4fb0cbdfe3f1ac344ddd809..46d48640ba7f8426f8deb6486326d952e0ea3d9f 100644 --- a/files.c +++ b/files.c @@ -421,6 +421,10 @@ int do_insertfile(int loading_file) { int i, old_current_x = current_x; char *realname = NULL; + static char *inspath = NULL; + + if (inspath == NULL) + inspath = mallocstrcpy(inspath, ""); wrap_reset(); @@ -430,17 +434,33 @@ int do_insertfile(int loading_file) #ifndef DISABLE_OPERATINGDIR if (operating_dir && strcmp(operating_dir, ".")) - i = statusq(1, insertfile_list, "", _("File to insert [from %s] "), +#ifdef ENABLE_MULTIBUFFER + if (ISSET(MULTIBUFFER)) + i = statusq(1, insertfile_list, inspath, _("File to insert into new buffer [from %s] "), + operating_dir); + else +#endif + i = statusq(1, insertfile_list, inspath, _("File to insert [from %s] "), operating_dir); + else #endif - i = statusq(1, insertfile_list, "", _("File to insert [from ./] ")); +#ifdef ENABLE_MULTIBUFFER + if (ISSET(MULTIBUFFER)) + i = statusq(1, insertfile_list, inspath, _("File to insert into new buffer [from ./] ")); + else +#endif + i = statusq(1, insertfile_list, inspath, _("File to insert [from ./] ")); if (i != -1) { + + inspath = mallocstrcpy(inspath, answer); + #ifdef DEBUG fprintf(stderr, _("filename is %s\n"), answer); #endif + #ifndef DISABLE_TABCOMP realname = real_dir_from_tilde(answer); #else @@ -473,6 +493,12 @@ int do_insertfile(int loading_file) } #endif +#ifdef ENABLE_MULTIBUFFER + if (i == TOGGLE_LOAD_KEY) { + TOGGLE(MULTIBUFFER); + return do_insertfile(loading_file); + } +#endif #ifndef NANO_SMALL if (i == NANO_EXTCMD_KEY) { int ts; @@ -548,6 +574,8 @@ int do_insertfile(int loading_file) } #endif + + /* If we've gone off the bottom, recenter; otherwise, just redraw */ if (current->lineno > editbot->lineno) edit_update(current, CENTER); @@ -558,15 +586,17 @@ int do_insertfile(int loading_file) update_color(); #endif - UNSET(KEEP_CUTBUFFER); - display_main_list(); - return i; } else { statusbar(_("Cancelled")); - UNSET(KEEP_CUTBUFFER); - display_main_list(); - return 0; + i = 0; } + + free(inspath); + inspath = NULL; + + UNSET(KEEP_CUTBUFFER); + display_main_list(); + return i; } int do_insertfile_void(void) diff --git a/global.c b/global.c index cf5b429ea78c6238475f4114b118a89372c88f02..83691d5a7d6710cadf598bb9707e0057335d01ad 100644 --- a/global.c +++ b/global.c @@ -325,7 +325,8 @@ void shortcut_init(int unjustify) "", *nano_backup_msg = ""; #ifdef ENABLE_MULTIBUFFER - char *nano_openprev_msg = "", *nano_opennext_msg = ""; + char *nano_openprev_msg = "", *nano_opennext_msg = "", + *nano_multibuffer_msg = ""; #endif #ifdef HAVE_REGEX_H char *nano_regexp_msg = "", *nano_bracket_msg = ""; @@ -384,6 +385,7 @@ void shortcut_init(int unjustify) #ifdef ENABLE_MULTIBUFFER nano_openprev_msg = _("Open previously loaded file"); nano_opennext_msg = _("Open next loaded file"); + nano_multibuffer_msg = _("Toggle insert into new buffer"); #endif #endif /* !DISABLE_HELP */ @@ -724,6 +726,10 @@ void shortcut_init(int unjustify) sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"), IFHELP(nano_execute_msg, 0), 0, 0, NOVIEW, 0); #endif +#ifdef ENABLE_MULTIBUFFER + sc_init_one(&insertfile_list, TOGGLE_LOAD_KEY, _("New Buffer"), + IFHELP(nano_multibuffer_msg, 0), 0, 0, NOVIEW, 0); +#endif free_shortcutage(&spell_list);