#pragma once #include #include namespace lumacs { /// RGB Color representation struct Color { int r, g, b; Color(int r = 0, int g = 0, int b = 0) : r(r), g(g), b(b) {} /// Convert to ncurses color index (will be assigned dynamically) int to_ncurses_color() const; /// Create Color from hex string (e.g., "#FF5500" or "FF5500") static Color from_hex(const std::string& hex) { std::string h = hex; // Remove leading # if present if (!h.empty() && h[0] == '#') { h = h.substr(1); } // Parse hex values if (h.length() >= 6) { int r = static_cast(std::strtol(h.substr(0, 2).c_str(), nullptr, 16)); int g = static_cast(std::strtol(h.substr(2, 2).c_str(), nullptr, 16)); int b = static_cast(std::strtol(h.substr(4, 2).c_str(), nullptr, 16)); return Color(r, g, b); } return Color(0, 0, 0); // Default to black on parse error } /// Comparison operator for use in maps bool operator<(const Color& other) const { if (r != other.r) return r < other.r; if (g != other.g) return g < other.g; return b < other.b; } bool operator==(const Color& other) const { return r == other.r && g == other.g && b == other.b; } }; } // namespace lumacs