Answer the question
In order to leave comments, you need to log in
Using mouse in newt (GUI console). Alternatives to ncurses?
I welcome everyone. Was looking for a cheap and easy alternative to ncurses. I thought about writing myself.
Because you want cheap, simple and tasteful. So that opa and molds with buttons fall out. And suddenly I discovered the newt library for myself . Where you can easily do some really cool stuff. Here is an example with checkboxes and radio buttons
The code is generally minimalistic
#include <newt.h>
#include <stdlib.h>
#include <stdio.h>
void main(void) {
newtComponent form, checkbox, rb[3], button;
char cbValue;
int i;
newtInit();
newtCls();
newtOpenWindow(10, 5, 40, 11, "Checkboxes and Radio buttons");
checkbox = newtCheckbox(1, 1, "A checkbox", ' ', " *X", &cbValue);
rb[0] = newtRadiobutton(1, 3, "Choice 1", 1, NULL);
rb[1] = newtRadiobutton(1, 4, "Choice 2", 0, rb[0]);
rb[2] = newtRadiobutton(1, 5, "Choice 3", 0, rb[1]);
button = newtButton(1, 7, "Ok");
form = newtForm(NULL, NULL, 0);
newtFormAddComponent(form, checkbox);
for (i = 0; i < 3; i++)
newtFormAddComponent(form, rb[i]);
newtFormAddComponent(form, button);
newtRunForm(form);
newtFinished();
/* We cannot destroy the form until after we've found the current
radio button */
for (i = 0; i < 3; i++)
if (newtRadioGetCurrent(rb[0]) == rb[i])
printf("radio button picked: %d\n", i);
newtFormDestroy(form);
/* But the checkbox's value is stored locally */
printf("checkbox value: '%c'\n", cbValue);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question