18 define(
"NCURSES_KEY_CR", 13);
24 ncurses_attron(NCURSES_A_BOLD);
26 ncurses_mvaddstr(0, 1, _(
"terminal too small (must ne at least 80 columns by 24 lines)"));
27 ncurses_attroff(NCURSES_A_BOLD);
37 ncurses_getmaxyx($fullscreen, $lines, $columns);
38 $wsel = ncurses_newwin($lines - 9, $columns - 4, 7, 2);
39 ncurses_wborder($wsel, 0, 0, 0, 0, 0, 0, 0, 0);
40 ncurses_wcolor_set($wsel, 3);
41 foreach ($tr as $k => $v) {
43 ncurses_wcolor_set($wsel, ($pairsel == 0) ? 1 : $pairsel);
44 ncurses_wattron($wsel, NCURSES_A_REVERSE);
46 ncurses_wcolor_set($wsel, 1);
48 ncurses_mvwaddstr($wsel, $k + 1, 4, ($k + 1) .
") $v");
50 ncurses_wattroff($wsel, NCURSES_A_REVERSE);
54 ncurses_wrefresh($wsel);
57 ncurses_mvaddstr($lines - 2, 4, $msg);
60 $maxsel = count($tr) - 1;
64 if ($iselect > 0) $iselect--;
67 case NCURSES_KEY_DOWN:
68 if ($iselect < $maxsel) $iselect++;
71 ncurses_getyx($wsel, $y, $x);
82 $small = ncurses_newwin(10, 50, 7, 25);
86 ncurses_wborder($small, 0, 0, 0, 0, 0, 0, 0, 0);
87 ncurses_wcolor_set($small, 1);
88 ncurses_mvwaddstr($small, 4, 5,
$ret);
89 ncurses_wattron($small, NCURSES_A_BOLD);
90 ncurses_mvwaddstr($small, 5, 5,
$err);
91 ncurses_wattroff($small, NCURSES_A_BOLD);
93 ncurses_wrefresh($small);
106 case NCURSES_KEY_BACKSPACE:
108 $s = substr(
$s, 0, -1);
126 $ncurse = ncurses_init();
128 $fullscreen = ncurses_newwin(0, 0, 0, 0);
132 ncurses_getmaxyx($fullscreen, $lines, $columns);
134 ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
135 if (ncurses_has_colors()) {
136 ncurses_start_color();
137 ncurses_init_pair(1, NCURSES_COLOR_RED, NCURSES_COLOR_BLACK);
138 ncurses_init_pair(2, NCURSES_COLOR_BLUE, NCURSES_COLOR_BLACK);
139 ncurses_init_pair(3, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLACK);
140 ncurses_init_pair(4, NCURSES_COLOR_GREEN, NCURSES_COLOR_BLACK);
141 ncurses_init_pair(5, NCURSES_COLOR_MAGENTA, NCURSES_COLOR_BLACK);
142 ncurses_init_pair(6, NCURSES_COLOR_CYAN, NCURSES_COLOR_BLACK);
143 ncurses_init_pair(7, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLACK);
145 ncurses_attron(NCURSES_A_BOLD);
146 ncurses_mvaddstr(0, 1,
$title);
147 ncurses_attroff(NCURSES_A_BOLD);
148 ncurses_color_set(6);
159 if (strpos($chars,
$cpress) ===
false) {
168 ncurses_getmaxyx($fullscreen, $lines, $columns);
170 $wact = ncurses_newwin($lines - 9, $columns - 4, 7, 2);
171 ncurses_wborder(
$wact, 0, 0, 0, 0, 0, 0, 0, 0);
172 ncurses_wcolor_set(
$wact, 3);
175 ncurses_mvaddstr($lines - 2, 4,
"Execute (Y|N|I) ? ");
183 $format =
"%2d)%-" . ($columns - 9) .
"s";
184 foreach ($actions as $k => $v) {
189 for ($i = $k -
$slice; $i < $k; $i++) {
191 ncurses_wcolor_set(
$wact, $colors[$i]);
192 ncurses_wattron(
$wact, NCURSES_A_BOLD);
193 ncurses_mvwaddstr(
$wact, $j++, 1, sprintf(
$format, ($i + 1) , substr($actions[$i], 0, $columns - 9)));
194 ncurses_wattroff(
$wact, NCURSES_A_BOLD);
198 ncurses_wattron(
$wact, NCURSES_A_BLINK);
199 ncurses_wcolor_set(
$wact, 5);
200 ncurses_mvwaddstr(
$wact, $ki, 1, sprintf(
$format, ($k + 1) , substr($v, 0, $columns - 9)));
201 ncurses_wattroff(
$wact, NCURSES_A_BLINK);
202 ncurses_wrefresh(
$wact);
203 if ((
$cpress ==
"I") && ($v[0] !=
"#")) {
204 ncurses_mvaddstr($lines - 2, 4,
"(S)kip, (E)xecute, (A)bord, (C)ontinue ?");
206 if ($ccont ==
"C")
$cpress =
"Y";
207 elseif ($ccont ==
"A") {
213 if ((
$cpress !=
"I") || ($ccont ==
"E")) {
214 ncurses_mvaddstr($lines - 2, 4,
"Executing " . ($k + 1) .
"..." . str_repeat(
" ", 40));
215 ncurses_refresh(
$wact);
217 $err = system(
"echo `date` \"" . addslashes($v) .
"\" >>" .
getTmpDir() .
"/whatchk.log");
222 if ($v[0] ==
'#') $colors[$k] = 5;
223 else $colors[$k] = 1;
224 ncurses_wcolor_set(
$wact, $colors[$k]);
227 if ($v[0] ==
'#') $colors[$k] = 5;
228 else $colors[$k] = 4;
229 ncurses_wcolor_set(
$wact, $colors[$k]);
233 if ($v[0] ==
'#') $colors[$k] = 5;
234 else $colors[$k] = 6;
235 ncurses_wcolor_set(
$wact, $colors[$k]);
238 ncurses_wattron(
$wact, NCURSES_A_BOLD);
239 ncurses_mvwaddstr(
$wact, $ki, 1, sprintf(
$format, ($k + 1) , substr($v, 0, $columns - 9)));
240 ncurses_wattroff(
$wact, NCURSES_A_BOLD);
241 ncurses_wrefresh(
$wact);
248 ncurses_getmaxyx($fullscreen, $lines, $columns);
250 if ($wlist ==
"") $wlist = ncurses_newwin($lines - 9, $columns - 4, 7, 2);
251 ncurses_wborder($wlist, 0, 0, 0, 0, 0, 0, 0, 0);
252 ncurses_wcolor_set($wlist, 3);
254 $maxsel = count($actions);
261 $format =
"%2d)%-" . ($columns - 9) .
"s";
264 if ($end > $maxsel) $end = $maxsel;
267 for ($k =
$start; $k < $end; $k++) {
268 ncurses_mvwaddstr($wlist, $k + 1 -
$start, 1, sprintf(
$format, ($k + 1) , substr($actions[$k], 0, $columns - 9)));
270 if ($end < $maxsel) ncurses_mvwaddstr($wlist, $end -
$start + 1, 4,
" next...");
271 else ncurses_mvwaddstr($wlist, $end -
$start + 1, 4,
" ");
273 ncurses_wrefresh($wlist);
274 ncurses_mvaddstr($lines - 2, 4,
"Press Return Key to continue" . str_repeat(
" ", 40));
286 case NCURSES_KEY_DOWN:
290 case NCURSES_KEY_NPAGE:
295 case NCURSES_KEY_PPAGE:
307 ncurses_mvaddstr($lines - 2, 4,
"Press Return Key" . str_repeat(
" ", 40));
313 ncurses_wrefresh($wlist);