X-Git-Url: https://git.deb.at/?a=blobdiff_plain;ds=sidebyside;f=list.c;h=de47d6b419246c5df21ebf85837bd9312e5514ac;hb=781c0d657fffe80e45d0fda6ed5ddbf5f796fefb;hp=62159522a74368d295f03f681d51193f2bfbeadf;hpb=8e362f5a1e900ad2cd11192436b5182e8b0e6ef6;p=pkg%2Fabook.git diff --git a/list.c b/list.c index 6215952..de47d6b 100644 --- a/list.c +++ b/list.c @@ -17,6 +17,7 @@ #include "list.h" #include "misc.h" #include "options.h" +#include "xmalloc.h" #define MIN_EXTRA_COLUMN ADDRESS /* 2 */ #define MAX_EXTRA_COLUMN LAST_FIELD @@ -32,7 +33,7 @@ extern int items; extern list_item *database; extern struct abook_field abook_fields[]; -WINDOW *list = NULL; +static WINDOW *list = NULL; static int init_extra_field(enum str_opts option) @@ -82,17 +83,17 @@ void refresh_list() { int i, line; - + werase(list); ui_print_number_of_items(); - - if(items < 1) { + + if(list_is_empty()) { refresh(); wrefresh(list); return; } - + if(curitem < 0) curitem = 0; @@ -110,6 +111,11 @@ refresh_list() print_list_line(i, line, i == curitem); } + if(opt_get_bool(BOOL_SHOW_CURSOR)) { + wmove(list, curitem - first_list_item, 0); + /* need to call refresh() to update the cursor positions */ + refresh(); + } wrefresh(list); } @@ -127,7 +133,7 @@ print_list_line(int i, int line, int highlight) if(selected[i]) mvwaddch(list, line, 0, '*' ); - + mvwaddnstr(list, line, NAMEPOS, database[i][NAME], bytes2width(database[i][NAME], NAMELEN)); if(opt_get_bool(BOOL_SHOW_ALL_EMAILS)) @@ -150,7 +156,7 @@ print_list_line(int i, int line, int highlight) if(highlight) wstandend(list); } - + void list_headerline() @@ -196,10 +202,10 @@ page_up() { if(curitem < 1) return; - + curitem = curitem == first_list_item ? ((curitem -= LIST_LINES) < 0 ? 0 : curitem) : first_list_item; - + refresh_list(); } @@ -262,7 +268,7 @@ goto_home() { if(items > 0) curitem = 0; - + refresh_list(); } @@ -349,7 +355,7 @@ duplicate_item() return 1; for(i = 0; i < ITEM_FIELDS; i++) - item[i] = database[curitem][i] ? strdup(database[curitem][i]) : + item[i] = database[curitem][i] ? xstrdup(database[curitem][i]) : NULL; if(add_item2database(item))