* external variables
*/
-extern int items, curitem;
extern char *datafile;
extern bool alternative_datafile;
wattrset(bottom, (*p == '>') ? A_BOLD : A_NORMAL);
tmp = xstrndup(start, p - start);
mvwaddstr(bottom, 1, pos, tmp);
+ pos += strwidth(tmp);
free(tmp);
- pos += p - start;
}
if(*p) {
start = p + 1;
char *s;
int ch;
- assert((dflt < 0) || (dflt > strlen(choices)));
+ assert((dflt >= 0) && (dflt <= strlen(choices)));
if(dflt) {
- s = mkstr("%s [%c]", msg, choices[dflt - 1]);
+ s = strdup_printf("%s [%c]", msg, choices[dflt - 1]);
statusline_addhlstr(s);
free(s);
} else
}
char *
-ui_readline(char *prompt, char *s, size_t limit, bool use_completion)
+ui_readline(const char *prompt, char *s, size_t limit, bool use_completion)
{
int y, x;
char *ret;
}
int
-statusline_ask_boolean(char *msg, int def)
+statusline_ask_boolean(const char *msg, int def)
{
int ret;
char *msg2 = strconcat(msg, def ? _(" (Y/n)?") : _(" (y/N)?"), NULL);
}
char *
-ask_filename(char *prompt)
+ask_filename(const char *prompt)
{
char *buf = NULL;
*/
extern char *selected;
-extern int curitem;
void
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);
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();
}
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;
}
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 = mkstr(" " "|%3d/%3d", selected_items(), items);
+ char *str = strdup_printf(" " "|%3d/%3d",
+ selected_items(), db_n_items());
mvaddstr(0, COLS-strlen(str), str);
{
char *msg;
- if(items > 0) {
- msg = mkstr(_("Your current data will be lost - "
+ if(!list_is_empty()) {
+ msg = strdup_printf(_("Your current data will be lost - "
"Press '%c' to continue"),
*(S_("keybinding for yes|y")));
if(!statusline_ask_boolean(msg, FALSE)) {
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 {