From: Jaakko Heinonen Date: Thu, 6 Nov 2003 17:32:00 +0000 (+0000) Subject: quit without saving command X-Git-Tag: upstream/0.6.1~2^2~238 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=853a82571bfc466bc9257046ef172512220e00b5;p=pkg%2Fabook.git quit without saving command --- diff --git a/ChangeLog b/ChangeLog index 110d937..624a979 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 0.5.1 - sort by field command + - duplicate item command + - quit without saving command - minor filter fixes - tried to fix \" quotation problem with mutt import filter - removed obsolete filesel_sort option from abookrc manual page diff --git a/abook.c b/abook.c index 7ce99ae..5181203 100644 --- a/abook.c +++ b/abook.c @@ -137,12 +137,15 @@ init_abook() } void -quit_abook() +quit_abook(int save_db) { - if(opt_get_bool(BOOL_AUTOSAVE)) - save_database(); - else if(statusline_ask_boolean("Save database", TRUE)) - save_database(); + if(save_db) { + if(opt_get_bool(BOOL_AUTOSAVE)) + save_database(); + else if(statusline_ask_boolean("Save database", TRUE)) + save_database(); + } else if(!statusline_ask_boolean("Quit without saving", FALSE)) + return; free_opts(); close_database(); @@ -155,7 +158,7 @@ quit_abook() static void quit_abook_sig(int i) { - quit_abook(); + quit_abook(QUIT_SAVE); } int @@ -171,7 +174,7 @@ main(int argc, char **argv) get_commands(); - quit_abook(); + quit_abook(QUIT_SAVE); return 0; } @@ -577,7 +580,7 @@ abook_malloc(size_t size) if ( (ptr = malloc(size)) == NULL ) { if( is_ui_initialized() ) - quit_abook(); + quit_abook(QUIT_SAVE); perror("malloc() failed"); exit(1); } @@ -595,7 +598,7 @@ abook_realloc(void *ptr, size_t size) if(ptr == NULL) { if(is_ui_initialized()) - quit_abook(); + quit_abook(QUIT_SAVE); perror("realloc() failed"); exit(1); } diff --git a/abook.h b/abook.h index 790d052..f6c756b 100644 --- a/abook.h +++ b/abook.h @@ -6,7 +6,7 @@ void *abook_malloc(size_t size); void *abook_realloc(void *ptr, size_t size); FILE *abook_fopen (const char *path, const char *mode); -void quit_abook(); +void quit_abook(int save_db); void launch_wwwbrowser(int item); void launch_mutt(int item); void print_stderr(int item); @@ -28,6 +28,9 @@ int strncasecmp (const char *, const char *, size_t); #define RCFILE "abookrc" +#define QUIT_SAVE 1 +#define QUIT_DONTSAVE 0 + /* * some "abookwide" useful macros */ diff --git a/help.h b/help.h index 95d27f4..181aa45 100644 --- a/help.h +++ b/help.h @@ -9,7 +9,8 @@ static char *mainhelp[] = { " ? help\n", " q quit\n", -" Q quit and print selected item(s) to stderr\n", +" Q quit without saving\n", +" P quit and print selected item(s) to stderr\n", " ^L refresh screen\n", "\n", " arrows / j,k scroll list\n", diff --git a/ui.c b/ui.c index 9d59cc7..3d7e01a 100644 --- a/ui.c +++ b/ui.c @@ -383,7 +383,8 @@ get_commands() can_resize = FALSE; /* it's not safe to resize anymore */ switch( ch ) { case 'q': return; - case 'Q': print_stderr(selected_items() ? + case 'Q': quit_abook(QUIT_DONTSAVE); break; + case 'P': print_stderr(selected_items() ? -1 : list_current_item()); return; case '?':