kconfig: Lindent scripts/lxdialog
The lxdialog code was not easy to read. So as first step the code was run through Lindent. Fix-ups will come in next patchset. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
This commit is contained in:
parent
b286e39207
commit
b1c5f1c635
10 changed files with 1861 additions and 1787 deletions
|
@ -29,8 +29,7 @@ static int list_width, check_x, item_x, checkflag;
|
|||
* Print list item
|
||||
*/
|
||||
static void
|
||||
print_item (WINDOW * win, const char *item, int status,
|
||||
int choice, int selected)
|
||||
print_item(WINDOW * win, const char *item, int status, int choice, int selected)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -70,8 +69,7 @@ print_arrows (WINDOW * win, int choice, int item_no, int scroll,
|
|||
wattrset(win, uarrow_attr);
|
||||
waddch(win, ACS_UARROW);
|
||||
waddstr(win, "(-)");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
wattrset(win, menubox_attr);
|
||||
waddch(win, ACS_HLINE);
|
||||
waddch(win, ACS_HLINE);
|
||||
|
@ -86,8 +84,7 @@ print_arrows (WINDOW * win, int choice, int item_no, int scroll,
|
|||
wattrset(win, darrow_attr);
|
||||
waddch(win, ACS_DARROW);
|
||||
waddstr(win, "(+)");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
wattrset(win, menubox_border_attr);
|
||||
waddch(win, ACS_HLINE);
|
||||
waddch(win, ACS_HLINE);
|
||||
|
@ -99,8 +96,7 @@ print_arrows (WINDOW * win, int choice, int item_no, int scroll,
|
|||
/*
|
||||
* Display the termination buttons
|
||||
*/
|
||||
static void
|
||||
print_buttons( WINDOW *dialog, int height, int width, int selected)
|
||||
static void print_buttons(WINDOW * dialog, int height, int width, int selected)
|
||||
{
|
||||
int x = width / 2 - 11;
|
||||
int y = height - 2;
|
||||
|
@ -118,8 +114,8 @@ print_buttons( WINDOW *dialog, int height, int width, int selected)
|
|||
*/
|
||||
int
|
||||
dialog_checklist(const char *title, const char *prompt, int height, int width,
|
||||
int list_height, int item_no, const char * const * items, int flag)
|
||||
|
||||
int list_height, int item_no, const char *const *items,
|
||||
int flag)
|
||||
{
|
||||
int i, x, y, box_x, box_y;
|
||||
int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
|
||||
|
@ -138,7 +134,8 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
/* Initializes status */
|
||||
for (i = 0; i < item_no; i++) {
|
||||
status[i] = !strcasecmp(items[i * 3 + 2], "on");
|
||||
if ((!choice && status[i]) || !strcasecmp (items[i * 3 + 2], "selected"))
|
||||
if ((!choice && status[i])
|
||||
|| !strcasecmp(items[i * 3 + 2], "selected"))
|
||||
choice = i + 1;
|
||||
}
|
||||
if (choice)
|
||||
|
@ -186,7 +183,9 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
box_x = (width - list_width) / 2 - 1;
|
||||
|
||||
/* create new window for the list */
|
||||
list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1);
|
||||
list =
|
||||
subwin(dialog, list_height, list_width, y + box_y + 1,
|
||||
x + box_x + 1);
|
||||
|
||||
keypad(list, TRUE);
|
||||
|
||||
|
@ -226,10 +225,10 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
key = wgetch(dialog);
|
||||
|
||||
for (i = 0; i < max_choice; i++)
|
||||
if (toupper(key) == toupper(items[(scroll+i)*3+1][0]))
|
||||
if (toupper(key) ==
|
||||
toupper(items[(scroll + i) * 3 + 1][0]))
|
||||
break;
|
||||
|
||||
|
||||
if (i < max_choice || key == KEY_UP || key == KEY_DOWN ||
|
||||
key == '+' || key == '-') {
|
||||
if (key == KEY_UP || key == '-') {
|
||||
|
@ -239,8 +238,11 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
/* Scroll list down */
|
||||
if (list_height > 1) {
|
||||
/* De-highlight current first item */
|
||||
print_item (list, items[scroll * 3 + 1],
|
||||
status[scroll], 0, FALSE);
|
||||
print_item(list,
|
||||
items[scroll * 3 +
|
||||
1],
|
||||
status[scroll], 0,
|
||||
FALSE);
|
||||
scrollok(list, TRUE);
|
||||
wscrl(list, -1);
|
||||
scrollok(list, FALSE);
|
||||
|
@ -250,8 +252,10 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
status[scroll], 0, TRUE);
|
||||
wnoutrefresh(list);
|
||||
|
||||
print_arrows(dialog, choice, item_no, scroll,
|
||||
box_y, box_x + check_x + 5, list_height);
|
||||
print_arrows(dialog, choice, item_no,
|
||||
scroll, box_y,
|
||||
box_x + check_x + 5,
|
||||
list_height);
|
||||
|
||||
wrefresh(dialog);
|
||||
|
||||
|
@ -265,21 +269,32 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
/* Scroll list up */
|
||||
if (list_height > 1) {
|
||||
/* De-highlight current last item before scrolling up */
|
||||
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
|
||||
status[scroll + max_choice - 1],
|
||||
max_choice - 1, FALSE);
|
||||
print_item(list,
|
||||
items[(scroll +
|
||||
max_choice -
|
||||
1) * 3 + 1],
|
||||
status[scroll +
|
||||
max_choice -
|
||||
1],
|
||||
max_choice - 1,
|
||||
FALSE);
|
||||
scrollok(list, TRUE);
|
||||
wscrl(list, 1);
|
||||
scrollok(list, FALSE);
|
||||
}
|
||||
scroll++;
|
||||
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
|
||||
status[scroll + max_choice - 1],
|
||||
max_choice - 1, TRUE);
|
||||
print_item(list,
|
||||
items[(scroll + max_choice -
|
||||
1) * 3 + 1],
|
||||
status[scroll + max_choice -
|
||||
1], max_choice - 1,
|
||||
TRUE);
|
||||
wnoutrefresh(list);
|
||||
|
||||
print_arrows(dialog, choice, item_no, scroll,
|
||||
box_y, box_x + check_x + 5, list_height);
|
||||
print_arrows(dialog, choice, item_no,
|
||||
scroll, box_y,
|
||||
box_x + check_x + 5,
|
||||
list_height);
|
||||
|
||||
wrefresh(dialog);
|
||||
|
||||
|
@ -289,12 +304,16 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
}
|
||||
if (i != choice) {
|
||||
/* De-highlight current item */
|
||||
print_item (list, items[(scroll + choice) * 3 + 1],
|
||||
status[scroll + choice], choice, FALSE);
|
||||
print_item(list,
|
||||
items[(scroll + choice) * 3 + 1],
|
||||
status[scroll + choice], choice,
|
||||
FALSE);
|
||||
/* Highlight new item */
|
||||
choice = i;
|
||||
print_item (list, items[(scroll + choice) * 3 + 1],
|
||||
status[scroll + choice], choice, TRUE);
|
||||
print_item(list,
|
||||
items[(scroll + choice) * 3 + 1],
|
||||
status[scroll + choice], choice,
|
||||
TRUE);
|
||||
wnoutrefresh(list);
|
||||
wrefresh(dialog);
|
||||
}
|
||||
|
@ -323,18 +342,28 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
case '\n':
|
||||
if (!button) {
|
||||
if (flag == FLAG_CHECK) {
|
||||
status[scroll + choice] = !status[scroll + choice];
|
||||
status[scroll + choice] =
|
||||
!status[scroll + choice];
|
||||
wmove(list, choice, check_x);
|
||||
wattrset(list, check_selected_attr);
|
||||
wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' ');
|
||||
wprintw(list, "[%c]",
|
||||
status[scroll +
|
||||
choice] ? 'X' : ' ');
|
||||
} else {
|
||||
if (!status[scroll + choice]) {
|
||||
for (i = 0; i < item_no; i++)
|
||||
status[i] = 0;
|
||||
status[scroll + choice] = 1;
|
||||
for (i = 0; i < max_choice; i++)
|
||||
print_item (list, items[(scroll + i) * 3 + 1],
|
||||
status[scroll + i], i, i == choice);
|
||||
print_item(list,
|
||||
items[(scroll
|
||||
+
|
||||
i) *
|
||||
3 + 1],
|
||||
status[scroll
|
||||
+ i],
|
||||
i,
|
||||
i == choice);
|
||||
}
|
||||
}
|
||||
wnoutrefresh(list);
|
||||
|
@ -343,15 +372,19 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
for (i = 0; i < item_no; i++) {
|
||||
if (status[i]) {
|
||||
if (flag == FLAG_CHECK) {
|
||||
fprintf (stderr, "\"%s\" ", items[i * 3]);
|
||||
fprintf(stderr,
|
||||
"\"%s\" ",
|
||||
items[i * 3]);
|
||||
} else {
|
||||
fprintf (stderr, "%s", items[i * 3]);
|
||||
fprintf(stderr, "%s",
|
||||
items[i * 3]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else
|
||||
fprintf (stderr, "%s", items[(scroll + choice) * 3]);
|
||||
fprintf(stderr, "%s",
|
||||
items[(scroll + choice) * 3]);
|
||||
delwin(dialog);
|
||||
free(status);
|
||||
return button;
|
||||
|
@ -366,7 +399,6 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
|
|||
doupdate();
|
||||
}
|
||||
|
||||
|
||||
delwin(dialog);
|
||||
free(status);
|
||||
return -1; /* ESC pressed */
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Default color definitions
|
||||
*
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#define MIN(x,y) (x < y ? x : y)
|
||||
#define MAX(x,y) (x > y ? x : y)
|
||||
|
||||
|
||||
#ifndef ACS_ULCORNER
|
||||
#define ACS_ULCORNER '+'
|
||||
#endif
|
||||
|
@ -140,7 +139,6 @@ extern const char *backtitle;
|
|||
extern void create_rc(const char *filename);
|
||||
extern int parse_rc(void);
|
||||
|
||||
|
||||
void init_dialog(void);
|
||||
void end_dialog(void);
|
||||
void attr_clear(WINDOW * win, int height, int width, chtype attr);
|
||||
|
@ -178,7 +176,6 @@ int dialog_inputbox (const char *title, const char *prompt, int height,
|
|||
*/
|
||||
#define M_EVENT (KEY_MAX+1)
|
||||
|
||||
|
||||
/*
|
||||
* The `flag' parameter in checklist is used to select between
|
||||
* radiolist and checklist
|
||||
|
|
|
@ -26,8 +26,7 @@ char dialog_input_result[MAX_LEN + 1];
|
|||
/*
|
||||
* Print the termination buttons
|
||||
*/
|
||||
static void
|
||||
print_buttons(WINDOW *dialog, int height, int width, int selected)
|
||||
static void print_buttons(WINDOW * dialog, int height, int width, int selected)
|
||||
{
|
||||
int x = width / 2 - 11;
|
||||
int y = height - 2;
|
||||
|
@ -55,7 +54,6 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
|
|||
x = (COLS - width) / 2;
|
||||
y = (LINES - height) / 2;
|
||||
|
||||
|
||||
draw_shadow(stdscr, y, x, height, width);
|
||||
|
||||
dialog = newwin(height, width, y, x);
|
||||
|
@ -138,17 +136,26 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
|
|||
if (input_x || scroll) {
|
||||
wattrset(dialog, inputbox_attr);
|
||||
if (!input_x) {
|
||||
scroll = scroll < box_width - 1 ?
|
||||
0 : scroll - (box_width - 1);
|
||||
scroll =
|
||||
scroll <
|
||||
box_width - 1 ? 0 : scroll -
|
||||
(box_width - 1);
|
||||
wmove(dialog, box_y, box_x);
|
||||
for (i = 0; i < box_width; i++)
|
||||
waddch (dialog, instr[scroll + input_x + i] ?
|
||||
instr[scroll + input_x + i] : ' ');
|
||||
input_x = strlen (instr) - scroll;
|
||||
waddch(dialog,
|
||||
instr[scroll +
|
||||
input_x +
|
||||
i] ?
|
||||
instr[scroll +
|
||||
input_x +
|
||||
i] : ' ');
|
||||
input_x =
|
||||
strlen(instr) - scroll;
|
||||
} else
|
||||
input_x--;
|
||||
instr[scroll + input_x] = '\0';
|
||||
mvwaddch (dialog, box_y, input_x + box_x, ' ');
|
||||
mvwaddch(dialog, box_y, input_x + box_x,
|
||||
' ');
|
||||
wmove(dialog, box_y, input_x + box_x);
|
||||
wrefresh(dialog);
|
||||
}
|
||||
|
@ -158,14 +165,23 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
|
|||
if (scroll + input_x < MAX_LEN) {
|
||||
wattrset(dialog, inputbox_attr);
|
||||
instr[scroll + input_x] = key;
|
||||
instr[scroll + input_x + 1] = '\0';
|
||||
instr[scroll + input_x + 1] =
|
||||
'\0';
|
||||
if (input_x == box_width - 1) {
|
||||
scroll++;
|
||||
wmove (dialog, box_y, box_x);
|
||||
for (i = 0; i < box_width - 1; i++)
|
||||
waddch (dialog, instr[scroll + i]);
|
||||
wmove(dialog, box_y,
|
||||
box_x);
|
||||
for (i = 0;
|
||||
i < box_width - 1;
|
||||
i++)
|
||||
waddch(dialog,
|
||||
instr
|
||||
[scroll +
|
||||
i]);
|
||||
} else {
|
||||
wmove (dialog, box_y, input_x++ + box_x);
|
||||
wmove(dialog, box_y,
|
||||
input_x++ +
|
||||
box_x);
|
||||
waddch(dialog, key);
|
||||
}
|
||||
wrefresh(dialog);
|
||||
|
|
|
@ -34,8 +34,7 @@ struct Mode {
|
|||
jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox;
|
||||
jumperFn j_msgbox, j_infobox;
|
||||
|
||||
static struct Mode modes[] =
|
||||
{
|
||||
static struct Mode modes[] = {
|
||||
{"--menu", 9, 0, 3, j_menu},
|
||||
{"--checklist", 9, 0, 3, j_checklist},
|
||||
{"--radiolist", 9, 0, 3, j_radiolist},
|
||||
|
@ -53,8 +52,7 @@ static struct Mode *modePtr;
|
|||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, const char * const * argv)
|
||||
int main(int argc, const char *const *argv)
|
||||
{
|
||||
int offset = 0, opt_clear = 0, end_common_opts = 0, retval;
|
||||
const char *title = NULL;
|
||||
|
@ -122,8 +120,6 @@ main (int argc, const char * const * argv)
|
|||
if (modePtr->argmax && argc - offset > modePtr->argmax)
|
||||
Usage(argv[0]);
|
||||
|
||||
|
||||
|
||||
init_dialog();
|
||||
retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
|
||||
|
||||
|
@ -139,8 +135,7 @@ main (int argc, const char * const * argv)
|
|||
/*
|
||||
* Print program usage
|
||||
*/
|
||||
static void
|
||||
Usage (const char *name)
|
||||
static void Usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "\
|
||||
\ndialog, by Savio Lam (lam836@cs.cuhk.hk).\
|
||||
|
@ -169,41 +164,35 @@ Usage (const char *name)
|
|||
* These are the program jumpers
|
||||
*/
|
||||
|
||||
int
|
||||
j_menu (const char *t, int ac, const char * const * av)
|
||||
int j_menu(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]),
|
||||
atoi(av[5]), av[6], (ac - 6) / 2, av + 7);
|
||||
}
|
||||
|
||||
int
|
||||
j_checklist (const char *t, int ac, const char * const * av)
|
||||
int j_checklist(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]),
|
||||
atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);
|
||||
}
|
||||
|
||||
int
|
||||
j_radiolist (const char *t, int ac, const char * const * av)
|
||||
int j_radiolist(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]),
|
||||
atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);
|
||||
}
|
||||
|
||||
int
|
||||
j_textbox (const char *t, int ac, const char * const * av)
|
||||
int j_textbox(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4]));
|
||||
}
|
||||
|
||||
int
|
||||
j_yesno (const char *t, int ac, const char * const * av)
|
||||
int j_yesno(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4]));
|
||||
}
|
||||
|
||||
int
|
||||
j_inputbox (const char *t, int ac, const char * const * av)
|
||||
int j_inputbox(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]),
|
||||
ac == 6 ? av[5] : (char *)NULL);
|
||||
|
@ -212,15 +201,12 @@ j_inputbox (const char *t, int ac, const char * const * av)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
j_msgbox (const char *t, int ac, const char * const * av)
|
||||
int j_msgbox(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1);
|
||||
}
|
||||
|
||||
int
|
||||
j_infobox (const char *t, int ac, const char * const * av)
|
||||
int j_infobox(const char *t, int ac, const char *const *av)
|
||||
{
|
||||
return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,7 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey
|
|||
* Print the scroll indicators.
|
||||
*/
|
||||
static void
|
||||
print_arrows (WINDOW * win, int item_no, int scroll,
|
||||
int y, int x, int height)
|
||||
print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, int height)
|
||||
{
|
||||
int cur_y, cur_x;
|
||||
|
||||
|
@ -114,8 +113,7 @@ print_arrows (WINDOW * win, int item_no, int scroll,
|
|||
wattrset(win, uarrow_attr);
|
||||
waddch(win, ACS_UARROW);
|
||||
waddstr(win, "(-)");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
wattrset(win, menubox_attr);
|
||||
waddch(win, ACS_HLINE);
|
||||
waddch(win, ACS_HLINE);
|
||||
|
@ -130,8 +128,7 @@ print_arrows (WINDOW * win, int item_no, int scroll,
|
|||
wattrset(win, darrow_attr);
|
||||
waddch(win, ACS_DARROW);
|
||||
waddstr(win, "(+)");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
wattrset(win, menubox_border_attr);
|
||||
waddch(win, ACS_HLINE);
|
||||
waddch(win, ACS_HLINE);
|
||||
|
@ -145,8 +142,7 @@ print_arrows (WINDOW * win, int item_no, int scroll,
|
|||
/*
|
||||
* Display the termination buttons.
|
||||
*/
|
||||
static void
|
||||
print_buttons (WINDOW *win, int height, int width, int selected)
|
||||
static void print_buttons(WINDOW * win, int height, int width, int selected)
|
||||
{
|
||||
int x = width / 2 - 16;
|
||||
int y = height - 2;
|
||||
|
@ -166,10 +162,10 @@ int
|
|||
dialog_menu(const char *title, const char *prompt, int height, int width,
|
||||
int menu_height, const char *current, int item_no,
|
||||
const char *const *items)
|
||||
|
||||
{
|
||||
int i, j, x, y, box_x, box_y;
|
||||
int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice;
|
||||
int key = 0, button = 0, scroll = 0, choice = 0, first_item =
|
||||
0, max_choice;
|
||||
WINDOW *dialog, *menu;
|
||||
FILE *f;
|
||||
|
||||
|
@ -230,8 +226,10 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
*/
|
||||
item_x = 0;
|
||||
for (i = 0; i < item_no; i++) {
|
||||
item_x = MAX (item_x, MIN(menu_width, strlen (items[i * 2 + 1]) + 2));
|
||||
if (strcmp(current, items[i*2]) == 0) choice = i;
|
||||
item_x =
|
||||
MAX(item_x, MIN(menu_width, strlen(items[i * 2 + 1]) + 2));
|
||||
if (strcmp(current, items[i * 2]) == 0)
|
||||
choice = i;
|
||||
}
|
||||
|
||||
item_x = (menu_width - item_x) / 2;
|
||||
|
@ -261,7 +259,8 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
|
||||
/* Print the menu */
|
||||
for (i = 0; i < max_choice; i++) {
|
||||
print_item (menu, items[(first_item + i) * 2 + 1], i, i == choice,
|
||||
print_item(menu, items[(first_item + i) * 2 + 1], i,
|
||||
i == choice,
|
||||
(items[(first_item + i) * 2][0] != ':'));
|
||||
}
|
||||
|
||||
|
@ -277,20 +276,27 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
while (key != ESC) {
|
||||
key = wgetch(menu);
|
||||
|
||||
if (key < 256 && isalpha(key)) key = tolower(key);
|
||||
if (key < 256 && isalpha(key))
|
||||
key = tolower(key);
|
||||
|
||||
if (strchr("ynmh", key))
|
||||
i = max_choice;
|
||||
else {
|
||||
for (i = choice + 1; i < max_choice; i++) {
|
||||
j = first_alpha(items[(scroll+i)*2+1], "YyNnMmHh");
|
||||
if (key == tolower(items[(scroll+i)*2+1][j]))
|
||||
j = first_alpha(items[(scroll + i) * 2 + 1],
|
||||
"YyNnMmHh");
|
||||
if (key ==
|
||||
tolower(items[(scroll + i) * 2 + 1][j]))
|
||||
break;
|
||||
}
|
||||
if (i == max_choice)
|
||||
for (i = 0; i < max_choice; i++) {
|
||||
j = first_alpha(items[(scroll+i)*2+1], "YyNnMmHh");
|
||||
if (key == tolower(items[(scroll+i)*2+1][j]))
|
||||
j = first_alpha(items
|
||||
[(scroll + i) * 2 + 1],
|
||||
"YyNnMmHh");
|
||||
if (key ==
|
||||
tolower(items[(scroll + i) * 2 + 1]
|
||||
[j]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +306,8 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
key == '-' || key == '+' ||
|
||||
key == KEY_PPAGE || key == KEY_NPAGE) {
|
||||
|
||||
print_item (menu, items[(scroll+choice)*2+1], choice, FALSE,
|
||||
print_item(menu, items[(scroll + choice) * 2 + 1],
|
||||
choice, FALSE,
|
||||
(items[(scroll + choice) * 2][0] != ':'));
|
||||
|
||||
if (key == KEY_UP || key == '-') {
|
||||
|
@ -312,15 +319,20 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
|
||||
scroll--;
|
||||
|
||||
print_item (menu, items[scroll * 2 + 1], 0, FALSE,
|
||||
(items[scroll*2][0] != ':'));
|
||||
print_item(menu, items[scroll * 2 + 1],
|
||||
0, FALSE,
|
||||
(items[scroll * 2][0] !=
|
||||
':'));
|
||||
} else
|
||||
choice = MAX(choice - 1, 0);
|
||||
|
||||
} else if (key == KEY_DOWN || key == '+') {
|
||||
|
||||
print_item (menu, items[(scroll+choice)*2+1], choice, FALSE,
|
||||
(items[(scroll+choice)*2][0] != ':'));
|
||||
print_item(menu,
|
||||
items[(scroll + choice) * 2 + 1],
|
||||
choice, FALSE,
|
||||
(items[(scroll + choice) * 2][0] !=
|
||||
':'));
|
||||
|
||||
if ((choice > max_choice - 3) &&
|
||||
(scroll + max_choice < item_no)
|
||||
|
@ -332,11 +344,16 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
|
||||
scroll++;
|
||||
|
||||
print_item (menu, items[(scroll+max_choice-1)*2+1],
|
||||
print_item(menu,
|
||||
items[(scroll + max_choice -
|
||||
1) * 2 + 1],
|
||||
max_choice - 1, FALSE,
|
||||
(items[(scroll+max_choice-1)*2][0] != ':'));
|
||||
(items
|
||||
[(scroll + max_choice -
|
||||
1) * 2][0] != ':'));
|
||||
} else
|
||||
choice = MIN(choice+1, max_choice-1);
|
||||
choice =
|
||||
MIN(choice + 1, max_choice - 1);
|
||||
|
||||
} else if (key == KEY_PPAGE) {
|
||||
scrollok(menu, TRUE);
|
||||
|
@ -344,8 +361,11 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
if (scroll > 0) {
|
||||
wscrl(menu, -1);
|
||||
scroll--;
|
||||
print_item (menu, items[scroll * 2 + 1], 0, FALSE,
|
||||
(items[scroll*2][0] != ':'));
|
||||
print_item(menu,
|
||||
items[scroll * 2 +
|
||||
1], 0, FALSE,
|
||||
(items[scroll * 2][0]
|
||||
!= ':'));
|
||||
} else {
|
||||
if (choice > 0)
|
||||
choice--;
|
||||
|
@ -360,9 +380,17 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
wscrl(menu, 1);
|
||||
scrollok(menu, FALSE);
|
||||
scroll++;
|
||||
print_item (menu, items[(scroll+max_choice-1)*2+1],
|
||||
max_choice-1, FALSE,
|
||||
(items[(scroll+max_choice-1)*2][0] != ':'));
|
||||
print_item(menu,
|
||||
items[(scroll +
|
||||
max_choice -
|
||||
1) * 2 + 1],
|
||||
max_choice - 1,
|
||||
FALSE,
|
||||
(items
|
||||
[(scroll +
|
||||
max_choice -
|
||||
1) * 2][0] !=
|
||||
':'));
|
||||
} else {
|
||||
if (choice + 1 < max_choice)
|
||||
choice++;
|
||||
|
@ -372,7 +400,8 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
} else
|
||||
choice = i;
|
||||
|
||||
print_item (menu, items[(scroll+choice)*2+1], choice, TRUE,
|
||||
print_item(menu, items[(scroll + choice) * 2 + 1],
|
||||
choice, TRUE,
|
||||
(items[(scroll + choice) * 2][0] != ':'));
|
||||
|
||||
print_arrows(dialog, item_no, scroll,
|
||||
|
@ -408,12 +437,18 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
delwin(dialog);
|
||||
fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
|
||||
switch (key) {
|
||||
case 's': return 3;
|
||||
case 'y': return 3;
|
||||
case 'n': return 4;
|
||||
case 'm': return 5;
|
||||
case ' ': return 6;
|
||||
case '/': return 7;
|
||||
case 's':
|
||||
return 3;
|
||||
case 'y':
|
||||
return 3;
|
||||
case 'n':
|
||||
return 4;
|
||||
case 'm':
|
||||
return 5;
|
||||
case ' ':
|
||||
return 6;
|
||||
case '/':
|
||||
return 7;
|
||||
}
|
||||
return 0;
|
||||
case 'h':
|
||||
|
@ -425,9 +460,12 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
|
|||
fprintf(stderr, "%s \"%s\"\n",
|
||||
items[(scroll + choice) * 2],
|
||||
items[(scroll + choice) * 2 + 1] +
|
||||
first_alpha(items[(scroll + choice) * 2 + 1],""));
|
||||
first_alpha(items
|
||||
[(scroll + choice) * 2 + 1],
|
||||
""));
|
||||
else
|
||||
fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
|
||||
fprintf(stderr, "%s\n",
|
||||
items[(scroll + choice) * 2]);
|
||||
|
||||
remove("lxdialog.scrltmp");
|
||||
return button;
|
||||
|
|
|
@ -68,8 +68,7 @@ dialog_msgbox (const char *title, const char *prompt, int height, int width,
|
|||
wattrset(dialog, dialog_attr);
|
||||
waddch(dialog, ACS_RTEE);
|
||||
|
||||
print_button (dialog, " Ok ",
|
||||
height - 2, width / 2 - 4, TRUE);
|
||||
print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE);
|
||||
|
||||
wrefresh(dialog);
|
||||
while (key != ESC && key != '\n' && key != ' ' &&
|
||||
|
|
|
@ -34,8 +34,7 @@ static char *buf, *page;
|
|||
/*
|
||||
* Display text from a file in a dialog box.
|
||||
*/
|
||||
int
|
||||
dialog_textbox (const char *title, const char *file, int height, int width)
|
||||
int dialog_textbox(const char *title, const char *file, int height, int width)
|
||||
{
|
||||
int i, x, y, cur_x, cur_y, fpos, key = 0;
|
||||
int passed_end;
|
||||
|
@ -55,19 +54,22 @@ dialog_textbox (const char *title, const char *file, int height, int width)
|
|||
since it's only the last byte offset from the beginning */
|
||||
if ((file_size = lseek(fd, 0, SEEK_END)) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError getting file size in dialog_textbox().\n");
|
||||
fprintf(stderr,
|
||||
"\nError getting file size in dialog_textbox().\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* Restore file pointer to beginning of file after getting file size */
|
||||
if (lseek(fd, 0, SEEK_SET) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n");
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer in dialog_textbox().\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* Allocate space for read buffer */
|
||||
if ((buf = malloc(BUF_SIZE + 1)) == NULL) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n");
|
||||
fprintf(stderr,
|
||||
"\nCan't allocate memory in dialog_textbox().\n");
|
||||
exit(-1);
|
||||
}
|
||||
if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) {
|
||||
|
@ -82,7 +84,6 @@ dialog_textbox (const char *title, const char *file, int height, int width)
|
|||
x = (COLS - width) / 2;
|
||||
y = (LINES - height) / 2;
|
||||
|
||||
|
||||
draw_shadow(stdscr, y, x, height, width);
|
||||
|
||||
dialog = newwin(height, width, y, x);
|
||||
|
@ -156,11 +157,13 @@ dialog_textbox (const char *title, const char *file, int height, int width)
|
|||
if (fpos > bytes_read) { /* Yes, we have to read it in */
|
||||
if (lseek(fd, 0, SEEK_SET) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer in "
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer in "
|
||||
"dialog_textbox().\n");
|
||||
exit(-1);
|
||||
}
|
||||
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
|
||||
if ((bytes_read =
|
||||
read(fd, buf, BUF_SIZE)) == -1) {
|
||||
endwin();
|
||||
fprintf(stderr,
|
||||
"\nError reading file in dialog_textbox().\n");
|
||||
|
@ -193,7 +196,8 @@ dialog_textbox (const char *title, const char *file, int height, int width)
|
|||
"\nError moving file pointer in dialog_textbox().\n");
|
||||
exit(-1);
|
||||
}
|
||||
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
|
||||
if ((bytes_read =
|
||||
read(fd, buf, BUF_SIZE)) == -1) {
|
||||
endwin();
|
||||
fprintf(stderr,
|
||||
"\nError reading file in dialog_textbox().\n");
|
||||
|
@ -324,8 +328,7 @@ dialog_textbox (const char *title, const char *file, int height, int width)
|
|||
* Go back 'n' lines in text file. Called by dialog_textbox().
|
||||
* 'page' will be updated to point to the desired line in 'buf'.
|
||||
*/
|
||||
static void
|
||||
back_lines (int n)
|
||||
static void back_lines(int n)
|
||||
{
|
||||
int i, fpos;
|
||||
|
||||
|
@ -339,7 +342,8 @@ back_lines (int n)
|
|||
if (page == buf) {
|
||||
if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer in "
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer in "
|
||||
"back_lines().\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -354,24 +358,30 @@ back_lines (int n)
|
|||
/* No, move less then */
|
||||
if (lseek(fd, 0, SEEK_SET) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer in "
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer in "
|
||||
"back_lines().\n");
|
||||
exit(-1);
|
||||
}
|
||||
page = buf + fpos - bytes_read;
|
||||
} else { /* Move backward BUF_SIZE/2 bytes */
|
||||
if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR)
|
||||
if (lseek
|
||||
(fd, -(BUF_SIZE / 2 + bytes_read),
|
||||
SEEK_CUR)
|
||||
== -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer "
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer "
|
||||
"in back_lines().\n");
|
||||
exit(-1);
|
||||
}
|
||||
page = buf + BUF_SIZE / 2;
|
||||
}
|
||||
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
|
||||
if ((bytes_read =
|
||||
read(fd, buf, BUF_SIZE)) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError reading file in back_lines().\n");
|
||||
fprintf(stderr,
|
||||
"\nError reading file in back_lines().\n");
|
||||
exit(-1);
|
||||
}
|
||||
buf[bytes_read] = '\0';
|
||||
|
@ -401,26 +411,34 @@ back_lines (int n)
|
|||
/* Really possible to move backward BUF_SIZE/2 bytes? */
|
||||
if (fpos < BUF_SIZE / 2 + bytes_read) {
|
||||
/* No, move less then */
|
||||
if (lseek (fd, 0, SEEK_SET) == -1) {
|
||||
if (lseek(fd, 0, SEEK_SET) ==
|
||||
-1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer "
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer "
|
||||
"in back_lines().\n");
|
||||
exit(-1);
|
||||
}
|
||||
page = buf + fpos - bytes_read;
|
||||
} else { /* Move backward BUF_SIZE/2 bytes */
|
||||
if (lseek (fd, -(BUF_SIZE / 2 + bytes_read),
|
||||
if (lseek
|
||||
(fd,
|
||||
-(BUF_SIZE / 2 +
|
||||
bytes_read),
|
||||
SEEK_CUR) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer"
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer"
|
||||
" in back_lines().\n");
|
||||
exit(-1);
|
||||
}
|
||||
page = buf + BUF_SIZE / 2;
|
||||
}
|
||||
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
|
||||
if ((bytes_read =
|
||||
read(fd, buf, BUF_SIZE)) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError reading file in "
|
||||
fprintf(stderr,
|
||||
"\nError reading file in "
|
||||
"back_lines().\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -437,8 +455,7 @@ back_lines (int n)
|
|||
/*
|
||||
* Print a new page of text. Called by dialog_textbox().
|
||||
*/
|
||||
static void
|
||||
print_page (WINDOW * win, int height, int width)
|
||||
static void print_page(WINDOW * win, int height, int width)
|
||||
{
|
||||
int i, passed_end = 0;
|
||||
|
||||
|
@ -456,8 +473,7 @@ print_page (WINDOW * win, int height, int width)
|
|||
/*
|
||||
* Print a new line of text. Called by dialog_textbox() and print_page().
|
||||
*/
|
||||
static void
|
||||
print_line (WINDOW * win, int row, int width)
|
||||
static void print_line(WINDOW * win, int row, int width)
|
||||
{
|
||||
int y, x;
|
||||
char *line;
|
||||
|
@ -486,8 +502,7 @@ print_line (WINDOW * win, int row, int width)
|
|||
* 'page' should point to start of current line before calling, and will be
|
||||
* updated to point to start of next line.
|
||||
*/
|
||||
static char *
|
||||
get_line (void)
|
||||
static char *get_line(void)
|
||||
{
|
||||
int i = 0, fpos;
|
||||
static char line[MAX_LEN + 1];
|
||||
|
@ -498,16 +513,19 @@ get_line (void)
|
|||
/* Either end of file or end of buffer reached */
|
||||
if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer in "
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer in "
|
||||
"get_line().\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (fpos < file_size) { /* Not end of file yet */
|
||||
/* We've reached end of buffer, but not end of file yet,
|
||||
so read next part of file into buffer */
|
||||
if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
|
||||
if ((bytes_read =
|
||||
read(fd, buf, BUF_SIZE)) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError reading file in get_line().\n");
|
||||
fprintf(stderr,
|
||||
"\nError reading file in get_line().\n");
|
||||
exit(-1);
|
||||
}
|
||||
buf[bytes_read] = '\0';
|
||||
|
@ -537,14 +555,14 @@ get_line (void)
|
|||
/*
|
||||
* Print current position
|
||||
*/
|
||||
static void
|
||||
print_position (WINDOW * win, int height, int width)
|
||||
static void print_position(WINDOW * win, int height, int width)
|
||||
{
|
||||
int fpos, percent;
|
||||
|
||||
if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) {
|
||||
endwin();
|
||||
fprintf (stderr, "\nError moving file pointer in print_position().\n");
|
||||
fprintf(stderr,
|
||||
"\nError moving file pointer in print_position().\n");
|
||||
exit(-1);
|
||||
}
|
||||
wattrset(win, position_indicator_attr);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "dialog.h"
|
||||
|
||||
|
||||
/* use colors by default? */
|
||||
bool use_colors = 1;
|
||||
|
||||
|
@ -32,8 +31,7 @@ const char *dialog_result;
|
|||
/*
|
||||
* Attribute values, default is for mono display
|
||||
*/
|
||||
chtype attributes[] =
|
||||
{
|
||||
chtype attributes[] = {
|
||||
A_NORMAL, /* screen_attr */
|
||||
A_NORMAL, /* shadow_attr */
|
||||
A_NORMAL, /* dialog_attr */
|
||||
|
@ -65,14 +63,12 @@ chtype attributes[] =
|
|||
A_BOLD /* darrow_attr */
|
||||
};
|
||||
|
||||
|
||||
#include "colors.h"
|
||||
|
||||
/*
|
||||
* Table of color values
|
||||
*/
|
||||
int color_table[][3] =
|
||||
{
|
||||
int color_table[][3] = {
|
||||
{SCREEN_FG, SCREEN_BG, SCREEN_HL},
|
||||
{SHADOW_FG, SHADOW_BG, SHADOW_HL},
|
||||
{DIALOG_FG, DIALOG_BG, DIALOG_HL},
|
||||
|
@ -81,8 +77,10 @@ int color_table[][3] =
|
|||
{BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL},
|
||||
{BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL},
|
||||
{BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL},
|
||||
{BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL},
|
||||
{BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL},
|
||||
{BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG,
|
||||
BUTTON_KEY_INACTIVE_HL},
|
||||
{BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG,
|
||||
BUTTON_LABEL_ACTIVE_HL},
|
||||
{BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG,
|
||||
BUTTON_LABEL_INACTIVE_HL},
|
||||
{INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL},
|
||||
|
@ -108,8 +106,7 @@ int color_table[][3] =
|
|||
/*
|
||||
* Set window to attribute 'attr'
|
||||
*/
|
||||
void
|
||||
attr_clear (WINDOW * win, int height, int width, chtype attr)
|
||||
void attr_clear(WINDOW * win, int height, int width, chtype attr)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -141,27 +138,23 @@ void dialog_clear (void)
|
|||
/*
|
||||
* Do some initialization for dialog
|
||||
*/
|
||||
void
|
||||
init_dialog (void)
|
||||
void init_dialog(void)
|
||||
{
|
||||
initscr(); /* Init curses */
|
||||
keypad(stdscr, TRUE);
|
||||
cbreak();
|
||||
noecho();
|
||||
|
||||
|
||||
if (use_colors) /* Set up colors */
|
||||
color_setup();
|
||||
|
||||
|
||||
dialog_clear();
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup for color display
|
||||
*/
|
||||
void
|
||||
color_setup (void)
|
||||
void color_setup(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -181,21 +174,18 @@ color_setup (void)
|
|||
/*
|
||||
* End using dialog functions.
|
||||
*/
|
||||
void
|
||||
end_dialog (void)
|
||||
void end_dialog(void)
|
||||
{
|
||||
endwin();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print a string of text in a window, automatically wrap around to the
|
||||
* next line if the string is too long to fit on one line. Newline
|
||||
* characters '\n' are replaced by spaces. We start on a new line
|
||||
* if there is no room for at least 4 nonblanks following a double-space.
|
||||
*/
|
||||
void
|
||||
print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
|
||||
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
||||
{
|
||||
int newl, cur_x, cur_y;
|
||||
int i, prompt_len, room, wlen;
|
||||
|
@ -209,7 +199,8 @@ print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
|
|||
* Remove newlines
|
||||
*/
|
||||
for (i = 0; i < prompt_len; i++) {
|
||||
if(tempstr[i] == '\n') tempstr[i] = ' ';
|
||||
if (tempstr[i] == '\n')
|
||||
tempstr[i] = ' ';
|
||||
}
|
||||
|
||||
if (prompt_len <= width - x * 2) { /* If prompt is short */
|
||||
|
@ -231,8 +222,10 @@ print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
|
|||
room = width - cur_x;
|
||||
wlen = strlen(word);
|
||||
if (wlen > room ||
|
||||
(newl && wlen < 4 && sp && wlen+1+strlen(sp) > room
|
||||
&& (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) {
|
||||
(newl && wlen < 4 && sp
|
||||
&& wlen + 1 + strlen(sp) > room
|
||||
&& (!(sp2 = index(sp, ' '))
|
||||
|| wlen + 1 + (sp2 - sp) > room))) {
|
||||
cur_y++;
|
||||
cur_x = x;
|
||||
}
|
||||
|
@ -254,8 +247,7 @@ print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
|
|||
/*
|
||||
* Print a button
|
||||
*/
|
||||
void
|
||||
print_button (WINDOW * win, const char *label, int y, int x, int selected)
|
||||
void print_button(WINDOW * win, const char *label, int y, int x, int selected)
|
||||
{
|
||||
int i, temp;
|
||||
|
||||
|
@ -317,8 +309,7 @@ draw_box (WINDOW * win, int y, int x, int height, int width,
|
|||
* Draw shadows along the right and bottom edge to give a more 3D look
|
||||
* to the boxes
|
||||
*/
|
||||
void
|
||||
draw_shadow (WINDOW * win, int y, int x, int height, int width)
|
||||
void draw_shadow(WINDOW * win, int y, int x, int height, int width)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -339,19 +330,19 @@ draw_shadow (WINDOW * win, int y, int x, int height, int width)
|
|||
/*
|
||||
* Return the position of the first alphabetic character in a string.
|
||||
*/
|
||||
int
|
||||
first_alpha(const char *string, const char *exempt)
|
||||
int first_alpha(const char *string, const char *exempt)
|
||||
{
|
||||
int i, in_paren = 0, c;
|
||||
|
||||
for (i = 0; i < strlen(string); i++) {
|
||||
c = tolower(string[i]);
|
||||
|
||||
if (strchr("<[(", c)) ++in_paren;
|
||||
if (strchr(">])", c) && in_paren > 0) --in_paren;
|
||||
if (strchr("<[(", c))
|
||||
++in_paren;
|
||||
if (strchr(">])", c) && in_paren > 0)
|
||||
--in_paren;
|
||||
|
||||
if ((! in_paren) && isalpha(c) &&
|
||||
strchr(exempt, c) == 0)
|
||||
if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
/*
|
||||
* Display termination buttons
|
||||
*/
|
||||
static void
|
||||
print_buttons(WINDOW *dialog, int height, int width, int selected)
|
||||
static void print_buttons(WINDOW * dialog, int height, int width, int selected)
|
||||
{
|
||||
int x = width / 2 - 10;
|
||||
int y = height - 2;
|
||||
|
@ -40,8 +39,7 @@ print_buttons(WINDOW *dialog, int height, int width, int selected)
|
|||
/*
|
||||
* Display a dialog box with two buttons - Yes and No
|
||||
*/
|
||||
int
|
||||
dialog_yesno (const char *title, const char *prompt, int height, int width)
|
||||
int dialog_yesno(const char *title, const char *prompt, int height, int width)
|
||||
{
|
||||
int i, x, y, key = 0, button = 0;
|
||||
WINDOW *dialog;
|
||||
|
|
Loading…
Add table
Reference in a new issue