From c7f3599ebca82fcd1c2a00de234f90ac1f5f0ede Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 22 Feb 2014 01:38:47 +0000 Subject: [PATCH 1/2] Fix -fg/-bg/-style with 256 colour terminals. --- style.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/style.c b/style.c index 97d5576e..99744086 100644 --- a/style.c +++ b/style.c @@ -203,8 +203,14 @@ style_apply(struct grid_cell *gc, struct options *oo, const char *name) memcpy(gc, &grid_default_cell, sizeof *gc); gcp = options_get_style(oo, name); - colour_set_fg(gc, gcp->fg); - colour_set_bg(gc, gcp->bg); + if (gcp->flags & GRID_FLAG_FG256) + colour_set_fg(gc, gcp->fg | 0x100); + else + colour_set_fg(gc, gcp->fg); + if (gcp->flags & GRID_FLAG_BG256) + colour_set_bg(gc, gcp->bg | 0x100); + else + colour_set_bg(gc, gcp->bg); gc->attr |= gcp->attr; } @@ -215,10 +221,18 @@ style_apply_update(struct grid_cell *gc, struct options *oo, const char *name) struct grid_cell *gcp; gcp = options_get_style(oo, name); - if (gcp->fg != 8) - colour_set_fg(gc, gcp->fg); - if (gcp->bg != 8) - colour_set_bg(gc, gcp->bg); + if (gcp->fg != 8) { + if (gcp->flags & GRID_FLAG_FG256) + colour_set_fg(gc, gcp->fg | 0x100); + else + colour_set_fg(gc, gcp->fg); + } + if (gcp->bg != 8) { + if (gcp->flags & GRID_FLAG_BG256) + colour_set_bg(gc, gcp->bg | 0x100); + else + colour_set_bg(gc, gcp->bg); + } if (gcp->attr != 0) gc->attr |= gcp->attr; } From 315d45a0eb596048f2513dab98e4bb47ec1852a4 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 22 Feb 2014 18:01:10 +0000 Subject: [PATCH 2/2] Fix crash due to uninitialized lastwp member of layout_cell, reported by Balazs Kezes. --- layout.c | 1 + window.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/layout.c b/layout.c index b91b86cd..1c76f986 100644 --- a/layout.c +++ b/layout.c @@ -53,6 +53,7 @@ layout_create_cell(struct layout_cell *lcparent) lc->yoff = UINT_MAX; lc->wp = NULL; + lc->lastwp = NULL; return (lc); } diff --git a/window.c b/window.c index 1e11cace..842a5c63 100644 --- a/window.c +++ b/window.c @@ -410,8 +410,9 @@ window_pane_active_set(struct window_pane *wp, struct window_pane *nextwp) * Previously active pane, if any, must not be the same as the source * pane. */ - if (nextwp->layout_cell->parent != NULL) { - lastwp = nextwp->layout_cell->parent->lastwp; + lc = nextwp->layout_cell->parent; + if (lc != NULL && lc->lastwp != NULL) { + lastwp = lc->lastwp; if (lastwp != wp && window_pane_visible(lastwp)) return (lastwp); }