History

kconfig/lxdialog: clear long menu lines

Menulines that were wider than the available line width is now properly null terminated. While at it renamed the variable choice => line_y so it better reflect the usage in do_print_item().

Sam Ravnborg committed 20 years ago

Commit 737ecae1 parent c29121b1 file · +6 −6Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kconfig/lxdialog/menubox.c+6−6
@@ -63,19 +63,19 @@ static int menu_width, item_x; · 62 unmodified lines
63/*63/*
64 * Print menu item64 * Print menu item
65 */65 */
66static void do_print_item(WINDOW * win, const char *item, int choice,66static void do_print_item(WINDOW * win, const char *item, int line_y,
67 int selected, int hotkey)67 int selected, int hotkey)
68{68{
69 int j;69 int j;
70 char *menu_item = malloc(menu_width + 1);70 char *menu_item = malloc(menu_width + 1);
71 71
72 strncpy(menu_item, item, menu_width - item_x);72 strncpy(menu_item, item, menu_width - item_x);
73 menu_item[menu_width] = 0;73 menu_item[menu_width - item_x] = '\0';
74 j = first_alpha(menu_item, "YyNnMmHh");74 j = first_alpha(menu_item, "YyNnMmHh");
75 75
76 /* Clear 'residue' of last item */76 /* Clear 'residue' of last item */
77 wattrset(win, dlg.menubox.atr);77 wattrset(win, dlg.menubox.atr);
78 wmove(win, choice, 0);78 wmove(win, line_y, 0);
79#if OLD_NCURSES79#if OLD_NCURSES
80 {80 {
81 int i;81 int i;
@@ -86,14 +86,14 @@ static void do_print_item(WINDOW * win, const char *item, int choice, · 4 unmodified lines
86 wclrtoeol(win);86 wclrtoeol(win);
87#endif87#endif
88 wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);88 wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
89 mvwaddstr(win, choice, item_x, menu_item);89 mvwaddstr(win, line_y, item_x, menu_item);
90 if (hotkey) {90 if (hotkey) {
91 wattrset(win, selected ? dlg.tag_key_selected.atr91 wattrset(win, selected ? dlg.tag_key_selected.atr
92 : dlg.tag_key.atr);92 : dlg.tag_key.atr);
93 mvwaddch(win, choice, item_x + j, menu_item[j]);93 mvwaddch(win, line_y, item_x + j, menu_item[j]);
94 }94 }
95 if (selected) {95 if (selected) {
96 wmove(win, choice, item_x + 1);96 wmove(win, line_y, item_x + 1);
97 }97 }
98 free(menu_item);98 free(menu_item);
99 wrefresh(win);99 wrefresh(win);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t