Path: blob/main/contrib/bsddialog/examples_library/checklist.c
39476 views
/*-1* SPDX-License-Identifier: CC0-1.02*3* Written in 2021 by Alfonso Sabato Siciliano.4* To the extent possible under law, the author has dedicated all copyright5* and related and neighboring rights to this software to the public domain6* worldwide. This software is distributed without any warranty, see:7* <http://creativecommons.org/publicdomain/zero/1.0/>.8*/910#include <bsddialog.h>11#include <stdio.h>1213int main()14{15int i, output;16struct bsddialog_conf conf;17struct bsddialog_menuitem items[5] = {18{"i", true, 0, "Name 1", "Desc 1", "Bottom Desc 1"},19{"ii", false, 0, "Name 2", "Desc 2", "Bottom Desc 2"},20{"iii", true, 0, "Name 3", "Desc 3", "Bottom Desc 3"},21{"iv", false, 0, "Name 4", "Desc 4", "Bottom Desc 4"},22{"v", true, 0, "Name 5", "Desc 5", "Bottom Desc 5"}23};2425if (bsddialog_init() == BSDDIALOG_ERROR) {26printf("Error: %s\n", bsddialog_geterror());27return (1);28}29bsddialog_initconf(&conf);30conf.title = "checklist";31output = bsddialog_checklist(&conf, "Example", 15, 30, 5, 5, items,32NULL);33bsddialog_end();34if (output == BSDDIALOG_ERROR) {35printf("Error: %s\n", bsddialog_geterror());36return (1);37}3839printf("Checklist:\n");40for (i = 0; i < 5; i++)41printf(" [%c] %s\n", items[i].on ? 'X' : ' ', items[i].name);4243return (0);44}4546