patch 8.2.3628: looking terminal colors is a bit slow
Problem: Looking terminal colors is a bit slow.
Solution: Cache the terminal colors. (closes #9130, closes #9058)
diff --git a/src/libvterm/include/vterm.h b/src/libvterm/include/vterm.h
index fe4a6fc..9873b6d 100644
--- a/src/libvterm/include/vterm.h
+++ b/src/libvterm/include/vterm.h
@@ -122,7 +122,12 @@
/**
* Mask that can be used to extract the default foreground/background bit.
*/
- VTERM_COLOR_DEFAULT_MASK = 0x06
+ VTERM_COLOR_DEFAULT_MASK = 0x06,
+
+ /**
+ * If set, indicates that the color is invalid.
+ */
+ VTERM_COLOR_INVALID = 0x08
} VTermColorType;
/**
@@ -155,6 +160,12 @@
#define VTERM_COLOR_IS_DEFAULT_BG(col) \
(!!((col)->type & VTERM_COLOR_DEFAULT_BG))
+/**
+ * Returns true if the VTERM_COLOR_INVALID `type` flag is set, indicating
+ * that the given VTermColor instance is an invalid color.
+ */
+#define VTERM_COLOR_IS_INVALID(col) (!!((col)->type & VTERM_COLOR_INVALID))
+
typedef struct {
/**
* Tag indicating which member is actually valid.