diff --git a/src/Config.cpp b/src/Config.cpp index 6a99189ad..ac63f9871 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -32,8 +32,9 @@ #include #include #include -#include "task.h" #include "Config.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // These are default (but overridable) reports. These entries are necessary diff --git a/src/Date.cpp b/src/Date.cpp index 995011345..cdc5cc7d3 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -28,8 +28,9 @@ #include #include #include -#include "task.h" #include "Date.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // Defaults to "now". diff --git a/src/Duration.cpp b/src/Duration.cpp index d0cb4a469..7c55be345 100644 --- a/src/Duration.cpp +++ b/src/Duration.cpp @@ -26,7 +26,8 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include "task.h" +#include "text.h" +#include "util.h" #include "Duration.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/T.cpp b/src/T.cpp index 58a280f62..43bf0e200 100644 --- a/src/T.cpp +++ b/src/T.cpp @@ -27,8 +27,9 @@ #include #include #include -#include "task.h" #include "T.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // Default diff --git a/src/TDB.cpp b/src/TDB.cpp index 98c2c8009..299eda3e6 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -31,8 +31,9 @@ #include #include -#include "task.h" +#include "T.h" #include "TDB.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// TDB::TDB () diff --git a/src/Table.cpp b/src/Table.cpp index 37b9a48e5..f737d52e6 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -49,7 +49,8 @@ #include #include #include -#include +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// Table::Table () diff --git a/src/command.cpp b/src/command.cpp index 4a89427e1..4f8cc67cc 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -34,6 +34,10 @@ #include #include +#include "T.h" +#include "TDB.h" +#include "text.h" +#include "util.h" #include "task.h" #ifdef HAVE_LIBNCURSES diff --git a/src/edit.cpp b/src/edit.cpp index 445e8a1c6..30be75ec7 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -33,6 +33,11 @@ #include #include #include +#include "T.h" +#include "TDB.h" +#include "Date.h" +#include "text.h" +#include "util.h" #include "task.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/import.cpp b/src/import.cpp index 163dca30d..bcb154147 100644 --- a/src/import.cpp +++ b/src/import.cpp @@ -29,6 +29,10 @@ #include #include #include "Date.h" +#include "T.h" +#include "TDB.h" +#include "text.h" +#include "util.h" #include "task.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/parse.cpp b/src/parse.cpp index 7e5a86f9f..b4e40aa34 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -32,8 +32,9 @@ #include "Date.h" #include "Duration.h" -#include "task.h" #include "T.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // NOTE: These are static arrays only because there is no initializer list for diff --git a/src/report.cpp b/src/report.cpp index 050f6e85c..17f5bd1fb 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -40,6 +40,8 @@ #include "Table.h" #include "TDB.h" #include "T.h" +#include "text.h" +#include "util.h" #include "task.h" #ifdef HAVE_LIBNCURSES diff --git a/src/rules.cpp b/src/rules.cpp index 5744dd3ca..2030e1a36 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -30,7 +30,8 @@ #include "Table.h" #include "Date.h" #include "T.h" -#include "task.h" +#include "text.h" +#include "util.h" static std::map gsFg; static std::map gsBg; diff --git a/src/task.cpp b/src/task.cpp index 4984b5a11..57526180a 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -42,6 +42,8 @@ #include "Table.h" #include "TDB.h" #include "T.h" +#include "text.h" +#include "util.h" #include "task.h" #ifdef HAVE_LIBNCURSES diff --git a/src/task.h b/src/task.h index 7599007ea..3104c5d6d 100644 --- a/src/task.h +++ b/src/task.h @@ -33,26 +33,8 @@ #include "Table.h" #include "Date.h" #include "color.h" -#include "TDB.h" -#include "T.h" #include "../auto.h" -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#define foreach(i, c) \ -for (typeof (c) *foreach_p = & (c); \ - foreach_p; \ - foreach_p = 0) \ - for (typeof (foreach_p->begin()) i = foreach_p->begin(); \ - i != foreach_p->end(); \ - ++i) - // parse.cpp void parse (std::vector &, std::string&, T&, Config&); bool validPriority (const std::string&); @@ -120,44 +102,6 @@ std::string handleCustomReport (TDB&, T&, Config&, const std::string&); void validReportColumns (const std::vector &); void validSortColumns (const std::vector &, const std::vector &); -// text.cpp -void wrapText (std::vector &, const std::string&, const int); -std::string trimLeft (const std::string& in, const std::string& t = " "); -std::string trimRight (const std::string& in, const std::string& t = " "); -std::string trim (const std::string& in, const std::string& t = " "); -std::string unquoteText (const std::string&); -void extractLine (std::string&, std::string&, int); -void split (std::vector&, const std::string&, const char); -void split (std::vector&, const std::string&, const std::string&); -void join (std::string&, const std::string&, const std::vector&); -std::string commify (const std::string&); -std::string lowerCase (const std::string&); -std::string upperCase (const std::string&); -const char* optionalBlankLine (Config&); - -// util.cpp -bool confirm (const std::string&); -void delay (float); -void formatTimeDeltaDays (std::string&, time_t); -std::string formatSeconds (time_t); -int autoComplete (const std::string&, const std::vector&, std::vector&); -const std::string uuid (); -int convertDuration (const std::string&); -std::string expandPath (const std::string&); - -#ifdef SOLARIS - #define LOCK_SH 1 - #define LOCK_EX 2 - #define LOCK_NB 4 - #define LOCK_UN 8 - - int flock (int, int); -#endif - -bool slurp (const std::string&, std::vector &, bool trimLines = false); -bool slurp (const std::string&, std::string&, bool trimLines = false); -void spit (const std::string&, const std::string&); - // rules.cpp void initializeColorRules (Config&); void autoColorize (T&, Text::color&, Text::color&, Config&); diff --git a/src/text.cpp b/src/text.cpp index 69689a5ac..ac1015031 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -27,7 +27,9 @@ #include #include #include -#include "task.h" +#include "Config.h" +#include "util.h" +#include "text.h" static const char* newline = "\n"; static const char* noline = ""; diff --git a/src/text.h b/src/text.h new file mode 100644 index 000000000..458d714d0 --- /dev/null +++ b/src/text.h @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_TEXT +#define INCLUDED_TEXT + +#include +#include +#include "Config.h" +#include "../auto.h" + +// text.cpp +void wrapText (std::vector &, const std::string&, const int); +std::string trimLeft (const std::string& in, const std::string& t = " "); +std::string trimRight (const std::string& in, const std::string& t = " "); +std::string trim (const std::string& in, const std::string& t = " "); +std::string unquoteText (const std::string&); +void extractLine (std::string&, std::string&, int); +void split (std::vector&, const std::string&, const char); +void split (std::vector&, const std::string&, const std::string&); +void join (std::string&, const std::string&, const std::vector&); +std::string commify (const std::string&); +std::string lowerCase (const std::string&); +std::string upperCase (const std::string&); +const char* optionalBlankLine (Config&); + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/util.cpp b/src/util.cpp index 736f24825..8cbb9cfe2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -38,6 +38,9 @@ #include #include "Date.h" #include "Table.h" +#include "T.h" +#include "TDB.h" +#include "text.h" #include "task.h" #include "../auto.h" diff --git a/src/util.h b/src/util.h new file mode 100644 index 000000000..2bfaef59a --- /dev/null +++ b/src/util.h @@ -0,0 +1,76 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_UTIL +#define INCLUDED_UTIL + +#include +#include +#include +#include +#include "../auto.h" + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#define foreach(i, c) \ +for (typeof (c) *foreach_p = & (c); \ + foreach_p; \ + foreach_p = 0) \ + for (typeof (foreach_p->begin()) i = foreach_p->begin(); \ + i != foreach_p->end(); \ + ++i) + +// util.cpp +bool confirm (const std::string&); +void delay (float); +void formatTimeDeltaDays (std::string&, time_t); +std::string formatSeconds (time_t); +int autoComplete (const std::string&, const std::vector&, std::vector&); +const std::string uuid (); +int convertDuration (const std::string&); +std::string expandPath (const std::string&); + +#ifdef SOLARIS + #define LOCK_SH 1 + #define LOCK_EX 2 + #define LOCK_NB 4 + #define LOCK_UN 8 + + int flock (int, int); +#endif + +bool slurp (const std::string&, std::vector &, bool trimLines = false); +bool slurp (const std::string&, std::string&, bool trimLines = false); +void spit (const std::string&, const std::string&); + +#endif +////////////////////////////////////////////////////////////////////////////////