Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13763916 authored by Dirk Gouders's avatar Dirk Gouders Committed by Yann E. MORIN
Browse files

kconfig/lxdialog: handle newline characters in print_autowrap()



When exiting menuconfig with unsaved changes, a dialog like
the following is shown:

        Do you wish to save your new configuration ? <ESC><ESC>
        to continue.

The author of the dialog text specified a newline after the '?',
and probably expected it to be processed, so let print_autowrap()
handle newlines propperly.

Also, reword that dialog's second phrase with a real sentence.

Signed-off-by: default avatarDirk Gouders <dirk@gouders.net>
Tested-by: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
[yann.morin.1998@free.fr: very slightly tweak the commit message]
Signed-off-by: default avatarYann E. MORIN <yann.morin.1998@free.fr>
parent ff7b0c2c
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -371,27 +371,19 @@ void print_title(WINDOW *dialog, const char *title, int width)
/*
 * Print a string of text in a window, automatically wrap around to the
 * next line if the string is too long to fit on one line. Newline
 * characters '\n' are replaced by spaces.  We start on a new line
 * characters '\n' are propperly processed.  We start on a new line
 * if there is no room for at least 4 nonblanks following a double-space.
 */
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
{
	int newl, cur_x, cur_y;
	int i, prompt_len, room, wlen;
	char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
	int prompt_len, room, wlen;
	char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;

	strcpy(tempstr, prompt);

	prompt_len = strlen(tempstr);

	/*
	 * Remove newlines
	 */
	for (i = 0; i < prompt_len; i++) {
		if (tempstr[i] == '\n')
			tempstr[i] = ' ';
	}

	if (prompt_len <= width - x * 2) {	/* If prompt is short */
		wmove(win, y, (width - prompt_len) / 2);
		waddstr(win, tempstr);
@@ -401,7 +393,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
		newl = 1;
		word = tempstr;
		while (word && *word) {
			sp = strchr(word, ' ');
			sp = strpbrk(word, "\n ");
			if (sp && *sp == '\n')
				newline_separator = sp;

			if (sp)
				*sp++ = 0;

@@ -413,7 +408,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
			if (wlen > room ||
			    (newl && wlen < 4 && sp
			     && wlen + 1 + strlen(sp) > room
			     && (!(sp2 = strchr(sp, ' '))
			     && (!(sp2 = strpbrk(sp, "\n "))
				 || wlen + 1 + (sp2 - sp) > room))) {
				cur_y++;
				cur_x = x;
@@ -421,7 +416,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
			wmove(win, cur_y, cur_x);
			waddstr(win, word);
			getyx(win, cur_y, cur_x);

			/* Move to the next line if the word separator was a newline */
			if (newline_separator) {
				cur_y++;
				cur_x = x;
				newline_separator = 0;
			} else
				cur_x++;

			if (sp && *sp == ' ') {
				cur_x++;	/* double space */
				while (*++sp == ' ') ;
+2 −2
Original line number Diff line number Diff line
@@ -959,7 +959,7 @@ static int handle_exit(void)
	if (conf_get_changed())
		res = dialog_yesno(NULL,
				   _("Do you wish to save your new configuration?\n"
				     "<ESC><ESC> to continue."),
				     "(Press <ESC><ESC> to continue kernel configuration.)"),
				   6, 60);
	else
		res = -1;