From: Jaakko Heinonen Date: Thu, 6 Nov 2003 17:14:06 +0000 (+0000) Subject: added duplicate item command X-Git-Tag: upstream/0.6.1~2^2~239 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=28b7c8bdd6dc85f7412233d99e5526e148f81d81;p=pkg%2Fabook.git added duplicate item command --- diff --git a/help.h b/help.h index f9058bb..95d27f4 100644 --- a/help.h +++ b/help.h @@ -16,6 +16,7 @@ static char *mainhelp[] = { " enter view/edit item\n", " a add item\n", " r / del remove selected items\n", +" D duplicate item\n", "\n", " space select item\n", " + select all\n", diff --git a/list.c b/list.c index 25c5382..7197723 100644 --- a/list.c +++ b/list.c @@ -340,3 +340,25 @@ list_is_empty() return items < 1; } +int +duplicate_item() +{ + int i; + list_item item; + + if(curitem < 0) + return 1; + + for(i = 0; i < ITEM_FIELDS; i++) + item[i] = database[curitem][i] ? strdup(database[curitem][i]) : + NULL; + + if(add_item2database(item)) + return 1; + + curitem = LAST_ITEM; + refresh_list(); + + return 0; +} + diff --git a/list.h b/list.h index cdffe73..ac8377f 100644 --- a/list.h +++ b/list.h @@ -22,6 +22,7 @@ int selected_items(); void invert_selection(); int list_current_item(); int list_is_empty(); +int duplicate_item(); enum { diff --git a/ui.c b/ui.c index 023f206..9d59cc7 100644 --- a/ui.c +++ b/ui.c @@ -395,6 +395,7 @@ get_commands() case KEY_DC: case 'd': case 'r': ui_remove_items(); break; + case 'D': duplicate_item(); break; case 12: refresh_screen(); break; case 'k':