\fBshow_cursor\fP=[true|false]
Defines if the cursor is visible in main display. Default is false.
+.TP
+\fBuse_colors\fP=[true|false]
+Defines if the output of abook is colorized. Default is false.
+
+.TP
+Color settings:
+\fBcolor_header_fg\fP=color
+Foreground color for header bar
+
+\fBcolor_header_bg\fP=color
+Background color for header bar
+
+\fBcolor_footer_fg\fP=color
+Foreground color for footer bar
+
+\fBcolor_footer_bg\fP=color
+Background color for footer bar
+
+\fBcolor_list_even_fg\fP=color
+Foreground color for normal list entries with even index in the list (starting
+with index 0)
+
+\fBcolor_list_even_bg\fP=color
+Background color for normal list entries with even index in the list (starting
+with index 0)
+
+\fBcolor_list_odd_fg\fP=color
+Foreground color for normal list entries with odd index in the list (starting
+with index 0)
+
+\fBcolor_list_odd_bg\fP=color
+Background color for normal list entries with odd index in the list (starting
+with index 0)
+
+\fBcolor_list_header_fg\fP=color
+Foreground color for the list header
+
+\fBcolor_list_header_bg\fP=color
+Background color for the list header
+
+\fBcolor_list_highlight_fg\fP=color
+Foreground color for highlighted list entries
+
+\fBcolor_list_highlight_bg\fP=color
+Background color for highlighted list entries
+
+\fBcolor_tab_border_fg\fP=color
+Foreground color for tab borders on details page
+
+\fBcolor_tab_border_bg\fP=color
+Background color for tab borders on details page
+
+\fBcolor_tab_label_fg\fP=color
+Foreground color for tab labes on details page
+
+\fBcolor_tab_label_bg\fP=color
+Background color for tab labes on details page
+
+\fBcolor_field_name_fg\fP=color
+Foreground color for field names on details page
+
+\fBcolor_field_name_bg\fP=color
+Background color for field names on details page
+
+\fBcolor_field_value_fg\fP=color
+Foreground color for field values on details page
+
+\fBcolor_field_value_bg\fP=color
+Background color for field values on details page
+
+Where \fBcolor\fP can be: default, black, red, green, yellow, blue, magenta, cyan, white
+
+
+
.SH SAMPLE CONFIGURATION FILE
.nf
--- /dev/null
+
+#ifndef __ABOOK_COLORS_H_
+#define __ABOOK_COLORS_H_
+
+#define COLOR_DEFAULT -1
+
+enum {
+ CP_HEADER = 1,
+ CP_FOOTER,
+ CP_LIST_EVEN,
+ CP_LIST_ODD,
+ CP_LIST_HEADER,
+ CP_LIST_HIGHLIGHT,
+ CP_TAB_BORDER,
+ CP_TAB_LABEL,
+ CP_FIELD_NAME,
+ CP_FIELD_VALUE,
+};
+
+#endif
+
#include "misc.h"
#include "views.h"
#include "xmalloc.h"
+#include "color.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
int x_pos = 2; /* current x pos */
char *tab_name;
+ wattrset(editw, COLOR_PAIR(CP_TAB_BORDER));
mvwhline(editw, TABLINE + 1, 0, UI_HLINE_CHAR, EDITW_COLS);
for(i = 0; i < views_count; i++) {
mvwaddch(editw, TABLINE, x_pos, UI_ULCORNER_CHAR);
mvwaddch(editw, TABLINE, x_pos + 1, UI_LBOXLINE_CHAR);
+ wattrset(editw, COLOR_PAIR(CP_TAB_LABEL));
mvwaddstr(editw, TABLINE, x_pos + 2, tab_name);
+ wattrset(editw, COLOR_PAIR(CP_TAB_BORDER));
mvwaddch(editw, TABLINE, x_pos + width - 3, UI_RBOXLINE_CHAR);
mvwaddch(editw, TABLINE, x_pos + width - 2, UI_URCORNER_CHAR);
else
snprintf(header, EDITW_COLS, "%s", db_name_get(item));
+ wattrset(editw, COLOR_PAIR(CP_TAB_LABEL));
mvwaddstr(editw, 0, (EDITW_COLS - strwidth(header)) / 2, header);
free(header);
} else
y = FIELDS_START_Y;
+ wattrset(editw, COLOR_PAIR(CP_FIELD_NAME));
mvwprintw(editw, y, FIELDS_START_X, "%c - ",
(j < 10) ? '0' + j : 'A' + j - 10);
mvwaddnstr(editw, y, FIELDS_START_X + 4, cur->field->name,
FIELDNAME_MAX_WIDTH));
mvwaddch(editw, y, TAB_COLON_POS, ':');
+ wattrset(editw, COLOR_PAIR(CP_FIELD_VALUE));
if((cur->field->type == FIELD_EMAILS) ||
(cur->field->type == FIELD_LIST)) {
abook_list *emails, *e;
#include "misc.h"
#include "options.h"
#include "xmalloc.h"
+#include "color.h"
int curitem = -1;
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
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);
#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)
{ "preserve_fields", OT_STR, STR_PRESERVE_FIELDS, UL "standard" },
{ "sort_field", OT_STR, STR_SORT_FIELD, UL "nick" },
{ "show_cursor", OT_BOOL, BOOL_SHOW_CURSOR, FALSE },
-
+ { "use_colors", OT_BOOL, BOOL_USE_COLORS, FALSE },
+ { "color_header_fg", OT_STR, STR_COLOR_HEADER_FG, UL "blue" },
+ { "color_header_fg", OT_STR, STR_COLOR_HEADER_FG, UL "blue" },
+ { "color_header_bg", OT_STR, STR_COLOR_HEADER_BG, UL "red" },
+ { "color_footer_fg", OT_STR, STR_COLOR_FOOTER_FG, UL "red" },
+ { "color_footer_bg", OT_STR, STR_COLOR_FOOTER_BG, UL "default" },
+ { "color_list_even_fg", OT_STR, STR_COLOR_LIST_EVEN_FG, UL "yellow" },
+ { "color_list_even_bg", OT_STR, STR_COLOR_LIST_EVEN_BG, UL "default" },
+ { "color_list_odd_fg", OT_STR, STR_COLOR_LIST_ODD_FG, UL "default" },
+ { "color_list_odd_bg", OT_STR, STR_COLOR_LIST_ODD_BG, UL "default" },
+ { "color_list_header_fg", OT_STR, STR_COLOR_LIST_HEADER_FG, UL "white" },
+ { "color_list_header_bg", OT_STR, STR_COLOR_LIST_HEADER_BG, UL "blue" },
+ { "color_list_highlight_fg", OT_STR, STR_COLOR_LIST_HIGHLIGHT_FG, UL "black" },
+ { "color_list_highlight_bg", OT_STR, STR_COLOR_LIST_HIGHLIGHT_BG, UL "green" },
+ { "color_tab_border_fg", OT_STR, STR_COLOR_TAB_BORDER_FG, UL "cyan" },
+ { "color_tab_border_bg", OT_STR, STR_COLOR_TAB_BORDER_BG, UL "default" },
+ { "color_tab_label_fg", OT_STR, STR_COLOR_TAB_LABEL_FG, UL "magenta" },
+ { "color_tab_label_bg", OT_STR, STR_COLOR_TAB_LABEL_BG, UL "default" },
+ { "color_field_name_fg", OT_STR, STR_COLOR_FIELD_NAME_FG, UL "yellow" },
+ { "color_field_name_bg", OT_STR, STR_COLOR_FIELD_NAME_BG, UL "default" },
+ { "color_field_value_fg", OT_STR, STR_COLOR_FIELD_VALUE_FG, UL "green" },
+ { "color_field_value_bg", OT_STR, STR_COLOR_FIELD_VALUE_BG, UL "default" },
{ NULL }
};
BOOL_USE_ASCII_ONLY,
BOOL_ADD_EMAIL_PREVENT_DUPLICATES,
BOOL_SHOW_CURSOR,
+ BOOL_USE_COLORS,
BOOL_MAX
};
STR_ADDRESS_STYLE,
STR_PRESERVE_FIELDS,
STR_SORT_FIELD,
+ STR_COLOR_HEADER_FG,
+ STR_COLOR_HEADER_BG,
+ STR_COLOR_FOOTER_FG,
+ STR_COLOR_FOOTER_BG,
+ STR_COLOR_LIST_EVEN_FG,
+ STR_COLOR_LIST_EVEN_BG,
+ STR_COLOR_LIST_ODD_FG,
+ STR_COLOR_LIST_ODD_BG,
+ STR_COLOR_LIST_HEADER_FG,
+ STR_COLOR_LIST_HEADER_BG,
+ STR_COLOR_LIST_HIGHLIGHT_FG,
+ STR_COLOR_LIST_HIGHLIGHT_BG,
+ STR_COLOR_TAB_BORDER_FG,
+ STR_COLOR_TAB_BORDER_BG,
+ STR_COLOR_TAB_LABEL_FG,
+ STR_COLOR_TAB_LABEL_BG,
+ STR_COLOR_FIELD_NAME_FG,
+ STR_COLOR_FIELD_NAME_BG,
+ STR_COLOR_FIELD_VALUE_FG,
+ STR_COLOR_FIELD_VALUE_BG,
STR_MAX
};
#include "options.h"
#include "filter.h"
#include "xmalloc.h"
+#include "color.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
+ if(opt_get_bool(BOOL_USE_COLORS)) {
+ start_color();
+ use_default_colors();
+ ui_init_color_pairs_user();
+ }
+}
+
+
+#define CHECK_COLOR_NAME(value, name, DEFNAME) \
+ if(!strcmp((name), (value))){ \
+ return DEFNAME; \
+ }
+short
+opt_color_to_color(enum str_opts enum_name)
+{
+ char* name = opt_get_str(enum_name);
+ CHECK_COLOR_NAME(name, "default", COLOR_DEFAULT)
+ else CHECK_COLOR_NAME(name, "black", COLOR_BLACK)
+ else CHECK_COLOR_NAME(name, "red", COLOR_RED)
+ else CHECK_COLOR_NAME(name, "green", COLOR_GREEN)
+ else CHECK_COLOR_NAME(name, "yellow", COLOR_YELLOW)
+ else CHECK_COLOR_NAME(name, "blue", COLOR_BLUE)
+ else CHECK_COLOR_NAME(name, "magenta", COLOR_MAGENTA)
+ else CHECK_COLOR_NAME(name, "cyan", COLOR_CYAN)
+ else CHECK_COLOR_NAME(name, "white", COLOR_WHITE)
+ else return COLOR_DEFAULT;
+}
+
+void
+ui_init_color_pairs_user()
+{
+ init_pair(CP_HEADER, opt_color_to_color(STR_COLOR_HEADER_FG),
+ opt_color_to_color(STR_COLOR_HEADER_BG));
+ init_pair(CP_FOOTER, opt_color_to_color(STR_COLOR_FOOTER_FG),
+ opt_color_to_color(STR_COLOR_FOOTER_BG));
+ init_pair(CP_LIST_EVEN, opt_color_to_color(STR_COLOR_LIST_EVEN_FG),
+ opt_color_to_color(STR_COLOR_LIST_EVEN_BG));
+ init_pair(CP_LIST_ODD, opt_color_to_color(STR_COLOR_LIST_ODD_FG),
+ opt_color_to_color(STR_COLOR_LIST_ODD_BG));
+ init_pair(CP_LIST_HEADER, opt_color_to_color(STR_COLOR_LIST_HEADER_FG),
+ opt_color_to_color(STR_COLOR_LIST_HEADER_BG));
+ init_pair(CP_LIST_HIGHLIGHT, opt_color_to_color(STR_COLOR_LIST_HIGHLIGHT_FG),
+ opt_color_to_color(STR_COLOR_LIST_HIGHLIGHT_BG));
+ init_pair(CP_TAB_BORDER, opt_color_to_color(STR_COLOR_TAB_BORDER_FG),
+ opt_color_to_color(STR_COLOR_TAB_BORDER_BG));
+ init_pair(CP_TAB_LABEL, opt_color_to_color(STR_COLOR_TAB_LABEL_FG),
+ opt_color_to_color(STR_COLOR_TAB_LABEL_BG));
+ init_pair(CP_FIELD_NAME, opt_color_to_color(STR_COLOR_FIELD_NAME_FG),
+ opt_color_to_color(STR_COLOR_FIELD_NAME_BG));
+ init_pair(CP_FIELD_VALUE, opt_color_to_color(STR_COLOR_FIELD_VALUE_FG),
+ opt_color_to_color(STR_COLOR_FIELD_VALUE_BG));
}
int
{
werase(top);
+ wattrset(top, COLOR_PAIR(CP_HEADER));
+ mvwhline(top, 0, 0, ' ', COLS);
mvwhline(top, 1, 0, UI_HLINE_CHAR, COLS);
mvwprintw(top, 0, 0, "%s | %s", PACKAGE " " VERSION, str);
{
werase(bottom);
+ wattrset(bottom, COLOR_PAIR(CP_FOOTER));
mvwhline(bottom, 0, 0, UI_HLINE_CHAR, COLS);
refresh();
char *str = strdup_printf(" " "|%3d/%3d",
selected_items(), db_n_items());
+ attrset(COLOR_PAIR(CP_HEADER));
mvaddstr(0, COLS-strlen(str), str);
free(str);
int is_ui_initialized();
void ui_init_curses();
+void ui_init_color_pairs_user();
int init_ui();
void close_ui();
void headerline(const char *str);