X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=list.c;h=ca4892baea2e4f7bd495b225c0649c14f3052ac6;hb=7c501d6668c722e4b0200c4303c70fe840a708a9;hp=55046927e30303aa42a85268064662079da1bd90;hpb=b8c3c825e80317c07c8864d4dfb5054f8a5b8658;p=pkg%2Fabook.git diff --git a/list.c b/list.c index 5504692..ca4892b 100644 --- a/list.c +++ b/list.c @@ -19,6 +19,7 @@ #include "misc.h" #include "options.h" #include "xmalloc.h" +#include "color.h" int curitem = -1; @@ -180,7 +181,7 @@ print_list_field(int item, int line, int *x_pos, struct index_elem *e) width = len ? bytes2width(s, len) : strwidth(s); x_start = *x_pos + ((e->d.field.len < 0) ? len - width : 0); if(width + x_start >= COLS) - width = COLS - x_start; + width = bytes2width(s, COLS - x_start); if(width) mvwaddnstr(list, line, x_start, s, width); @@ -194,7 +195,10 @@ print_list_field(int item, int line, int *x_pos, struct index_elem *e) static void highlight_line(WINDOW *win, int line) { - wstandout(win); + wattrset(win, COLOR_PAIR(CP_LIST_HIGHLIGHT)); + if(!opt_get_bool(BOOL_USE_COLORS)) { + wstandout(win); + } /* * this is a tricky one @@ -224,6 +228,10 @@ print_list_line(int item, int line, int highlight) struct index_elem *cur; int x_pos = 1; + if(item % 2 == 0) + wattrset(list, COLOR_PAIR(CP_LIST_EVEN)); + else + wattrset(list, COLOR_PAIR(CP_LIST_ODD)); scrollok(list, FALSE); if(highlight) highlight_line(list, line); @@ -300,13 +308,18 @@ list_headerline() #if defined(A_BOLD) && defined(A_NORMAL) attrset(A_BOLD); #endif + attrset(COLOR_PAIR(CP_LIST_HEADER)); + mvhline(2, 0, ' ', COLS); for(e = index_elements; e; e = e->next) if(e->type == INDEX_TEXT) x_pos += strwidth(e->d.text); else if(e->type == INDEX_FIELD) { get_field_info(e->d.field.id, NULL, &str, NULL); - width = e->d.field.len ? abs(e->d.field.len) : strwidth(str); + width = e->d.field.len ? + abs(e->d.field.len) : strwidth(str); + if(width + x_pos > COLS) + width = bytes2width(str, COLS - x_pos); mvaddnstr(2, x_pos, str, width); x_pos += width; } else @@ -485,6 +498,12 @@ list_get_curitem() return curitem; } +int +list_get_firstitem() +{ + return first_list_item; +} + void list_set_curitem(int i) {