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().
Unified · Split
| @@ -63,19 +63,19 @@ static int menu_width, item_x; · 62 unmodified lines | ||
| 63 | 63 | /* |
| 64 | 64 | * Print menu item |
| 65 | 65 | */ |
| 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, | |
| 67 | 67 | int selected, int hotkey) |
| 68 | 68 | { |
| 69 | 69 | int j; |
| 70 | 70 | char *menu_item = malloc(menu_width + 1); |
| 71 | 71 | |
| 72 | 72 | strncpy(menu_item, item, menu_width - item_x); |
| 73 | − menu_item[menu_width] = 0; | |
| 73 | + menu_item[menu_width - item_x] = '\0'; | |
| 74 | 74 | j = first_alpha(menu_item, "YyNnMmHh"); |
| 75 | 75 | |
| 76 | 76 | /* Clear 'residue' of last item */ |
| 77 | 77 | wattrset(win, dlg.menubox.atr); |
| 78 | − wmove(win, choice, 0); | |
| 78 | + wmove(win, line_y, 0); | |
| 79 | 79 | #if OLD_NCURSES |
| 80 | 80 | { |
| 81 | 81 | int i; |
| @@ -86,14 +86,14 @@ static void do_print_item(WINDOW * win, const char *item, int choice, · 4 unmodified lines | ||
| 86 | 86 | wclrtoeol(win); |
| 87 | 87 | #endif |
| 88 | 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 | 90 | if (hotkey) { |
| 91 | 91 | wattrset(win, selected ? dlg.tag_key_selected.atr |
| 92 | 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 | 95 | if (selected) { |
| 96 | − wmove(win, choice, item_x + 1); | |
| 96 | + wmove(win, line_y, item_x + 1); | |
| 97 | 97 | } |
| 98 | 98 | free(menu_item); |
| 99 | 99 | wrefresh(win); |