tweaks: rename a variable to be more accurate

When we get a ^J as verbatim input, it is not possible to include it
into the file buffer or the prompt answer, because this would mean
adding an encoded null to the buffer or answer, and that is not what
the user intended.  One option would have been to simply ignore a ^J
in verbatim input.  But the choice has been made to act the same way
as when the ^J (0x0A) is found in the file data: start a new line.

That is the same response as to the Enter key, yes -- but the code
for the Enter key is ^M (0x0D), not ^J.  So, to be more precise,
rename the relevant variable from 'got_enter' to 'got_newline'.
master
Benno Schulenberg 2016-07-03 16:19:27 +02:00
parent 03a81aa9c5
commit 528b79b5f3
3 changed files with 16 additions and 16 deletions

View File

@ -1833,8 +1833,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#endif
while (i < output_len) {
/* If control codes are allowed, encode a null as a newline, and
* let a newline character create a whole new line. */
/* If control codes are allowed, encode a verbatim null as a newline,
* and let a verbatim ^J create a whole new line. */
if (allow_cntrls) {
if (output[i] == '\0')
output[i] = '\n';

View File

@ -158,15 +158,15 @@ int do_statusbar_input(bool *ran_func, bool *finished,
* prompt, disable verbatim input. */
if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
openfile->filename[0] == '\0') {
bool got_enter = FALSE;
/* Whether we got the Enter key. */
bool got_newline = FALSE;
/* Whether we got a verbatim ^J. */
do_statusbar_verbatim_input(&got_enter);
do_statusbar_verbatim_input(&got_newline);
/* If we got the Enter key, remove it from the input
/* If we got a verbatim ^J, remove it from the input
* buffer, set input to the key value for Enter, and
* set finished to TRUE to indicate that we're done. */
if (got_enter) {
if (got_newline) {
get_input(NULL, 1);
input = sc_seq_or(do_enter, 0);
*finished = TRUE;
@ -236,10 +236,10 @@ int do_statusbar_mouse(void)
#endif
/* The user typed input_len multibyte characters. Add them to the
* statusbar prompt, setting got_enter to TRUE if we get a newline,
* statusbar prompt, setting got_newline to TRUE if we got a verbatim ^J,
* and filtering out ASCII control characters if filtering is TRUE. */
void do_statusbar_output(int *the_input, size_t input_len,
bool filtering, bool *got_enter)
bool filtering, bool *got_newline)
{
char *output = charalloc(input_len + 1);
char *char_buf = charalloc(mb_cur_max());
@ -261,9 +261,9 @@ void do_statusbar_output(int *the_input, size_t input_len,
output[i] = '\n';
else if (output[i] == '\n') {
/* Put back the rest of the characters for reparsing,
* indicate that we got the Enter key and get out. */
* indicate that we got a ^J and get out. */
unparse_kbinput(output + i, input_len - i);
*got_enter = TRUE;
*got_newline = TRUE;
return;
}
}
@ -425,9 +425,9 @@ void do_statusbar_prev_word(void)
}
#endif /* !NANO_TINY */
/* Get verbatim input. Set got_enter to TRUE if we got the Enter key as
/* Get verbatim input, setting got_newline to TRUE if we get a ^J as
* part of the verbatim input. */
void do_statusbar_verbatim_input(bool *got_enter)
void do_statusbar_verbatim_input(bool *got_newline)
{
int *kbinput;
size_t kbinput_len;
@ -437,7 +437,7 @@ void do_statusbar_verbatim_input(bool *got_enter)
/* Display all the verbatim characters at once, not filtering out
* control characters. */
do_statusbar_output(kbinput, kbinput_len, FALSE, got_enter);
do_statusbar_output(kbinput, kbinput_len, FALSE, got_newline);
}
/* Return the placewewant associated with statusbar_x, i.e. the

View File

@ -509,7 +509,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
int do_statusbar_mouse(void);
#endif
void do_statusbar_output(int *the_input, size_t input_len,
bool filtering, bool *got_enter);
bool filtering, bool *got_newline);
void do_statusbar_home(void);
void do_statusbar_end(void);
void do_statusbar_left(void);
@ -521,7 +521,7 @@ void do_statusbar_cut_text(void);
void do_statusbar_prev_word(void);
void do_statusbar_next_word(void);
#endif
void do_statusbar_verbatim_input(bool *got_enter);
void do_statusbar_verbatim_input(bool *got_newline);
size_t statusbar_xplustabs(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
void reinit_statusbar_x(void);