]>
git.ipfire.org Git - people/ms/u-boot.git/blob - scripts/kconfig/lxdialog/yesno.c
2 * yesno.c -- implements the yes/no box
4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 * SPDX-License-Identifier: GPL-2.0+
13 * Display termination buttons
15 static void print_buttons(WINDOW
* dialog
, int height
, int width
, int selected
)
17 int x
= width
/ 2 - 10;
20 print_button(dialog
, gettext(" Yes "), y
, x
, selected
== 0);
21 print_button(dialog
, gettext(" No "), y
, x
+ 13, selected
== 1);
23 wmove(dialog
, y
, x
+ 1 + 13 * selected
);
28 * Display a dialog box with two buttons - Yes and No
30 int dialog_yesno(const char *title
, const char *prompt
, int height
, int width
)
32 int i
, x
, y
, key
= 0, button
= 0;
36 if (getmaxy(stdscr
) < (height
+ YESNO_HEIGTH_MIN
))
37 return -ERRDISPLAYTOOSMALL
;
38 if (getmaxx(stdscr
) < (width
+ YESNO_WIDTH_MIN
))
39 return -ERRDISPLAYTOOSMALL
;
41 /* center dialog box on screen */
42 x
= (getmaxx(stdscr
) - width
) / 2;
43 y
= (getmaxy(stdscr
) - height
) / 2;
45 draw_shadow(stdscr
, y
, x
, height
, width
);
47 dialog
= newwin(height
, width
, y
, x
);
50 draw_box(dialog
, 0, 0, height
, width
,
51 dlg
.dialog
.atr
, dlg
.border
.atr
);
52 wattrset(dialog
, dlg
.border
.atr
);
53 mvwaddch(dialog
, height
- 3, 0, ACS_LTEE
);
54 for (i
= 0; i
< width
- 2; i
++)
55 waddch(dialog
, ACS_HLINE
);
56 wattrset(dialog
, dlg
.dialog
.atr
);
57 waddch(dialog
, ACS_RTEE
);
59 print_title(dialog
, title
, width
);
61 wattrset(dialog
, dlg
.dialog
.atr
);
62 print_autowrap(dialog
, prompt
, width
- 2, 1, 3);
64 print_buttons(dialog
, height
, width
, 0);
66 while (key
!= KEY_ESC
) {
81 button
= ((key
== KEY_LEFT
? --button
: ++button
) < 0) ? 1 : (button
> 1 ? 0 : button
);
83 print_buttons(dialog
, height
, width
, button
);
91 key
= on_key_esc(dialog
);
101 return key
; /* ESC pressed */