Width fix in checkbox.c . If the content of checkbox is too long the subwindow 
slips.

Signed-off-by: Egry Gabor <[EMAIL PROTECTED]>
---

 scripts/lxdialog/checklist.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff -puN scripts/lxdialog/checklist.c~kconfig-i18n-02-lxdialog-witdh-fix 
scripts/lxdialog/checklist.c
--- 
linux-2.6.13-rc3-i18n-kconfig/scripts/lxdialog/checklist.c~kconfig-i18n-02-lxdialog-witdh-fix
       2005-07-13 18:32:16.000000000 +0200
+++ linux-2.6.13-rc3-i18n-kconfig-gabaman/scripts/lxdialog/checklist.c  
2005-07-13 18:37:06.000000000 +0200
@@ -32,7 +32,8 @@ static void
 print_item (WINDOW * win, const char *item, int status,
            int choice, int selected)
 {
-    int i;
+    int i, item_width=list_width+check_x-item_x;
+    char list_item[item_width+1];
 
     /* Clear 'residue' of last item */
     wattrset (win, menubox_attr);
@@ -47,10 +48,13 @@ print_item (WINDOW * win, const char *it
     else
        wprintw (win, "(%c)", status ? 'X' : ' ');
 
+    strncpy (list_item, item, item_width);
+    list_item[item_width] = 0;
+
     wattrset (win, selected ? tag_selected_attr : tag_attr);
-    mvwaddch(win, choice, item_x, item[0]);
+    mvwaddch(win, choice, item_x, list_item[0]);
     wattrset (win, selected ? item_selected_attr : item_attr);
-    waddstr (win, (char *)item+1);
+    waddstr (win, &list_item[1]);
     if (selected) {
        wmove (win, choice, check_x+1);
        wrefresh (win);
@@ -197,7 +201,7 @@ dialog_checklist (const char *title, con
     /* Find length of longest item in order to center checklist */
     check_x = 0;
     for (i = 0; i < item_no; i++) 
-       check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4);
+       check_x = MAX (check_x, MIN(list_width, strlen (items[i * 3 + 1]) + 4));
 
     check_x = (list_width - check_x) / 2;
     item_x = check_x + 4;
_


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to