summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/nc-menu.c
Commit message (Collapse)AuthorAgeFilesLines
* ui/ncurses: Check for NULL in pmenu_item_get_index()Samuel Mendoza-Jonas2015-12-171-3/+4
| | | | | | Fixes Coverity defect #30476 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Consolidate display string for optical devicesSamuel Mendoza-Jonas2015-08-311-2/+0
| | | | | | | Instead of using 'Optical' in some places and 'CD/DVD' in others, simply use 'CD/DVD' for all cases. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Recognise storage devices on USB busSamuel Mendoza-Jonas2015-08-311-2/+4
| | | | | | | | Users may want to prioritise USB-attached storage devices differently to other devices. Detect if a device is USB-attached and add a new device type to identify it. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui/ncurses: Reduce unnecessary calls to redrawwinSamuel Mendoza-Jonas2015-02-161-1/+0
| | | | | | | | | | | | | | | | | | | | | | | All current *_post() methods in ui/ncurses call redrawwin() and wrefresh() together. wrefresh() updates any lines on the screen that have been marked as changed or invalid. However redrawwin() marks the entire screen as invalid unconditionally. We can reduce the amount of data written to the screen by avoiding calls to redrawwin(). Screen transitions are the primary use case of redrawwin(), where the whole screen must be invalidated to avoid stale data remaining on screen. All other 'in-screen' updates such as changes to widgets or changing focus do not require a call to redrawwin(). The most noticeable performance improvement is in nc-menu, which makes an unnecssary call to redrawwin() after every addition to the boot option menu. eg. The number of bytes written to STDOUT in the main menu: # Boot options | Before | After -------------------------------- 8 | 5488 | 1149 133 | 422454 | 4652 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui/ncurses: Make device labels translateableJeremy Kerr2014-08-211-5/+5
| | | | | | | | | | We're not using gettext for the device label strings; this change adds the necessary macros to do so. Also, we change "Interface" to "Network", to make the label a little more obvious. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add language selector & support for language changesJeremy Kerr2014-07-281-0/+3
| | | | | | | This change adds a language selector UI, and allows language changes from incoming configuration messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Move menu initialisation to cui codeJeremy Kerr2014-07-281-19/+15
| | | | | | | | | | | We'll want to re-initialise the petitboot main menu (when the language is changed), which we can't do if the items are populated entirely from the main() function. This change moves the menu initilisation to the cui code, we we can re-init when necessary. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* i18n: Mark translatable strings for ncurses UIJeremy Kerr2014-07-281-1/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add device hierarchySamuel Mendoza-Jonas2014-07-221-0/+155
| | | | | | | | Boot options are now listed under their matching boot device in the ncurses UI to help differentitate similar boot option names Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Ensure boot option labels are displayable as menu itemsJeremy Kerr2014-04-101-1/+43
| | | | | | | | | | | | | | | ncurses' new_item() expects the name parameter to be a "printable string", by converting it to a wchar *, and checking that each character is printable with iswprint(). If it fails, we won't see a boot option at all. This change introduces a function to convert the label into something we know is printable, and valid UTF-8. If mbstowcs fails, we replace it with a generic 'Invalid option' label. If we encounter a valid multibyte string with unprintable characters, we replace those with U+fffd REPLACEMENT CHARACTER. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: unpost ncurses menu in pmenu cleanup pathJeremy Kerr2014-04-101-0/+1
| | | | | | We need to unpost the menu so that free_item can actually free the item. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Use pmenu_item destrutor to free ncurses ITEMsJeremy Kerr2014-04-101-6/+9
| | | | | | | | | | Currently, pemnu_destroy is used to free items. This means that the menu code needs to iterate over items, and we have no way to free the ITEM * of items that aren't in a menu. Instead, free the ITEM in the pmenu_item destructor. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Separate menu item creation & initialisation from insertionJeremy Kerr2014-04-101-24/+20
| | | | | | | | | | | | | | | | | | | | | | | Currently, the menu item creation is has two main functions: pmenu_item_alloc and pmenu_item_setup. The latter does initialisation (it sets item->name), and inserts the item into the menu. We have pmenu_item_init to combine this into one, but that means we need to do further initialisation (eg, to set on_execute) after the item has been added to the menu. Instead, this change use a more direct _create and _insert interface. Create does the allocation and initialisation, while _insert does the actual insertion. This means new_item failures will be detected at creation time, rather than during pmenu_insert. Also, we're now insert a completely-populated item into the menu, rather than populating on_edit, on_execute and data after insertion. Because we can detect errors from creation (ie, from new_item failing), we add handling code to cui_boot_option_add and cui_boot_editor_on_exit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Remove pmenu_item_replaceJeremy Kerr2014-04-081-48/+0
| | | | | | ... as nothing uses it. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Don't free item in pmenu_item_setupJeremy Kerr2014-04-081-3/+1
| | | | | | | | | | | | | Currently pmenu_item_setup may free its item parameter on error. This makes it non-obvious whether the item is still allocated on exit to the caller. Instead, this change removes the talloc_free, and requires that the caller do this on error. This makes the potential use-after-free in cui_boot_editor_on_exit obvious, so we fix that too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Unify key bindings & key help textJeremy Kerr2014-01-311-0/+7
| | | | | | | | | | This change is a small cleanup of the key bindings; we ensure that the general key bindings are available (and documented) on all screens. In order to keep things consistent, this change adds an initial UI guidelines text file, which documents the general key bindings. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add help text to nc-menu & generic-mainJeremy Kerr2014-01-311-0/+5
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* configure: Use AC_GNU_SOURCEJeremy Kerr2013-12-181-2/+2
| | | | | | | Rather than #defining _GNU_SOURCE in our .c files, we can define this from config.h instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses/menu: Allow space to select menu itemsJeremy Kerr2013-11-141-0/+1
| | | | | | To keep consistent with buttons, which also accept space. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add basic config editorJeremy Kerr2013-11-141-0/+4
| | | | | | This change adds a simple configuration editor to the ncurses UI. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add sysinfo screenJeremy Kerr2013-11-131-0/+5
| | | | | | | | Add a simple screen for displaying the struct system_info. We add this to the main menu as a selectable option, and separate it from the boot option list with an unselectable blank entry. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add nc_scr_{un,}post()Jeremy Kerr2013-11-131-2/+2
| | | | | | | We may have nc_scrs that aren't interested in post/unpost information, so create helper functions that allow a NULL callback. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Use 'x' as exit keyJeremy Kerr2013-10-111-0/+1
| | | | | | | | | | | Because terminals will send escape-sequences starting with escape, ncurses will pause after receiving a signle escape, to detect these sequences. This introduces a 1-second delay when exiting the petitboot UI. Instead, use 'x'. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Defer item creation until boot editor is doneJeremy Kerr2013-10-101-2/+2
| | | | | | | | | | | | Currently, when creating new menu entries, we create an empty item, add it to the menu, then run the boot editor. This means that cancelling the edit will leave an empty item in the menu. This change defers the creation until the boot editor is done. To do this, we modify the on_open callback to take a menu rather than an item, and pass NULL boot data to the editor. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Use 'New' instead of 'Open'Jeremy Kerr2013-10-101-2/+1
| | | | | | "Open" is ambiguous in the context of the boot menu; use "new" instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* configure: Update to use AX_WITH_CURSESGeoff Levand2013-07-231-0/+2
| | | | | | | | | | | For a more portable build system convert to using the autoconf-archive AX_WITH_CURSES macros. Allows building on openSUSE, which has a different header file layout than other distros, and fixes menu entries with UTF-8 characters; this causes fedora installs (codename "Schrödinger´s cat") to break the UI. Signed-off-by: Geoff Levand <geoff@infradead.org>
* ui/ncurses: move getch() out of process_key callbacksJeremy Kerr2013-05-211-55/+46
| | | | | | | | All process_key callbacks will want to query the key that was pressed, so do the getch() once in cui_process_key, and pass the result to the callback. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Fix warning from unnecessary if statementJeremy Kerr2013-03-051-1/+1
| | | | | | | | ui/ncurses/nc-menu.c: In function 'pmenu_process_key': ui/ncurses/nc-menu.c:207:33: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body] Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
* Remove KEY_LEFT in nc-menuGeoff Levand2011-11-121-1/+0
| | | | Signed-off-by: Geoff Levand <geoff@infradead.org>
* cui: Remove tab hotkeyGeoff Levand2009-08-261-1/+0
| | | | | | Remove the 'tab' hotkey that was used for kboot compatability. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
* Add ncurses joystick supportGeoff Levand2009-07-091-1/+1
| | | | Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
* Update item text on editGeoff Levand2009-07-091-14/+66
| | | | | | Update the boot option menu item text on edit. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
* Remove nc menu descriptionGeoff Levand2009-07-091-3/+2
| | | | | | Remove some unused nc menu description code. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
* CUI add empty itemGeoff Levand2009-07-091-2/+5
| | | | | | Add a CUI hot-key 'o' that opens a new empty menu item. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
* Add ncurses UI menuGeoff Levand2009-06-301-0/+358
Add support for an ncurses UI menu object. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud