* RFC: let lxdialog/util.c:print_autowrap() handle newline characters
@ 2013-05-08 11:54 Dirk Gouders
2013-05-08 12:36 ` Dirk Gouders
0 siblings, 1 reply; 7+ messages in thread
From: Dirk Gouders @ 2013-05-08 11:54 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild
[-- Attachment #1: Type: text/plain, Size: 897 bytes --]
Hello Michal,
this is just a cosmetical issue and probably I oversee a reason why
print_autowrap() ignores newline characters:
When I exit menuconfig with unsaved changes I get a dialog that looks
like
Do you wish to save your new configuration ? <ESC><ESC>
to continue.
and I thought that could look prettier (and probably should use complete
sentences).
In mconf.c, the above text is defined with a newline, so I guess the
author expected it to be processed, but the comment before
print_autowrap() clearly states that newline characters will be replaced
by spaces. I am not sure if this is a must -- I did not find a reason
why print_autowrap() should not process newline characters and gave it a
try.
Attached is a first version of a patch. There are other (indirect)
users of print_autowrap() but for now I just modified the text for the
exit dialog.
Dirk
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3494 bytes --]
From b09a6b6bb171ebc3cd0db0605a9ab32554eadb6b Mon Sep 17 00:00:00 2001
From: Dirk Gouders <dirk@gouders.net>
Date: Wed, 8 May 2013 13:04:44 +0200
Subject: [PATCH] mconf: let print_autowrap() handle newline characters.
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 and probably
expected it to be processed, so let print_autowrap() handle newlines propperly.
---
scripts/kconfig/lxdialog/util.c | 34 ++++++++++++++++++++++------------
scripts/kconfig/mconf.c | 8 ++++----
2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index a0e97c2..d362364 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -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;
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);
@@ -402,6 +394,17 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
word = tempstr;
while (word && *word) {
sp = strchr(word, ' ');
+ newline = strchr(word, '\n');
+
+ /* If we found a newline, then check if there are other
+ word separators (spaces) in front of it that we must respect. */
+ if (newline) {
+ if (sp && (newline > sp))
+ newline = 0;
+ else {
+ sp = newline;
+ }
+ }
if (sp)
*sp++ = 0;
@@ -421,7 +424,14 @@ 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);
- cur_x++;
+
+ /* Move to the next line if the word separator was a newline */
+ if (newline) {
+ cur_y++;
+ cur_x = x;
+ } else
+ cur_x++;
+
if (sp && *sp == ' ') {
cur_x++; /* double space */
while (*++sp == ' ') ;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 387dc8d..4f56ec6 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -955,10 +955,10 @@ static int handle_exit(void)
reset_subtitle();
dialog_clear();
if (conf_get_changed())
- res = dialog_yesno(NULL,
- _("Do you wish to save your new configuration ?\n"
- "<ESC><ESC> to continue."),
- 6, 60);
+ res = dialog_yesno("Exit Kernel Configuration",
+ _("Do you wish to save your new configuration?\n\n"
+ "(Press <ESC><ESC> to continue kernel configuration.)"),
+ 8, 60);
else
res = -1;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: RFC: let lxdialog/util.c:print_autowrap() handle newline characters
2013-05-08 11:54 RFC: let lxdialog/util.c:print_autowrap() handle newline characters Dirk Gouders
@ 2013-05-08 12:36 ` Dirk Gouders
2013-05-08 13:35 ` Yann E. MORIN
0 siblings, 1 reply; 7+ messages in thread
From: Dirk Gouders @ 2013-05-08 12:36 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild
[-- Attachment #1: Type: text/plain, Size: 396 bytes --]
Dirk Gouders <dirk@gouders.net> writes:
> Attached is a first version of a patch. There are other (indirect)
> users of print_autowrap() but for now I just modified the text for the
> exit dialog.
Sorry for the noise, but I noticed that my patch did not propperly
handle cases with short first words of new sentences. While at it I
noticed that strpbrk() makes the code more readable.
Dirk
[-- Attachment #2: Patch --]
[-- Type: text/plain, Size: 3609 bytes --]
From 490668696c253bef74e8acd2ff943f20cc4da26b Mon Sep 17 00:00:00 2001
From: Dirk Gouders <dirk@gouders.net>
Date: Wed, 8 May 2013 14:28:30 +0200
Subject: [PATCH] mconf: let print_autowrap() handle newline characters.
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 and probably
expected it to be processed, so let print_autowrap() handle newlines propperly.
---
scripts/kconfig/lxdialog/util.c | 31 +++++++++++++++++--------------
scripts/kconfig/mconf.c | 4 ++--
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index a0e97c2..50a3b68 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -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;
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);
- 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 == ' ') ;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 387dc8d..a258b8c 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -956,8 +956,8 @@ static int handle_exit(void)
dialog_clear();
if (conf_get_changed())
res = dialog_yesno(NULL,
- _("Do you wish to save your new configuration ?\n"
- "<ESC><ESC> to continue."),
+ _("Do you wish to save your new configuration?\n"
+ "(Press <ESC><ESC> to continue kernel configuration.)"),
6, 60);
else
res = -1;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: RFC: let lxdialog/util.c:print_autowrap() handle newline characters
2013-05-08 12:36 ` Dirk Gouders
@ 2013-05-08 13:35 ` Yann E. MORIN
2013-05-08 14:14 ` Dirk Gouders
0 siblings, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2013-05-08 13:35 UTC (permalink / raw)
To: Dirk Gouders; +Cc: Michal Marek, linux-kbuild
Dirk, All,
On Wed, May 08, 2013 at 02:36:44PM +0200, Dirk Gouders wrote:
> > Attached is a first version of a patch. There are other (indirect)
> > users of print_autowrap() but for now I just modified the text for the
> > exit dialog.
>
> Sorry for the noise, but I noticed that my patch did not propperly
> handle cases with short first words of new sentences. While at it I
> noticed that strpbrk() makes the code more readable.
Next time you have to send a patch, could you please:
- use 'git send-email': that will properly format the patch for
sending via email, especially, it does not attach the patch, but
in-lines it in the body of the mail, which makes it easier to review
- when you send a second (or third...) version of a patch, append a 'v2'
(or v3, and so on...) to the subject, like: [PATCH v2] Bla blabla...
> From 490668696c253bef74e8acd2ff943f20cc4da26b Mon Sep 17 00:00:00 2001
> From: Dirk Gouders <dirk@gouders.net>
> Date: Wed, 8 May 2013 14:28:30 +0200
> Subject: [PATCH] mconf: let print_autowrap() handle newline characters.
>
> 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.
Did you try to replace all the spaces there with newlines, and see what
happens? Hint: it's ugly, but not because of the newlines: the window is
not resized accordingly to the new number of lines, so better fix that
before, too.
> The author of the dialog text specified a newline and probably
> expected it to be processed, so let print_autowrap() handle newlines propperly.
Also, please add your SoB (Signed-off-by) line:
http://elinux.org/Developer_Certificate_Of_Origin
Otherwise, looks good. I'll do a more thorough review (and testing)
later (hopefully when you have fixed that window height issue).
Thank you!
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: let lxdialog/util.c:print_autowrap() handle newline characters
2013-05-08 13:35 ` Yann E. MORIN
@ 2013-05-08 14:14 ` Dirk Gouders
2013-05-08 15:04 ` Yann E. MORIN
0 siblings, 1 reply; 7+ messages in thread
From: Dirk Gouders @ 2013-05-08 14:14 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: Michal Marek, linux-kbuild
"Yann E. MORIN" <yann.morin.1998@free.fr> writes:
> Dirk, All,
>
> On Wed, May 08, 2013 at 02:36:44PM +0200, Dirk Gouders wrote:
>> > Attached is a first version of a patch. There are other (indirect)
>> > users of print_autowrap() but for now I just modified the text for the
>> > exit dialog.
>>
>> Sorry for the noise, but I noticed that my patch did not propperly
>> handle cases with short first words of new sentences. While at it I
>> noticed that strpbrk() makes the code more readable.
>
> Next time you have to send a patch, could you please:
> - use 'git send-email': that will properly format the patch for
> sending via email, especially, it does not attach the patch, but
> in-lines it in the body of the mail, which makes it easier to review
> - when you send a second (or third...) version of a patch, append a 'v2'
> (or v3, and so on...) to the subject, like: [PATCH v2] Bla blabla...
Sorry for the inconveniences, I will do my best with the revised version
of the patch.
>> Do you wish to save your new configuration ? <ESC><ESC>
>> to continue.
>
> Did you try to replace all the spaces there with newlines, and see what
> happens? Hint: it's ugly, but not because of the newlines: the window is
> not resized accordingly to the new number of lines, so better fix that
> before, too.
Yes, I noticed that when I put just two newlines into that text. In general
it happens for any text (also without newlines) that does not fit the
window height.
I solved the problem by adjusting the third parameter in the call to
dialog_yesno() and thought that that is the correct way to handle the
window-height-problem if the text does not fit, because print_autowrap()
currently does not care at all if the given text breaks the window.
But I agree, I would be nice if print_autowrap() could handle such cases
and I will see if I find a way to do that. I am unsure if that should
go into one single patch/commit, though.
>> The author of the dialog text specified a newline and probably
>> expected it to be processed, so let print_autowrap() handle newlines propperly.
>
> Also, please add your SoB (Signed-off-by) line:
> http://elinux.org/Developer_Certificate_Of_Origin
>
> Otherwise, looks good. I'll do a more thorough review (and testing)
> later (hopefully when you have fixed that window height issue).
Thank you for your first prompt feedback.
Dirk
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: let lxdialog/util.c:print_autowrap() handle newline characters
2013-05-08 14:14 ` Dirk Gouders
@ 2013-05-08 15:04 ` Yann E. MORIN
2013-05-08 15:29 ` [PATCH v3] " Dirk Gouders
0 siblings, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2013-05-08 15:04 UTC (permalink / raw)
To: Dirk Gouders; +Cc: Michal Marek, linux-kbuild
Dirk, All,
On Wed, May 08, 2013 at 04:14:56PM +0200, Dirk Gouders wrote:
> "Yann E. MORIN" <yann.morin.1998@free.fr> writes:
> > On Wed, May 08, 2013 at 02:36:44PM +0200, Dirk Gouders wrote:
> >> > Attached is a first version of a patch. There are other (indirect)
> >> > users of print_autowrap() but for now I just modified the text for the
> >> > exit dialog.
> >>
> >> Sorry for the noise, but I noticed that my patch did not propperly
> >> handle cases with short first words of new sentences. While at it I
> >> noticed that strpbrk() makes the code more readable.
> >
> > Next time you have to send a patch, could you please:
> > - use 'git send-email': that will properly format the patch for
> > sending via email, especially, it does not attach the patch, but
> > in-lines it in the body of the mail, which makes it easier to review
> > - when you send a second (or third...) version of a patch, append a 'v2'
> > (or v3, and so on...) to the subject, like: [PATCH v2] Bla blabla...
>
> Sorry for the inconveniences, I will do my best with the revised version
> of the patch.
No problem, I was just giving some hints! :-)
> >> Do you wish to save your new configuration ? <ESC><ESC>
> >> to continue.
> >
> > Did you try to replace all the spaces there with newlines, and see what
> > happens? Hint: it's ugly, but not because of the newlines: the window is
> > not resized accordingly to the new number of lines, so better fix that
> > before, too.
>
> Yes, I noticed that when I put just two newlines into that text. In general
> it happens for any text (also without newlines) that does not fit the
> window height.
>
> I solved the problem by adjusting the third parameter in the call to
> dialog_yesno() and thought that that is the correct way to handle the
> window-height-problem if the text does not fit, because print_autowrap()
> currently does not care at all if the given text breaks the window.
You are right: it is a non-issue so far; all rendered text currently fit
in their respective windows. If those texts get updated, it will be the
responsibility to the author to adjust the windows height.
Note: the english texts do fit, but I did not check that all
translations do. But are there anyone really using the localised texts
at all?
I'll get your patch as-is in my tree. Depending on Michal, maybe we can
queue it in for 3.10. Not too sure, though: the merge window is on the
verge of closing, and I'd prefer changes linger for a while in Michal'
then next's trees before getting mainlined.
> But I agree, I would be nice if print_autowrap() could handle such cases
> and I will see if I find a way to do that. I am unsure if that should
> go into one single patch/commit, though.
Not needed for now, but if you want to work on this, then please do one
patch for each semantically self-contained change. Adjusting the height
of the window is not tied to rendering the '\n'.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] let lxdialog/util.c:print_autowrap() handle newline characters
2013-05-08 15:04 ` Yann E. MORIN
@ 2013-05-08 15:29 ` Dirk Gouders
2013-05-08 21:40 ` Yann E. MORIN
0 siblings, 1 reply; 7+ messages in thread
From: Dirk Gouders @ 2013-05-08 15:29 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: Michal Marek, linux-kbuild
[-- Attachment #1: Type: text/plain, Size: 3073 bytes --]
"Yann E. MORIN" <yann.morin.1998@free.fr> writes:
>> > Next time you have to send a patch, could you please:
>> > - use 'git send-email': that will properly format the patch for
>> > sending via email, especially, it does not attach the patch, but
>> > in-lines it in the body of the mail, which makes it easier to review
>> > - when you send a second (or third...) version of a patch, append a 'v2'
>> > (or v3, and so on...) to the subject, like: [PATCH v2] Bla blabla...
>>
>> Sorry for the inconveniences, I will do my best with the revised version
>> of the patch.
>
> No problem, I was just giving some hints! :-)
Please do not get it as if I am ignoring your hints, Yann, but I still
need some time for "git send-email", because of certificate-based
authorization. So, for this mail I still use gnus...
But I hope I got the Subject right and will do my best to get the patch
attached inline.
>> >> Do you wish to save your new configuration ? <ESC><ESC>
>> >> to continue.
>> >
>> > Did you try to replace all the spaces there with newlines, and see what
>> > happens? Hint: it's ugly, but not because of the newlines: the window is
>> > not resized accordingly to the new number of lines, so better fix that
>> > before, too.
>>
>> Yes, I noticed that when I put just two newlines into that text. In general
>> it happens for any text (also without newlines) that does not fit the
>> window height.
>>
>> I solved the problem by adjusting the third parameter in the call to
>> dialog_yesno() and thought that that is the correct way to handle the
>> window-height-problem if the text does not fit, because print_autowrap()
>> currently does not care at all if the given text breaks the window.
>
> You are right: it is a non-issue so far; all rendered text currently fit
> in their respective windows. If those texts get updated, it will be the
> responsibility to the author to adjust the windows height.
>
> Note: the english texts do fit, but I did not check that all
> translations do. But are there anyone really using the localised texts
> at all?
>
> I'll get your patch as-is in my tree. Depending on Michal, maybe we can
> queue it in for 3.10. Not too sure, though: the merge window is on the
> verge of closing, and I'd prefer changes linger for a while in Michal'
> then next's trees before getting mainlined.
I found another issue in my patch and that is a missing initialization of
the variable "newline_separator", so you probably prefer this third
version. I did not notice problems with this issue, but I could well
imagine, others will.
>> But I agree, I would be nice if print_autowrap() could handle such cases
>> and I will see if I find a way to do that. I am unsure if that should
>> go into one single patch/commit, though.
>
> Not needed for now, but if you want to work on this, then please do one
> patch for each semantically self-contained change. Adjusting the height
> of the window is not tied to rendering the '\n'.
I agree and I expect it to be a more serious change to mconf.
Dirk
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3631 bytes --]
From dcaab3b8c6c9df84cba26fcc47c244932642f292 Mon Sep 17 00:00:00 2001
From: Dirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de>
Date: Wed, 8 May 2013 17:06:37 +0200
Subject: [PATCH v3] 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 and probably
expected it to be processed, so let print_autowrap() handle newlines propperly.
Signed-off-by: Dirk Gouders <dirk@gouders.net>
---
scripts/kconfig/lxdialog/util.c | 31 +++++++++++++++++--------------
scripts/kconfig/mconf.c | 4 ++--
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index a0e97c2..cfee00c 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -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);
- 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 == ' ') ;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 387dc8d..a258b8c 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -956,8 +956,8 @@ static int handle_exit(void)
dialog_clear();
if (conf_get_changed())
res = dialog_yesno(NULL,
- _("Do you wish to save your new configuration ?\n"
- "<ESC><ESC> to continue."),
+ _("Do you wish to save your new configuration?\n"
+ "(Press <ESC><ESC> to continue kernel configuration.)"),
6, 60);
else
res = -1;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] let lxdialog/util.c:print_autowrap() handle newline characters
2013-05-08 15:29 ` [PATCH v3] " Dirk Gouders
@ 2013-05-08 21:40 ` Yann E. MORIN
0 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2013-05-08 21:40 UTC (permalink / raw)
To: Dirk Gouders; +Cc: Michal Marek, linux-kbuild
Dirk, All,
On Wed, May 08, 2013 at 05:29:42PM +0200, Dirk Gouders wrote:
> From dcaab3b8c6c9df84cba26fcc47c244932642f292 Mon Sep 17 00:00:00 2001
> From: Dirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de>
> Date: Wed, 8 May 2013 17:06:37 +0200
> Subject: [PATCH v3] 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 and probably
> expected it to be processed, so let print_autowrap() handle newlines propperly.
>
> Signed-off-by: Dirk Gouders <dirk@gouders.net>
I've taken this in my tree:
git://gitorious.org/linux-kconfig/linux-kconfig.git yem-kconfig-for-next
I had to edit the commit log, as 'git am' pulled the complete mail, and
I further edited it a little teeny bit:
(The repository is unbrowseable on gitorious, but you can see the commit
here: https://www.gitorious.org/linux-kconfig/linux-kconfig/commit/87d46f0 )
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-05-08 21:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-08 11:54 RFC: let lxdialog/util.c:print_autowrap() handle newline characters Dirk Gouders
2013-05-08 12:36 ` Dirk Gouders
2013-05-08 13:35 ` Yann E. MORIN
2013-05-08 14:14 ` Dirk Gouders
2013-05-08 15:04 ` Yann E. MORIN
2013-05-08 15:29 ` [PATCH v3] " Dirk Gouders
2013-05-08 21:40 ` Yann E. MORIN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox