diff options
Diffstat (limited to 'scripts/config/lxdialog/menubox.c')
-rw-r--r-- | scripts/config/lxdialog/menubox.c | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/scripts/config/lxdialog/menubox.c b/scripts/config/lxdialog/menubox.c index 873dc587b..d0990c34e 100644 --- a/scripts/config/lxdialog/menubox.c +++ b/scripts/config/lxdialog/menubox.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * | 26 | * |
27 | * *) A bugfix for the Page-Down problem | 27 | * *) A bugfix for the Page-Down problem |
28 | * | 28 | * |
29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set | 29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set |
30 | * to the first position in the menu box. Now lxdialog is a bit | 30 | * to the first position in the menu box. Now lxdialog is a bit |
31 | * smarter and works more like other menu systems (just have a look at | 31 | * smarter and works more like other menu systems (just have a look at |
32 | * it). | 32 | * it). |
@@ -78,8 +78,8 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey | |||
78 | wmove (win, choice, 0); | 78 | wmove (win, choice, 0); |
79 | #if OLD_NCURSES | 79 | #if OLD_NCURSES |
80 | { | 80 | { |
81 | int i; | 81 | int i; |
82 | for (i = 0; i < menu_width; i++) | 82 | for (i = 0; i < menu_width; i++) |
83 | waddch (win, ' '); | 83 | waddch (win, ' '); |
84 | } | 84 | } |
85 | #else | 85 | #else |
@@ -88,8 +88,8 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey | |||
88 | wattrset (win, selected ? item_selected_attr : item_attr); | 88 | wattrset (win, selected ? item_selected_attr : item_attr); |
89 | mvwaddstr (win, choice, item_x, menu_item); | 89 | mvwaddstr (win, choice, item_x, menu_item); |
90 | if (hotkey) { | 90 | if (hotkey) { |
91 | wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); | 91 | wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); |
92 | mvwaddch(win, choice, item_x+j, menu_item[j]); | 92 | mvwaddch(win, choice, item_x+j, menu_item[j]); |
93 | } | 93 | } |
94 | if (selected) { | 94 | if (selected) { |
95 | wmove (win, choice, item_x+1); | 95 | wmove (win, choice, item_x+1); |
@@ -225,7 +225,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
225 | 225 | ||
226 | /* | 226 | /* |
227 | * Find length of longest item in order to center menu. | 227 | * Find length of longest item in order to center menu. |
228 | * Set 'choice' to default item. | 228 | * Set 'choice' to default item. |
229 | */ | 229 | */ |
230 | item_x = 0; | 230 | item_x = 0; |
231 | for (i = 0; i < item_no; i++) { | 231 | for (i = 0; i < item_no; i++) { |
@@ -261,7 +261,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
261 | /* Print the menu */ | 261 | /* Print the menu */ |
262 | for (i=0; i < max_choice; i++) { | 262 | for (i=0; i < max_choice; i++) { |
263 | print_item (menu, items[first_item + i]->name, i, i == choice, | 263 | print_item (menu, items[first_item + i]->name, i, i == choice, |
264 | (items[first_item + i]->tag[0] != ':')); | 264 | (items[first_item + i]->tag[0] != ':')); |
265 | } | 265 | } |
266 | 266 | ||
267 | wnoutrefresh (menu); | 267 | wnoutrefresh (menu); |
@@ -281,107 +281,107 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
281 | if (strchr("ynmh", key)) | 281 | if (strchr("ynmh", key)) |
282 | i = max_choice; | 282 | i = max_choice; |
283 | else { | 283 | else { |
284 | for (i = choice+1; i < max_choice; i++) { | 284 | for (i = choice+1; i < max_choice; i++) { |
285 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); | 285 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); |
286 | if (key == tolower(items[scroll + i]->name[j])) | 286 | if (key == tolower(items[scroll + i]->name[j])) |
287 | break; | 287 | break; |
288 | } | 288 | } |
289 | if (i == max_choice) | 289 | if (i == max_choice) |
290 | for (i = 0; i < max_choice; i++) { | 290 | for (i = 0; i < max_choice; i++) { |
291 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); | 291 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); |
292 | if (key == tolower(items[scroll + i]->name[j])) | 292 | if (key == tolower(items[scroll + i]->name[j])) |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | if (i < max_choice || | 297 | if (i < max_choice || |
298 | key == KEY_UP || key == KEY_DOWN || | 298 | key == KEY_UP || key == KEY_DOWN || |
299 | key == '-' || key == '+' || | 299 | key == '-' || key == '+' || |
300 | key == KEY_PPAGE || key == KEY_NPAGE) { | 300 | key == KEY_PPAGE || key == KEY_NPAGE) { |
301 | 301 | ||
302 | print_item (menu, items[scroll + choice]->name, choice, FALSE, | 302 | print_item (menu, items[scroll + choice]->name, choice, FALSE, |
303 | (items[scroll + choice]->tag[0] != ':')); | 303 | (items[scroll + choice]->tag[0] != ':')); |
304 | 304 | ||
305 | if (key == KEY_UP || key == '-') { | 305 | if (key == KEY_UP || key == '-') { |
306 | if (choice < 2 && scroll) { | 306 | if (choice < 2 && scroll) { |
307 | /* Scroll menu down */ | 307 | /* Scroll menu down */ |
308 | scrollok (menu, TRUE); | 308 | scrollok (menu, TRUE); |
309 | wscrl (menu, -1); | 309 | wscrl (menu, -1); |
310 | scrollok (menu, FALSE); | 310 | scrollok (menu, FALSE); |
311 | 311 | ||
312 | scroll--; | 312 | scroll--; |
313 | 313 | ||
314 | print_item (menu, items[scroll]->name, 0, FALSE, | 314 | print_item (menu, items[scroll]->name, 0, FALSE, |
315 | (items[scroll]->tag[0] != ':')); | 315 | (items[scroll]->tag[0] != ':')); |
316 | } else | 316 | } else |
317 | choice = MAX(choice - 1, 0); | 317 | choice = MAX(choice - 1, 0); |
318 | 318 | ||
319 | } else if (key == KEY_DOWN || key == '+') { | 319 | } else if (key == KEY_DOWN || key == '+') { |
320 | 320 | ||
321 | print_item (menu, items[scroll + choice]->name, choice, FALSE, | 321 | print_item (menu, items[scroll + choice]->name, choice, FALSE, |
322 | (items[scroll + choice]->tag[0] != ':')); | 322 | (items[scroll + choice]->tag[0] != ':')); |
323 | 323 | ||
324 | if ((choice > max_choice-3) && | 324 | if ((choice > max_choice-3) && |
325 | (scroll + max_choice < item_no) | 325 | (scroll + max_choice < item_no) |
326 | ) { | 326 | ) { |
327 | /* Scroll menu up */ | 327 | /* Scroll menu up */ |
328 | scrollok (menu, TRUE); | 328 | scrollok (menu, TRUE); |
329 | scroll (menu); | 329 | scroll (menu); |
330 | scrollok (menu, FALSE); | 330 | scrollok (menu, FALSE); |
331 | 331 | ||
332 | scroll++; | 332 | scroll++; |
333 | 333 | ||
334 | print_item (menu, items[scroll + max_choice - 1]->name, | 334 | print_item (menu, items[scroll + max_choice - 1]->name, |
335 | max_choice-1, FALSE, | 335 | max_choice-1, FALSE, |
336 | (items[scroll + max_choice - 1]->tag[0] != ':')); | 336 | (items[scroll + max_choice - 1]->tag[0] != ':')); |
337 | } else | 337 | } else |
338 | choice = MIN(choice+1, max_choice-1); | 338 | choice = MIN(choice+1, max_choice-1); |
339 | 339 | ||
340 | } else if (key == KEY_PPAGE) { | 340 | } else if (key == KEY_PPAGE) { |
341 | scrollok (menu, TRUE); | 341 | scrollok (menu, TRUE); |
342 | for (i=0; (i < max_choice); i++) { | 342 | for (i=0; (i < max_choice); i++) { |
343 | if (scroll > 0) { | 343 | if (scroll > 0) { |
344 | wscrl (menu, -1); | 344 | wscrl (menu, -1); |
345 | scroll--; | 345 | scroll--; |
346 | print_item (menu, items[scroll]->name, 0, FALSE, | 346 | print_item (menu, items[scroll]->name, 0, FALSE, |
347 | (items[scroll]->tag[0] != ':')); | 347 | (items[scroll]->tag[0] != ':')); |
348 | } else { | 348 | } else { |
349 | if (choice > 0) | 349 | if (choice > 0) |
350 | choice--; | 350 | choice--; |
351 | } | 351 | } |
352 | } | 352 | } |
353 | scrollok (menu, FALSE); | 353 | scrollok (menu, FALSE); |
354 | 354 | ||
355 | } else if (key == KEY_NPAGE) { | 355 | } else if (key == KEY_NPAGE) { |
356 | for (i=0; (i < max_choice); i++) { | 356 | for (i=0; (i < max_choice); i++) { |
357 | if (scroll+max_choice < item_no) { | 357 | if (scroll+max_choice < item_no) { |
358 | scrollok (menu, TRUE); | 358 | scrollok (menu, TRUE); |
359 | scroll(menu); | 359 | scroll(menu); |
360 | scrollok (menu, FALSE); | 360 | scrollok (menu, FALSE); |
361 | scroll++; | 361 | scroll++; |
362 | print_item (menu, items[scroll + max_choice - 1]->name, | 362 | print_item (menu, items[scroll + max_choice - 1]->name, |
363 | max_choice-1, FALSE, | 363 | max_choice-1, FALSE, |
364 | (items[scroll + max_choice - 1]->tag[0] != ':')); | 364 | (items[scroll + max_choice - 1]->tag[0] != ':')); |
365 | } else { | 365 | } else { |
366 | if (choice+1 < max_choice) | 366 | if (choice+1 < max_choice) |
367 | choice++; | 367 | choice++; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | } else | 371 | } else |
372 | choice = i; | 372 | choice = i; |
373 | 373 | ||
374 | print_item (menu, items[scroll + choice]->name, choice, TRUE, | 374 | print_item (menu, items[scroll + choice]->name, choice, TRUE, |
375 | (items[scroll + choice]->tag[0] != ':')); | 375 | (items[scroll + choice]->tag[0] != ':')); |
376 | 376 | ||
377 | print_arrows(dialog, item_no, scroll, | 377 | print_arrows(dialog, item_no, scroll, |
378 | box_y, box_x+item_x+1, menu_height); | 378 | box_y, box_x+item_x+1, menu_height); |
379 | 379 | ||
380 | wnoutrefresh (dialog); | 380 | wnoutrefresh (dialog); |
381 | wrefresh (menu); | 381 | wrefresh (menu); |
382 | 382 | ||
383 | continue; /* wait for another key press */ | 383 | continue; /* wait for another key press */ |
384 | } | 384 | } |
385 | 385 | ||
386 | switch (key) { | 386 | switch (key) { |
387 | case KEY_LEFT: | 387 | case KEY_LEFT: |
@@ -405,15 +405,15 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
405 | fclose(f); | 405 | fclose(f); |
406 | } | 406 | } |
407 | delwin (dialog); | 407 | delwin (dialog); |
408 | items[scroll + choice]->selected = 1; | 408 | items[scroll + choice]->selected = 1; |
409 | switch (key) { | 409 | switch (key) { |
410 | case 's': return 3; | 410 | case 's': return 3; |
411 | case 'y': return 3; | 411 | case 'y': return 3; |
412 | case 'n': return 4; | 412 | case 'n': return 4; |
413 | case 'm': return 5; | 413 | case 'm': return 5; |
414 | case ' ': return 6; | 414 | case ' ': return 6; |
415 | case '/': return 7; | 415 | case '/': return 7; |
416 | } | 416 | } |
417 | return 0; | 417 | return 0; |
418 | case 'h': | 418 | case 'h': |
419 | case '?': | 419 | case '?': |