From a7710f921d66c0065f457fca093452d8a7ce9f65 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 22 Jan 2024 19:01:04 +0100 Subject: [PATCH] Drop gray from the highlight colors, and let colorFromName return `nil` This allows us to fairly easily make gray behave as our legacy grayscale highlights, honoring the user's opacity value. --- ffi/blitbuffer.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ffi/blitbuffer.lua b/ffi/blitbuffer.lua index 4443f2715..e26d7ddc4 100644 --- a/ffi/blitbuffer.lua +++ b/ffi/blitbuffer.lua @@ -2559,7 +2559,7 @@ function BB.gray(level) end --[[ -return a Color value resembling a given hex string +return a Color value resembling a given hex string (nil on failure) --]] function BB.colorFromString(value) value = value:gsub('#','') @@ -2601,13 +2601,14 @@ BB.HIGHLIGHT_COLORS = { ["cyan"] = "#00FFEE", ["blue"] = "#0066FF", ["purple"] = "#EE00FF", - ["gray"] = "#CCCCCC", -- Matches the default highlight style on grayscale screens (i.e., darkenRect by 0.2) } --[[ -return a Color value given a common color name (fall back to gray for unknown colors) +return a Color value given a common color name (nil for unknown colors) --]] function BB.colorFromName(name) - return BB.colorFromString(BB.HIGHLIGHT_COLORS[name:lower()] or "#808080") + local color_hash = BB.HIGHLIGHT_COLORS[name:lower()] + if not color_hash then return nil end + return BB.colorFromString(color_hash) end --[[