aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-06-22 12:59:53 +0200
committerOmar Polo <op@omarpolo.com>2021-06-22 12:59:53 +0200
commit33d904b669e543d144ac195a28f32de6b6785117 (patch)
tree6740bb01f4461cc8ae4a45e0b59afb2e174d20e5
parentab728b01d1279e1be73604998298534a5462a72a (diff)
downloadtelescope-33d904b669e543d144ac195a28f32de6b6785117.tar.gz
telescope-33d904b669e543d144ac195a28f32de6b6785117.tar.bz2
allow changing the colors/attributes of the tabline
-rw-r--r--ChangeLog2
-rw-r--r--defaults.c60
-rw-r--r--telescope.h12
-rw-r--r--ui.c6
4 files changed, 71 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 42f48f2..efb9ffd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2021-06-22 Omar Polo <op@omarpolo.com>
+ * defaults.c (config_setcolor): allow changing the colors/attributes of the tabline
+
* parse.y (attrname): allow changing the attributes
2021-06-21 Omar Polo <op@omarpolo.com>
diff --git a/defaults.c b/defaults.c
index 66f9250..0201ef3 100644
--- a/defaults.c
+++ b/defaults.c
@@ -71,9 +71,17 @@ struct line_face line_faces[] = {
};
struct tab_face tab_face = {
- .background = A_REVERSE,
- .tab = A_REVERSE,
- .current_tab = A_NORMAL,
+ .bg_attr = A_REVERSE, .bg_bg = -1, .bg_fg = -1,
+ .t_attr = A_REVERSE, .t_bg = -1, .t_fg = -1,
+ .c_attr = A_NORMAL, .c_bg = -1, .c_fg = -1,
+
+ /*
+ * set these so that even when enable-color=0 the bar has some
+ * sane defaults.
+ */
+ .background = A_REVERSE,
+ .tab = A_REVERSE,
+ .current = A_NORMAL,
};
struct body_face body_face = {
@@ -189,7 +197,27 @@ config_setcolor(int bg, const char *name, int prfx, int line, int trail)
struct mapping *m;
struct lineface_descr *d;
- if (has_prefix(name, "line.")) {
+ if (!strcmp(name, "tabline")) {
+ if (bg)
+ tab_face.bg_bg = prfx;
+ else
+ tab_face.bg_fg = prfx;
+ } else if (has_prefix(name, "tabline.")) {
+ name += 8;
+
+ if (!strcmp(name, "tab")) {
+ if (bg)
+ tab_face.t_bg = prfx;
+ else
+ tab_face.t_fg = prfx;
+ } else if (!strcmp(name, "current")) {
+ if (bg)
+ tab_face.c_bg = prfx;
+ else
+ tab_face.c_fg = prfx;
+ } else
+ return 0;
+ } else if (has_prefix(name, "line.")) {
name += 5;
if ((m = mapping_by_name(name)) == NULL)
@@ -229,7 +257,18 @@ config_setattr(const char *name, int prfx, int line, int trail)
struct mapping *m;
struct lineface_descr *d;
- if (has_prefix(name, "line.")) {
+ if (!strcmp(name, "tabline")) {
+ tab_face.bg_attr = prfx;
+ } else if (has_prefix(name, "tabline.")) {
+ name += 8;
+
+ if (!strcmp(name, "tab"))
+ tab_face.t_attr = prfx;
+ else if (!strcmp(name, "current"))
+ tab_face.c_attr = prfx;
+ else
+ return 0;
+ } else if (has_prefix(name, "line.")) {
name += 5;
if ((m = mapping_by_name(name)) == NULL)
@@ -269,6 +308,17 @@ config_apply_colors(void)
f->trail_prop = COLOR_PAIR(d->tp) | d->trail_attr;
}
+ /* tab line */
+ init_pair(PTL_BG, tab_face.bg_fg, tab_face.bg_bg);
+ tab_face.background = COLOR_PAIR(PTL_BG) | tab_face.bg_attr;
+
+ init_pair(PTL_TAB, tab_face.t_fg, tab_face.t_bg);
+ tab_face.tab = COLOR_PAIR(PTL_TAB) | tab_face.t_attr;
+
+ init_pair(PTL_CURR, tab_face.c_fg, tab_face.c_bg);
+ tab_face.current = COLOR_PAIR(PTL_CURR) | tab_face.c_attr;
+
+ /* body */
init_pair(PBODY, body_face.fg, body_face.bg);
body_face.body = COLOR_PAIR(PBODY);
diff --git a/telescope.h b/telescope.h
index 5a4e64e..a9c7216 100644
--- a/telescope.h
+++ b/telescope.h
@@ -77,7 +77,11 @@ struct line_face {
extern struct line_face line_faces[];
struct tab_face {
- int background, tab, current_tab;
+ int bg_attr, bg_bg, bg_fg;
+ int t_attr, t_bg, t_fg;
+ int c_attr, c_bg, c_fg;
+
+ int background, tab, current;
};
extern struct tab_face tab_face;
@@ -337,7 +341,11 @@ extern int body_cols;
extern int in_minibuffer;
enum pairs {
- PBODY = 1,
+ PTL_BG = 1,
+ PTL_TAB,
+ PTL_CURR,
+
+ PBODY,
PBLEFT,
PBRIGHT,
diff --git a/ui.c b/ui.c
index b7b531e..81b7a7a 100644
--- a/ui.c
+++ b/ui.c
@@ -868,7 +868,7 @@ redraw_tabline(void)
}
if (current)
- wattron(tabline, tab_face.current_tab);
+ wattron(tabline, tab_face.current);
else
wattron(tabline, tab_face.tab);
@@ -877,7 +877,7 @@ redraw_tabline(void)
wprintw(tabline, " ");
if (current)
- wattroff(tabline, tab_face.current_tab);
+ wattroff(tabline, tab_face.current);
else
wattroff(tabline, tab_face.tab);
}
@@ -887,6 +887,7 @@ redraw_tabline(void)
waddch(tabline, ' ');
if (truncated)
mvwprintw(tabline, 0, COLS-1, ">");
+ wattroff(tabline, tab_face.background);
}
static void
@@ -1432,6 +1433,7 @@ ui_init(int argc, char * const *argv)
body_lines = LINES-3;
body_cols = COLS;
+
wbkgd(body, body_face.body);
update_x_offset();