// SPDX-License-Identifier: GPL-2.0+ /* * checklist.c -- implements the checklist box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
*/
#include"dialog.h"
staticint list_width, check_x, item_x;
/* * Print list item
*/ staticvoid print_item(WINDOW * win, int choice, int selected)
{ int i; char *list_item = malloc(list_width + 1);
/* * Print the scroll indicators.
*/ staticvoid print_arrows(WINDOW * win, int choice, int item_no, int scroll, int y, int x, int height)
{
wmove(win, y, x);
/* * Display the termination buttons
*/ staticvoid print_buttons(WINDOW * dialog, int height, int width, int selected)
{ int x = width / 2 - 11; int y = height - 2;
print_button(dialog, "Select", y, x, selected == 0);
print_button(dialog, " Help ", y, x + 14, selected == 1);
wmove(dialog, y, x + 1 + 14 * selected);
wrefresh(dialog);
}
/* * Display a dialog box with a list of options that can be turned on or off * in the style of radiolist (only one option turned on at a time).
*/ int dialog_checklist(constchar *title, constchar *prompt, int height, int width, int list_height)
{ int i, x, y, box_x, box_y; int key = 0, button = 0, choice = 0, scroll = 0, max_choice;
WINDOW *dialog, *list;
/* which item to highlight */
item_foreach() { if (item_is_tag('X'))
choice = item_n(); if (item_is_selected()) {
choice = item_n(); break;
}
}
do_resize: if (getmaxy(stdscr) < (height + CHECKLIST_HEIGHT_MIN)) return -ERRDISPLAYTOOSMALL; if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN)) return -ERRDISPLAYTOOSMALL;
max_choice = MIN(list_height, item_count());
/* center dialog box on screen */
x = (getmaxx(stdscr) - width) / 2;
y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
dialog = newwin(height, width, y, x);
keypad(dialog, TRUE);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.