diff options
Diffstat (limited to 'conf-update.c')
-rw-r--r-- | conf-update.c | 125 |
1 files changed, 64 insertions, 61 deletions
diff --git a/conf-update.c b/conf-update.c index 5143500..009f566 100644 --- a/conf-update.c +++ b/conf-update.c @@ -192,28 +192,6 @@ int main(int argc, char **argv) { menu_changed = FALSE; while ((item_count(mymenu) > 1) && (c = wgetch(inner)) != 'q' && c != 'Q') { switch(c) { - // navigation 1up/down - case KEY_DOWN: - menu_driver(mymenu, REQ_DOWN_ITEM); - break; - case KEY_UP: - menu_driver(mymenu, REQ_UP_ITEM); - break; - //navigation 1 page up/down - case KEY_PPAGE: - menu_driver(mymenu, REQ_SCR_UPAGE); - break; - case KEY_NPAGE: - menu_driver(mymenu, REQ_SCR_DPAGE); - break; - // navigation top/bottom - case KEY_HOME: - menu_driver(mymenu, REQ_FIRST_ITEM); - break; - case KEY_END: - menu_driver(mymenu, REQ_LAST_ITEM); - break; - // select single case ' ': if ((strrchr(item_name(current_item(mymenu)), '/'))) { @@ -256,26 +234,28 @@ int main(int argc, char **argv) { } menu_driver(mymenu, REQ_FIRST_ITEM); break; - // deselect all - case 'u': - case 'U': - menu_driver(mymenu, REQ_LAST_ITEM); + // delete update + case 'd': + case 'D': + firstrun = config.check_actions; + doit = TRUE; for (i=0;i<item_count(mymenu);i++) { - menu_driver(mymenu, REQ_UP_ITEM); - set_item_value(current_item(mymenu), FALSE); - } - menu_driver(mymenu, REQ_FIRST_ITEM); - break; - // disp diff - case '\n': - case KEY_ENTER: - if (item_userptr(current_item(mymenu))) { - endwin(); - int ret = show_diff(*((char **)item_userptr(current_item(mymenu)))); - if (!ret) { - fprintf(stderr, "show_diff failed with error code: %d\n", ret); + if (item_value(items_list[i]) == TRUE || (current_item(mymenu) == items_list[i] && item_userptr(items_list[i]))) { + if (firstrun) { + doit = get_confirmation(inner, "delete"); + firstrun = false; + } + if (doit) { + myupdate = (char **)item_userptr(items_list[i]); + exit_error(!unlink(*(myupdate)), *(myupdate)); + removed_updates_ct++; + removed_updates_report = (char**)realloc(removed_updates_report, removed_updates_ct * sizeof(char *)); + removed_updates_report[removed_updates_ct-1] = get_real_filename(*myupdate); + free(*myupdate); + *myupdate = SKIP_ENTRY; + menu_changed = TRUE; + } } - reset_prog_mode(); } break; // edit update @@ -290,6 +270,16 @@ int main(int argc, char **argv) { reset_prog_mode(); } break; + // down + case KEY_DOWN: + case 'j': + menu_driver(mymenu, REQ_DOWN_ITEM); + break; + // up + case KEY_UP: + case 'k': + menu_driver(mymenu, REQ_UP_ITEM); + break; // merge interactively case 'm': case 'M': @@ -300,7 +290,6 @@ int main(int argc, char **argv) { menu_changed = TRUE; } break; - // merge/replace update case 'r': case 'R': @@ -330,28 +319,42 @@ int main(int argc, char **argv) { } } break; - // delete update - case 'd': - case 'D': - firstrun = config.check_actions; - doit = TRUE; + // deselect all + case 'u': + case 'U': + menu_driver(mymenu, REQ_LAST_ITEM); for (i=0;i<item_count(mymenu);i++) { - if (item_value(items_list[i]) == TRUE || (current_item(mymenu) == items_list[i] && item_userptr(items_list[i]))) { - if (firstrun) { - doit = get_confirmation(inner, "delete"); - firstrun = false; - } - if (doit) { - myupdate = (char **)item_userptr(items_list[i]); - exit_error(!unlink(*(myupdate)), *(myupdate)); - removed_updates_ct++; - removed_updates_report = (char**)realloc(removed_updates_report, removed_updates_ct * sizeof(char *)); - removed_updates_report[removed_updates_ct-1] = get_real_filename(*myupdate); - free(*myupdate); - *myupdate = SKIP_ENTRY; - menu_changed = TRUE; - } + menu_driver(mymenu, REQ_UP_ITEM); + set_item_value(current_item(mymenu), FALSE); + } + menu_driver(mymenu, REQ_FIRST_ITEM); + break; + // page up + case KEY_PPAGE: + menu_driver(mymenu, REQ_SCR_UPAGE); + break; + // page down + case KEY_NPAGE: + menu_driver(mymenu, REQ_SCR_DPAGE); + break; + // top + case KEY_HOME: + menu_driver(mymenu, REQ_FIRST_ITEM); + break; + // bottom + case KEY_END: + menu_driver(mymenu, REQ_LAST_ITEM); + break; + // show differences + case '\n': + case KEY_ENTER: + if (item_userptr(current_item(mymenu))) { + endwin(); + int ret = show_diff(*((char **)item_userptr(current_item(mymenu)))); + if (!ret) { + fprintf(stderr, "show_diff failed with error code: %d\n", ret); } + reset_prog_mode(); } break; case KEY_RESIZE: |