X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=ui.c;fp=ui.c;h=b7c486a1cd57fb86dcb0eabadde8f511505541a4;hb=7751b3edc145646e6b55e2fda82eb5619fbe0074;hp=d42f26e9eb78597e91b536573c7c731db2d16431;hpb=627bebd233fee0136a6ffbef005da3e62a87f99b;p=pkg%2Fabook.git diff --git a/ui.c b/ui.c index d42f26e..b7c486a 100644 --- a/ui.c +++ b/ui.c @@ -1,6 +1,6 @@ /* - * $Id: ui.c,v 1.54.4.1 2006/04/09 18:57:34 jheinonen Exp $ + * $Id: ui.c,v 1.57 2006/04/10 08:15:46 jheinonen Exp $ * * by JH * @@ -38,7 +38,6 @@ * external variables */ -extern int items, curitem; extern char *datafile; extern bool alternative_datafile; @@ -281,7 +280,7 @@ statusline_askchoice(const char *msg, const char *choices, short dflt) char *s; int ch; - assert((dflt < 0) || (dflt > strlen(choices))); + assert((dflt >= 0) && (dflt <= strlen(choices))); if(dflt) { s = strdup_printf("%s [%c]", msg, choices[dflt - 1]); @@ -433,7 +432,6 @@ display_help(int help) */ extern char *selected; -extern int curitem; void get_commands() @@ -454,7 +452,7 @@ get_commands() case 'q': return; case 'Q': quit_abook(QUIT_DONTSAVE); break; case 'P': print_stderr(selected_items() ? - -1 : list_current_item()); + -1 : list_get_curitem()); return; case '?': display_help(HELP_MAIN); @@ -491,15 +489,15 @@ get_commands() case 'o': ui_open_datafile(); break; - case 's': sort_by_field(NAME); break; + case 's': sort_by_field("name");break; case 'S': sort_surname(); break; - case 'F': sort_by_field(-1); break; + case 'F': sort_by_field(NULL); break; case '/': ui_find(0); break; case '\\': ui_find(1); break; - case ' ': if(curitem >= 0) { - selected[curitem] = !selected[curitem]; + case ' ': if(list_get_curitem() >= 0) { + list_invert_curitem_selection(); ui_print_number_of_items(); refresh_list(); } @@ -519,13 +517,13 @@ get_commands() break; case 'm': launch_mutt(selected_items() ? - -1 : list_current_item()); + -1 : list_get_curitem()); refresh_screen(); break; case 'p': ui_print_database(); break; - case 'v': launch_wwwbrowser(list_current_item()); + case 'v': launch_wwwbrowser(list_get_curitem()); refresh_screen(); break; } @@ -574,21 +572,22 @@ ui_find(int next) refresh_screen(); } - if( (item = find_item(findstr, curitem + !!next, search_fields)) < 0 && + if( (item = find_item(findstr, list_get_curitem() + !!next, + search_fields)) < 0 && (item = find_item(findstr, 0, search_fields)) >= 0) statusline_addstr(_("Search hit bottom, continuing at top")); if(item >= 0) { - curitem = item; + list_set_curitem(item); refresh_list(); } } - void ui_print_number_of_items() { - char *str = strdup_printf(" " "|%3d/%3d", selected_items(), items); + char *str = strdup_printf(" " "|%3d/%3d", + selected_items(), db_n_items()); mvaddstr(0, COLS-strlen(str), str); @@ -600,7 +599,7 @@ ui_read_database() { char *msg; - if(items > 0) { + if(!list_is_empty()) { msg = strdup_printf(_("Your current data will be lost - " "Press '%c' to continue"), *(S_("keybinding for yes|y"))); @@ -675,7 +674,7 @@ ui_open_datafile() load_database(filename); - if(items == 0) { + if(list_is_empty()) { statusline_msg(_("Sorry, the specified file appears not to be a valid abook addressbook")); load_database(datafile); } else {