diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0fbf17eb..f3da275c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,7 @@ set (timew_SRCS Database.cpp Database.h Timeline.cpp Timeline.h classifier.cpp init.cpp + helper.cpp util.cpp) set (libshared_SRCS libshared/src/Args.cpp libshared/src/Args.h diff --git a/src/helper.cpp b/src/helper.cpp new file mode 100644 index 00000000..eea998f3 --- /dev/null +++ b/src/helper.cpp @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// http://www.opensource.org/licenses/mit-license.php +// +//////////////////////////////////////////////////////////////////////////////// + +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +Color tagColor (const Rules& rules, const std::string& tag) +{ + Color c; + std::string name = std::string ("tag.") + tag + ".color"; + if (rules.has (name)) + c = Color (rules.get (name)); + + return c; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/timew.h b/src/timew.h index 72dccda7..f4d0e4a9 100644 --- a/src/timew.h +++ b/src/timew.h @@ -31,6 +31,7 @@ #include #include #include +#include // init.cpp bool lightweightVersionCheck (const std::vector &); @@ -41,6 +42,9 @@ int dispatchCommand (const std::vector &, Database&, Rules&, Extens // classifier.cpp std::vector getKeywords (const std::vector &); +// helper.cpp +Color tagColor (const Rules&, const std::string&); + // utiƀ.cpp std::string osName (); std::string escape (const std::string&, int);