MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / initializeColorRules

Function initializeColorRules

src/rules.cpp:40–77  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

38
39////////////////////////////////////////////////////////////////////////////////
40void 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////////////////////////////////////////////////////////////////////////////////
80static void applyColor(const Color& base, Color& c, bool merge) {

Callers 1

initializeMethod · 0.85

Calls 4

colorMethod · 0.80
clearMethod · 0.80
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected