#include <form.h>
int main(void)
{
int ch;
FORM *formp;
FIELD *fields[3];
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
fields[0] = new_field(1, 32, 4, 18, 0, 0);
fields[1] = new_field(4, 32, 6, 18, 0, 0);
fields[2] = NULL;
set_field_back(fields[0], A_STANDOUT);
field_opts_off(fields[0], O_AUTOSKIP);
set_field_back(fields[1], A_STANDOUT);
field_opts_off(fields[1], O_AUTOSKIP);
formp = new_form(fields);
post_form(formp);
refresh();
mvprintw(4, 5, "IP Address:");
mvprintw(6, 5, "Message:");
move(4, 18);
refresh();
while( (ch = getch()) != KEY_F(1) )
{
switch(ch)
{
case KEY_DOWN:
form_driver(formp, REQ_NEXT_FIELD);
form_driver(formp, REQ_END_LINE);
break;
case KEY_UP:
form_driver(formp, REQ_PREV_FIELD);
form_driver(formp, REQ_END_LINE);
break;
default:
form_driver(formp, ch);
break;
}
}
unpost_form(formp);
free_form(formp);
free_field(fields[0]);
free_field(fields[1]);
endwin();
return 0;
} |