Messages in this thread Patch in this message | | | Subject | [PATCH 5/19] Kconfig I18N: lxdialog: answering | From | Egry Gábor <> | Date | Wed, 13 Jul 2005 19:13:09 +0200 |
| |
I18N support for answering in lxdialog. This patch is useful for non-latin based languages.
Signed-off-by: Egry Gabor <gaboregry@t-online.hu> ---
scripts/lxdialog/menubox.c | 33 ++++++++++++++++++++++++++++++++- scripts/lxdialog/yesno.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 3 deletions(-)
diff -puN scripts/lxdialog/yesno.c~kconfig-i18n-05-lxdialog-key scripts/lxdialog/yesno.c --- linux-2.6.13-rc3-i18n-kconfig/scripts/lxdialog/yesno.c~kconfig-i18n-05-lxdialog-key 2005-07-13 18:32:17.000000000 +0200 +++ linux-2.6.13-rc3-i18n-kconfig-gabaman/scripts/lxdialog/yesno.c 2005-07-13 18:32:17.000000000 +0200 @@ -43,10 +43,12 @@ print_buttons(WINDOW *dialog, int height int dialog_yesno (const char *title, const char *prompt, int height, int width) { - int i, x, y, key = 0, button = 0; + int i, x, y, key = 0, answer = 0, button = 0; WINDOW *dialog; #ifdef USE_WIDE_CURSES - wchar_t *wtitle; + wchar_t *wtitle, *yes, *Yes, *no, *No; +#else /* USE_WIDE_CURSES */ + const char *yes, *Yes, *no, *No; #endif /* USE_WIDE_CURSES */ /* center dialog box on screen */ @@ -107,6 +109,33 @@ dialog_yesno (const char *title, const c while (key != ESC) { key = wgetch (dialog); +#ifdef USE_WIDE_CURSES + yes = to_wchar (_("y")); + Yes = to_wchar (_("Y")); + no = to_wchar (_("n")); + No = to_wchar (_("N")); +#else /* USE_WIDE_CURSES */ + yes = _("y"); + Yes = _("Y"); + no = _("n"); + No = _("N"); +#endif /* USE_WIDE_CURSES */ + if (yes && (yes[0] == key)) + answer = 'y'; + if (Yes && (Yes[0] == key)) + answer = 'Y'; + if (no && (no[0] == key)) + answer = 'n'; + if (No && (No[0] == key)) + answer = 'N'; +#ifdef USE_WIDE_CURSES + free (yes); + free (Yes); + free (no); + free (No); +#endif /* USE_WIDE_CURSES */ + if (answer) + key = answer; switch (key) { case 'Y': case 'y': diff -puN scripts/lxdialog/menubox.c~kconfig-i18n-05-lxdialog-key scripts/lxdialog/menubox.c --- linux-2.6.13-rc3-i18n-kconfig/scripts/lxdialog/menubox.c~kconfig-i18n-05-lxdialog-key 2005-07-13 18:32:17.000000000 +0200 +++ linux-2.6.13-rc3-i18n-kconfig-gabaman/scripts/lxdialog/menubox.c 2005-07-13 18:32:17.000000000 +0200 @@ -189,10 +189,14 @@ dialog_menu (const char *title, const ch { int i, j, x, y, box_x, box_y; int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice; + int answer = 0; WINDOW *dialog, *menu; FILE *f; #ifdef USE_WIDE_CURSES wchar_t *wtitle, *witems, *witem2, *wcurrent; + wchar_t *yes, *Yes, *no, *No; +#else /* USE_WIDE_CURSES */ + const char *yes, *Yes, *no, *No; #endif /* USE_WIDE_CURSES */ max_choice = MIN (menu_height, item_no); @@ -541,7 +545,34 @@ dialog_menu (const char *title, const ch continue; /* wait for another key press */ } - switch (key) { +#ifdef USE_WIDE_CURSES + yes = to_wchar (_("y")); + Yes = to_wchar (_("Y")); + no = to_wchar (_("n")); + No = to_wchar (_("N")); +#else /* USE_WIDE_CURSES */ + yes = _("y"); + Yes = _("Y"); + no = _("n"); + No = _("N"); +#endif /* USE_WIDE_CURSES */ + if (yes && (yes[0] == key)) + answer = 'y'; + if (Yes && (Yes[0] == key)) + answer = 'Y'; + if (no && (no[0] == key)) + answer = 'n'; + if (No && (No[0] == key)) + answer = 'N'; +#ifdef USE_WIDE_CURSES + free (yes); + free (Yes); + free (no); + free (No); +#endif /* USE_WIDE_CURSES */ + if (answer) + key = answer; + switch (key) { case KEY_LEFT: case TAB: case KEY_RIGHT: _
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |