bindings: allow toggling a new buffer when multiple buffers are enabled

When configured with --enable-tiny --enable-multibuffer,
/do/ include the new-buffer toggle in the Read-File menu.
master
Benno Schulenberg 2017-05-08 13:20:07 +02:00
parent e701bb01aa
commit 9ea5eef200
3 changed files with 14 additions and 8 deletions

View File

@ -1106,12 +1106,11 @@ void do_insertfile(void)
} else {
ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER) || defined(ENABLE_MULTIBUFFER)
functionptrtype func = func_from_key(&i);
#endif
given = mallocstrcpy(given, answer);
#ifndef NANO_TINY
#ifdef ENABLE_MULTIBUFFER
if (func == new_buffer_void) {
/* Don't allow toggling when in view mode. */
@ -1122,12 +1121,12 @@ void do_insertfile(void)
continue;
}
#endif
#ifndef NANO_TINY
if (func == flip_execute_void) {
execute = !execute;
continue;
}
#endif /* !NANO_TINY */
#endif
#ifndef DISABLE_BROWSER
if (func == to_files_void) {
char *chosen = do_browse_from(answer);

View File

@ -297,9 +297,11 @@ void backup_file_void(void)
void discard_buffer(void)
{
}
#ifdef ENABLE_MULTIBUFFER
void new_buffer_void(void)
{
}
#endif
void flip_replace_void(void)
{
}
@ -999,13 +1001,13 @@ void shortcut_init(void)
add_to_funcs(flip_execute_void, MEXTCMD,
read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
}
#endif /* !NANO_TINY */
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
add_to_funcs(new_buffer_void, MINSERTFILE|MEXTCMD,
N_("New Buffer"), IFSCHELP(nano_newbuffer_msg), TOGETHER, NOVIEW);
#endif
}
#endif /* !NANO_TINY */
#ifndef DISABLE_BROWSER
if (!ISSET(RESTRICTED))
@ -1287,9 +1289,12 @@ void shortcut_init(void)
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
}
#endif
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
#endif
#ifndef DISABLE_BROWSER
/* In restricted mode, don't allow entering the file browser. */
if (!ISSET(RESTRICTED))

View File

@ -697,7 +697,9 @@ void prepend_void(void);
void backup_file_void(void);
#endif
void discard_buffer(void);
#ifdef ENABLE_MULTIBUFFER
void new_buffer_void(void);
#endif
void backwards_void(void);
void goto_dir_void(void);
void flip_replace_void(void);