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

Unified · Split

scripts/kconfig/lxdialog/menubox.c+6−6
@@ -63,19 +63,19 @@ static int menu_width, item_x; · 62 unmodified lines
6363 /*
6464 * Print menu item
6565 */
66−static void do_print_item(WINDOW * win, const char *item, int choice,
66+static void do_print_item(WINDOW * win, const char *item, int line_y,
6767 int selected, int hotkey)
6868 {
6969 int j;
7070 char *menu_item = malloc(menu_width + 1);
7171
7272 strncpy(menu_item, item, menu_width - item_x);
73− menu_item[menu_width] = 0;
73+ menu_item[menu_width - item_x] = '\0';
7474 j = first_alpha(menu_item, "YyNnMmHh");
7575
7676 /* Clear 'residue' of last item */
7777 wattrset(win, dlg.menubox.atr);
78− wmove(win, choice, 0);
78+ wmove(win, line_y, 0);
7979 #if OLD_NCURSES
8080 {
8181 int i;
@@ -86,14 +86,14 @@ static void do_print_item(WINDOW * win, const char *item, int choice, · 4 unmodified lines
8686 wclrtoeol(win);
8787 #endif
8888 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);
9090 if (hotkey) {
9191 wattrset(win, selected ? dlg.tag_key_selected.atr
9292 : 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]);
9494 }
9595 if (selected) {
96− wmove(win, choice, item_x + 1);
96+ wmove(win, line_y, item_x + 1);
9797 }
9898 free(menu_item);
9999 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