]> git.deb.at Git - pkg/abook.git/commitdiff
added duplicate item command
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Thu, 6 Nov 2003 17:14:06 +0000 (17:14 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Thu, 6 Nov 2003 17:14:06 +0000 (17:14 +0000)
help.h
list.c
list.h
ui.c

diff --git a/help.h b/help.h
index f9058bb517d5f78d57e0610fc682f5261b137cb3..95d27f4bc76c80a71c1acf7f4cb3019ee1ce3857 100644 (file)
--- 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 25c53826130c6ba5fcc40c97e8c2aff297480cf4..7197723d03fcad6f03f8b5165146e8add20f65e8 100644 (file)
--- 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 cdffe73903e4acc193eb7274e35b817b14abe9fc..ac8377f1228e734ffdd2ee9bfacc95e630604da5 100644 (file)
--- 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 023f20667b730f5a25dbae7f3640d71ccf013440..9d59cc796d62b2a5f404f59646326af8bcfa6071 100644 (file)
--- 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':