From e7152bad56906838fb306aee15b04ab778f2c69c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 23 Oct 2015 13:34:03 +0100 Subject: [PATCH] Add an exclusive attribute that overrides existing face --- src/face.hh | 20 +++++++++++--------- src/face_registry.cc | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/face.hh b/src/face.hh index 2540705e..806089a9 100644 --- a/src/face.hh +++ b/src/face.hh @@ -10,12 +10,13 @@ namespace Kakoune enum class Attribute : int { Normal = 0, - Underline = 1 << 1, - Reverse = 1 << 2, - Blink = 1 << 3, - Bold = 1 << 4, - Dim = 1 << 5, - Italic = 1 << 6, + Exclusive = 1 << 1, + Underline = 1 << 2, + Reverse = 1 << 3, + Blink = 1 << 4, + Bold = 1 << 5, + Dim = 1 << 6, + Italic = 1 << 7, }; template<> struct WithBitOps : std::true_type {}; @@ -45,9 +46,10 @@ constexpr bool operator!=(const Face& lhs, const Face& rhs) constexpr Face merge_faces(const Face& base, const Face& face) { - return { face.fg == Color::Default ? base.fg : face.fg, - face.bg == Color::Default ? base.bg : face.bg, - face.attributes | base.attributes }; + return face.attributes & Attribute::Exclusive ? + face : Face{ face.fg == Color::Default ? base.fg : face.fg, + face.bg == Color::Default ? base.bg : face.bg, + face.attributes | base.attributes }; } } diff --git a/src/face_registry.cc b/src/face_registry.cc index a1a0e582..2f0be21b 100644 --- a/src/face_registry.cc +++ b/src/face_registry.cc @@ -24,6 +24,7 @@ static Face parse_face(StringView facedesc) { switch (*attr_it) { + case 'e': res.attributes |= Attribute::Exclusive; break; case 'u': res.attributes |= Attribute::Underline; break; case 'r': res.attributes |= Attribute::Reverse; break; case 'b': res.attributes |= Attribute::Bold; break;