aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-21 08:58:09 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-21 08:58:09 +0000
commit29d855d7c6930bd6c42a0d9f01f466e4602834d8 (patch)
tree18b4d98ec9f946a65bbce72f24bab7a9ba71f4da
parentosc: add TODO (diff)
term: prepare for configurable colors; add color variables to terminal
-rw-r--r--csi.c4
-rw-r--r--main.c4
-rw-r--r--osc.c2
-rw-r--r--render.c6
-rw-r--r--terminal.h13
5 files changed, 19 insertions, 10 deletions
diff --git a/csi.c b/csi.c
index 7709dfd6..fb5e7cb9 100644
--- a/csi.c
+++ b/csi.c
@@ -111,8 +111,8 @@ static void
sgr_reset(struct terminal *term)
{
memset(&term->vt.attrs, 0, sizeof(term->vt.attrs));
- term->vt.attrs.foreground = term->foreground;
- term->vt.attrs.background = term->background;
+ term->vt.attrs.foreground = term->colors.fg;
+ term->vt.attrs.background = term->colors.bg;
}
static const char *
diff --git a/main.c b/main.c
index 0c618d39..3903bf66 100644
--- a/main.c
+++ b/main.c
@@ -346,8 +346,8 @@ main(int argc, char *const *argv)
.cmd = REPEAT_STOP,
},
},
- .foreground = default_foreground,
- .background = default_background,
+ .colors.fg = default_foreground,
+ .colors.bg = default_background,
.selection = {
.start = {-1, -1},
.end = {-1, -1},
diff --git a/osc.c b/osc.c
index bd693a8d..02f393b6 100644
--- a/osc.c
+++ b/osc.c
@@ -18,7 +18,7 @@ osc_query(struct terminal *term, unsigned param)
switch (param) {
case 10:
case 11: {
- uint32_t color = param == 10 ? term->foreground : term->background;
+ uint32_t color = param == 10 ? term->colors.fg : term->colors.bg;
uint8_t r = (color >> 16) & 0xff;
uint8_t g = (color >> 8) & 0xff;
uint8_t b = (color >> 0) & 0xff;
diff --git a/render.c b/render.c
index 5b3c2956..f9c7fbca 100644
--- a/render.c
+++ b/render.c
@@ -105,10 +105,10 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell,
uint32_t _fg = cell->attrs.foreground >> 31
? cell->attrs.foreground
- : !term->reverse ? term->foreground : term->background;
+ : !term->reverse ? term->colors.fg : term->colors.bg;
uint32_t _bg = cell->attrs.background >> 31
? cell->attrs.background
- : !term->reverse ? term->background : term->foreground;
+ : !term->reverse ? term->colors.bg : term->colors.fg;
/* If *one* is set, we reverse */
if (has_cursor ^ cell->attrs.reverse ^ is_selected) {
@@ -307,7 +307,7 @@ grid_render(struct terminal *term)
int rmargin_width = term->width - rmargin;
int bmargin_height = term->height - bmargin;
- uint32_t _bg = !term->reverse ? term->background : term->foreground;
+ uint32_t _bg = !term->reverse ? term->colors.bg : term->colors.fg;
struct rgb bg = color_hex_to_rgb(_bg);
cairo_set_source_rgb(buf->cairo, bg.r, bg.g, bg.b);
diff --git a/terminal.h b/terminal.h
index c0d68f21..a2ffbb92 100644
--- a/terminal.h
+++ b/terminal.h
@@ -259,8 +259,17 @@ struct terminal {
bool print_needs_wrap;
struct scroll_region scroll_region;
- uint32_t foreground;
- uint32_t background;
+ struct {
+ uint32_t fg;
+ uint32_t bg;
+ uint32_t regular[8];
+ uint32_t bright[8];
+
+ uint32_t default_fg;
+ uint32_t defualt_bg;
+ uint32_t default_regular[8];
+ uint32_t defualt_bright[8];
+ } colors;
struct {
int col;