31 int x = width / 2 - 11;
34 print_button(dialog, gettext(
" Ok "), y, x, selected == 0);
35 print_button(dialog, gettext(
" Help "), y, x + 14, selected == 1);
37 wmove(dialog, y, x + 1 + 14 * selected);
47 int i,
x,
y, box_y, box_x, box_width;
48 int input_x = 0, scroll = 0,
key = 0,
button = -1;
58 if (getmaxy(stdscr) <= (height - 2))
60 if (getmaxx(stdscr) <= (width - 2))
69 dialog = newwin(height, width, y, x);
72 draw_box(dialog, 0, 0, height, width,
73 dlg.dialog.atr,
dlg.border.atr);
74 wattrset(dialog,
dlg.border.atr);
75 mvwaddch(dialog, height - 3, 0,
ACS_LTEE);
76 for (i = 0; i < width - 2; i++)
78 wattrset(dialog,
dlg.dialog.atr);
83 wattrset(dialog,
dlg.dialog.atr);
87 box_width = width - 6;
90 box_x = (width - box_width) / 2;
91 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
92 dlg.dialog.atr,
dlg.border.atr);
94 print_buttons(dialog, height, width, 0);
97 wmove(dialog, box_y, box_x);
98 wattrset(dialog,
dlg.inputbox.atr);
102 if (input_x >= box_width) {
103 scroll = input_x - box_width + 1;
104 input_x = box_width - 1;
105 for (i = 0; i < box_width - 1; i++)
106 waddch(dialog, instr[scroll + i]);
108 waddstr(dialog, instr);
111 wmove(dialog, box_y, box_x + input_x);
116 key = wgetch(dialog);
130 if (input_x || scroll) {
131 wattrset(dialog,
dlg.inputbox.atr);
133 scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
134 wmove(dialog, box_y, box_x);
135 for (i = 0; i < box_width; i++)
137 instr[scroll + input_x + i] ?
138 instr[scroll + input_x + i] :
' ');
139 input_x =
strlen(instr) - scroll;
142 instr[scroll + input_x] =
'\0';
143 mvwaddch(dialog, box_y, input_x + box_x,
' ');
144 wmove(dialog, box_y, input_x + box_x);
150 if (scroll + input_x <
MAX_LEN) {
151 wattrset(dialog,
dlg.inputbox.atr);
152 instr[scroll + input_x] =
key;
153 instr[scroll + input_x + 1] =
'\0';
154 if (input_x == box_width - 1) {
156 wmove(dialog, box_y, box_x);
157 for (i = 0; i < box_width - 1; i++)
158 waddch(dialog, instr [scroll + i]);
160 wmove(dialog, box_y, input_x++ + box_x);
184 print_buttons(dialog, height, width, 1);
188 print_buttons(dialog, height, width, 0);
189 wmove(dialog, box_y, box_x + input_x);
194 print_buttons(dialog, height, width, 0);
204 print_buttons(dialog, height, width, 0);
208 print_buttons(dialog, height, width, 1);
212 print_buttons(dialog, height, width, 0);
213 wmove(dialog, box_y, box_x + input_x);