///////////////////////////////////////////////////////////////////////////
| 38 | |
| 39 | //////////////////////////////////////////////////////////////////////////////// |
| 40 | void initializeColorRules() { |
| 41 | // If color is not enable/supported, short circuit. |
| 42 | if (!Context::getContext().color()) return; |
| 43 | |
| 44 | try { |
| 45 | gsColor.clear(); |
| 46 | gsPrecedence.clear(); |
| 47 | |
| 48 | // Load all the configuration values, filter to only the ones that begin with |
| 49 | // "color.", then store name/value in gsColor, and name in rules. |
| 50 | std::vector<std::string> rules; |
| 51 | for (const auto& v : Context::getContext().config) { |
| 52 | if (!v.first.compare(0, 6, "color.", 6)) { |
| 53 | Color c(v.second); |
| 54 | gsColor[v.first] = c; |
| 55 | |
| 56 | rules.push_back(v.first); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // Load the rule.precedence.color list, split it, then autocomplete against |
| 61 | // the 'rules' vector loaded above. |
| 62 | std::vector<std::string> results; |
| 63 | auto precedence = split(Context::getContext().config.get("rule.precedence.color"), ','); |
| 64 | |
| 65 | for (const auto& p : precedence) { |
| 66 | // Add the leading "color." string. |
| 67 | std::string rule = "color." + p; |
| 68 | autoComplete(rule, rules, results, 3); // Hard-coded 3. |
| 69 | |
| 70 | for (auto& r : results) gsPrecedence.push_back(r); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | catch (const std::string& e) { |
| 75 | Context::getContext().error(e); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | //////////////////////////////////////////////////////////////////////////////// |
| 80 | static void applyColor(const Color& base, Color& c, bool merge) { |
no test coverage detected