Path: blob/main/contrib/bsddialog/examples_library/mixedgauge.c
39476 views
/*-1* SPDX-License-Identifier: CC0-1.02*3* Written in 2023 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 <stdlib.h>12#include <stdio.h>13#include <unistd.h>1415#define NMINIBAR 131617static const char *minilabels[NMINIBAR] = {18"Label 1",19"Label 2",20"Label 3",21"Label 4",22"Label 5",23"Label 6",24"Label 7",25"Label 8",26"Label 9",27"Label 10",28"Label 11",29"Label X",30"Label Y",31};3233static int minipercs[NMINIBAR] = {34BSDDIALOG_MG_SUCCEEDED,35BSDDIALOG_MG_FAILED,36BSDDIALOG_MG_PASSED,37BSDDIALOG_MG_COMPLETED,38BSDDIALOG_MG_CHECKED,39BSDDIALOG_MG_DONE,40BSDDIALOG_MG_SKIPPED,41BSDDIALOG_MG_INPROGRESS,42BSDDIALOG_MG_BLANK,43BSDDIALOG_MG_NA,44BSDDIALOG_MG_PENDING,4567,460,47};4849static void exit_error()50{51if (bsddialog_inmode())52bsddialog_end();53printf("Error: %s\n", bsddialog_geterror());54exit (1);55}5657int main()58{59int retval, i;60struct bsddialog_conf conf;6162if (bsddialog_init() == BSDDIALOG_ERROR)63exit_error();64bsddialog_initconf(&conf);65conf.title = "mixedgauge";66for (i = 0; i <= 10; i++) {67minipercs[11] += 3;68minipercs[12] = i * 10;69retval= bsddialog_mixedgauge(&conf, "Example", 20, 40,7050 + i * 5, NMINIBAR, minilabels, minipercs);71if (retval == BSDDIALOG_ERROR)72exit_error();73sleep(1);74}75bsddialog_end();7677return (0);78}7980