LibBSDDialog provides an API to build TUI dialogs and widgets to show messages, to get input and to inform about a computation status.
Example to build a msgbox with Hello World!:
#include <bsddialog.h>
int main()
{
struct bsddialog_conf conf;
();
bsddialog_init(&conf);
bsddialog_initconf(&conf, "Hello World!", 8, 20);
bsddialog_msgbox();
bsddialog_end
return (0);
}
Of course, it is possible to get user input and to change the UI, “Yes-No Question” example:
#include <bsddialog.h>
#include <bsddialog_theme.h>
#include <stdio.h>
int main()
{
int output;
struct bsddialog_conf conf;
();
bsddialog_init(BSDDIALOG_THEME_BSDDIALOG);
bsddialog_set_default_theme
(&conf);
bsddialog_initconf.title = " yesno ";
conf.text.highlight = true;
conf= bsddialog_yesno(&conf, "\nHello \\Z3World\\Zn!", 10, 30);
output
();
bsddialog_end
switch (output) {
case BSDDIALOG_YES:
("YES\n");
printfbreak;
case BSDDIALOG_NO:
("NO\n");
printfbreak;
}
return (0);
}
And to show computation status:
To compile the examples:
% git clone https://gitlab.com/alfix/bsddialog.git
% cd bsddialog
% make
% cc -I./lib example.c -o example -L./lib -lbsddialog -Wl,-rpath=./lib % ./example
Dialogs and widgets:
- infobox, msgbox, yesno.
- radiolist, checklist, menu, mixedlist.
- form.
- gauge, pause, mixedgauge, rangebox.
- datebox, timebox.
- textbox.
Documentation:
The library has a manual to describe the API
% man ./lib/bsddialog.3
and a collection of examples in the Public Domain to build new projects
% cd examples_library
% sh compile
% ./datebox
% ./form
% ./infobox
% ./menu
% ./mixedlist
% ./msgbox
% ./pause
% ./radiolist
% ./rangebox
% ./theme
% ./timebox % ./yesno
LibBSDDialog is an open source project released under the term of the BSD 2 Clause License, repository: https://gitlab.com/alfix/bsddialog.
Happy Coding!