Commit Diff


commit - f3bcf8f2286bb8e34ca1364a582c15978458c67c
commit + d89b86d670dc0e5acd7731a97f60ebafcf1f1bf2
blob - 4cc3d76a1df4f2ac16293f6ceee899224b20170e
blob + 6094f3b3e66731039b087a33738e03d989daa66f
--- defaults.c
+++ defaults.c
@@ -27,21 +27,22 @@ int olivetti_mode = 0;
 int enable_colors = 1;
 
 static struct lineface_descr {
-	int	prfx_used, used;
-	int	prfx_pair, pair;
-	int	prfx_bg, bg;
-	int	prfx_fg, fg;
+	int	used;
+	int	pp, p, tp;
+	int	prfx_bg, bg, trail_bg;
+	int	prfx_fg, fg, trail_fg;
 } linefaces_descr[] = {
-	[LINE_TEXT] =		{ 0, 0, PAIR_TEXT_PRFX,		PAIR_TEXT,	0, 0, 0, 0 },
-	[LINE_LINK] =		{ 0, 0, PAIR_LINK_PRFX,		PAIR_LINK,	0, 0, 0, 0 },
-	[LINE_TITLE_1] =	{ 0, 0, PAIR_TITLE_1_PRFX,	PAIR_TITLE_1,	0, 0, 0, 0 },
-	[LINE_TITLE_2] =	{ 0, 0, PAIR_TITLE_2_PRFX,	PAIR_TITLE_1,	0, 0, 0, 0 },
-	[LINE_TITLE_3] =	{ 0, 0, PAIR_TITLE_3_PRFX,	PAIR_TITLE_3,	0, 0, 0, 0 },
-	[LINE_ITEM] =		{ 0, 0, PAIR_ITEM_PRFX,		PAIR_ITEM,	0, 0, 0, 0 },
-	[LINE_QUOTE] =		{ 0, 0, PAIR_QUOTE_PRFX,	PAIR_QUOTE,	0, 0, 0, 0 },
-	[LINE_PRE_START] =	{ 0, 0, PAIR_PRE_START_PRFX,	PAIR_TEXT,	0, 0, 0, 0 },
-	[LINE_PRE_CONTENT] =	{ 0, 0, PAIR_PRE_PRFX,		PAIR_PRE,	0, 0, 0, 0 },
-	[LINE_PRE_END] =	{ 0, 0, PAIR_PRE_END_PRFX,	PAIR_PRE_END,	0, 0, 0, 0 },
+	[LINE_TEXT] =		{.pp=PT_PRFX,		.p=PT,		.tp=PT_TRAIL},
+	[LINE_LINK] =		{.pp=PL_PRFX,		.p=PL,		.tp=PL_TRAIL},
+	[LINE_TITLE_1] =	{.pp=PT1_PRFX,		.p=PT1,		.tp=PT1_TRAIL},
+	[LINE_TITLE_2] =	{.pp=PT2_PRFX,		.p=PT1,		.tp=PT1_TRAIL},
+	[LINE_TITLE_3] =	{.pp=PT3_PRFX,		.p=PT3,		.tp=PT3_TRAIL},
+	[LINE_ITEM] =		{.pp=PI_PRFX,		.p=PI,		.tp=PI_TRAIL},
+	[LINE_QUOTE] =		{.pp=PQ_PRFX,		.p=PQ,		.tp=PQ_TRAIL},
+	[LINE_PRE_START] =	{.pp=PPSTART_PRFX,	.p=PT,		.tp=PT_TRAIL},
+	[LINE_PRE_CONTENT] =	{.pp=PP_PRFX,		.p=PP,		.tp=PP_TRAIL},
+	[LINE_PRE_END] =	{.pp=PPEND_PRFX,	.p=PPEND,	.tp=PPEND_TRAIL},
+
 };
 
 struct lineprefix line_prefixes[] = {
@@ -58,16 +59,16 @@ struct lineprefix line_prefixes[] = {
 };
 
 struct line_face line_faces[] = {
-	[LINE_TEXT] =		{ 0,		0 },
-	[LINE_LINK] =		{ 0,		A_UNDERLINE },
-	[LINE_TITLE_1] =	{ A_BOLD,	A_BOLD },
-	[LINE_TITLE_2] =	{ A_BOLD,	A_BOLD },
-	[LINE_TITLE_3] =	{ A_BOLD,	A_BOLD },
-	[LINE_ITEM] =		{ 0,		0 },
-	[LINE_QUOTE] =		{ 0,		A_DIM },
-	[LINE_PRE_START] =	{ 0,		0 },
-	[LINE_PRE_CONTENT] =	{ 0,		0 },
-	[LINE_PRE_END] =	{ 0,		0 },
+	[LINE_TEXT] =		{ 0,		0,		0 },
+	[LINE_LINK] =		{ 0,		A_UNDERLINE,	0 },
+	[LINE_TITLE_1] =	{ A_BOLD,	A_BOLD,		0 },
+	[LINE_TITLE_2] =	{ A_BOLD,	A_BOLD,		0 },
+	[LINE_TITLE_3] =	{ A_BOLD,	A_BOLD,		0 },
+	[LINE_ITEM] =		{ 0,		0,		0 },
+	[LINE_QUOTE] =		{ 0,		A_DIM,		0 },
+	[LINE_PRE_START] =	{ 0,		0,		0 },
+	[LINE_PRE_CONTENT] =	{ 0,		0,		0 },
+	[LINE_PRE_END] =	{ 0,		0,		0 },
 };
 
 struct tab_face tab_face = {
@@ -87,19 +88,17 @@ struct minibuffer_face minibuffer_face = {
 struct mapping {
 	const char	*label;
 	int		 linetype;
-	int		 facetype;
-	int		 facetype_prfx;
 } mappings[] = {
-	{"text",	LINE_TEXT,		PAIR_TEXT,	PAIR_TEXT_PRFX},
-	{"link",	LINE_LINK,		PAIR_LINK,	PAIR_LINK_PRFX},
-	{"title1",	LINE_TITLE_1,		PAIR_TITLE_1,	PAIR_TITLE_1_PRFX},
-	{"title2",	LINE_TITLE_2,		PAIR_TITLE_2,	PAIR_TITLE_2_PRFX},
-	{"title3",	LINE_TITLE_3,		PAIR_TITLE_3,	PAIR_TITLE_3_PRFX},
-	{"item",	LINE_ITEM,		PAIR_ITEM,	PAIR_ITEM_PRFX},
-	{"quote",	LINE_QUOTE,		PAIR_QUOTE,	PAIR_QUOTE_PRFX},
-	{"pre.start",	LINE_PRE_START,		PAIR_PRE_START,	PAIR_PRE_START_PRFX},
-	{"pre",		LINE_PRE_CONTENT,	PAIR_PRE,	PAIR_PRE_PRFX},
-	{"pre.end",	LINE_PRE_END,		PAIR_PRE_END,	PAIR_PRE_END_PRFX},
+	{"text",	LINE_TEXT},
+	{"link",	LINE_LINK},
+	{"title1",	LINE_TITLE_1},
+	{"title2",	LINE_TITLE_2},
+	{"title3",	LINE_TITLE_3},
+	{"item",	LINE_ITEM},
+	{"quote",	LINE_QUOTE},
+	{"pre.start",	LINE_PRE_START},
+	{"pre",		LINE_PRE_CONTENT},
+	{"pre.end",	LINE_PRE_END},
 };
 
 static struct mapping *
@@ -116,7 +115,7 @@ mapping_by_name(const char *name)
 }
 
 int
-config_setprfx(const char *name, int cont, const char *str)
+config_setprfx(const char *name, const char *prfx, const char *cont)
 {
 	struct lineprefix *p;
 	struct mapping *m;
@@ -129,12 +128,9 @@ config_setprfx(const char *name, int cont, const char 
 		return 0;
 
 	p = &line_prefixes[m->linetype];
+	p->prfx1 = prfx;
+	p->prfx2 = cont;
 
-	if (cont)
-		p->prfx2 = str;
-	else
-		p->prfx1 = str;
-
 	return 1;
 }
 
@@ -168,7 +164,7 @@ config_setvars(const char *var, char *val)
 }
 
 int
-config_setcolor(const char *name, int prfx, int bg, int color)
+config_setcolor(int bg, const char *name, int prfx, int line, int trail)
 {
         struct mapping *m;
 	struct lineface_descr *d;
@@ -182,18 +178,15 @@ config_setcolor(const char *name, int prfx, int bg, in
 
 	d = &linefaces_descr[m->linetype];
 
-	if (prfx) {
-		d->prfx_used = 1;
-		if (bg)
-			d->prfx_bg = color;
-		else
-			d->prfx_fg = color;
+	d->used = 1;
+	if (bg) {
+		d->prfx_bg = prfx;
+		d->bg = line;
+		d->trail_bg = trail;
 	} else {
-		d->used = 1;
-		if (bg)
-			d->bg = color;
-		else
-			d->fg = color;
+		d->prfx_fg = prfx;
+		d->fg = line;
+		d->trail_fg = trail;
 	}
 
 	return 1;
@@ -211,14 +204,15 @@ config_apply_colors(void)
 		d = &linefaces_descr[i];
 		f = &line_faces[i];
 
-		if (d->prfx_used) {
-			init_pair(d->prfx_pair, d->prfx_fg, d->prfx_bg);
-			f->prefix_prop = COLOR_PAIR(d->prfx_pair);
-		}
-
 		if (d->used) {
-			init_pair(d->pair, d->fg, d->bg);
-			f->text_prop = COLOR_PAIR(d->pair);
+			init_pair(d->pp, d->prfx_fg, d->prfx_bg);
+			f->prefix_prop = COLOR_PAIR(d->pp);
+
+			init_pair(d->p, d->fg, d->bg);
+			f->text_prop = COLOR_PAIR(d->p);
+
+			init_pair(d->tp, d->trail_fg, d->trail_bg);
+			f->trail_prop = COLOR_PAIR(d->tp);
 		}
 	}
 }
blob - fdf77d8b09ba20ee67de5e5c8f2fc2325a7ab835
blob + 4de5b445b0e1faa557eabf4284c95d39c03427da
--- parse.y
+++ parse.y
@@ -42,7 +42,7 @@ typedef struct {
 #define YYSTYPE yystype
 
 static char *current_style;
-static int current_bg, current_fg;
+static int color_type;
 
 static const char *path;
 
@@ -52,11 +52,11 @@ int parse_errors = 0;
 
 static void yyerror(const char *, ...);
 static int yylex(void);
-static void setprfx(int, const char *);
+static void setprfx(const char *, const char *);
 static void setvari(char *, int);
 static void setvars(char *, char *);
 static int colorname(const char *);
-static void setcolor(int, int, const char *);
+static void setcolor(const char *, const char *, const char *);
 
 %}
 
@@ -96,20 +96,17 @@ styleopts	: /* empty */
 		| styleopts styleopt '\n'
 		;
 
-styleopt	: TPRFX TSTRING	{ setprfx(0, $2); }
-		| TCONT TSTRING	{ setprfx(1, $2); }
-		| TBG TSTRING {
-			setcolor(0, 1, $2);
-			setcolor(1, 1, $2);
-			free($2);
-		}
-		| TFG TSTRING {
-			setcolor(0, 0, $2);
-			setcolor(1, 0, $2);
-			free($2);
-		}
+styleopt	: TPRFX TSTRING		{ setprfx($2, $2); }
+		| TPRFX TSTRING TSTRING	{ setprfx($2, $2); }
+		| TBG { color_type = TBG; } colorspec
+		| TFG { color_type = TFG; } colorspec
 		| TATTR TBOLD			{ printf("style attr setted to bold\n"); }
 		| TATTR TUNDERLINE		{ printf("style attr setted to underline\n"); }
+		;
+
+colorspec	: TSTRING			{ setcolor($1, $1, $1); free($1); }
+		| TSTRING TSTRING		{ setcolor($1, $2, $1); free($1); free($2); }
+		| TSTRING TSTRING TSTRING	{ setcolor($1, $2, $3); free($1); free($2); free($3); }
 		;
 
 bind		: TBIND TSTRING TSTRING TSTRING	{ printf("TODO: bind %s %s %s\n", $2, $3, $4); }
@@ -287,12 +284,12 @@ eof:
 }
 
 static void
-setprfx(int cont, const char *name)
+setprfx(const char *prfx, const char *cont)
 {
 	assert(current_style != NULL);
 
-	if (!config_setprfx(current_style, cont, name))
-		yyerror("invalid style %s", name);
+	if (!config_setprfx(current_style, prfx, cont))
+		yyerror("invalid style %s", current_style);
 }
 
 static void
@@ -344,18 +341,19 @@ colorname(const char *name)
 }
 
 void
-setcolor(int prfx, int bg, const char *color)
+setcolor(const char *prfx, const char *line, const char *trail)
 {
-	int c;
+	int p, l, t;
 
 	assert(current_style != NULL);
 
-	if ((c = colorname(color)) == -1)
+	if ((p = colorname(prfx)) == -1 ||
+	    (l = colorname(line)) == -1 ||
+	    (t = colorname(trail)) == -1)
 		return;
 
-	if (!config_setcolor(current_style, prfx, bg, c))
-		yyerror("can't set color \"%s\" for %s", color,
-		    current_style);
+	if (!config_setcolor(color_type == TBG, current_style, p, l, t))
+		yyerror("invalid style %s", current_style);
 }
 
 void
blob - 90f4104950dd1220eefcc8e57d8720f7ee1c9212
blob + a75fd076a6ea7e8626f35cf42171a790679918c7
--- telescope.h
+++ telescope.h
@@ -72,6 +72,7 @@ extern struct lineprefix line_prefixes[];
 struct line_face {
 	int prefix_prop;
 	int text_prop;
+	int trail_prop;
 };
 extern struct line_face line_faces[];
 
@@ -245,10 +246,10 @@ struct keymap {
 };
 
 /* defaults.c */
-int		 config_setprfx(const char *, int, const char *);
+int		 config_setprfx(const char *, const char *, const char *);
 int		 config_setvari(const char *, int);
 int		 config_setvars(const char *, char *);
-int		 config_setcolor(const char *, int, int, int);
+int		 config_setcolor(int, const char *, int, int, int);
 void		 config_apply_colors(void);
 
 /* fs.c */
@@ -324,27 +325,37 @@ extern int	 body_lines;
 extern int	 body_cols;
 extern int	 in_minibuffer;
 
-enum {
-	PAIR_TEXT = 1,
-	PAIR_TEXT_PRFX,
-	PAIR_LINK,
-	PAIR_LINK_PRFX,
-	PAIR_TITLE_1,
-	PAIR_TITLE_1_PRFX,
-	PAIR_TITLE_2,
-	PAIR_TITLE_2_PRFX,
-	PAIR_TITLE_3,
-	PAIR_TITLE_3_PRFX,
-	PAIR_ITEM,
-	PAIR_ITEM_PRFX,
-	PAIR_QUOTE,
-	PAIR_QUOTE_PRFX,
-	PAIR_PRE_START,
-	PAIR_PRE_START_PRFX,
-	PAIR_PRE,
-	PAIR_PRE_PRFX,
-	PAIR_PRE_END,
-	PAIR_PRE_END_PRFX,
+enum pairs {
+	PT = 1,
+	PT_PRFX,
+	PT_TRAIL,
+	PL,
+	PL_PRFX,
+	PL_TRAIL,
+	PT1,
+	PT1_PRFX,
+	PT1_TRAIL,
+	PT2,
+	PT2_PRFX,
+	PT2_TRAIL,
+	PT3,
+	PT3_PRFX,
+	PT3_TRAIL,
+	PI,
+	PI_PRFX,
+	PI_TRAIL,
+	PQ,
+	PQ_PRFX,
+	PQ_TRAIL,
+	PPSTART,
+	PPSTART_PRFX,
+	PPSTART_TRAIL,
+	PP,
+	PP_PRFX,
+	PP_TRAIL,
+	PPEND,
+	PPEND_PRFX,
+	PPEND_TRAIL,
 };
 
 struct thiskey {
blob - 57cf9dda26dfdeda3b3abca7808cd272f000e568
blob + a323d02b25a6ef46571eaf8ce6a7e01cf9b75e3c
--- ui.c
+++ ui.c
@@ -753,9 +753,10 @@ print_vline(int off, int width, WINDOW *window, struct
 	const char *prfx;
 	int prefix_face = line_faces[vl->parent->type].prefix_prop;
 	int text_face = line_faces[vl->parent->type].text_prop;
+	int trail_face = line_faces[vl->parent->type].trail_prop;
 	int i, left, x, y;
 
-	/* unused, set by wgetyx */
+	/* unused, set by getyx */
 	(void)y;
 
 	if (!vl->flags)
@@ -766,7 +767,6 @@ print_vline(int off, int width, WINDOW *window, struct
 	if (text == NULL)
 		text = "";
 
-	/* TODO: load the pair for the default background */
 	for (i = 0; i < off; i++)
 		waddch(window, ' ');
 
@@ -776,16 +776,17 @@ print_vline(int off, int width, WINDOW *window, struct
 
 	wattron(window, text_face);
 	wprintw(window, "%s", text);
+	wattroff(window, text_face);
 
 	getyx(window, y, x);
 
 	left = width - x;
 
-	/* draw the rest of the line with line face */
-	for (i = 0; i < left - off; ++i)
+	wattron(window, trail_face);
+	for (i = 0; i < left - off - 1; ++i)
 		waddch(window, ' ');
+	wattroff(window, trail_face);
 
-	wattroff(window, text_face);
 }
 
 static void