mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
FF4 - header file reorg
- Added new util.h and text.h header files. - Corresponding edits.
This commit is contained in:
parent
58e1f3691c
commit
04f60a4d8c
18 changed files with 166 additions and 65 deletions
|
@ -32,8 +32,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include "task.h"
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// These are default (but overridable) reports. These entries are necessary
|
// These are default (but overridable) reports. These entries are necessary
|
||||||
|
|
|
@ -28,8 +28,9 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "task.h"
|
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Defaults to "now".
|
// Defaults to "now".
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "task.h"
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
#include "Duration.h"
|
#include "Duration.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "task.h"
|
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Default
|
// Default
|
||||||
|
|
|
@ -31,8 +31,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "task.h"
|
#include "T.h"
|
||||||
#include "TDB.h"
|
#include "TDB.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
TDB::TDB ()
|
TDB::TDB ()
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
#include <Table.h>
|
#include <Table.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
#include <task.h>
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Table::Table ()
|
Table::Table ()
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "T.h"
|
||||||
|
#include "TDB.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBNCURSES
|
#ifdef HAVE_LIBNCURSES
|
||||||
|
|
|
@ -33,6 +33,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "T.h"
|
||||||
|
#include "TDB.h"
|
||||||
|
#include "Date.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
|
#include "T.h"
|
||||||
|
#include "TDB.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -32,8 +32,9 @@
|
||||||
|
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
#include "Duration.h"
|
#include "Duration.h"
|
||||||
#include "task.h"
|
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// NOTE: These are static arrays only because there is no initializer list for
|
// NOTE: These are static arrays only because there is no initializer list for
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "TDB.h"
|
#include "TDB.h"
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBNCURSES
|
#ifdef HAVE_LIBNCURSES
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
#include "task.h"
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
static std::map <std::string, Text::color> gsFg;
|
static std::map <std::string, Text::color> gsFg;
|
||||||
static std::map <std::string, Text::color> gsBg;
|
static std::map <std::string, Text::color> gsBg;
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "TDB.h"
|
#include "TDB.h"
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "util.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBNCURSES
|
#ifdef HAVE_LIBNCURSES
|
||||||
|
|
56
src/task.h
56
src/task.h
|
@ -33,26 +33,8 @@
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "TDB.h"
|
|
||||||
#include "T.h"
|
|
||||||
#include "../auto.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
|
// parse.cpp
|
||||||
void parse (std::vector <std::string>&, std::string&, T&, Config&);
|
void parse (std::vector <std::string>&, std::string&, T&, Config&);
|
||||||
bool validPriority (const std::string&);
|
bool validPriority (const std::string&);
|
||||||
|
@ -120,44 +102,6 @@ std::string handleCustomReport (TDB&, T&, Config&, const std::string&);
|
||||||
void validReportColumns (const std::vector <std::string>&);
|
void validReportColumns (const std::vector <std::string>&);
|
||||||
void validSortColumns (const std::vector <std::string>&, const std::vector <std::string>&);
|
void validSortColumns (const std::vector <std::string>&, const std::vector <std::string>&);
|
||||||
|
|
||||||
// text.cpp
|
|
||||||
void wrapText (std::vector <std::string>&, 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<std::string>&, const std::string&, const char);
|
|
||||||
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
|
||||||
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
|
||||||
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::string>&, std::vector<std::string>&);
|
|
||||||
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 <std::string>&, bool trimLines = false);
|
|
||||||
bool slurp (const std::string&, std::string&, bool trimLines = false);
|
|
||||||
void spit (const std::string&, const std::string&);
|
|
||||||
|
|
||||||
// rules.cpp
|
// rules.cpp
|
||||||
void initializeColorRules (Config&);
|
void initializeColorRules (Config&);
|
||||||
void autoColorize (T&, Text::color&, Text::color&, Config&);
|
void autoColorize (T&, Text::color&, Text::color&, Config&);
|
||||||
|
|
|
@ -27,7 +27,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "task.h"
|
#include "Config.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "text.h"
|
||||||
|
|
||||||
static const char* newline = "\n";
|
static const char* newline = "\n";
|
||||||
static const char* noline = "";
|
static const char* noline = "";
|
||||||
|
|
51
src/text.h
Normal file
51
src/text.h
Normal file
|
@ -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 <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "Config.h"
|
||||||
|
#include "../auto.h"
|
||||||
|
|
||||||
|
// text.cpp
|
||||||
|
void wrapText (std::vector <std::string>&, 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<std::string>&, const std::string&, const char);
|
||||||
|
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
||||||
|
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
||||||
|
std::string commify (const std::string&);
|
||||||
|
std::string lowerCase (const std::string&);
|
||||||
|
std::string upperCase (const std::string&);
|
||||||
|
const char* optionalBlankLine (Config&);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
|
@ -38,6 +38,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
|
#include "T.h"
|
||||||
|
#include "TDB.h"
|
||||||
|
#include "text.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "../auto.h"
|
#include "../auto.h"
|
||||||
|
|
||||||
|
|
76
src/util.h
Normal file
76
src/util.h
Normal file
|
@ -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 <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <sys/types.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)
|
||||||
|
|
||||||
|
// 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::string>&, std::vector<std::string>&);
|
||||||
|
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 <std::string>&, bool trimLines = false);
|
||||||
|
bool slurp (const std::string&, std::string&, bool trimLines = false);
|
||||||
|
void spit (const std::string&, const std::string&);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue