Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I dynamically update menu items in ncurses?

Is there a standard way to add/remove items, or change the descriptions, etc ? Or do I need to simply unpost, free up everything, then reallocate a new menu and start over? My menu has up to 2000 options so I'd really like to avoid allocating and reallocating if possible.

There is this question that doesn't really have any answer: Creating a dynamic menu in ncurses

like image 531
jterm Avatar asked Feb 27 '26 15:02

jterm


1 Answers

No - there's no standard way. With ncurses, the structure members are visible, so you could make a variation of new_item, which modified the pointers (and lengths) for the text.

Aside from that, there's (standard) set_menu_items. A quick read of the source shows that you could replace the items in the menu with the same list (with a different item here and there), but that resets the overall menu state, so you would have to save/restore those values before posting the menu again.

like image 112
Thomas Dickey Avatar answered Mar 01 '26 03:03

Thomas Dickey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!