tweaks: frob some comments plus miscellaneous other stuff
This commit is contained in:
@@ -2420,8 +2420,8 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
|
|||||||
|
|
||||||
/* We consider the first buf_len characters of buf for filename tab
|
/* We consider the first buf_len characters of buf for filename tab
|
||||||
* completion. */
|
* completion. */
|
||||||
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
|
char **cwd_tab_completion(const char *buf, bool allow_files,
|
||||||
*num_matches, size_t buf_len)
|
size_t *num_matches, size_t buf_len)
|
||||||
{
|
{
|
||||||
char *dirname = mallocstrcpy(NULL, buf);
|
char *dirname = mallocstrcpy(NULL, buf);
|
||||||
char *slash, *filename;
|
char *slash, *filename;
|
||||||
|
|||||||
12
src/global.c
12
src/global.c
@@ -1013,8 +1013,7 @@ void shortcut_init(void)
|
|||||||
N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
|
N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're using restricted mode, file insertion is disabled, and
|
/* Command execution is only available when not in restricted mode. */
|
||||||
* thus command execution and the multibuffer toggle have no place. */
|
|
||||||
if (!ISSET(RESTRICTED)) {
|
if (!ISSET(RESTRICTED)) {
|
||||||
add_to_funcs(flip_execute, MINSERTFILE,
|
add_to_funcs(flip_execute, MINSERTFILE,
|
||||||
N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
|
N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
|
||||||
@@ -1024,12 +1023,14 @@ void shortcut_init(void)
|
|||||||
}
|
}
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
|
/* Multiple buffers are only available when not in restricted mode. */
|
||||||
if (!ISSET(RESTRICTED))
|
if (!ISSET(RESTRICTED))
|
||||||
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
|
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
|
||||||
N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
|
N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
|
/* The file browser is only available when not in restricted mode. */
|
||||||
if (!ISSET(RESTRICTED))
|
if (!ISSET(RESTRICTED))
|
||||||
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
|
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
|
||||||
N_("To Files"), WITHORSANS(tofiles_gist), TOGETHER, VIEW);
|
N_("To Files"), WITHORSANS(tofiles_gist), TOGETHER, VIEW);
|
||||||
@@ -1311,8 +1312,8 @@ void shortcut_init(void)
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
|
||||||
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
|
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
|
||||||
/* In restricted mode, don't allow Appending, Prepending, nor making
|
/* Only when not in restricted mode, allow Appending, Prepending,
|
||||||
* backups, nor executing a command, nor opening a new buffer. */
|
* making backups, and executing a command. */
|
||||||
if (!ISSET(RESTRICTED)) {
|
if (!ISSET(RESTRICTED)) {
|
||||||
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
|
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
|
||||||
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
|
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
|
||||||
@@ -1321,11 +1322,12 @@ void shortcut_init(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
|
/* Only when not in restricted mode, allow multiple buffers. */
|
||||||
if (!ISSET(RESTRICTED))
|
if (!ISSET(RESTRICTED))
|
||||||
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
|
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
/* In restricted mode, don't allow entering the file browser. */
|
/* Only when not in restricted mode, allow entering the file browser. */
|
||||||
if (!ISSET(RESTRICTED))
|
if (!ISSET(RESTRICTED))
|
||||||
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
|
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ static struct sigaction act;
|
|||||||
static bool input_was_aborted = FALSE;
|
static bool input_was_aborted = FALSE;
|
||||||
/* Whether reading from standard input was aborted via ^C. */
|
/* Whether reading from standard input was aborted via ^C. */
|
||||||
|
|
||||||
/* Create a new linestruct node. Note that we do not set prevnode->next
|
/* Create a new linestruct node. Note that we do not set prevnode->next. */
|
||||||
* to the new line. */
|
|
||||||
filestruct *make_new_node(filestruct *prevnode)
|
filestruct *make_new_node(filestruct *prevnode)
|
||||||
{
|
{
|
||||||
filestruct *newnode = nmalloc(sizeof(filestruct));
|
filestruct *newnode = nmalloc(sizeof(filestruct));
|
||||||
@@ -1647,7 +1646,7 @@ bool okay_for_view(const sc *shortcut)
|
|||||||
{
|
{
|
||||||
const subnfunc *func = sctofunc(shortcut);
|
const subnfunc *func = sctofunc(shortcut);
|
||||||
|
|
||||||
return (func && func->viewok);
|
return (func != NULL && func->viewok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read in a keystroke. Act on the keystroke if it is a shortcut or a toggle;
|
/* Read in a keystroke. Act on the keystroke if it is a shortcut or a toggle;
|
||||||
|
|||||||
16
src/prompt.c
16
src/prompt.c
@@ -187,27 +187,25 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
|||||||
{
|
{
|
||||||
char *output = charalloc(input_len + 1);
|
char *output = charalloc(input_len + 1);
|
||||||
char onechar[MAXCHARLEN];
|
char onechar[MAXCHARLEN];
|
||||||
size_t char_len, i;
|
size_t char_len, i, j = 0;
|
||||||
|
|
||||||
/* Copy the typed stuff so it can be treated. */
|
/* Copy the typed stuff so it can be treated. */
|
||||||
for (i = 0; i < input_len; i++)
|
for (i = 0; i < input_len; i++)
|
||||||
output[i] = (char)the_input[i];
|
output[i] = (char)the_input[i];
|
||||||
output[i] = '\0';
|
output[i] = '\0';
|
||||||
|
|
||||||
i = 0;
|
while (j < input_len) {
|
||||||
|
|
||||||
while (i < input_len) {
|
|
||||||
/* Encode any NUL byte as 0x0A. */
|
/* Encode any NUL byte as 0x0A. */
|
||||||
if (output[i] == '\0')
|
if (output[j] == '\0')
|
||||||
output[i] = '\n';
|
output[j] = '\n';
|
||||||
|
|
||||||
/* Interpret the next multibyte character. */
|
/* Interpret the next multibyte character. */
|
||||||
char_len = parse_mbchar(output + i, onechar, NULL);
|
char_len = parse_mbchar(output + j, onechar, NULL);
|
||||||
|
|
||||||
i += char_len;
|
j += char_len;
|
||||||
|
|
||||||
/* When filtering, skip any ASCII control character. */
|
/* When filtering, skip any ASCII control character. */
|
||||||
if (filtering && is_ascii_cntrl_char(*(output + i - char_len)))
|
if (filtering && is_ascii_cntrl_char(*(output + j - char_len)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Insert the typed character into the existing answer string. */
|
/* Insert the typed character into the existing answer string. */
|
||||||
|
|||||||
Reference in New Issue
Block a user