=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/style.c,v retrieving revision 1.26 retrieving revision 1.27 diff -c -r1.26 -r1.27 *** src/usr.bin/tmux/style.c 2020/05/16 14:53:23 1.26 --- src/usr.bin/tmux/style.c 2020/05/16 15:01:31 1.27 *************** *** 1,4 **** ! /* $OpenBSD: style.c,v 1.26 2020/05/16 14:53:23 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: style.c,v 1.27 2020/05/16 15:01:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 260,276 **** return (s); } ! /* Apply a style. */ void ! style_apply(struct grid_cell *gc, struct options *oo, const char *name) { ! struct style *sy; ! memcpy(gc, &grid_default_cell, sizeof *gc); ! sy = options_get_style(oo, name); ! gc->fg = sy->gc.fg; ! gc->bg = sy->gc.bg; gc->attr |= sy->gc.attr; } /* Initialize style from cell. */ --- 260,296 ---- return (s); } ! /* Apply a style on top of the given style. */ void ! style_add(struct grid_cell *gc, struct options *oo, const char *name, ! struct format_tree *ft) { ! struct style *sy; ! struct format_tree *ft0 = NULL; ! if (ft == NULL) ! ft = ft0 = format_create(NULL, NULL, 0, FORMAT_NOJOBS); ! ! sy = options_string_to_style(oo, name, ft); ! if (sy == NULL) ! sy = &style_default; ! if (sy->gc.fg != 8) ! gc->fg = sy->gc.fg; ! if (sy->gc.bg != 8) ! gc->bg = sy->gc.bg; gc->attr |= sy->gc.attr; + + if (ft0 != NULL) + format_free(ft0); + } + + /* Apply a style on top of the default style. */ + void + style_apply(struct grid_cell *gc, struct options *oo, const char *name, + struct format_tree *ft) + { + memcpy(gc, &grid_default_cell, sizeof *gc); + style_add(gc, oo, name, ft); } /* Initialize style from cell. */