Compare commits
129 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a6de7d940 | ||
|
|
994f98b57a | ||
|
|
44ca388b52 | ||
|
|
06a85c24ad | ||
|
|
ceaba87ba3 | ||
|
|
61acf6239c | ||
|
|
8dc8cdeea7 | ||
|
|
10ef3013e3 | ||
|
|
3899f5352f | ||
|
|
64fbf88f48 | ||
|
|
2e0964aeb8 | ||
|
|
35d878de96 | ||
|
|
d771586080 | ||
|
|
6673e408a2 | ||
|
|
422ad576ea | ||
|
|
c1a1d13aab | ||
|
|
42189ce998 | ||
|
|
43287d7fc9 | ||
|
|
06f6aaaded | ||
|
|
0c17986303 | ||
|
|
feb9959907 | ||
|
|
7409e23ce0 | ||
|
|
4572c97c9d | ||
|
|
9bca303113 | ||
|
|
7fb3ab0c3d | ||
|
|
56037fe3bc | ||
|
|
a2f8ce41cf | ||
|
|
598bd3b4ef | ||
|
|
315a7d69fb | ||
|
|
64fff6c2ff | ||
|
|
969ecd7b5d | ||
|
|
cede865693 | ||
|
|
d68395bc51 | ||
|
|
7ec523d5ea | ||
|
|
08fc906d5f | ||
|
|
f3e995ef92 | ||
|
|
a4304c97af | ||
|
|
d1ef0d17d5 | ||
|
|
c54cb4d6c8 | ||
|
|
c393d47cdf | ||
|
|
3525b6db2c | ||
|
|
d50efe5e27 | ||
|
|
2c0a1ddb3a | ||
|
|
d7ac37783c | ||
|
|
03bb50c4ea | ||
|
|
1535010ac9 | ||
|
|
8d90035bbc | ||
|
|
fd7bb9daa9 | ||
|
|
88b12bc66a | ||
|
|
a8ac82ca22 | ||
|
|
438f3cb134 | ||
|
|
131693f617 | ||
|
|
07d1f63e31 | ||
|
|
73286e8662 | ||
|
|
95c3f78c68 | ||
|
|
90df505982 | ||
|
|
e8b7114ce8 | ||
|
|
714d9c5544 | ||
|
|
f2ba9f796b | ||
|
|
e025ecc3d4 | ||
|
|
ccd2b9fc44 | ||
|
|
6cb902c499 | ||
|
|
d216d40121 | ||
|
|
08f4ead97e | ||
|
|
f3de5c0711 | ||
|
|
89d4dd74da | ||
|
|
9ff83281c5 | ||
|
|
787b3b4a51 | ||
|
|
74e77e4dc5 | ||
|
|
f73c64801c | ||
|
|
039c3119ff | ||
|
|
fb9f5e2ab3 | ||
|
|
3077c50774 | ||
|
|
0ec24aaef5 | ||
|
|
1a580b1967 | ||
|
|
fd8f63dec6 | ||
|
|
7c9554e8c5 | ||
|
|
f57e22124f | ||
|
|
9aec4efefa | ||
|
|
8a0b8e0328 | ||
|
|
1aa9051885 | ||
|
|
654eb260c7 | ||
|
|
b061ef6191 | ||
|
|
86a9f0f6d5 | ||
|
|
0bf87ed311 | ||
|
|
abc9aa08ec | ||
|
|
a42b8a89c3 | ||
|
|
011ad8fafd | ||
|
|
586883a98d | ||
|
|
40dc0490e1 | ||
|
|
abef040ebc | ||
|
|
cb4f86e9f1 | ||
|
|
b8fc8a0172 | ||
|
|
35dd5df583 | ||
|
|
e666772477 | ||
|
|
6b07f04338 | ||
|
|
334eb45534 | ||
|
|
5e6b256df5 | ||
|
|
e392b8a95e | ||
|
|
18fd59a1ed | ||
|
|
4549af6b84 | ||
|
|
4825b37df5 | ||
|
|
148088c775 | ||
|
|
45a25ca47b | ||
|
|
ab0a57ec89 | ||
|
|
65c2fe438f | ||
|
|
37bdfe06da | ||
|
|
b54b07ef77 | ||
|
|
e3eb87aa74 | ||
|
|
b34cb90709 | ||
|
|
04da56193e | ||
|
|
25dc415094 | ||
|
|
0b37b6a980 | ||
|
|
42493dbdee | ||
|
|
3e1afc5777 | ||
|
|
a8fa293695 | ||
|
|
e7341a19cf | ||
|
|
2ecf500322 | ||
|
|
494ed3b964 | ||
|
|
53747cc984 | ||
|
|
b63cf606f0 | ||
|
|
3dd45611ff | ||
|
|
e32d0562a2 | ||
|
|
a991cbf242 | ||
|
|
2e047367b0 | ||
|
|
f9ed90bee0 | ||
|
|
62e6b31a17 | ||
|
|
ce52f88f4b | ||
|
|
6d5de69f90 |
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
auto.h*
|
||||
config.h.in
|
||||
config.status
|
||||
src/.deps
|
||||
src/Makefile
|
||||
src/task
|
||||
stamp-h1
|
||||
Makefile
|
||||
configure
|
||||
config.log
|
||||
15
AUTHORS
15
AUTHORS
@@ -0,0 +1,15 @@
|
||||
Principal Author:
|
||||
Paul Beckingham, paul@beckingham.net
|
||||
|
||||
Contributing Authors:
|
||||
Damian Glenny
|
||||
|
||||
With thanks to:
|
||||
Eugene Kramer
|
||||
Srijith K
|
||||
Richard Querin
|
||||
Bruce Israel
|
||||
Thomas Engel
|
||||
Nishiishii
|
||||
galvanizd
|
||||
|
||||
|
||||
59
COPYING
59
COPYING
@@ -278,63 +278,4 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
214
ChangeLog
214
ChangeLog
@@ -1,16 +1,212 @@
|
||||
Version numbers are of the form:
|
||||
|
||||
0.9.2
|
||||
4/3/2008
|
||||
- Configure now detects ncurses, flock.
|
||||
X.Y.Z
|
||||
|
||||
where the X represents a major version number, or architecture. The Y
|
||||
represents a feature release, and the Z represents a patch.
|
||||
|
||||
------ plans -------------------------------------
|
||||
|
||||
- Configurable columns in reports
|
||||
- Dependencies
|
||||
- Recurring tasks
|
||||
|
||||
|
||||
0.9.1
|
||||
4/1/2008
|
||||
- First autoconf version released.
|
||||
- Bug: due dates not checked for correctness
|
||||
- Bug: attributes without values stored instead of removed
|
||||
1.3.1 (6/21/2008)
|
||||
+ New configuration variable, "defaultwidth" that determines the width
|
||||
of tables when ncurses support is not available
|
||||
+ Bug: "showage" configuration variable should apply to all reports, not
|
||||
just the ones based on "list"
|
||||
+ Bug: Fixed segmentation faults on Ubuntu when the "dateformat"
|
||||
configuration variables was missing. This was a code bug, and should
|
||||
have affected more platforms
|
||||
+ Bug: Task now will recreate a missing ~/.taskrc file, OR a missing
|
||||
~/.task directory
|
||||
|
||||
------ reality -----------------------------------
|
||||
|
||||
0.9.0
|
||||
1.3.0 (6/18/2008)
|
||||
+ "task calendar" now displays multiple months per line, adjustable by the
|
||||
"monthsperline" configuration variable. Feature added by Damian Glenny
|
||||
+ "task export" can now filter tasks like the reports
|
||||
+ Factored out code to filter tasks
|
||||
+ Displays shorter message when a command is entered incorrectly, and the
|
||||
full usage for "task help"
|
||||
+ "task oldest" shows the oldest tasks
|
||||
+ "task newest" shows the newest tasks
|
||||
+ Bug: Segmentation fault when no "dateformat" configuration variable
|
||||
specified
|
||||
+ Bug: Fixed bug whereby if you have more than one task with a due date, 7
|
||||
days gets added to the entry date of task 2..n
|
||||
+ Bug: Fixed bug whereby "1 wks" was being improperly pluralized
|
||||
|
||||
1.2.0 (6/13/2008)
|
||||
+ Bug: "dateformat" configuration variable used to display dates, but
|
||||
not parse them
|
||||
+ "task list x" now performs a caseless comparison between "x" and the
|
||||
description
|
||||
+ Task sub projects supported
|
||||
+ "showage" confguration determines whether "Age" column appears on the
|
||||
"list" and "next" reports
|
||||
+ Improved TUTORIAL
|
||||
|
||||
1.1.0 (6/7/2008)
|
||||
+ "blanklines" configuration to stop displaying unnecessary white
|
||||
space and thus work better on small-screen devices
|
||||
+ "dateformat" configuration now determines how dates are formatted
|
||||
+ Better formatting of "task tags" output
|
||||
+ http://www.beckingham.net/task.html home page set up
|
||||
+ Added tags to the "task long" report
|
||||
|
||||
1.0.1 (6/4/2008)
|
||||
+ Bug: UUID generator not properly terminating string.
|
||||
+ Bug: srandom/srand not called prior to UUID generation.
|
||||
|
||||
1.0.0 (6/3/2008)
|
||||
+ New movie made, uploaded
|
||||
+ Bug: assertion fails on mobile for t v
|
||||
+ Bug: configure.ac does not properly determine ncurses availability
|
||||
+ Bug: Cannot seem to use the percent character in a task description
|
||||
+ Bug: New installation "task stats" reports newest task 12/31/1969
|
||||
+ Bug: New installation task projects displays header but no data - should short-circuit
|
||||
+ Bug: incorrect color specification in sample .taskrc file
|
||||
+ Bug: when run without arguments, task dumps core on Solaris 10
|
||||
+ "task calendar" now reports all months with due pending tasks
|
||||
+ Added rules for colorization by tag, project and keyword
|
||||
+ Added legend to "task calendar"
|
||||
|
||||
0.9.9 (5/27/2008)
|
||||
+ Autoconf/automake behaving properly.
|
||||
+ Clean build on OS X 10.5.
|
||||
+ Clean build on Ubuntu 8.0.
|
||||
+ Clean build on Fedora Core 8.
|
||||
+ Clean build on Fedora Core 9.
|
||||
|
||||
0.9.8 (5/25/2008)
|
||||
+ Added "task color" command.
|
||||
+ Removed unnecessary files.
|
||||
+ Completed documentation.
|
||||
|
||||
0.9.7 (5/24/2008)
|
||||
+ Migrated old compiler flags into Makefile.am
|
||||
+ Added ncurses endwin function check to configure.ac
|
||||
+ Set up structure for AUTHORS file.
|
||||
+ Set up NEWS file, with pleas for feedback.
|
||||
+ Added welcome message to README.
|
||||
+ Completed a chunk of the TUTORIAL.
|
||||
+ Added error handling for "task export" when a file name is not specified.
|
||||
+ Task offers to create a sample ~/.taskrc file if one is not found.
|
||||
+ Task offers to create a ~/.task directory if one is not found.
|
||||
+ Removed unnecessary SAMPLE_taskrc, and assorted references.
|
||||
+ Cleaned up ChangeLog.
|
||||
+ Minor mods to standard docs.
|
||||
+ Bumped version to 0.9.7
|
||||
+ Changed some autoconf details
|
||||
+ Corrected comment in T.cpp
|
||||
+ Made unit tests compile and run again.
|
||||
+ Removed tests from distibution.
|
||||
|
||||
0.9.6 (5/13/208)
|
||||
+ Corrected wrong include file in Table.cpp
|
||||
+ Replaced color management code.
|
||||
+ Improved color rules code.
|
||||
|
||||
0.9.5 (5/12/2008)
|
||||
+ Replaced Table storage with Grid.
|
||||
+ Added Grid.cpp to configure.ac
|
||||
+ Added Makefile to src/.gitignore
|
||||
+ Makefile should not be part of the repository.
|
||||
+ Added Grid.cpp
|
||||
+ Added Grid::Cell::operator==
|
||||
+ ChangeLog file begun.
|
||||
+ Bumped version to 0.9.5 for next release.
|
||||
|
||||
0.9.4 (4/26/2008)
|
||||
+ Integrated new Grid object into build - not yet integrated into Table.
|
||||
+ More .gitignore tweaks.
|
||||
+ Added .gitignore
|
||||
+ Added more missing files.
|
||||
+ Added all source code.
|
||||
+ Generic OSS files added.
|
||||
+ Initial commit.
|
||||
|
||||
0.9.3 (4/6/2008)
|
||||
+ Added "task completed" command.
|
||||
+ Properly recognizes ncurses.
|
||||
|
||||
0.9.2 (4/3/2008)
|
||||
+ Recognizes whether ncurses, flock is available.
|
||||
+ "task" duplicated to "task_rel" for preparation of a fork.
|
||||
|
||||
0.9.1 (4/1/2008)
|
||||
+ Blank attributes read are longer be written out.
|
||||
+ Completed "task export" command.
|
||||
+ Added configuration values to "task version" command.
|
||||
+ Consolidated header files, removed unnecessary ones.
|
||||
|
||||
0.9.0 (3/23/2008)
|
||||
+ flat source directory
|
||||
+ autoconf complete
|
||||
+ "task next"
|
||||
+ "task stats"
|
||||
+ "task export"
|
||||
+ Rules-based colorization
|
||||
|
||||
0.8.1 (1/28/2008) - 0.8.16 (3/13/2008)
|
||||
+ autoconf conversion (many builds)
|
||||
|
||||
0.8.0 Polish (1/25/2008)
|
||||
+ Code cleanup, reorganization
|
||||
+ "task overdue"
|
||||
+ Add "age" column to list and long
|
||||
+ Use 'conf' for build, version tracking
|
||||
+ Add "/from/to/" description editing
|
||||
|
||||
0.7.0 Multi-user, File handling, atomicity (1/8/2008)
|
||||
+ Clean, publishable API reimplementation
|
||||
+ File locking
|
||||
+ retain deleted tasks
|
||||
+ "task info ID" report showing all metadata
|
||||
+ File format v2
|
||||
|
||||
[Development hiatus while planning for T, TDB API, new features and the future
|
||||
of the project. Seeded to two testers for feedback, suggestions.]
|
||||
|
||||
0.6.0 Reports (12/27/2006)
|
||||
+ "task history"
|
||||
+ "task summary"
|
||||
+ "task calendar"
|
||||
+ due support
|
||||
+ Table sorting
|
||||
|
||||
0.5.0 Multi-user support (12/10/2006)
|
||||
+ Command logging
|
||||
+ "task usage" report
|
||||
|
||||
0.4.0 Destructive / modification commands (12/3/2006)
|
||||
+ "task delete" complete
|
||||
+ "task id ..." complete
|
||||
+ "task list ..." synonym for "task find ..."
|
||||
|
||||
0.3.0 Work in progress support (12/3/2006)
|
||||
+ "task start" complete
|
||||
+ "task done" complete
|
||||
+ completed.data support
|
||||
|
||||
0.2.0 Neutral commands (12/2/2006)
|
||||
+ "task find" complete
|
||||
+ "task projects" complete
|
||||
+ "task tags" complete
|
||||
|
||||
0.1.0 Constructive commands (12/1/2006)
|
||||
+ "task add" complete
|
||||
+ completed.data support
|
||||
+ ~/.taskrc support
|
||||
|
||||
0.0.1 Basic infrastructure (11/29/2006)
|
||||
+ Command line parsing
|
||||
+ API layer
|
||||
+ Usage
|
||||
|
||||
------ start -----------------------------------
|
||||
|
||||
|
||||
20
DEVELOPERS
Normal file
20
DEVELOPERS
Normal file
@@ -0,0 +1,20 @@
|
||||
Developers may wish to change task, and here is a high-level guide to the files
|
||||
included.
|
||||
|
||||
task.{cpp,h} Functions that implement the task commands, and main.
|
||||
parse.cpp Parses the command line.
|
||||
TDB.{cpp,h} The task database, performs all file I/O
|
||||
T.{cpp,h} Represents a single task - parses a record from TDB, and also
|
||||
composes record for TDB. Provides accessors for tasks.
|
||||
Grid.{cpp,h} Implements a sparse 2D array, provides data storage for the
|
||||
Table object.
|
||||
Table.{cpp,h} Implements tabular data rendering, wrapping etc.
|
||||
Config.{cpp,h} Implements a reader for the .taskrc file.
|
||||
Date.{cpp,h} General date class for the time_t type.
|
||||
text.cpp Text manipulation functions.
|
||||
util.cpp General utility functions.
|
||||
color.cpp Color support functions.
|
||||
rules.cpp Auto-colorization rules.
|
||||
|
||||
Don't forget, please send bugs, patches to task@beckingham.net
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
SUBDIRS = src
|
||||
EXTRA_DIST = TUTORIAL SAMPLE_taskrc
|
||||
EXTRA_DIST = TUTORIAL DEVELOPERS
|
||||
|
||||
|
||||
29
NEWS
29
NEWS
@@ -1,4 +1,31 @@
|
||||
Welcome to Task 1.3.1.
|
||||
|
||||
Task 1.0 is released.
|
||||
Task has been built and tested on the following configurations:
|
||||
|
||||
- OS X 10.4 Tiger
|
||||
- OS X 10.5 Leopard
|
||||
- Fedora Core 8
|
||||
- Fedora Core 9
|
||||
- Ubuntu 8 Hardy Heron
|
||||
- Solaris 10
|
||||
- Cygwin 1.5.25-14
|
||||
|
||||
While Task has undergone testing, bugs are sure to remain. If you encounter a
|
||||
bug, please contact me at task@beckingham.net. Here is what you could do, in
|
||||
order of increasing effort (to you) and usefulness (to me):
|
||||
|
||||
- Do nothing. Bug probably won't get fixed.
|
||||
|
||||
- Send an email to task@beckingham.net, explaining what you saw. The bug
|
||||
will be addressed, and a new release will be made. You will be a hero.
|
||||
|
||||
- Send an email, and a reproducible test case in the form of the few commands
|
||||
it takes to recreate the problem. The bug will be addressed, and a new
|
||||
release will be made. You will be a hero.
|
||||
|
||||
- If you are a developer, send a patch that fixes the problem. Your patch
|
||||
will be applied and tested, and a new release will be made. You will be a
|
||||
hero.
|
||||
|
||||
Thank you.
|
||||
|
||||
|
||||
51
README
51
README
@@ -1,7 +1,48 @@
|
||||
Thank you for taking a look at task. Task is a GTD utility featuring:
|
||||
|
||||
Thank you
|
||||
GTD
|
||||
Based on ideas in todo.sh
|
||||
Movie at www.b.n/task.mov
|
||||
Feedback, suggestions to task@beckingham.net
|
||||
- Robust C++ implementation
|
||||
- Tags
|
||||
- Colorful, tabular output
|
||||
- Reports
|
||||
- Lots of commands
|
||||
- Low-level API
|
||||
- Abbreviations for all commands, options
|
||||
- Multi-user file locking
|
||||
- Clean architecture allowing quick addition of new features
|
||||
|
||||
It is intended that features, mainly in the form of reports will be added
|
||||
frequently, with best practices and useful reports evolving from usage patterns.
|
||||
|
||||
Task is scope-limited to GTD functionality only.
|
||||
|
||||
You may want to jump straight to the TUTORIAL file, or perhaps watch the old
|
||||
task movie on YouTube:
|
||||
|
||||
http://www.youtube.com/watch?v=l68LCl6BYvs
|
||||
|
||||
or the new improved one:
|
||||
|
||||
http://www.youtube.com/watch?v=D2Kn4DMOVSw
|
||||
|
||||
Either will give you a fairly good idea of what task is capable of, and whether
|
||||
it fits in to your way of working. As a command line application, task is not
|
||||
for everyone and some of you may prefer to not proceed. The movie or TUTORIAL
|
||||
file are the quickest way for you to make that decision.
|
||||
|
||||
Task is based on ideas presented in the todo.sh script, found on:
|
||||
|
||||
http://todotxt.org
|
||||
|
||||
Task has a few more features than todo.sh, but fundamentally, they are both
|
||||
working toward the same goals, which is to help you follow basic Getting Things
|
||||
Done (GTD) principles.
|
||||
|
||||
All feedback is welcome, in addition to any bug reports or patches to:
|
||||
|
||||
task@beckingham.net
|
||||
|
||||
Got an idea for an enhancement? Send a message!
|
||||
|
||||
I have found that task makes me more productive and organized. I hope task can
|
||||
do the same for you.
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
data.location=/home/bob/.task
|
||||
#command.logging=on
|
||||
confirmation=yes
|
||||
nag=Note: try to stick to high priority tasks. See "task next".
|
||||
next=2
|
||||
|
||||
#color.overdue=red
|
||||
#color.due=on yellow
|
||||
#color.pri.H=red
|
||||
#color.pri.M=yellow
|
||||
#color.pri.L=green
|
||||
#color.pri.none=white on yellow
|
||||
#color.active=blue
|
||||
#color.tagged=yellow
|
||||
|
||||
685
TUTORIAL
685
TUTORIAL
@@ -1,9 +1,18 @@
|
||||
Task program tutorial, for version 0.9.0
|
||||
Task program tutorial, for version 1.3.1
|
||||
----------------------------------------
|
||||
|
||||
This guide shows how to quickly set up the task program, and become proficient
|
||||
with it.
|
||||
|
||||
Contents:
|
||||
Quick Setup
|
||||
Simple Usage
|
||||
Advanced Usage
|
||||
Interacting with the Shell
|
||||
Configuring Task
|
||||
Colors
|
||||
|
||||
|
||||
|
||||
Quick Setup
|
||||
-----------
|
||||
@@ -12,32 +21,35 @@ Build the task program according to the directions in the INSTALL file. This
|
||||
transcript illustrates a typical installation:
|
||||
|
||||
% ls
|
||||
task-0.9.0.tar.gz
|
||||
% gunzip task-0.9.0.tar.gz
|
||||
% tar xf task-0.9.0.tar
|
||||
% cd task-0.9.0
|
||||
task-1.3.1.tar.gz
|
||||
% gunzip task-1.3.1.tar.gz
|
||||
% tar xf task-1.3.1.tar
|
||||
% cd task-1.3.1
|
||||
% ./configure
|
||||
...
|
||||
% make
|
||||
...
|
||||
% make install
|
||||
% make install # (may require sudo, depending on --prefix)
|
||||
|
||||
You need to make sure that the installed task program is in your PATH
|
||||
environment variable. The next step is to create a configuration file for the
|
||||
task program. This file resides in your home directory, is called .taskrc, and
|
||||
contains various configuration settings. Use the provided SAMPLE_taskrc file
|
||||
as a starting point for your own:
|
||||
environment variable.
|
||||
|
||||
% cp SAMPLE_taskrc ~/.taskrc
|
||||
% mkdir ~/.task
|
||||
Task reads a configuration file - called .taskrc in your home directory - and
|
||||
stores pending and completed tasks in in a directory specified in the
|
||||
configuration file.
|
||||
|
||||
Your .taskrc files contains an entry that points to the .task directory
|
||||
belonging to user bob. Change this entry to point to your own home directory,
|
||||
and the .task directory you just created. Your task program is now ready to
|
||||
use. Verify that task is properly installed with:
|
||||
The simplest way to get a configuration file and task directory is to run task.
|
||||
On startup, task will check to see if it can find the configuration file and
|
||||
task directory, and if not found, will ask you whether it may create both.
|
||||
|
||||
% task version
|
||||
[show sample output]
|
||||
|
||||
A configuration file could not be found in /Users/paul/.taskrc
|
||||
|
||||
Would you like a sample .taskrc created, so task can proceed? (y/n) y
|
||||
Done.
|
||||
|
||||
[then task will show version information]
|
||||
|
||||
|
||||
Simple Usage
|
||||
@@ -55,7 +67,7 @@ interface. Let us take a look at those tasks:
|
||||
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
ID Project Pri Description
|
||||
1 Book plane ticket
|
||||
2 Rent a tux
|
||||
3 Reserve a rental car
|
||||
@@ -70,21 +82,22 @@ task 2:
|
||||
Permanently delete task? (y/n) y
|
||||
|
||||
Task wants you to confirm deletions. To remove the confirmation, edit your
|
||||
.taskrc file and remove the line:
|
||||
.taskrc file and change the line:
|
||||
|
||||
confirmation=yes
|
||||
|
||||
or change the yes to no.
|
||||
to have a value of "no".
|
||||
|
||||
While projects and priorities are not necessary, they can be very useful when
|
||||
the list of tasks grows large. Let's assign a project to these tasks:
|
||||
While the use of projects and priorities are not essential to benefitting from
|
||||
task, they can be very useful when the list of tasks grows large. Let's assign
|
||||
a project to these tasks:
|
||||
|
||||
% task 1 project:Wedding
|
||||
% task 3 project:Wedding
|
||||
% task 4 project:Family
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
ID Project Pri Description
|
||||
3 Family Send John a birthday card
|
||||
2 Wedding Reserve a rental car
|
||||
1 Wedding Book plane ticket
|
||||
@@ -92,13 +105,48 @@ the list of tasks grows large. Let's assign a project to these tasks:
|
||||
Notice that the id numbers have changed. When tasks get deleted, or have their
|
||||
attributes changed (project, for example), the ids are prone to change. But the
|
||||
id numbers will remain valid until the next 'ls' command is run. You should
|
||||
only use the ids from the most recent 'ls' command.
|
||||
only use the ids from the most recent 'ls' command. The ids change, because
|
||||
task is always trying to use small numbers so that it is easy for you to enter
|
||||
them correctly.
|
||||
|
||||
Subprojects are supported. If you have a project "Wedding", you can specify
|
||||
that a task is a subproject "Transport" of "Wedding" by assigning the project
|
||||
"Wedding.Transport". Let's do this:
|
||||
|
||||
% task 2 project:Wedding.Transport
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
3 Family Send John a birthday card
|
||||
2 Wedding.Transport Reserve a rental car
|
||||
1 Wedding Book plane ticket
|
||||
|
||||
Task matches the leftmost part of the project when searching, so projects
|
||||
may be abbreviated:
|
||||
|
||||
% task ls project:Wedding.Tra
|
||||
|
||||
ID Project Pri Description
|
||||
2 Wedding.Transport Reserve a rental car
|
||||
|
||||
This way of matching projects can be used to see all tasks under the
|
||||
"Wedding" project and all subprojects:
|
||||
|
||||
% task ls project:Wedding
|
||||
|
||||
ID Project Pri Description
|
||||
2 Wedding.Transport Reserve a rental car
|
||||
1 Wedding Book plane ticket
|
||||
|
||||
Let's reassign 2 back to the "Wedding" project:
|
||||
|
||||
% task 2 project:Wedding
|
||||
|
||||
Now that projects are assigned, we can look at just the Wedding project tasks:
|
||||
|
||||
% task ls project:Wedding
|
||||
|
||||
ID Project Pri Description
|
||||
ID Project Pri Description
|
||||
1 Wedding Book plane ticket
|
||||
2 Wedding Reserve a rental car
|
||||
|
||||
@@ -107,14 +155,14 @@ could also have requested:
|
||||
|
||||
% task ls ticket plane
|
||||
|
||||
ID Project Pri Description
|
||||
ID Project Pri Description
|
||||
1 Wedding Book plane ticket
|
||||
|
||||
Now let's prioritize. Priorities can be H, M or L (High, Medium, Low).
|
||||
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
ID Project Pri Description
|
||||
3 Family Send John a birthday card
|
||||
2 Wedding Reserve a rental car
|
||||
1 Wedding Book plane ticket
|
||||
@@ -126,7 +174,7 @@ Now let's prioritize. Priorities can be H, M or L (High, Medium, Low).
|
||||
% task 3 pri:H
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
ID Project Pri Description
|
||||
3 Family H Send John a birthday card
|
||||
1 Wedding H Book plane ticket
|
||||
2 Wedding M Reserve a rental car
|
||||
@@ -136,37 +184,44 @@ Priority can be abbreviated to pri, but not pr, because it is ambiguous. Now
|
||||
that tasks have been prioritized, you can see that the tasks are being sorted
|
||||
by priority, with the highest priority tasks at the top.
|
||||
|
||||
These attributes can all be provided when the task is added, instead of
|
||||
applying them afterwards, as shown. The following command shows how to set all
|
||||
the attributes at once:
|
||||
|
||||
% task add project:Wedding priority:H Book plane ticket
|
||||
|
||||
The 'ls' command provides the least information for each task. The 'list'
|
||||
command provides more:
|
||||
|
||||
% task list
|
||||
|
||||
ID Project Pri Due Active Age Description
|
||||
ID Project Pri Due Active Age Description
|
||||
3 Family H 4 mins Send John a birthday card
|
||||
1 Wedding H 5 mins Book plane ticket
|
||||
2 Wedding M 5 mins Reserve a rental car
|
||||
|
||||
Notice that task can have a due date, and can be active. The task lists are
|
||||
Notice that a task can have a due date, and can be active. The task lists are
|
||||
sorted by due date, then priority. Let's add due dates:
|
||||
|
||||
% task 3 due:3/25/2008
|
||||
% task 1 due:5/31/2008
|
||||
% task 3 due:6/25/2008
|
||||
% task 1 due:7/31/2008
|
||||
% task list
|
||||
|
||||
ID Project Pri Due Active Age Description
|
||||
3 Family H 3/25/2008 6 mins Send John a birthday card
|
||||
1 Wedding H 5/31/2008 7 mins Book plane ticket
|
||||
ID Project Pri Due Active Age Description
|
||||
3 Family H 6/25/2008 6 mins Send John a birthday card
|
||||
1 Wedding H 7/31/2008 7 mins Book plane ticket
|
||||
2 Wedding M 7 mins Reserve a rental car
|
||||
|
||||
If today's date is 3/23/2008, then task 3 is due in 2 days. It will be colored
|
||||
If today's date is 6/23/2008, then task 3 is due in 2 days. It will be colored
|
||||
yellow if your terminal supports color. To change this color, edit your
|
||||
.taskrc file, and change the line to one of these alternatives:
|
||||
|
||||
color.due=<foreground color> on <background color>
|
||||
color.due=<foreground color>
|
||||
color.due=on <background color>
|
||||
color.due=red
|
||||
color.due=on_blue
|
||||
color.due=red on_blue
|
||||
color.due=bold_red on_blue
|
||||
|
||||
Where color is one of:
|
||||
Where color is one of the following:
|
||||
|
||||
black
|
||||
blue
|
||||
@@ -178,38 +233,536 @@ Where color is one of:
|
||||
white
|
||||
|
||||
All colors are specified in this way. Take a look in .taskrc for all the other
|
||||
colors you control.
|
||||
color rules that you control.
|
||||
|
||||
Tagging tasks is a good way to group them, aside from specifying a project. To
|
||||
add a tag to a task:
|
||||
|
||||
% task <id> +tag
|
||||
|
||||
The plus sign indicates that this is a tag. Any number of tags may be applied
|
||||
to a task, and then used for searching. Tags are just single words that are
|
||||
labels.
|
||||
|
||||
% task list
|
||||
|
||||
ID Project Pri Due Active Age Description
|
||||
3 Family H 6/25/2008 8 mins Send John a birthday card
|
||||
1 Wedding H 7/31/2008 9 mins Book plane ticket
|
||||
2 Wedding M 9 mins Reserve a rental car
|
||||
|
||||
% task 1 +phone
|
||||
% task 2 +phone
|
||||
% task 3 +shopping
|
||||
% task 3 +john
|
||||
|
||||
% task list +phone
|
||||
|
||||
ID Project Pri Due Active Age Description
|
||||
1 Wedding H 7/31/2008 9 mins Book plane ticket
|
||||
2 Wedding M 9 mins Reserve a rental car
|
||||
|
||||
To remove a tag from a task, use the minus sign:
|
||||
|
||||
% task 3 -john
|
||||
|
||||
|
||||
|
||||
Advanced Use
|
||||
------------
|
||||
|
||||
Commands:
|
||||
- task add
|
||||
- task list
|
||||
- task long
|
||||
- task ls
|
||||
- task done
|
||||
- task completed
|
||||
- task delete
|
||||
- task start
|
||||
- task summary
|
||||
- task history
|
||||
- task next
|
||||
- task <modify>
|
||||
- task /from/to/
|
||||
- task projects
|
||||
- task tags
|
||||
- task info
|
||||
- task active
|
||||
- task overdue
|
||||
- task calendar
|
||||
- task stats
|
||||
- task usage
|
||||
- task export
|
||||
- task version
|
||||
Here are the other commands, in some detail. Note that the command:
|
||||
|
||||
% task
|
||||
|
||||
with no arguments will generate a help message that lists all these commands.
|
||||
|
||||
|
||||
% task projects
|
||||
---------------
|
||||
|
||||
This report generates a list of all the different projects that you are using
|
||||
along with a count of the pending tasks for each project. For example:
|
||||
|
||||
% task projects
|
||||
|
||||
Project Tasks
|
||||
Errands 1
|
||||
Birthdays 3
|
||||
Car 2
|
||||
|
||||
|
||||
|
||||
% task summary
|
||||
--------------
|
||||
|
||||
This report lists all the projects and a summary of their task status.
|
||||
|
||||
% task summary
|
||||
|
||||
Project Remaining Avg age Complete 0% 100%
|
||||
Errands 1 3 days 50% XXXXXXXXXXXXXXXX
|
||||
Birthdays 3 7 mths 0%
|
||||
Car 2 2 wks 25% XXXXXXXXX
|
||||
|
||||
This shows the project, the remaining tasks, the average age of each task,
|
||||
the percentage completed (remaining vs total) and a bar indicating that
|
||||
percentage.
|
||||
|
||||
|
||||
|
||||
% task delete <id>
|
||||
------------------
|
||||
|
||||
There are two ways of getting rid of tasks - mark them as done, or delete
|
||||
them.
|
||||
|
||||
|
||||
|
||||
% task done <id>
|
||||
----------------
|
||||
|
||||
This is how a task is marked as done.
|
||||
|
||||
|
||||
|
||||
% task list ...
|
||||
---------------
|
||||
|
||||
The list report will show the active status, and age of the task in addition
|
||||
to the columns that "task ls" shows. It is just a more detailed list.
|
||||
|
||||
|
||||
|
||||
% task long ...
|
||||
---------------
|
||||
|
||||
The long report will show the entry date and start date of a task, in
|
||||
addition to the columns that the "task list" shows.
|
||||
|
||||
|
||||
|
||||
% task start <id>
|
||||
-----------------
|
||||
|
||||
This marks a task as started (and therefore active), which is shown in the
|
||||
"list" report:
|
||||
|
||||
% task list
|
||||
|
||||
ID Project Pri Due Active Age Description
|
||||
12 Errand L Remember to deposit check
|
||||
...
|
||||
|
||||
% task start 12
|
||||
% task list
|
||||
|
||||
ID Project Pri Due Active Age Description
|
||||
12 Errand L * 3 days Remember to deposit check
|
||||
...
|
||||
|
||||
|
||||
|
||||
% task active
|
||||
-------------
|
||||
|
||||
Shows all active tasks, that is, the tasks for which the "task start ..."
|
||||
command was run, as shown above.
|
||||
|
||||
|
||||
|
||||
% task overdue
|
||||
--------------
|
||||
|
||||
Simply lists all the task that have a due date that is past, in "list"
|
||||
format.
|
||||
|
||||
|
||||
|
||||
% task oldest
|
||||
-------------
|
||||
|
||||
Lists the oldest tasks. Shows 10 tasks by default, but can be set via the
|
||||
"oldest" configuration variable.
|
||||
|
||||
|
||||
|
||||
% task newest
|
||||
-------------
|
||||
|
||||
Lists the newest tasks. Shows 10 tasks by default, but can be set via the
|
||||
"newest" configuration variable.
|
||||
|
||||
|
||||
|
||||
% task history
|
||||
--------------
|
||||
|
||||
This report shows you an overview of how many tasks were added, completed and
|
||||
deleted, by month. It looks like this:
|
||||
|
||||
% task history
|
||||
|
||||
Year Month Added Completed Deleted Net
|
||||
2008 March 21 16 0 5
|
||||
April 13 11 1 1
|
||||
May 8 14 3 -9
|
||||
|
||||
This shows that for the three months that task has been used, March and April
|
||||
saw the total number of tasks increase, but in May the number decreased as
|
||||
more task were completed than added.
|
||||
|
||||
|
||||
|
||||
% task calendar
|
||||
---------------
|
||||
|
||||
This report shows a calendar of the current month, with any task due or
|
||||
overdue dates marked on it. Color is used to mark these dates.
|
||||
|
||||
% task calendar
|
||||
|
||||
May 2008
|
||||
|
||||
Su Mo Tu We Th Fr Sa
|
||||
1 2 3
|
||||
4 5 6 7 8 9 10
|
||||
11 12 13 14 15 16 17
|
||||
18 19 20 21 22 23 24
|
||||
25 26 27 28 29 30 31
|
||||
|
||||
|
||||
|
||||
% task next
|
||||
-----------
|
||||
|
||||
This report shows you the tasks you should probable work on next. Task will
|
||||
scan all the tasks and will pick two task from each project to report. Those
|
||||
two tasks will be chosen in order of overdue, due soon, High, Medium or Low
|
||||
priority. Essentially task chooses the two most important task for each
|
||||
project and displays them ordered in the usual way.
|
||||
|
||||
If you wish to show a different number of tasks per project, modify the entry
|
||||
in .taskrc:
|
||||
|
||||
next=2
|
||||
|
||||
To be your preferred number.
|
||||
|
||||
|
||||
|
||||
% task <id> ...
|
||||
---------------
|
||||
|
||||
When a task id is specified, everything applies to just that task. Suppose
|
||||
we needed to correct a task:
|
||||
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
12 Errand L Remember to deposit chekc
|
||||
...
|
||||
|
||||
% task 12 Remember to deposit bonus check
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
12 Errand L Remember to deposit bonus check
|
||||
...
|
||||
|
||||
|
||||
|
||||
% task /from/to/
|
||||
----------------
|
||||
|
||||
If a task has been entered with a typo, it can be easily corrected by this
|
||||
command. For example:
|
||||
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
12 Errand L Remember to deposit chekc
|
||||
...
|
||||
|
||||
% task 12 /chekc/check/
|
||||
% task ls
|
||||
|
||||
ID Project Pri Description
|
||||
12 Errand L Remember to deposit check
|
||||
...
|
||||
|
||||
This command makes single corrections to a task description.
|
||||
|
||||
|
||||
|
||||
% task tags
|
||||
-----------
|
||||
|
||||
This command will generate a list of all the tags that are currently in use
|
||||
by task.
|
||||
|
||||
|
||||
|
||||
% task info <id>
|
||||
----------------
|
||||
|
||||
This command gives detailed information about a single task. It will tell
|
||||
you when the task was entered, when started, its status, tags, and more.
|
||||
|
||||
|
||||
|
||||
% task stats
|
||||
------------
|
||||
|
||||
This command generates a list of statistics about your task usage, such as
|
||||
the average time it takes to complete a task, how often new tasks are added,
|
||||
and more.
|
||||
|
||||
|
||||
|
||||
% task completed
|
||||
----------------
|
||||
|
||||
This generates a list of all tasks that have been completed, sorted by their
|
||||
completion date.
|
||||
|
||||
|
||||
|
||||
% task export <file name>
|
||||
-------------------------
|
||||
|
||||
This instructs task to write out a CSV format dump of all tasks, both pending
|
||||
and completed, to the file specified. This is how you might view tasks in a
|
||||
spreadsheet.
|
||||
|
||||
|
||||
|
||||
% task colors
|
||||
-------------
|
||||
|
||||
This command displays all the colors that task supports.
|
||||
|
||||
|
||||
|
||||
% task usage
|
||||
------------
|
||||
|
||||
If logging has been enabled by the "command.logging=on" directive in the
|
||||
.taskrc file, then task will record every command that is run. When this
|
||||
command is run, task will display a count of how many times each command was
|
||||
used.
|
||||
|
||||
This command is for the purpose of seeing whether command are actually used.
|
||||
|
||||
|
||||
|
||||
% task version
|
||||
--------------
|
||||
|
||||
This can be used to show the version number of task, and to display all the
|
||||
current configuration settings, as read from the .taskrc file.
|
||||
|
||||
|
||||
|
||||
Interacting with the Shell
|
||||
--------------------------
|
||||
- Escaping shell metacharacters
|
||||
|
||||
Certain characters are interpreted by the shell. For example, the "&". If
|
||||
you wish to include the & in a task description, you need to escape it, so
|
||||
the shell doesn't interpret it. For example:
|
||||
|
||||
% task add Buy bread & milk
|
||||
|
||||
This command is an error because of the &. The shell will consider this to
|
||||
be two commands:
|
||||
|
||||
% task add Buy bread &
|
||||
% milk
|
||||
|
||||
The shell treats the & character as an indicator that the command is complete
|
||||
and should be run in the background. Then the shell considers "milk" to be a
|
||||
command all by itself. Which it is not. One way to get around this is to
|
||||
individually escape the & character:
|
||||
|
||||
% task add Buy bread \& milk
|
||||
|
||||
Another is to quote the entire description, with either ' or " characters:
|
||||
|
||||
% task add "Buy bread & milk"
|
||||
|
||||
Task itself interprets the commands, and it too can make mistakes. For
|
||||
example, any colon : character will be interpreted by task as a delimiter
|
||||
between an attribute name and its value. Currently there is no workaround
|
||||
for this.
|
||||
|
||||
|
||||
|
||||
% task <id> fg:... bg:...
|
||||
-------------------------
|
||||
|
||||
Not strictly a command, the setting of the fg and bg (foreground and
|
||||
background) attributes determines the colors used to represent the task.
|
||||
Valid foreground colors are:
|
||||
|
||||
bold underline bold_underline
|
||||
black bold_black underline_black bold_underline_black
|
||||
red bold_red underline_red bold_underline_red
|
||||
green bold_green underline_green bold_underline_green
|
||||
yellow bold_yellow underline_yellow bold_underline_yellow
|
||||
blue bold_blue underline_blue bold_underline_blue
|
||||
magenta bold_magenta underline_magenta bold_underline_magenta
|
||||
cyan bold_cyan underline_cyan bold_underline_cyan
|
||||
white bold_white underline_white bold_underline_white
|
||||
|
||||
Valid background colors are:
|
||||
|
||||
on_black on_bright_black
|
||||
on_red on_bright_red
|
||||
on_green on_bright_green
|
||||
on_yellow on_bright_yellow
|
||||
on_blue on_bright_blue
|
||||
on_magenta on_bright_magenta
|
||||
on_cyan on_bright_cyan
|
||||
on_white on_bright_white
|
||||
|
||||
Note that these are not just colors, but combinations of colors and
|
||||
attributes.
|
||||
|
||||
Note also that this capability does depend on whether your terminal program
|
||||
can display these colors.
|
||||
|
||||
|
||||
|
||||
|
||||
Configuring Task
|
||||
----------------
|
||||
|
||||
Task recognizes several entries in the .taskrc file for configuration
|
||||
purposes. Valid entries are of the form:
|
||||
|
||||
name=value
|
||||
|
||||
Valid examples are:
|
||||
|
||||
data.location This is a path to the directory containing all the task
|
||||
files. By default, it is set up to be ~/.task, for
|
||||
example: /Users/paul/.task
|
||||
|
||||
command.logging May be "on" or "off", defaulting to "off". This
|
||||
determines whether task records commands. This is not
|
||||
generally useful, except while developing task.
|
||||
|
||||
confirmation May be "yes" or "no", and determines whether task will
|
||||
ask for confirmation before deleting a task.
|
||||
|
||||
nag This may be a string of text, or blank. It is used as
|
||||
a prompt when a task is completed that is not considered
|
||||
high priority. The "task next" command lists important
|
||||
tasks, and completing one of those does not generate
|
||||
this nagging. Default value is:
|
||||
|
||||
Note: try to stick to high priority tasks.
|
||||
See "task next".
|
||||
|
||||
next Is a number, defaulting to 2, which is the number of
|
||||
tasks for each project that are shown in the "task next"
|
||||
command.
|
||||
|
||||
curses Determines whether task uses ncurses to establish the
|
||||
size of the window you are using, for text wrapping.
|
||||
|
||||
blanklines May be "on" or "off". Prevents the display of
|
||||
unnecessary blank lines so that task makes better use
|
||||
screen real estate on small-screened devices.
|
||||
|
||||
dateformat This is a string of characters that define how task
|
||||
formats dates. The default value is:
|
||||
|
||||
m/d/Y
|
||||
|
||||
which means dates look like:
|
||||
|
||||
6/7/2008
|
||||
|
||||
The string should contain the characters:
|
||||
|
||||
m minimal-digit month 1, 12
|
||||
d minimal-digit day 1, 30
|
||||
y two-digit year 08
|
||||
M two-digit month 01, 12
|
||||
D two-digit day 01, 30
|
||||
Y four-digit year 2008
|
||||
|
||||
The string may also contain other characters to act as
|
||||
spacers, or formatting. Other values could include
|
||||
(but are not limited to):
|
||||
|
||||
d/m/Y 7/6/2008
|
||||
YMD 20080607
|
||||
m-d-y 6-7-08
|
||||
|
||||
showage May be "yes" or "no". Determines whether the "Age"
|
||||
column appears on the "list" and "next" reports.
|
||||
|
||||
monthsperline Determines how many months the "task calendar" command
|
||||
renders across the screen. Defaults to 1.
|
||||
|
||||
oldest Determines how many tasks are shown on the "oldest"
|
||||
report. Defaults to 10.
|
||||
|
||||
newest Determines how many tasks are shown on the "newest"
|
||||
report. Defaults to 10.
|
||||
|
||||
defaultwidth The width of tables used when ncurses support is not
|
||||
available. Defaults to 80.
|
||||
|
||||
color May be "on" or "off". Determines whether task uses
|
||||
color.
|
||||
|
||||
color.overdue These are the coloration rules. They correspond to a
|
||||
color.due particular attribute of a task, such as it being due, or
|
||||
color.pri.H being active, and specifies the automatic coloring of
|
||||
color.pri.M that task.
|
||||
color.pri.L
|
||||
color.pri.none The value may be one optional foreground color (see
|
||||
color.active below) and one optional background color.
|
||||
color.tagged
|
||||
For example, the value may be:
|
||||
|
||||
bold_red on_bright_yellow
|
||||
|
||||
color.tag.X Colors any task that has the tag X.
|
||||
|
||||
color.project.X Colors any task assigned to project X.
|
||||
|
||||
color.keyword.X Colors any task where the description contains X.
|
||||
|
||||
|
||||
Colors
|
||||
------
|
||||
|
||||
Task supports color in several places. In cases where you may specify a
|
||||
color, a foreground, a background, or a combination foreground and background
|
||||
color may be used. The following are valid foreground colors:
|
||||
|
||||
bold underline bold_underline
|
||||
black bold_black underline_black bold_underline_black
|
||||
red bold_red underline_red bold_underline_red
|
||||
green bold_green underline_green bold_underline_green
|
||||
yellow bold_yellow underline_yellow bold_underline_yellow
|
||||
blue bold_blue underline_blue bold_underline_blue
|
||||
magenta bold_magenta underline_magenta bold_underline_magenta
|
||||
cyan bold_cyan underline_cyan bold_underline_cyan
|
||||
white bold_white underline_white bold_underline_white
|
||||
|
||||
and the following are valid background colors:
|
||||
|
||||
on_black on_bright_black
|
||||
on_red on_bright_red
|
||||
on_green on_bright_green
|
||||
on_yellow on_bright_yellow
|
||||
on_blue on_bright_blue
|
||||
on_magenta on_bright_magenta
|
||||
on_cyan on_bright_cyan
|
||||
on_white on_bright_white
|
||||
|
||||
|
||||
36
announcement.txt
Normal file
36
announcement.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
Some considerable time ago - longer than I had hoped - I demonstrated an
|
||||
alternate implementation of the todo script, called task, in the form of a
|
||||
YouTube movie:
|
||||
|
||||
http://www.youtube.com/watch?v=l68LCl6BYvs
|
||||
|
||||
A lot has happened since then, and the task program has been slowly improving
|
||||
thanks to feedback from some early testers, and continuous use by me. Today,
|
||||
I have uploaded a new movie:
|
||||
|
||||
http://www.youtube.com/watch?v=D2Kn4DMOVSw
|
||||
|
||||
This movie includes most of the changes and improvements to task, but behind
|
||||
the scenes are the biggest changes. There was a rewrite of the underlying
|
||||
storage mechanism yielding a clean API for the front end, and the code was
|
||||
reviewed for portability and converted to use GNU autoconf/automake.
|
||||
|
||||
Task has been released under GPL, and so far has been tested on:
|
||||
|
||||
Max OS X 10.4 (Tiger)
|
||||
Max OS X 10.5 (Leopard)
|
||||
Fedora 8
|
||||
Fedora 9
|
||||
Ubuntu 8 (Hardy Heron)
|
||||
Solaris 10
|
||||
|
||||
Task has been making me more organized and productive for some time now.
|
||||
Perhaps some of you might find it useful, and I welcome feedback of all kinds.
|
||||
|
||||
You can find the task source code at:
|
||||
|
||||
http://www.beckingham.net/task-1.0.0.tar.gz
|
||||
|
||||
Thank you.
|
||||
Paul Beckingham
|
||||
|
||||
11
configure.ac
11
configure.ac
@@ -2,11 +2,10 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT(task, 0.9.4, bugs@beckingham.net)
|
||||
AC_INIT(task, 1.3.1, bugs@beckingham.net)
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_SRCDIR([src/task.cpp])
|
||||
AC_CONFIG_HEADER([auto.h])
|
||||
#AC_CONFIG_SUBDIRS([src])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
@@ -14,12 +13,12 @@ AC_PROG_CC
|
||||
AC_LANG(C++)
|
||||
|
||||
# Checks for libraries.
|
||||
#AC_CHECK_LIB(ncurses, initscr, [LIBS="$LIBS -lncurses" AC_DEFINE([HAVE_NCURSES], [1], [Found ncurses])])
|
||||
AC_CHECK_LIB(ncurses,initscr)
|
||||
AC_CHECK_LIB(ncurses,endwin)
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([stdlib.h sys/file.h sys/time.h unistd.h])
|
||||
AC_CHECK_HEADERS([stdlib.h sys/file.h sys/stat.h sys/time.h unistd.h])
|
||||
AC_CHECK_HEADERS([string vector map])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
@@ -36,6 +35,8 @@ AC_FUNC_SELECT_ARGTYPES
|
||||
AC_CHECK_FUNCS([select])
|
||||
AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])])
|
||||
AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE([HAVE_UUID], [1], [Found uuid_unparse_lower])])
|
||||
AC_CHECK_FUNC(random, [AC_DEFINE([HAVE_RANDOM], [1], [Found random])])
|
||||
AC_CHECK_FUNC(srandom, [AC_DEFINE([HAVE_SRANDOM], [1], [Found srandom])])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
68
grammar.txt
Normal file
68
grammar.txt
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
This is a full BNF grammar for the task command line. It is intended that a
|
||||
future release of task will incorporate a complete lexer/parser implementing
|
||||
this grammar.
|
||||
|
||||
|
||||
command:
|
||||
VERSION
|
||||
| HELP
|
||||
| PROJECTS
|
||||
| TAGS
|
||||
| SUMMARY
|
||||
| HISTORY
|
||||
| NEXT
|
||||
| CALENDAR
|
||||
| ACTIVE
|
||||
| OVERDUE
|
||||
| STATS
|
||||
| USAGE
|
||||
| OLDEST
|
||||
| NEWEST
|
||||
| EXPORT <file>
|
||||
| COLOR
|
||||
| DELETE <id>
|
||||
| INFO <id>
|
||||
| START <id>
|
||||
| DONE <id>
|
||||
| ADD [<tags>] [<attrs>] [<desc>]
|
||||
| LIST [<tags>] [<attrs>] [<desc>]
|
||||
| LONG [<tags>] [<attrs>] [<desc>]
|
||||
| LS [<tags>] [<attrs>] [<desc>]
|
||||
| COMPLETED [<tags>] [<attrs>] [<desc>]
|
||||
| <id> [<tags>] [<attrs>] [<desc>]
|
||||
| <id> <substitution>
|
||||
|
||||
id:
|
||||
\d+
|
||||
| \d{8}-\d{4}-\d{4}-\d{12}
|
||||
|
||||
tags:
|
||||
+<tag>
|
||||
| -<tag>
|
||||
|
||||
tag:
|
||||
\w+
|
||||
|
||||
attrs:
|
||||
<attr>
|
||||
| <attr> <attrs>
|
||||
|
||||
attr:
|
||||
<name>:<value>
|
||||
|
||||
name:
|
||||
\w+
|
||||
|
||||
value:
|
||||
.+
|
||||
|
||||
substitution:
|
||||
/ <pattern> / <pattern> /
|
||||
|
||||
pattern:
|
||||
.+
|
||||
|
||||
file:
|
||||
?
|
||||
|
||||
126
html/task.css
Normal file
126
html/task.css
Normal file
@@ -0,0 +1,126 @@
|
||||
body {
|
||||
text-align: center;
|
||||
margin: 0; padding: 1em;
|
||||
}
|
||||
|
||||
#container {
|
||||
width: 740px;
|
||||
text-align: left;
|
||||
margin: 0 auto; padding: 0;
|
||||
}
|
||||
|
||||
#header {
|
||||
height: 60px;
|
||||
margin: 0 0 15px; padding: 0;
|
||||
}
|
||||
|
||||
#page {}
|
||||
|
||||
#content {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#header a:link,
|
||||
#header a:visited {
|
||||
color:#000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#header h1 {
|
||||
font: bold 400% georgia, serif;
|
||||
letter-spacing: -1px;
|
||||
margin: 0;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#header h2 {
|
||||
font: normal 12px verdana, arial, sans-serif;
|
||||
margin: 2.5em 0 0 0.8em;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#content {}
|
||||
|
||||
#content h1,
|
||||
#content h2,
|
||||
#content h3,
|
||||
#content h4,
|
||||
#content h5 {
|
||||
font-family: "lucidamac bold", "lucida grande", arial, sans-serif;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
|
||||
#content h1 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
#content h2 {
|
||||
font-size: 22px;
|
||||
border-bottom: 1px dotted #000;
|
||||
}
|
||||
|
||||
#content h3 {
|
||||
font-size: 20px;
|
||||
border-bottom: 1px dotted #bbb;
|
||||
}
|
||||
|
||||
#content h4 {
|
||||
font-size: 18px;
|
||||
border-bottom: 1px dotted #bbb;
|
||||
}
|
||||
|
||||
#content h5 {
|
||||
font-size: 18px;
|
||||
background: #ffd;
|
||||
border-bottom: 1px dotted #bbb;
|
||||
}
|
||||
|
||||
#content p {
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
#content ul,
|
||||
#content ol {
|
||||
}
|
||||
|
||||
#content code {
|
||||
font: normal 12px "bitstream vera sans mono", monaco "lucida console", "courier new", courier, serif;
|
||||
}
|
||||
|
||||
#content pre {
|
||||
color: #63FF00;
|
||||
background: #000;
|
||||
overflow: auto;
|
||||
font: normal 12px "bitstream vera sans mono", monaco "lucida console", "courier new", courier, serif;
|
||||
margin: 0.9em 0; padding: 8px;
|
||||
}
|
||||
|
||||
dt {
|
||||
font: bold 14px "lucida grande", verdana, arial, helvetica, sans-serif;
|
||||
}
|
||||
|
||||
dd {
|
||||
}
|
||||
|
||||
body {
|
||||
font: normal 12px "lucida grande", verdana, arial, helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.small {
|
||||
font: normal 10px verdana, arial, sans-serif;
|
||||
}
|
||||
|
||||
.table_h {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
.table_d {
|
||||
background-color: #f7f7f7;
|
||||
}
|
||||
input,
|
||||
textarea { font: normal 12px "bitstream vera sans", verdana, sans-serif; }
|
||||
|
||||
abbr { border: none; }
|
||||
cite { font-style: normal; }
|
||||
a img { border: none; padding: 0; margin: 0; }
|
||||
|
||||
1150
html/task.html
Normal file
1150
html/task.html
Normal file
File diff suppressed because it is too large
Load Diff
149
html/troubleshooting.html
Normal file
149
html/troubleshooting.html
Normal file
@@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Task Troubleshooting Guide</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="task.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<div id="content">
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<h1 class="title">Task Troubleshooting Guide</h1>
|
||||
<p>
|
||||
Here you will find tips and suggestions for making task behave
|
||||
properly, and bug workarounds.
|
||||
</p>
|
||||
|
||||
<br />
|
||||
<h2 class="title">Segmentation Fault for certain commands</h2>
|
||||
<div class="content">
|
||||
<p>
|
||||
Upgrading task to version 1.1.0, 1.2.0 and 1.3.0 can cause
|
||||
segmentation faults. This is mostly occurring for Ubuntu users,
|
||||
although there is no reason for it to be limited to Ubuntu.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Task 1.3.1 fixes this bug, but there is a workaround for users
|
||||
of earlier versions. Add the following line to your ~/.taskrc
|
||||
file:
|
||||
</p>
|
||||
|
||||
<code><pre>dateformat=m/d/Y</pre></code>
|
||||
|
||||
<p class="small">
|
||||
The "dateformat" setting is supported in task 1.1.0 and later.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<h2 class="title">How to get rid of the "Age" column</h2>
|
||||
<div class="content">
|
||||
<p>
|
||||
The "Age" column that shows up on several reports is proving
|
||||
to be unpopular. In task 1.2.0 and later, here is how to
|
||||
remove it from the reports - make sure you have the line:
|
||||
</p>
|
||||
|
||||
<code><pre>showage=no</pre></code>
|
||||
|
||||
<p>
|
||||
in your ~/.taskrc file.
|
||||
|
||||
Note that the "task long" report does not obey this setting
|
||||
in versions prior to 1.3.1.
|
||||
</p>
|
||||
|
||||
<p class="small">
|
||||
The "showage" setting is supported in task 1.2.0 or later.
|
||||
<br />
|
||||
The "task long" report supports this setting in versions 1.3.1
|
||||
or later.
|
||||
</p>
|
||||
<div>
|
||||
|
||||
<br />
|
||||
<h2 class="title">How do I build task under Cygwin?</h2>
|
||||
<div class="content">
|
||||
<p>
|
||||
Task is built the same way everywhere. But under Cygwin, you'll
|
||||
need to make sure you have the following packages available
|
||||
first:
|
||||
|
||||
<ul>
|
||||
<li>gcc
|
||||
<li>make
|
||||
<li>libncurses-devel
|
||||
<li>libncurses8
|
||||
</ul>
|
||||
|
||||
The gcc and make packages allow you to compile the code, and
|
||||
are therefore required, but the ncurses packages are optional.
|
||||
Ncurses will allow task to determine the width of the window, and
|
||||
therefore use the whole width and wrap text accordingly, for a
|
||||
more aesthetically pleasing display.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<div class="content">
|
||||
<p>
|
||||
Copyright 2006-2008, P. Beckingham. All rights reserved.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td align="right" valign="top" width="200px">
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<script type="text/javascript"><!--
|
||||
google_ad_client = "pub-9709799404235424";
|
||||
/* Task Main */
|
||||
google_ad_slot = "8660617875";
|
||||
google_ad_width = 120;
|
||||
google_ad_height = 600;
|
||||
//-->
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var pageTracker = _gat._getTracker("UA-4737637-1");
|
||||
pageTracker._initData();
|
||||
pageTracker._trackPageview();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
157
html/versions.html
Normal file
157
html/versions.html
Normal file
@@ -0,0 +1,157 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Task Prior Versions</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="task.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<div id="content">
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<h1 class="title">Task Prior Versions</h1>
|
||||
<br />
|
||||
|
||||
<div class="content">
|
||||
<p>
|
||||
<h4>New in version 1.3.0</h4>
|
||||
Source: <a href="http://www.beckingham.net/task-1.3.0.tar.gz">task-1.3.0.tar.gz</a>
|
||||
<br />
|
||||
Debian package: <a href="http://www.beckingham.net/task_1.3.0-0_i386.deb">task_1.3.0-0_i386.deb</a>
|
||||
(Thanks to <a href="http://blog.rfquerin.org">Richard Querin</a>)
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>"task calendar" now displays multiple months per line, adjustable
|
||||
by the "monthsperline" configuration variable. Feature added by
|
||||
Damian Glenny
|
||||
<li>Displays shorter message when a command is entered incorrectly,
|
||||
and the full usage for "task help"
|
||||
<li>"task export" can now filter tasks like the reports
|
||||
<li>"task oldest" shows the oldest tasks
|
||||
<li>"task newest" shows the newest tasks
|
||||
<li>Fixed bug where task generates a segmentation fault for several
|
||||
commands, when no "dateformat" configuration variable was present
|
||||
<li>Fixed bug whereby if you have more than one task with a due date,
|
||||
7 days gets added to the entry date of task 2..n
|
||||
<li>Fixed bug whereby "1 wks" was being improperly pluralized
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<h4>New in version 1.2.0</h4>
|
||||
Source: <a href="http://www.beckingham.net/task-1.2.0.tar.gz">task-1.2.0.tar.gz</a>
|
||||
<br />
|
||||
Debian package: <a href="http://www.beckingham.net/task_1.2.0-1_i386.deb">task_1.2.0-1_i386.deb</a>
|
||||
(Thanks to <a href="http://blog.rfquerin.org">Richard Querin</a>)
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Subprojects supported - please see documentation below, or TUTORIAL
|
||||
file
|
||||
<li>"dateformat" configuration variable now properly used to parse as
|
||||
well as render dates
|
||||
<li>"task list x" now performs a caseless comparison between "x" and
|
||||
the task description
|
||||
<li>"showage" configuration variable determines whether the "Age" column
|
||||
should appear on the "task list" and "task next" reports
|
||||
<li>Improvements to the TUTORIAL file and this page
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<h4>New in version 1.1.0</h4>
|
||||
Source: <a href="http://www.beckingham.net/task-1.1.0.tar.gz">task-1.1.0.tar.gz</a>
|
||||
<br />
|
||||
Debian package: <a href="http://www.beckingham.net/task_1.1.0-1_i386.deb">task_1.1.0-1_i386.deb</a>
|
||||
(Thanks to <a href="http://blog.rfquerin.org">Richard Querin</a>)
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>"blanklines" configuration variable to stop displaying unnecessary
|
||||
white space and thus work better on small-screen devices
|
||||
<li>"dateformat" configuration now determines how dates are formatted
|
||||
<li>Better formatting of "task tags" output
|
||||
<li>This home page set up, with TUTORIAL
|
||||
<li>Added tags to the "task long" report
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<h4>New in version 1.0.1</h4>
|
||||
Source: <a href="http://www.beckingham.net/task-1.0.1.tar.gz">task-1.0.1.tar.gz</a>
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Fixed bug where the UUID generator not properly terminating strings
|
||||
<li>Fixed bug where srandom/srand not called prior to custom UUID generation
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<h4>Version 1.0.0</h4>
|
||||
Source: <a href="http://www.beckingham.net/task-1.0.0.tar.gz">task-1.0.0.tar.gz</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Task 1.0.0 was the first publicly available version of task.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<div class="content">
|
||||
<p>
|
||||
Copyright 2006-2008, P. Beckingham. All rights reserved.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td align="right" valign="top" width="200px">
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<script type="text/javascript"><!--
|
||||
google_ad_client = "pub-9709799404235424";
|
||||
/* Task Main */
|
||||
google_ad_slot = "8660617875";
|
||||
google_ad_width = 120;
|
||||
google_ad_height = 600;
|
||||
//-->
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var pageTracker = _gat._getTracker("UA-4737637-1");
|
||||
pageTracker._initData();
|
||||
pageTracker._trackPageview();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
17
ideas.txt
Normal file
17
ideas.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
Real Parsing
|
||||
define grammar for command line
|
||||
implement flex/bison parser
|
||||
|
||||
User-Defined Reports
|
||||
report.xxx=id,project(2+),priority(1-),description
|
||||
change all list-based reports to user-defined
|
||||
|
||||
Generalized Report Writer
|
||||
provide column list, sort order, filter
|
||||
|
||||
Test Suite
|
||||
allow .taskrc override
|
||||
debug=on to cause all cout to be csv
|
||||
regression tests for every bug, command, feature
|
||||
|
||||
|
||||
105
script.txt
Normal file
105
script.txt
Normal file
@@ -0,0 +1,105 @@
|
||||
Hello, and welcome to this quick demo of the task program.
|
||||
|
||||
task add do laundry Let's add some tasks
|
||||
I need to do laundry
|
||||
|
||||
task add project:garage order dumpster Oh yeah, the dumpster
|
||||
|
||||
task add +phone tell mom i loveher Must call Mom (that "phone" there is a tag - they are
|
||||
useful for searching, categorizing)
|
||||
task add +phone pro:garage schedule
|
||||
goodwill pickup
|
||||
|
||||
task ad +email pro:garage ask Tom if Notice I can abbreviating commands
|
||||
he wants that old bkie
|
||||
|
||||
task ls Let's see what we've got
|
||||
I spelled bike wrong
|
||||
|
||||
task 5 /bkie/bike/
|
||||
task ls That's better
|
||||
|
||||
task 1 pro:home Let's assign projects
|
||||
task 3 pro:home tell mom I love her
|
||||
task ls pro:garage
|
||||
|
||||
task long pro:garage Let's see all the columns
|
||||
|
||||
task list pro:garage There are different ways to list
|
||||
|
||||
task lis +phone By tag
|
||||
task li pro:garage +phone By project and tag
|
||||
task l mom By word
|
||||
|
||||
task 1 priority:H Priorities can be High, Medium or Low
|
||||
task pri:H 3
|
||||
task 1 pri:M
|
||||
task li The list is sorted by priority.
|
||||
|
||||
task 2 pri:L
|
||||
task li
|
||||
|
||||
task done 3 Suppose task 3 is done
|
||||
task li ...and it's gone
|
||||
|
||||
task 2 +phone +mistake Lets add tags
|
||||
|
||||
# Oops!
|
||||
task 2 -mistake or remove tags
|
||||
|
||||
task tags or look at all the tags
|
||||
|
||||
task info 2 or all the details
|
||||
|
||||
task projects or all the projects
|
||||
|
||||
task 3 fg:bold Let's make it colorful
|
||||
task 4 fg:bold_green
|
||||
task li
|
||||
task 3 fg:bold_underline_white
|
||||
task li
|
||||
|
||||
task 4 bg:on_bright_red fg:bold_yellow
|
||||
task li Oh that's just nasty - let's get rid of that.
|
||||
task 4 bg:
|
||||
task li
|
||||
task 4 fg:
|
||||
task 3 fg:
|
||||
|
||||
task colors There are many combinations to choose from
|
||||
|
||||
(Slashes!!!)
|
||||
task 1 due:6/8/2008 Let's add a due date
|
||||
date
|
||||
|
||||
task li
|
||||
task calendar Notice the due task is in yellow, today is marked cyan
|
||||
|
||||
task 1 due:5/20/2008 This is now an overdue task
|
||||
task li and it shows up red
|
||||
task overdue
|
||||
task cal
|
||||
|
||||
task export file.csv You can export the tasks to a spreadsheet
|
||||
cat file.csv
|
||||
|
||||
task start 1 Started tasks can be used as reminders
|
||||
of what you are supposed to be doing
|
||||
|
||||
task active They show up as active
|
||||
task done 1 Let's clear out a couple
|
||||
task li
|
||||
task done 3
|
||||
task active
|
||||
|
||||
task summary Summary shows progress on all projects
|
||||
|
||||
task history History shows general activity - how many added,
|
||||
completed etc, by month
|
||||
|
||||
And that's it. There are more commands than this
|
||||
covered in the TUTORIAL file, but this should give
|
||||
the basic idea.
|
||||
|
||||
Thank you for watching.
|
||||
|
||||
@@ -91,14 +91,15 @@ Config.o Config.o: Config.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/istream.tcc /usr/include/c++/4.0.0/fstream \
|
||||
/usr/include/c++/4.0.0/i686-apple-darwin9/bits/basic_file.h \
|
||||
/usr/include/c++/4.0.0/bits/fstream.tcc /usr/include/c++/4.0.0/sstream \
|
||||
/usr/include/c++/4.0.0/bits/sstream.tcc task.h \
|
||||
/usr/include/c++/4.0.0/bits/sstream.tcc /usr/include/sys/types.h \
|
||||
/usr/include/sys/stat.h /usr/include/pwd.h task.h \
|
||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||
/usr/include/c++/4.0.0/bits/vector.tcc /usr/include/c++/4.0.0/map \
|
||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h Config.h Table.h color.h \
|
||||
Grid.h color.h TDB.h T.h ../auto.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -366,6 +367,12 @@ Config.o Config.o: Config.cpp /usr/include/c++/4.0.0/iostream \
|
||||
|
||||
/usr/include/c++/4.0.0/bits/sstream.tcc:
|
||||
|
||||
/usr/include/sys/types.h:
|
||||
|
||||
/usr/include/sys/stat.h:
|
||||
|
||||
/usr/include/pwd.h:
|
||||
|
||||
task.h:
|
||||
|
||||
/usr/include/c++/4.0.0/vector:
|
||||
@@ -384,18 +391,18 @@ task.h:
|
||||
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h:
|
||||
|
||||
/usr/include/sys/types.h:
|
||||
|
||||
Config.h:
|
||||
|
||||
Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
@@ -95,7 +95,7 @@ Date.o Date.o: Date.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h Date.h
|
||||
Config.h Table.h color.h Grid.h color.h TDB.h T.h ../auto.h Date.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -379,12 +379,14 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
Date.h:
|
||||
|
||||
@@ -95,7 +95,7 @@ T.o T.o: T.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h
|
||||
Config.h Table.h color.h Grid.h color.h TDB.h T.h ../auto.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -379,10 +379,12 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
@@ -99,7 +99,7 @@ TDB.o TDB.o: TDB.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h Config.h Table.h color.h \
|
||||
TDB.h T.h stlmacros.h ../auto.h
|
||||
Grid.h color.h TDB.h T.h ../auto.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -395,10 +395,12 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
@@ -94,8 +94,9 @@ Table.o Table.o: Table.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||
/usr/include/c++/4.0.0/bits/vector.tcc color.h Date.h stlmacros.h \
|
||||
task.h /usr/include/sys/types.h Config.h TDB.h T.h ../auto.h
|
||||
/usr/include/c++/4.0.0/bits/vector.tcc color.h Grid.h Date.h task.h \
|
||||
/usr/include/sys/types.h Config.h Table.h color.h TDB.h T.h T.h \
|
||||
../auto.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -373,9 +374,9 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Date.h:
|
||||
Grid.h:
|
||||
|
||||
stlmacros.h:
|
||||
Date.h:
|
||||
|
||||
task.h:
|
||||
|
||||
@@ -383,8 +384,14 @@ task.h:
|
||||
|
||||
Config.h:
|
||||
|
||||
Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
T.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
@@ -95,8 +95,8 @@ parse.o parse.o: parse.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h Date.h task.h \
|
||||
/usr/include/sys/types.h Config.h Table.h color.h TDB.h T.h stlmacros.h \
|
||||
../auto.h
|
||||
/usr/include/sys/types.h Config.h Table.h color.h Grid.h color.h TDB.h \
|
||||
T.h ../auto.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -382,10 +382,12 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
@@ -94,8 +94,8 @@ rules.o rules.o: rules.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||
/usr/include/c++/4.0.0/bits/vector.tcc Table.h color.h Date.h T.h \
|
||||
task.h /usr/include/sys/types.h TDB.h stlmacros.h ../auto.h
|
||||
/usr/include/c++/4.0.0/bits/vector.tcc Table.h color.h Grid.h Date.h \
|
||||
T.h task.h /usr/include/sys/types.h color.h TDB.h ../auto.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -375,6 +375,8 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
Date.h:
|
||||
|
||||
T.h:
|
||||
@@ -383,8 +385,8 @@ task.h:
|
||||
|
||||
/usr/include/sys/types.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
@@ -98,8 +98,8 @@ task.o task.o: task.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||
/usr/include/c++/4.0.0/bits/vector.tcc Date.h Table.h color.h \
|
||||
stlmacros.h TDB.h T.h task.h ../auto.h /usr/include/ncurses.h \
|
||||
/usr/include/c++/4.0.0/bits/vector.tcc Date.h Table.h color.h Grid.h \
|
||||
TDB.h T.h task.h color.h ../auto.h /usr/include/ncurses.h \
|
||||
/usr/include/ncurses_dll.h /usr/include/unctrl.h /usr/include/curses.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
@@ -396,7 +396,7 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
stlmacros.h:
|
||||
Grid.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
@@ -404,6 +404,8 @@ T.h:
|
||||
|
||||
task.h:
|
||||
|
||||
color.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
/usr/include/ncurses.h:
|
||||
|
||||
@@ -95,7 +95,7 @@ text.o text.o: text.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/c++/4.0.0/map /usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h
|
||||
Config.h Table.h color.h Grid.h color.h TDB.h T.h ../auto.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -379,10 +379,12 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
@@ -95,8 +95,8 @@ util.o util.o: util.cpp /usr/include/c++/4.0.0/iostream \
|
||||
/usr/include/sys/time.h Table.h /usr/include/c++/4.0.0/map \
|
||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h color.h task.h Config.h \
|
||||
TDB.h T.h stlmacros.h ../auto.h /usr/include/uuid/uuid.h
|
||||
/usr/include/c++/4.0.0/bits/stl_multimap.h color.h Grid.h task.h \
|
||||
Config.h color.h TDB.h T.h ../auto.h /usr/include/uuid/uuid.h
|
||||
|
||||
/usr/include/c++/4.0.0/iostream:
|
||||
|
||||
@@ -378,16 +378,18 @@ Table.h:
|
||||
|
||||
color.h:
|
||||
|
||||
Grid.h:
|
||||
|
||||
task.h:
|
||||
|
||||
Config.h:
|
||||
|
||||
color.h:
|
||||
|
||||
TDB.h:
|
||||
|
||||
T.h:
|
||||
|
||||
stlmacros.h:
|
||||
|
||||
../auto.h:
|
||||
|
||||
/usr/include/uuid/uuid.h:
|
||||
|
||||
2
src/.gitignore
vendored
Normal file
2
src/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
./Makefile
|
||||
*.o
|
||||
122
src/Config.cpp
122
src/Config.cpp
@@ -1,11 +1,37 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2005 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include "task.h"
|
||||
#include "Config.h"
|
||||
|
||||
@@ -34,7 +60,7 @@ bool Config::load (const std::string& file)
|
||||
while (getline (in, line))
|
||||
{
|
||||
// Remove comments.
|
||||
unsigned int pound = line.find ("#");
|
||||
size_type pound = line.find ("#");
|
||||
if (pound != std::string::npos)
|
||||
line = line.substr (0, pound);
|
||||
|
||||
@@ -43,7 +69,7 @@ bool Config::load (const std::string& file)
|
||||
// Skip empty lines.
|
||||
if (line.length () > 0)
|
||||
{
|
||||
unsigned int equal = line.find ("=");
|
||||
size_type equal = line.find ("=");
|
||||
if (equal != std::string::npos)
|
||||
{
|
||||
std::string key = trim (line.substr (0, equal), " \t");
|
||||
@@ -60,9 +86,68 @@ bool Config::load (const std::string& file)
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Config::createDefault (const std::string& home)
|
||||
{
|
||||
// Strip trailing slash off home directory, if necessary.
|
||||
std::string terminatedHome = home;
|
||||
if (home[home.length () - 1] == '/')
|
||||
terminatedHome = home.substr (0, home.length () - 1);
|
||||
|
||||
// Determine default names of init file and task directory.
|
||||
std::string rcFile = terminatedHome + "/.taskrc";
|
||||
std::string dataDir = terminatedHome + "/.task";;
|
||||
|
||||
// If rcFile is not found, offer to create one.
|
||||
if (-1 == access (rcFile.c_str (), F_OK))
|
||||
{
|
||||
if (confirm (
|
||||
"A configuration file could not be found in "
|
||||
+ rcFile
|
||||
+ "\n\n"
|
||||
+ "Would you like a sample .taskrc created, so task can proceed?"))
|
||||
{
|
||||
// Create a sample .taskrc file.
|
||||
FILE* out;
|
||||
if ((out = fopen (rcFile.c_str (), "w")))
|
||||
{
|
||||
fprintf (out, "data.location=%s\n", dataDir.c_str ());
|
||||
fprintf (out, "command.logging=off\n");
|
||||
fprintf (out, "confirmation=yes\n");
|
||||
fprintf (out, "next=2\n");
|
||||
fprintf (out, "dateformat=m/d/Y\n");
|
||||
fprintf (out, "showage=yes\n");
|
||||
fprintf (out, "monthsperline=1\n");
|
||||
fprintf (out, "curses=on\n");
|
||||
fprintf (out, "color=on\n");
|
||||
|
||||
fprintf (out, "color.overdue=bold_red\n");
|
||||
fprintf (out, "#color.due=on_bright_yellow\n");
|
||||
fprintf (out, "#color.pri.H=on_red\n");
|
||||
fprintf (out, "#color.pri.M=on_yellow\n");
|
||||
fprintf (out, "#color.pri.L=on_green\n");
|
||||
fprintf (out, "color.active=bold_cyan\n");
|
||||
fprintf (out, "color.tagged=yellow\n");
|
||||
fprintf (out, "#color.tag.bug=yellow\n");
|
||||
fprintf (out, "#color.project.home=on_green\n");
|
||||
fprintf (out, "#color.keyword.car=on_blue\n");
|
||||
|
||||
fclose (out);
|
||||
|
||||
std::cout << "Done." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->load (rcFile);
|
||||
|
||||
if (-1 == access (dataDir.c_str (), F_OK))
|
||||
mkdir (dataDir.c_str (), S_IRWXU);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the configuration value given the specified key.
|
||||
const std::string& Config::get (const char* key)
|
||||
const std::string Config::get (const char* key)
|
||||
{
|
||||
return this->get (std::string (key));
|
||||
}
|
||||
@@ -70,7 +155,7 @@ const std::string& Config::get (const char* key)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the configuration value given the specified key. If a default_value
|
||||
// is present, it will be the returned value in the event of a missing key.
|
||||
const std::string& Config::get (
|
||||
const std::string Config::get (
|
||||
const char* key,
|
||||
const char* default_value)
|
||||
{
|
||||
@@ -79,7 +164,7 @@ const std::string& Config::get (
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the configuration value given the specified key.
|
||||
const std::string& Config::get (const std::string& key)
|
||||
const std::string Config::get (const std::string& key)
|
||||
{
|
||||
return (*this)[key];
|
||||
}
|
||||
@@ -87,7 +172,7 @@ const std::string& Config::get (const std::string& key)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the configuration value given the specified key. If a default_value
|
||||
// is present, it will be the returned value in the event of a missing key.
|
||||
const std::string& Config::get (
|
||||
const std::string Config::get (
|
||||
const std::string& key,
|
||||
const std::string& default_value)
|
||||
{
|
||||
@@ -157,29 +242,6 @@ void Config::set (const std::string& key, const std::string& value)
|
||||
(*this)[key] = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The vector form of Config::get assumes the single value is comma-separated,
|
||||
// and splits accordingly.
|
||||
void Config::get (
|
||||
const std::string& key,
|
||||
std::vector <std::string>& values)
|
||||
{
|
||||
values.clear ();
|
||||
split (values, (*this)[key], ',');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The vector form of Config::set joins the values together with commas, and
|
||||
// stores the single value.
|
||||
void Config::set (
|
||||
const std::string& key,
|
||||
const std::vector <std::string>& values)
|
||||
{
|
||||
std::string conjoined;
|
||||
join (conjoined, ",", values);
|
||||
(*this)[key] = conjoined;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Provide a vector of all configuration keys.
|
||||
void Config::all (std::vector<std::string>& items)
|
||||
|
||||
35
src/Config.h
35
src/Config.h
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2005 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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_CONFIG
|
||||
@@ -17,18 +38,18 @@ public:
|
||||
Config (const std::string&);
|
||||
|
||||
bool load (const std::string&);
|
||||
const std::string& get (const char*);
|
||||
const std::string& get (const char*, const char*);
|
||||
const std::string& get (const std::string&);
|
||||
const std::string& get (const std::string&, const std::string&);
|
||||
void createDefault (const std::string&);
|
||||
|
||||
const std::string get (const char*);
|
||||
const std::string get (const char*, const char*);
|
||||
const std::string get (const std::string&);
|
||||
const std::string get (const std::string&, const std::string&);
|
||||
bool get (const std::string&, bool);
|
||||
int get (const std::string&, const int);
|
||||
double get (const std::string&, const double);
|
||||
void get (const std::string&, std::vector <std::string>&);
|
||||
void set (const std::string&, const int);
|
||||
void set (const std::string&, const double);
|
||||
void set (const std::string&, const std::string&);
|
||||
void set (const std::string&, const std::vector <std::string>&);
|
||||
void all (std::vector <std::string>&);
|
||||
};
|
||||
|
||||
|
||||
216
src/Date.cpp
216
src/Date.cpp
@@ -1,10 +1,33 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2005 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "task.h"
|
||||
#include "Date.h"
|
||||
|
||||
@@ -34,29 +57,134 @@ Date::Date (const int m, const int d, const int y)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Date::Date (const std::string& mdy)
|
||||
Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
||||
{
|
||||
unsigned int firstSlash = mdy.find ("/");
|
||||
unsigned int secondSlash = mdy.find ("/", firstSlash + 1);
|
||||
if (firstSlash != std::string::npos &&
|
||||
secondSlash != std::string::npos)
|
||||
{
|
||||
int m = ::atoi (mdy.substr (0, firstSlash ).c_str ());
|
||||
int d = ::atoi (mdy.substr (firstSlash + 1, secondSlash - firstSlash).c_str ());
|
||||
int y = ::atoi (mdy.substr (secondSlash + 1, std::string::npos ).c_str ());
|
||||
if (!valid (m, d, y))
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
int month = 0;
|
||||
int day = 0;
|
||||
int year = 0;
|
||||
|
||||
// Duplicate Date::Date (const int, const int, const int);
|
||||
struct tm t = {0};
|
||||
t.tm_mday = d;
|
||||
t.tm_mon = m - 1;
|
||||
t.tm_year = y - 1900;
|
||||
unsigned int i = 0; // Index into mdy.
|
||||
|
||||
for (unsigned int f = 0; f < format.length (); ++f)
|
||||
{
|
||||
switch (format[f])
|
||||
{
|
||||
// Single or double digit.
|
||||
case 'm':
|
||||
if (i >= mdy.length () ||
|
||||
! ::isdigit (mdy[i]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
if (i + 1 < mdy.length () &&
|
||||
mdy[i + 0] == '1' &&
|
||||
(mdy[i + 1] == '0' || mdy[i + 1] == '1' || mdy[i + 1] == '2'))
|
||||
{
|
||||
month = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
month = ::atoi (mdy.substr (i, 1).c_str ());
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (i >= mdy.length () ||
|
||||
! ::isdigit (mdy[i]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
if (i + 1 < mdy.length () &&
|
||||
(mdy[i + 0] == '1' || mdy[i + 0] == '2' || mdy[i + 0] == '3') &&
|
||||
::isdigit (mdy[i + 1]))
|
||||
{
|
||||
day = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
day = ::atoi (mdy.substr (i, 1).c_str ());
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
|
||||
// Double digit.
|
||||
case 'y':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
year = ::atoi (mdy.substr (i, 2).c_str ()) + 2000;
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
month = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if (i + 1 >= mdy.length () ||
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
day = ::atoi (mdy.substr (i, 2).c_str ());
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
// Quadruple digit.
|
||||
case 'Y':
|
||||
if (i + 3 >= mdy.length () ||
|
||||
! ::isdigit (mdy[i + 0]) ||
|
||||
! ::isdigit (mdy[i + 1]) ||
|
||||
! ::isdigit (mdy[i + 2]) ||
|
||||
! ::isdigit (mdy[i + 3]))
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
year = ::atoi (mdy.substr (i, 4).c_str ());
|
||||
i += 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (i >= mdy.length () ||
|
||||
mdy[i] != format[f])
|
||||
{
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid (month, day, year))
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
|
||||
// Duplicate Date::Date (const int, const int, const int);
|
||||
struct tm t = {0};
|
||||
t.tm_mday = day;
|
||||
t.tm_mon = month - 1;
|
||||
t.tm_year = year - 1900;
|
||||
|
||||
mT = mktime (&t);
|
||||
}
|
||||
else
|
||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -93,20 +221,32 @@ void Date::toMDY (int& m, int& d, int& y)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Date::toString (std::string& output)
|
||||
const std::string Date::toString (const std::string& format /*= "m/d/Y" */) const
|
||||
{
|
||||
output = toString ();
|
||||
}
|
||||
// Making this local copy seems to fix a bug. Remove the local copy and you'll
|
||||
// see segmentation faults and all kinds of gibberish.
|
||||
std::string localFormat = format;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Date::toString (void)
|
||||
{
|
||||
int m, d, y;
|
||||
toMDY (m, d, y);
|
||||
char buffer[12];
|
||||
std::string formatted;
|
||||
for (unsigned int i = 0; i < localFormat.length (); ++i)
|
||||
{
|
||||
char c = localFormat[i];
|
||||
switch (c)
|
||||
{
|
||||
case 'm': sprintf (buffer, "%d", this->month ()); break;
|
||||
case 'M': sprintf (buffer, "%02d", this->month ()); break;
|
||||
case 'd': sprintf (buffer, "%d", this->day ()); break;
|
||||
case 'D': sprintf (buffer, "%02d", this->day ()); break;
|
||||
case 'y': sprintf (buffer, "%02d", this->year () % 100); break;
|
||||
case 'Y': sprintf (buffer, "%d", this->year ()); break;
|
||||
default: sprintf (buffer, "%c", c); break;
|
||||
}
|
||||
|
||||
char formatted [11];
|
||||
sprintf (formatted, "%d/%d/%d", m, d, y);
|
||||
return std::string (formatted);
|
||||
formatted += buffer;
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -155,7 +295,7 @@ int Date::daysInMonth (int month, int year)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Date::monthName (int month)
|
||||
{
|
||||
static char* months[12] =
|
||||
static const char* months[12] =
|
||||
{
|
||||
"January",
|
||||
"February",
|
||||
@@ -179,7 +319,7 @@ std::string Date::monthName (int month)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Date::dayName (int dow, std::string& name)
|
||||
{
|
||||
static char* days[7] =
|
||||
static const char* days[7] =
|
||||
{
|
||||
"Sunday",
|
||||
"Monday",
|
||||
@@ -196,7 +336,7 @@ void Date::dayName (int dow, std::string& name)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Date::dayName (int dow)
|
||||
{
|
||||
static char* days[7] =
|
||||
static const char* days[7] =
|
||||
{
|
||||
"Sunday",
|
||||
"Monday",
|
||||
@@ -211,28 +351,28 @@ std::string Date::dayName (int dow)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::dayOfWeek ()
|
||||
int Date::dayOfWeek () const
|
||||
{
|
||||
struct tm* t = localtime (&mT);
|
||||
return t->tm_wday;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::month ()
|
||||
int Date::month () const
|
||||
{
|
||||
struct tm* t = localtime (&mT);
|
||||
return t->tm_mon + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::day ()
|
||||
int Date::day () const
|
||||
{
|
||||
struct tm* t = localtime (&mT);
|
||||
return t->tm_mday;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::year ()
|
||||
int Date::year () const
|
||||
{
|
||||
struct tm* t = localtime (&mT);
|
||||
return t->tm_year + 1900;
|
||||
|
||||
36
src/Date.h
36
src/Date.h
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2005 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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_DATE
|
||||
@@ -16,15 +37,14 @@ public:
|
||||
Date ();
|
||||
Date (time_t);
|
||||
Date (const int, const int, const int);
|
||||
Date (const std::string&);
|
||||
Date (const std::string&, const std::string& format = "m/d/Y");
|
||||
Date (const Date&);
|
||||
virtual ~Date ();
|
||||
|
||||
void toEpoch (time_t&);
|
||||
time_t toEpoch ();
|
||||
void toMDY (int&, int&, int&);
|
||||
void toString (std::string&);
|
||||
std::string toString (void);
|
||||
const std::string toString (const std::string& format = "m/d/Y") const;
|
||||
static bool valid (const int, const int, const int);
|
||||
|
||||
static bool leapYear (int);
|
||||
@@ -32,11 +52,11 @@ public:
|
||||
static std::string monthName (int);
|
||||
static void dayName (int, std::string&);
|
||||
static std::string dayName (int);
|
||||
int dayOfWeek ();
|
||||
int dayOfWeek () const;
|
||||
|
||||
int month ();
|
||||
int day ();
|
||||
int year ();
|
||||
int month () const;
|
||||
int day () const;
|
||||
int year () const;
|
||||
|
||||
bool operator== (const Date&);
|
||||
bool operator!= (const Date&);
|
||||
|
||||
425
src/Grid.cpp
Normal file
425
src/Grid.cpp
Normal file
@@ -0,0 +1,425 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
//
|
||||
//
|
||||
// Grid implements a sparse 2D array of Cell objects. Grid makes every effort
|
||||
// to perform well on cell insertion and retrieval. A Cell is a variant type,
|
||||
// capable of storing char, bool, int, float, double and std::string types.
|
||||
//
|
||||
// Every cell is accessible from both mColumns and mRows. This allows the
|
||||
// client code to specify which method is used, because there will be a
|
||||
// performance penalty with one of the methods, depending on the layout of
|
||||
// cells within the grid.
|
||||
//
|
||||
// mColumns, like mRows, is a vector of a vector of Cell*.
|
||||
//
|
||||
// mColumns
|
||||
// [0..n]
|
||||
// +---+---+-----------+---+
|
||||
// | 0 | 1 | | n |
|
||||
// +---+---+-----------+---+
|
||||
// | |
|
||||
// v |
|
||||
// +---+ . +---+ . | .
|
||||
// mRows | 0 | -------> | x | v
|
||||
// [0..1] +---+ . +---+ +---+
|
||||
// | 1 | -------> | y | --------> | z |
|
||||
// +---+ . +---+ +---+
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// +---+ . . . . .
|
||||
// | n |
|
||||
// +---+ . . . . .
|
||||
//
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <iostream>
|
||||
#include <Grid.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Grid::Grid ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The cells are deleted via their mRows reference, not by their mColumns
|
||||
// reference. This is because the cells are doubly-linked, and so the
|
||||
// convention is that rows own cells, columns merely own pointers.
|
||||
Grid::~Grid ()
|
||||
{
|
||||
std::vector < std::vector <Cell*>* >::iterator row;
|
||||
std::vector <Cell*>::iterator col;
|
||||
for (row = mRows.begin (); row != mRows.end (); ++row)
|
||||
if (*row)
|
||||
for (col = (*row)->begin (); col != (*row)->end (); ++col)
|
||||
if (*col)
|
||||
delete *col;
|
||||
|
||||
std::vector < std::vector <Cell*>* >::iterator it;
|
||||
for (it = mRows.begin (); it != mRows.end (); ++it)
|
||||
if (*it)
|
||||
delete *it;
|
||||
|
||||
for (it = mColumns.begin (); it != mColumns.end (); ++it)
|
||||
if (*it)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Grid::add (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
const bool value)
|
||||
{
|
||||
expandGrid (row, col);
|
||||
insertCell (row, col, new Cell (value));
|
||||
}
|
||||
|
||||
void Grid::add (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
const char value)
|
||||
{
|
||||
expandGrid (row, col);
|
||||
insertCell (row, col, new Cell (value));
|
||||
}
|
||||
|
||||
void Grid::add (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
const int value)
|
||||
{
|
||||
expandGrid (row, col);
|
||||
insertCell (row, col, new Cell (value));
|
||||
}
|
||||
|
||||
void Grid::add (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
const float value)
|
||||
{
|
||||
expandGrid (row, col);
|
||||
insertCell (row, col, new Cell (value));
|
||||
}
|
||||
|
||||
void Grid::add (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
const double value)
|
||||
{
|
||||
expandGrid (row, col);
|
||||
insertCell (row, col, new Cell (value));
|
||||
}
|
||||
|
||||
void Grid::add (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
const char* value)
|
||||
{
|
||||
expandGrid (row, col);
|
||||
insertCell (row, col, new Cell (std::string (value)));
|
||||
}
|
||||
|
||||
void Grid::add (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
const std::string& value)
|
||||
{
|
||||
expandGrid (row, col);
|
||||
insertCell (row, col, new Cell (value));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
unsigned int Grid::width () const
|
||||
{
|
||||
return mColumns.size ();
|
||||
}
|
||||
|
||||
unsigned int Grid::height () const
|
||||
{
|
||||
return mRows.size ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Grid::Cell* Grid::byRow (const unsigned int row, const unsigned int col) const
|
||||
{
|
||||
if (row < mRows.size () &&
|
||||
mRows[row] != NULL &&
|
||||
col < mRows[row]->size ())
|
||||
return (*mRows[row])[col];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Grid::Cell* Grid::byColumn (const unsigned int row, const unsigned int col) const
|
||||
{
|
||||
if (col < mColumns.size () &&
|
||||
mColumns[col] != NULL &&
|
||||
row < mColumns[col]->size ())
|
||||
return (*mColumns[col])[row];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Grid::expandGrid (const unsigned int row, const unsigned int col)
|
||||
{
|
||||
|
||||
// If the new row is outside the bounds of the current grid, add blank rows to
|
||||
// pad, then a new row vector.
|
||||
if (row >= mRows.size ())
|
||||
{
|
||||
for (unsigned int r = mRows.size (); r <= row; ++r)
|
||||
if (r < row)
|
||||
mRows.push_back (NULL);
|
||||
else
|
||||
mRows.push_back (new std::vector <Cell*>);
|
||||
}
|
||||
// If the new row is within the bounds of the current grid, ensure that the
|
||||
// row points to a vector of cells.
|
||||
else if (mRows[row] == NULL)
|
||||
mRows[row] = new std::vector <Cell*>;
|
||||
|
||||
if (col >= mRows[row]->size ())
|
||||
for (unsigned int c = mRows[row]->size (); c <= col; ++c)
|
||||
mRows[row]->push_back (NULL);
|
||||
|
||||
// If the new col is outside the bounds of the current grid, add blank cols to
|
||||
// pad, then a new col vector.
|
||||
if (col >= mColumns.size ())
|
||||
{
|
||||
for (unsigned int c = mColumns.size (); c <= col; ++c)
|
||||
if (c < col)
|
||||
mColumns.push_back (NULL);
|
||||
else
|
||||
mColumns.push_back (new std::vector <Cell*>);
|
||||
}
|
||||
// If the new col is within the bounds of the current grid, ensure that the
|
||||
// col points to a vector of cells.
|
||||
else if (mColumns[col] == NULL)
|
||||
mColumns[col] = new std::vector <Cell*>;
|
||||
|
||||
if (row >= mColumns[col]->size ())
|
||||
for (unsigned int r = mColumns[col]->size (); r <= row; ++r)
|
||||
mColumns[col]->push_back (NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Grid::insertCell (
|
||||
const unsigned int row,
|
||||
const unsigned int col,
|
||||
Cell* cell)
|
||||
{
|
||||
// Delete any existing cell, because cells are owned by rows, not columns.
|
||||
if ((*mRows[row])[col] != NULL)
|
||||
delete (*mRows[row])[col];
|
||||
|
||||
(*mRows[row])[col] = cell;
|
||||
(*mColumns[col])[row] = cell;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Grid::Cell::Cell (const bool value)
|
||||
: mType (CELL_BOOL)
|
||||
, mBool (value)
|
||||
{
|
||||
}
|
||||
|
||||
Grid::Cell::Cell (const char value)
|
||||
: mType (CELL_CHAR)
|
||||
, mChar (value)
|
||||
{
|
||||
}
|
||||
|
||||
Grid::Cell::Cell (const int value)
|
||||
: mType (CELL_INT)
|
||||
, mInt (value)
|
||||
{
|
||||
}
|
||||
|
||||
Grid::Cell::Cell (const float value)
|
||||
: mType (CELL_FLOAT)
|
||||
, mFloat (value)
|
||||
{
|
||||
}
|
||||
|
||||
Grid::Cell::Cell (const double value)
|
||||
: mType (CELL_DOUBLE)
|
||||
, mDouble (value)
|
||||
{
|
||||
}
|
||||
|
||||
Grid::Cell::Cell (const std::string& value)
|
||||
: mType (CELL_STRING)
|
||||
, mString (value)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// These cast operators make a best approximation to an appropriate rendering,
|
||||
// given the format change.
|
||||
Grid::Cell::operator bool () const
|
||||
{
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool;
|
||||
case CELL_CHAR: return mChar != '\0' &&
|
||||
mChar != ' ' &&
|
||||
mChar != '0';
|
||||
case CELL_INT: return mInt != 0;
|
||||
case CELL_FLOAT: return mFloat != 0.0;
|
||||
case CELL_DOUBLE: return mDouble != 0.0;
|
||||
case CELL_STRING: return mString.length () > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Grid::Cell::operator char () const
|
||||
{
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool ? 'Y' : 'N';
|
||||
case CELL_CHAR: return mChar;
|
||||
case CELL_INT: return (char) mInt;
|
||||
case CELL_FLOAT: return (char) (int) mFloat;
|
||||
case CELL_DOUBLE: return (char) (int) mDouble;
|
||||
case CELL_STRING: return mString[0];
|
||||
}
|
||||
|
||||
return '\0';
|
||||
}
|
||||
|
||||
Grid::Cell::operator int () const
|
||||
{
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool ? 1 : 0;
|
||||
case CELL_CHAR: return (int) mChar;
|
||||
case CELL_INT: return mInt;
|
||||
case CELL_FLOAT: return (int) mFloat;
|
||||
case CELL_DOUBLE: return (int) mDouble;
|
||||
case CELL_STRING: return mString.length ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Grid::Cell::operator float () const
|
||||
{
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool ? 1.0 : 0.0;
|
||||
case CELL_CHAR: return (float) (int) mChar;
|
||||
case CELL_INT: return (float) mInt;
|
||||
case CELL_FLOAT: return mFloat;
|
||||
case CELL_DOUBLE: return (float) mDouble;
|
||||
case CELL_STRING: return (float) mString.length ();
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
Grid::Cell::operator double () const
|
||||
{
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool ? 1.0 : 0.0;
|
||||
case CELL_CHAR: return (double) (int) mChar;
|
||||
case CELL_INT: return (double) mInt;
|
||||
case CELL_FLOAT: return (double) mFloat;
|
||||
case CELL_DOUBLE: return mDouble;
|
||||
case CELL_STRING: return (double) mString.length ();
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
Grid::Cell::operator std::string () const
|
||||
{
|
||||
char s[64] = {0};
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool ? "true" : "false";
|
||||
case CELL_CHAR: sprintf (s, "%c", mChar);
|
||||
return std::string (s);
|
||||
case CELL_INT: sprintf (s, "%d", mInt);
|
||||
return std::string (s);
|
||||
case CELL_FLOAT: sprintf (s, "%f", mFloat);
|
||||
return std::string (s);
|
||||
case CELL_DOUBLE: sprintf (s, "%f", mDouble);
|
||||
return std::string (s);
|
||||
case CELL_STRING: return mString;
|
||||
}
|
||||
|
||||
return std::string ("");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Grid::Cell::operator== (const Grid::Cell& rhs) const
|
||||
{
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool == rhs.mBool ? true : false;
|
||||
case CELL_CHAR: return mChar == rhs.mChar ? true : false;
|
||||
case CELL_INT: return mInt == rhs.mInt ? true : false;
|
||||
case CELL_FLOAT: return mFloat == rhs.mFloat ? true : false;
|
||||
case CELL_DOUBLE: return mDouble == rhs.mDouble ? true : false;
|
||||
case CELL_STRING: return mString == rhs.mString ? true : false;
|
||||
default: break; // To prevent warnings.
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Grid::Cell::operator!= (const Grid::Cell& rhs) const
|
||||
{
|
||||
switch (mType)
|
||||
{
|
||||
case CELL_BOOL: return mBool != rhs.mBool ? true : false;
|
||||
case CELL_CHAR: return mChar != rhs.mChar ? true : false;
|
||||
case CELL_INT: return mInt != rhs.mInt ? true : false;
|
||||
case CELL_FLOAT: return mFloat != rhs.mFloat ? true : false;
|
||||
case CELL_DOUBLE: return mDouble != rhs.mDouble ? true : false;
|
||||
case CELL_STRING: return mString != rhs.mString ? true : false;
|
||||
default: break; // To prevent warnings.
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Grid::Cell::cellType Grid::Cell::type () const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
99
src/Grid.h
Normal file
99
src/Grid.h
Normal file
@@ -0,0 +1,99 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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_GRID
|
||||
#define INCLUDED_GRID
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class Grid
|
||||
{
|
||||
public:
|
||||
class Cell
|
||||
{
|
||||
public:
|
||||
Cell (const bool);
|
||||
Cell (const char);
|
||||
Cell (const int);
|
||||
Cell (const float);
|
||||
Cell (const double);
|
||||
Cell (const std::string&);
|
||||
|
||||
operator bool () const;
|
||||
operator char () const;
|
||||
operator int () const;
|
||||
operator float () const;
|
||||
operator double () const;
|
||||
operator std::string () const;
|
||||
bool operator== (const Cell&) const;
|
||||
bool operator!= (const Cell&) const;
|
||||
|
||||
enum cellType {CELL_BOOL, CELL_CHAR, CELL_INT, CELL_FLOAT, CELL_DOUBLE, CELL_STRING};
|
||||
|
||||
cellType type () const;
|
||||
|
||||
private:
|
||||
cellType mType;
|
||||
bool mBool;
|
||||
char mChar;
|
||||
int mInt;
|
||||
float mFloat;
|
||||
double mDouble;
|
||||
std::string mString;
|
||||
};
|
||||
|
||||
public:
|
||||
Grid ();
|
||||
~Grid ();
|
||||
|
||||
void add (const unsigned int, const unsigned int, const bool);
|
||||
void add (const unsigned int, const unsigned int, const char);
|
||||
void add (const unsigned int, const unsigned int, const int);
|
||||
void add (const unsigned int, const unsigned int, const float);
|
||||
void add (const unsigned int, const unsigned int, const double);
|
||||
void add (const unsigned int, const unsigned int, const char*);
|
||||
void add (const unsigned int, const unsigned int, const std::string&);
|
||||
|
||||
unsigned int width () const;
|
||||
unsigned int height () const;
|
||||
|
||||
Cell* byRow (const unsigned int, const unsigned int) const;
|
||||
Cell* byColumn (const unsigned int, const unsigned int) const;
|
||||
|
||||
private:
|
||||
void expandGrid (const unsigned int, const unsigned int);
|
||||
void insertCell (const unsigned int, const unsigned int, Cell*);
|
||||
|
||||
private:
|
||||
std::vector < std::vector <Cell*>* > mRows;
|
||||
std::vector < std::vector <Cell*>* > mColumns;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
429
src/Makefile
429
src/Makefile
@@ -1,429 +0,0 @@
|
||||
# Makefile.in generated by automake 1.10 from Makefile.am.
|
||||
# src/Makefile. Generated from Makefile.in by configure.
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
|
||||
|
||||
pkgdatadir = $(datadir)/task
|
||||
pkglibdir = $(libdir)/task
|
||||
pkgincludedir = $(includedir)/task
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
bin_PROGRAMS = task$(EXEEXT)
|
||||
subdir = src
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/auto.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \
|
||||
TDB.$(OBJEXT) Table.$(OBJEXT) color.$(OBJEXT) parse.$(OBJEXT) \
|
||||
task.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT)
|
||||
task_OBJECTS = $(am_task_OBJECTS)
|
||||
task_LDADD = $(LDADD)
|
||||
DEFAULT_INCLUDES = -I. -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
||||
-o $@
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(task_SOURCES)
|
||||
DIST_SOURCES = $(task_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = ${SHELL} /Users/paul/work/task_rel/missing --run aclocal-1.10
|
||||
AMTAR = ${SHELL} /Users/paul/work/task_rel/missing --run tar
|
||||
AUTOCONF = ${SHELL} /Users/paul/work/task_rel/missing --run autoconf
|
||||
AUTOHEADER = ${SHELL} /Users/paul/work/task_rel/missing --run autoheader
|
||||
AUTOMAKE = ${SHELL} /Users/paul/work/task_rel/missing --run automake-1.10
|
||||
AWK = awk
|
||||
CC = gcc
|
||||
CCDEPMODE = depmode=gcc3
|
||||
CFLAGS = -g -O2
|
||||
CPPFLAGS =
|
||||
CXX = g++
|
||||
CXXCPP = g++ -E
|
||||
CXXDEPMODE = depmode=gcc3
|
||||
CXXFLAGS = -g -O2
|
||||
CYGPATH_W = echo
|
||||
DEFS = -DHAVE_CONFIG_H
|
||||
DEPDIR = .deps
|
||||
ECHO_C = \c
|
||||
ECHO_N =
|
||||
ECHO_T =
|
||||
EGREP = /usr/bin/grep -E
|
||||
EXEEXT =
|
||||
GREP = /usr/bin/grep
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
INSTALL_PROGRAM = ${INSTALL}
|
||||
INSTALL_SCRIPT = ${INSTALL}
|
||||
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
||||
LDFLAGS =
|
||||
LIBOBJS = ${LIBOBJDIR}mktime$U.o
|
||||
LIBS = -lncurses
|
||||
LTLIBOBJS = ${LIBOBJDIR}mktime$U.lo
|
||||
MAKEINFO = ${SHELL} /Users/paul/work/task_rel/missing --run makeinfo
|
||||
MKDIR_P = .././install-sh -c -d
|
||||
OBJEXT = o
|
||||
PACKAGE = task
|
||||
PACKAGE_BUGREPORT = bugs@beckingham.net
|
||||
PACKAGE_NAME = task
|
||||
PACKAGE_STRING = task 0.9.0
|
||||
PACKAGE_TARNAME = task
|
||||
PACKAGE_VERSION = 0.9.0
|
||||
PATH_SEPARATOR = :
|
||||
SET_MAKE =
|
||||
SHELL = /bin/sh
|
||||
STRIP =
|
||||
VERSION = 0.9.0
|
||||
abs_builddir = /Users/paul/work/task_rel/src
|
||||
abs_srcdir = /Users/paul/work/task_rel/src
|
||||
abs_top_builddir = /Users/paul/work/task_rel
|
||||
abs_top_srcdir = /Users/paul/work/task_rel
|
||||
ac_ct_CC = gcc
|
||||
ac_ct_CXX = g++
|
||||
am__include = include
|
||||
am__leading_dot = .
|
||||
am__quote =
|
||||
am__tar = ${AMTAR} chof - "$$tardir"
|
||||
am__untar = ${AMTAR} xf -
|
||||
bindir = ${exec_prefix}/bin
|
||||
build_alias =
|
||||
builddir = .
|
||||
datadir = ${datarootdir}
|
||||
datarootdir = ${prefix}/share
|
||||
docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
|
||||
dvidir = ${docdir}
|
||||
exec_prefix = ${prefix}
|
||||
host_alias =
|
||||
htmldir = ${docdir}
|
||||
includedir = ${prefix}/include
|
||||
infodir = ${datarootdir}/info
|
||||
install_sh = $(SHELL) /Users/paul/work/task_rel/install-sh
|
||||
libdir = ${exec_prefix}/lib
|
||||
libexecdir = ${exec_prefix}/libexec
|
||||
localedir = ${datarootdir}/locale
|
||||
localstatedir = ${prefix}/var
|
||||
mandir = ${datarootdir}/man
|
||||
mkdir_p = $(top_builddir)/./install-sh -c -d
|
||||
oldincludedir = /usr/include
|
||||
pdfdir = ${docdir}
|
||||
prefix = /usr/local
|
||||
program_transform_name = s,x,x,
|
||||
psdir = ${docdir}
|
||||
sbindir = ${exec_prefix}/sbin
|
||||
sharedstatedir = ${prefix}/com
|
||||
srcdir = .
|
||||
subdirs = src
|
||||
sysconfdir = ${prefix}/etc
|
||||
target_alias =
|
||||
top_builddir = ..
|
||||
top_srcdir = ..
|
||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h color.h stlmacros.h task.h
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu src/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
|
||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
if test -f $$p \
|
||||
; then \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
rm -f "$(DESTDIR)$(bindir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-binPROGRAMS:
|
||||
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
|
||||
task$(EXEEXT): $(task_OBJECTS) $(task_DEPENDENCIES)
|
||||
@rm -f task$(EXEEXT)
|
||||
$(CXXLINK) $(task_OBJECTS) $(task_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
include ./$(DEPDIR)/Config.Po
|
||||
include ./$(DEPDIR)/Date.Po
|
||||
include ./$(DEPDIR)/T.Po
|
||||
include ./$(DEPDIR)/TDB.Po
|
||||
include ./$(DEPDIR)/Table.Po
|
||||
include ./$(DEPDIR)/color.Po
|
||||
include ./$(DEPDIR)/parse.Po
|
||||
include ./$(DEPDIR)/rules.Po
|
||||
include ./$(DEPDIR)/task.Po
|
||||
include ./$(DEPDIR)/text.Po
|
||||
include ./$(DEPDIR)/util.Po
|
||||
|
||||
.cpp.o:
|
||||
$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
# source='$<' object='$@' libtool=no \
|
||||
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
|
||||
# $(CXXCOMPILE) -c -o $@ $<
|
||||
|
||||
.cpp.obj:
|
||||
$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
# source='$<' object='$@' libtool=no \
|
||||
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
|
||||
# $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(bindir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-exec-am: install-binPROGRAMS
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-binPROGRAMS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
|
||||
clean-generic ctags distclean distclean-compile \
|
||||
distclean-generic distclean-tags distdir dvi dvi-am html \
|
||||
html-am info info-am install install-am install-binPROGRAMS \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am uninstall-binPROGRAMS
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,2 +1,3 @@
|
||||
bin_PROGRAMS = task
|
||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h color.h stlmacros.h task.h
|
||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h Grid.h color.h task.h
|
||||
AM_CPPFLAGS = -Wall -pedantic -ggdb3 -fno-rtti
|
||||
|
||||
@@ -44,8 +44,9 @@ am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \
|
||||
TDB.$(OBJEXT) Table.$(OBJEXT) color.$(OBJEXT) parse.$(OBJEXT) \
|
||||
task.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT)
|
||||
TDB.$(OBJEXT) Table.$(OBJEXT) Grid.$(OBJEXT) color.$(OBJEXT) \
|
||||
parse.$(OBJEXT) task.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) \
|
||||
rules.$(OBJEXT)
|
||||
task_OBJECTS = $(am_task_OBJECTS)
|
||||
task_LDADD = $(LDADD)
|
||||
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
|
||||
@@ -149,12 +150,12 @@ psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
subdirs = @subdirs@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h color.h stlmacros.h task.h
|
||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h Grid.h color.h task.h
|
||||
AM_CPPFLAGS = -Wall -pedantic -ggdb3 -fno-rtti
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
@@ -223,6 +224,7 @@ distclean-compile:
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Date.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/T.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TDB.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table.Po@am__quote@
|
||||
|
||||
68
src/T.cpp
68
src/T.cpp
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2006 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
@@ -115,7 +136,7 @@ void T::addTag (const std::string& tag)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void T::addTags (const std::vector <std::string>& tags)
|
||||
{
|
||||
for (unsigned int i = 0; i < tags.size (); ++i)
|
||||
for (size_t i = 0; i < tags.size (); ++i)
|
||||
{
|
||||
if (tags[i].find (' ') != std::string::npos)
|
||||
throw std::string ("T::addTags - tags may not contain spaces");
|
||||
@@ -137,7 +158,7 @@ void T::addTags (const std::vector <std::string>& tags)
|
||||
void T::removeTag (const std::string& tag)
|
||||
{
|
||||
std::vector <std::string> copy;
|
||||
for (unsigned int i = 0; i < mTags.size (); ++i)
|
||||
for (size_t i = 0; i < mTags.size (); ++i)
|
||||
if (mTags[i] != tag)
|
||||
copy.push_back (mTags[i]);
|
||||
|
||||
@@ -242,7 +263,7 @@ const std::string T::compose () const
|
||||
else if (mStatus == deleted) line += "X [";
|
||||
|
||||
// Tags
|
||||
for (unsigned int i = 0; i < mTags.size (); ++i)
|
||||
for (size_t i = 0; i < mTags.size (); ++i)
|
||||
{
|
||||
line += (i > 0 ? " " : "");
|
||||
line += mTags[i];
|
||||
@@ -254,20 +275,8 @@ const std::string T::compose () const
|
||||
int count = 0;
|
||||
foreach (i, mAttributes)
|
||||
{
|
||||
std::string converted = i->second;
|
||||
|
||||
// Date attributes may need conversion to epoch.
|
||||
if (i->first == "due" ||
|
||||
i->first == "start" ||
|
||||
i->first == "entry" ||
|
||||
i->first == "end")
|
||||
{
|
||||
if (i->second.find ("/") != std::string::npos)
|
||||
validDate (converted);
|
||||
}
|
||||
|
||||
line += (count > 0 ? " " : "");
|
||||
line += i->first + ":" + converted;
|
||||
line += i->first + ":" + i->second;
|
||||
|
||||
++count;
|
||||
}
|
||||
@@ -297,7 +306,7 @@ const std::string T::composeCSV ()
|
||||
|
||||
// Tags
|
||||
line += "'";
|
||||
for (unsigned int i = 0; i < mTags.size (); ++i)
|
||||
for (size_t i = 0; i < mTags.size (); ++i)
|
||||
{
|
||||
line += (i > 0 ? " " : "");
|
||||
line += mTags[i];
|
||||
@@ -364,13 +373,13 @@ void T::parse (const std::string& line)
|
||||
if (line[0] == 'X')
|
||||
setStatus (deleted);
|
||||
|
||||
unsigned int openTagBracket = line.find ("[");
|
||||
unsigned int closeTagBracket = line.find ("]", openTagBracket);
|
||||
size_t openTagBracket = line.find ("[");
|
||||
size_t closeTagBracket = line.find ("]", openTagBracket);
|
||||
if (openTagBracket != std::string::npos &&
|
||||
closeTagBracket != std::string::npos)
|
||||
{
|
||||
unsigned int openAttrBracket = line.find ("[", closeTagBracket);
|
||||
unsigned int closeAttrBracket = line.find ("]", openAttrBracket);
|
||||
size_t openAttrBracket = line.find ("[", closeTagBracket);
|
||||
size_t closeAttrBracket = line.find ("]", openAttrBracket);
|
||||
if (openAttrBracket != std::string::npos &&
|
||||
closeAttrBracket != std::string::npos)
|
||||
{
|
||||
@@ -383,7 +392,7 @@ void T::parse (const std::string& line)
|
||||
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
|
||||
std::vector <std::string> pairs;
|
||||
split (pairs, attributes, ' ');
|
||||
for (unsigned int i = 0; i < pairs.size (); ++i)
|
||||
for (size_t i = 0; i < pairs.size (); ++i)
|
||||
{
|
||||
std::vector <std::string> pair;
|
||||
split (pair, pairs[i], ':');
|
||||
@@ -415,13 +424,13 @@ void T::parse (const std::string& line)
|
||||
: line[37] == 'X' ? deleted
|
||||
: pending;
|
||||
|
||||
unsigned int openTagBracket = line.find ("[");
|
||||
unsigned int closeTagBracket = line.find ("]", openTagBracket);
|
||||
size_t openTagBracket = line.find ("[");
|
||||
size_t closeTagBracket = line.find ("]", openTagBracket);
|
||||
if (openTagBracket != std::string::npos &&
|
||||
closeTagBracket != std::string::npos)
|
||||
{
|
||||
unsigned int openAttrBracket = line.find ("[", closeTagBracket);
|
||||
unsigned int closeAttrBracket = line.find ("]", openAttrBracket);
|
||||
size_t openAttrBracket = line.find ("[", closeTagBracket);
|
||||
size_t closeAttrBracket = line.find ("]", openAttrBracket);
|
||||
if (openAttrBracket != std::string::npos &&
|
||||
closeAttrBracket != std::string::npos)
|
||||
{
|
||||
@@ -434,7 +443,7 @@ void T::parse (const std::string& line)
|
||||
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
|
||||
std::vector <std::string> pairs;
|
||||
split (pairs, attributes, ' ');
|
||||
for (unsigned int i = 0; i < pairs.size (); ++i)
|
||||
for (size_t i = 0; i < pairs.size (); ++i)
|
||||
{
|
||||
std::vector <std::string> pair;
|
||||
split (pair, pairs[i], ':');
|
||||
@@ -500,7 +509,7 @@ int T::determineVersion (const std::string& line)
|
||||
// a UUID followed by a status, then there is still a way to differentiate
|
||||
// between 2 and 3.
|
||||
//
|
||||
// The danger is that a version 2 binary reads and misinterprets a version 2
|
||||
// The danger is that a version 2 binary reads and misinterprets a version 3
|
||||
// file. This is why it is a good idea to rely on an explicit version
|
||||
// declaration rather than chance positioning.
|
||||
|
||||
@@ -508,3 +517,4 @@ int T::determineVersion (const std::string& line)
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
23
src/T.h
23
src/T.h
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2006 - 2007, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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_T
|
||||
|
||||
33
src/TDB.cpp
33
src/TDB.cpp
@@ -1,12 +1,34 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2007, 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sys/file.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "task.h"
|
||||
#include "TDB.h"
|
||||
@@ -221,7 +243,6 @@ bool TDB::addT (const T& t) const
|
||||
std::vector <std::string> tags;
|
||||
task.getTags (tags);
|
||||
|
||||
// TODO This logic smells funny.
|
||||
// +tag or -tag are both considered valid tags to add to a new pending task.
|
||||
// Generating an error here would not be friendly.
|
||||
for (unsigned int i = 0; i < tags.size (); ++i)
|
||||
@@ -306,7 +327,7 @@ bool TDB::logCommand (int argc, char** argv) const
|
||||
delay (0.25);
|
||||
#endif
|
||||
|
||||
fprintf (out, command.c_str ());
|
||||
fputs (command.c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
return true;
|
||||
@@ -341,7 +362,7 @@ bool TDB::overwritePending (std::vector <T>& all) const
|
||||
|
||||
std::vector <T>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
fprintf (out, it->compose ().c_str ());
|
||||
fputs (it->compose ().c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
return true;
|
||||
@@ -363,7 +384,7 @@ bool TDB::writePending (const T& t) const
|
||||
delay (0.25);
|
||||
#endif
|
||||
|
||||
fprintf (out, t.compose ().c_str ());
|
||||
fputs (t.compose ().c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
return true;
|
||||
@@ -385,7 +406,7 @@ bool TDB::writeCompleted (const T& t) const
|
||||
delay (0.25);
|
||||
#endif
|
||||
|
||||
fprintf (out, t.compose ().c_str ());
|
||||
fputs (t.compose ().c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
return true;
|
||||
|
||||
23
src/TDB.h
23
src/TDB.h
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2007, 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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_TDB
|
||||
|
||||
456
src/Table.cpp
456
src/Table.cpp
@@ -1,7 +1,29 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
//
|
||||
//
|
||||
// Attributes Table Row Column Cell
|
||||
// ----------------------------------------------------
|
||||
@@ -22,10 +44,11 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include "Table.h"
|
||||
#include "Date.h"
|
||||
#include "stlmacros.h"
|
||||
#include "task.h"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <Table.h>
|
||||
#include <Date.h>
|
||||
#include <task.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Table::Table ()
|
||||
@@ -45,20 +68,20 @@ Table::~Table ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setTableColor (Text::color fg, Text::color bg)
|
||||
{
|
||||
mFg["table"] = fg;
|
||||
mBg["table"] = bg;
|
||||
mFg["table"] = Text::colorName (fg);
|
||||
mBg["table"] = Text::colorName (bg);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setTableFg (Text::color c)
|
||||
{
|
||||
mFg["table"] = c;
|
||||
mFg["table"] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setTableBg (Text::color c)
|
||||
{
|
||||
mBg["table"] = c;
|
||||
mBg["table"] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -97,8 +120,8 @@ void Table::setColumnColor (int column, Text::color fg, Text::color bg)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "col:%d", column);
|
||||
mFg[id] = fg;
|
||||
mBg[id] = bg;
|
||||
mFg[id] = Text::colorName (fg);
|
||||
mBg[id] = Text::colorName (bg);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -106,7 +129,7 @@ void Table::setColumnFg (int column, Text::color c)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "col:%d", column);
|
||||
mFg[id] = c;
|
||||
mFg[id] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -114,7 +137,7 @@ void Table::setColumnBg (int column, Text::color c)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "col:%d", column);
|
||||
mBg[id] = c;
|
||||
mBg[id] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -153,9 +176,7 @@ void Table::setColumnCommify (int column)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setColumnJustification (int column, just j)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "col:%d", column);
|
||||
mJustification[id] = j;
|
||||
mJustification[column] = j;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -172,36 +193,33 @@ int Table::addRow ()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setRowColor (int row, Text::color fg, Text::color bg)
|
||||
void Table::setRowColor (const int row, const Text::color fg, const Text::color bg)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "row:%d", row);
|
||||
mFg[id] = fg;
|
||||
mBg[id] = bg;
|
||||
mFg[id] = Text::colorName (fg);
|
||||
mBg[id] = Text::colorName (bg);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setRowFg (int row, Text::color c)
|
||||
void Table::setRowFg (const int row, const Text::color c)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "row:%d", row);
|
||||
mFg[id] = c;
|
||||
mFg[id] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setRowBg (int row, Text::color c)
|
||||
void Table::setRowBg (const int row, const Text::color c)
|
||||
{
|
||||
char id[12];
|
||||
sprintf (id, "row:%d", row);
|
||||
mBg[id] = c;
|
||||
mBg[id] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::addCell (int row, int col, const std::string& data)
|
||||
void Table::addCell (const int row, const int col, const std::string& data)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
|
||||
int length = 0;
|
||||
|
||||
if (mSuppressWS)
|
||||
@@ -214,14 +232,14 @@ void Table::addCell (int row, int col, const std::string& data)
|
||||
|
||||
clean (data2);
|
||||
length = data2.length ();
|
||||
mData[id] = data2;
|
||||
mData.add (row, col, data2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mCommify.find (col) != mCommify.end ())
|
||||
mData[id] = commify (data);
|
||||
mData.add (row, col, commify (data));
|
||||
else
|
||||
mData[id] = data;
|
||||
mData.add (row, col, data);
|
||||
|
||||
length = data.length ();
|
||||
}
|
||||
@@ -231,127 +249,114 @@ void Table::addCell (int row, int col, const std::string& data)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::addCell (int row, int col, char data)
|
||||
void Table::addCell (const int row, const int col, const char data)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
|
||||
char value[2];
|
||||
sprintf (value, "%c", data);
|
||||
|
||||
mData[id] = value;
|
||||
mData.add (row, col, data);
|
||||
|
||||
// Automatically maintain max width.
|
||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], 1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::addCell (int row, int col, int data)
|
||||
void Table::addCell (const int row, const int col, const int data)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
|
||||
char value[12];
|
||||
sprintf (value, "%d", data);
|
||||
|
||||
if (mCommify.find (col) != mCommify.end ())
|
||||
mData[id] = commify (value);
|
||||
mData.add (row, col, commify (value));
|
||||
else
|
||||
mData[id] = value;
|
||||
mData.add (row, col, value);
|
||||
|
||||
// Automatically maintain max width.
|
||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::addCell (int row, int col, float data)
|
||||
void Table::addCell (const int row, const int col, const float data)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
|
||||
char value[24];
|
||||
sprintf (value, "%.2f", data);
|
||||
|
||||
if (mCommify.find (col) != mCommify.end ())
|
||||
mData[id] = commify (value);
|
||||
mData.add (row, col, commify (value));
|
||||
else
|
||||
mData[id] = value;
|
||||
mData.add (row, col, value);
|
||||
|
||||
// Automatically maintain max width.
|
||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::addCell (int row, int col, double data)
|
||||
void Table::addCell (const int row, const int col, const double data)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
|
||||
char value[24];
|
||||
sprintf (value, "%.6f", data);
|
||||
|
||||
if (mCommify.find (col) != mCommify.end ())
|
||||
mData[id] = commify (value);
|
||||
mData.add (row, col, commify (value));
|
||||
else
|
||||
mData[id] = value;
|
||||
mData.add (row, col, value);
|
||||
|
||||
// Automatically maintain max width.
|
||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setCellColor (int row, int col, Text::color fg, Text::color bg)
|
||||
void Table::setCellColor (const int row, const int col, const Text::color fg, const Text::color bg)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
mFg[id] = fg;
|
||||
mBg[id] = bg;
|
||||
mFg[id] = Text::colorName (fg);
|
||||
mBg[id] = Text::colorName (bg);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setCellFg (int row, int col, Text::color c)
|
||||
void Table::setCellFg (const int row, const int col, const Text::color c)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
mFg[id] = c;
|
||||
mFg[id] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setCellBg (int row, int col, Text::color c)
|
||||
void Table::setCellBg (const int row, const int col, const Text::color c)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
mBg[id] = c;
|
||||
mBg[id] = Text::colorName (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Table::getCell (int row, int col)
|
||||
std::string Table::getCell (const int row, const int col)
|
||||
{
|
||||
char id[24];
|
||||
sprintf (id, "cell:%d,%d", row, col);
|
||||
return mData[id];
|
||||
Grid::Cell* c = mData.byRow (row, col);
|
||||
if (c)
|
||||
return (std::string) *c;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Text::color Table::getFg (int row, int col)
|
||||
Text::color Table::getFg (const int row, const int col)
|
||||
{
|
||||
char idCell[24];
|
||||
sprintf (idCell, "cell:%d,%d", row, col);
|
||||
if (mFg.find (idCell) != mFg.end ())
|
||||
return mFg[idCell];
|
||||
return Text::colorCode (mFg[idCell]);
|
||||
|
||||
char idRow[12];
|
||||
sprintf (idRow, "row:%d", row);
|
||||
if (mFg.find (idRow) != mFg.end ())
|
||||
return mFg[idRow];
|
||||
return Text::colorCode (mFg[idRow]);
|
||||
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
if (mFg.find (idCol) != mFg.end ())
|
||||
return mFg[idCol];
|
||||
return Text::colorCode (mFg[idCol]);
|
||||
|
||||
if (mFg.find ("table") != mFg.end ())
|
||||
return mFg["table"];
|
||||
return Text::colorCode (mFg["table"]);
|
||||
|
||||
return Text::nocolor;
|
||||
}
|
||||
@@ -362,31 +367,31 @@ Text::color Table::getHeaderFg (int col)
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
|
||||
return mFg.find (idCol) != mFg.end () ? mFg[idCol]
|
||||
: mFg.find ("table") != mFg.end () ? mFg["table"]
|
||||
return mFg.find (idCol) != mFg.end () ? Text::colorCode (mFg[idCol])
|
||||
: mFg.find ("table") != mFg.end () ? Text::colorCode (mFg["table"])
|
||||
: Text::nocolor;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Text::color Table::getBg (int row, int col)
|
||||
Text::color Table::getBg (const int row, const int col)
|
||||
{
|
||||
char idCell[24];
|
||||
sprintf (idCell, "cell:%d,%d", row, col);
|
||||
if (mBg.find (idCell) != mBg.end ())
|
||||
return mBg[idCell];
|
||||
return Text::colorCode (mBg[idCell]);
|
||||
|
||||
char idRow[12];
|
||||
sprintf (idRow, "row:%d", row);
|
||||
if (mBg.find (idRow) != mBg.end ())
|
||||
return mBg[idRow];
|
||||
return Text::colorCode (mBg[idRow]);
|
||||
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
if (mBg.find (idCol) != mBg.end ())
|
||||
return mBg[idCol];
|
||||
return Text::colorCode (mBg[idCol]);
|
||||
|
||||
if (mBg.find ("table") != mBg.end ())
|
||||
return mBg["table"];
|
||||
return Text::colorCode (mBg["table"]);
|
||||
|
||||
return Text::nocolor;
|
||||
}
|
||||
@@ -397,19 +402,19 @@ Text::color Table::getHeaderBg (int col)
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
|
||||
return mBg.find (idCol) != mBg.end () ? mBg[idCol]
|
||||
: mBg.find ("table") != mBg.end () ? mBg["table"]
|
||||
return mBg.find (idCol) != mBg.end () ? Text::colorCode (mBg[idCol])
|
||||
: mBg.find ("table") != mBg.end () ? Text::colorCode (mBg["table"])
|
||||
: Text::nocolor;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Text::attr Table::getHeaderUnderline (int col)
|
||||
Text::color Table::getHeaderUnderline (int col)
|
||||
{
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
|
||||
return mUnderline.find (idCol) != mUnderline.end () ? Text::underline
|
||||
: Text::normal;
|
||||
: Text::nocolor;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -433,7 +438,7 @@ void Table::calculateColumnWidths ()
|
||||
std::vector <int> ideal = mMaxDataWidth;
|
||||
int width = 0;
|
||||
int countFlexible = 0;
|
||||
for (unsigned int c = 0; c < mColumns.size (); ++c)
|
||||
for (size_t c = 0; c < mColumns.size (); ++c)
|
||||
{
|
||||
if (mSpecifiedWidth[c] == flexible)
|
||||
++countFlexible;
|
||||
@@ -458,7 +463,7 @@ void Table::calculateColumnWidths ()
|
||||
{
|
||||
ideal = mMaxDataWidth;
|
||||
width = 0;
|
||||
for (unsigned int c = 0; c < mColumns.size (); ++c)
|
||||
for (size_t c = 0; c < mColumns.size (); ++c)
|
||||
{
|
||||
if (mSpecifiedWidth[c] > 0)
|
||||
ideal[c] = mSpecifiedWidth[c];
|
||||
@@ -480,7 +485,7 @@ void Table::calculateColumnWidths ()
|
||||
int remainder = available % countFlexible;
|
||||
|
||||
int lastFlexible = mColumns.size () - 1;
|
||||
for (unsigned int c = 0; c < mColumns.size (); ++c)
|
||||
for (size_t c = 0; c < mColumns.size (); ++c)
|
||||
{
|
||||
if (mSpecifiedWidth[c] == flexible)
|
||||
{
|
||||
@@ -494,8 +499,16 @@ void Table::calculateColumnWidths ()
|
||||
mCalculatedWidth = ideal;
|
||||
return;
|
||||
}
|
||||
// else
|
||||
else
|
||||
{
|
||||
// std::cout << "# insufficient room, considering only flexible columns." << std::endl;
|
||||
|
||||
// The fallback position is to assume no width was specificed, and just
|
||||
// calculate widths accordingly.
|
||||
mTableWidth = 0;
|
||||
calculateColumnWidths ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Try again, treating minimum columns as flexible.
|
||||
@@ -503,22 +516,10 @@ void Table::calculateColumnWidths ()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Table::just Table::getJustification (int row, int col)
|
||||
Table::just Table::getJustification (const int row, const int col)
|
||||
{
|
||||
char idCell[24];
|
||||
sprintf (idCell, "cell:%d,%d", row, col);
|
||||
if (mJustification.find (idCell) != mJustification.end ())
|
||||
return mJustification[idCell];
|
||||
|
||||
char idRow[12];
|
||||
sprintf (idRow, "row:%d", row);
|
||||
if (mJustification.find (idRow) != mJustification.end ())
|
||||
return mJustification[idRow];
|
||||
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
if (mJustification.find (idCol) != mJustification.end ())
|
||||
return mJustification[idCol];
|
||||
if (mJustification.find (col) != mJustification.end ())
|
||||
return mJustification[col];
|
||||
|
||||
return left;
|
||||
}
|
||||
@@ -526,11 +527,7 @@ Table::just Table::getJustification (int row, int col)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Table::just Table::getHeaderJustification (int col)
|
||||
{
|
||||
char idCol[12];
|
||||
sprintf (idCol, "col:%d", col);
|
||||
|
||||
return mJustification.find (idCol) != mJustification.end () ? mJustification[idCol]
|
||||
: mJustification.find ("table") != mJustification.end () ? mJustification["table"]
|
||||
return mJustification.find (col) != mJustification.end () ? mJustification[col]
|
||||
: left;
|
||||
}
|
||||
|
||||
@@ -556,42 +553,17 @@ const std::string Table::formatHeader (
|
||||
{
|
||||
assert (width > 0);
|
||||
|
||||
Text::color fg = getHeaderFg (col);
|
||||
Text::color bg = getHeaderBg (col);
|
||||
std::string data = mColumns[col];
|
||||
Text::attr decoration = getHeaderUnderline (col);
|
||||
Text::color fg = getHeaderFg (col);
|
||||
Text::color bg = getHeaderBg (col);
|
||||
std::string data = mColumns[col];
|
||||
Text::color decoration = getHeaderUnderline (col);
|
||||
|
||||
std::string colorOn = "";
|
||||
std::string pad = "";
|
||||
std::string intraPad = "";
|
||||
std::string preJust = "";
|
||||
std::string attrOn = "";
|
||||
std::string attrOff = "";
|
||||
std::string postJust = "";
|
||||
std::string colorOff = "";
|
||||
|
||||
if (fg != Text::nocolor)
|
||||
{
|
||||
char c[12];
|
||||
sprintf (c, "\033[%dm", fg + 29);
|
||||
colorOn += c;
|
||||
}
|
||||
|
||||
if (bg != Text::nocolor)
|
||||
{
|
||||
char c[12];
|
||||
sprintf (c, "\033[%dm", bg + 39);
|
||||
colorOn += c;
|
||||
}
|
||||
|
||||
if (colorOn != "")
|
||||
colorOff += "\033[0m";
|
||||
|
||||
if (decoration == Text::underline)
|
||||
{
|
||||
attrOn = "\033[4m";
|
||||
attrOff = "\033[0m";
|
||||
}
|
||||
|
||||
for (int i = 0; i < padding; ++i)
|
||||
pad += " ";
|
||||
@@ -606,24 +578,19 @@ const std::string Table::formatHeader (
|
||||
for (int i = 0; i < getIntraPadding (); ++i)
|
||||
intraPad += " ";
|
||||
|
||||
return colorOn +
|
||||
attrOn +
|
||||
pad +
|
||||
preJust +
|
||||
data +
|
||||
postJust +
|
||||
pad +
|
||||
attrOff +
|
||||
intraPad +
|
||||
colorOff;
|
||||
return Text::colorize (
|
||||
fg, bg,
|
||||
Text::colorize (
|
||||
decoration, Text::nocolor,
|
||||
pad + preJust+ data + postJust + pad) + intraPad);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::formatCell (
|
||||
int row,
|
||||
int col,
|
||||
int width,
|
||||
int padding,
|
||||
const int row,
|
||||
const int col,
|
||||
const int width,
|
||||
const int padding,
|
||||
std::vector <std::string>& lines,
|
||||
std::string& blank)
|
||||
{
|
||||
@@ -634,27 +601,8 @@ void Table::formatCell (
|
||||
just justification = getJustification (row, col);
|
||||
std::string data = getCell (row, col);
|
||||
|
||||
std::string colorOn = "";
|
||||
std::string pad = "";
|
||||
std::string intraPad = "";
|
||||
std::string colorOff = "";
|
||||
|
||||
if (fg != Text::nocolor)
|
||||
{
|
||||
char c[12];
|
||||
sprintf (c, "\033[%dm", fg + 29);
|
||||
colorOn += c;
|
||||
}
|
||||
|
||||
if (bg != Text::nocolor)
|
||||
{
|
||||
char c[12];
|
||||
sprintf (c, "\033[%dm", bg + 39);
|
||||
colorOn += c;
|
||||
}
|
||||
|
||||
if (fg != Text::nocolor || bg != Text::nocolor)
|
||||
colorOff += "\033[0m";
|
||||
|
||||
for (int i = 0; i < padding; ++i)
|
||||
pad += " ";
|
||||
@@ -668,7 +616,7 @@ void Table::formatCell (
|
||||
std::string postJust;
|
||||
std::vector <std::string> chunks;
|
||||
wrapText (chunks, data, width);
|
||||
for (unsigned int chunk = 0; chunk < chunks.size (); ++chunk)
|
||||
for (size_t chunk = 0; chunk < chunks.size (); ++chunk)
|
||||
{
|
||||
// Place the data within the available space - justify.
|
||||
int gap = width - chunks[chunk].length ();
|
||||
@@ -689,19 +637,12 @@ void Table::formatCell (
|
||||
for (int i = 0; i < gap / 2; ++i)
|
||||
preJust += " ";
|
||||
|
||||
for (unsigned int i = 0; i < gap - preJust.length (); ++i)
|
||||
for (size_t i = 0; i < gap - preJust.length (); ++i)
|
||||
postJust += " ";
|
||||
}
|
||||
|
||||
lines.push_back (
|
||||
colorOn +
|
||||
pad +
|
||||
preJust +
|
||||
chunks[chunk] +
|
||||
postJust +
|
||||
pad +
|
||||
intraPad +
|
||||
colorOff);
|
||||
Text::colorize (fg, bg, pad + preJust + chunks[chunk] + postJust + pad + intraPad));
|
||||
}
|
||||
|
||||
// The blank is used to vertically pad cells that have blank lines.
|
||||
@@ -709,88 +650,7 @@ void Table::formatCell (
|
||||
for (int i = 0; i < width; ++i)
|
||||
pad += " ";
|
||||
|
||||
blank =
|
||||
colorOn +
|
||||
pad +
|
||||
intraPad +
|
||||
colorOff;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string Table::formatCell (
|
||||
int row,
|
||||
int col,
|
||||
int width,
|
||||
int padding)
|
||||
{
|
||||
assert (width > 0);
|
||||
|
||||
Text::color fg = getFg (row, col);
|
||||
Text::color bg = getBg (row, col);
|
||||
just justification = getJustification (row, col);
|
||||
std::string data = getCell (row, col);
|
||||
|
||||
std::string colorOn = "";
|
||||
std::string pad = "";
|
||||
std::string intraPad = "";
|
||||
std::string preJust = "";
|
||||
std::string postJust = "";
|
||||
std::string colorOff = "";
|
||||
|
||||
if (fg != Text::nocolor)
|
||||
{
|
||||
char c[12];
|
||||
sprintf (c, "\033[%dm", fg + 29);
|
||||
colorOn += c;
|
||||
}
|
||||
|
||||
if (bg != Text::nocolor)
|
||||
{
|
||||
char c[12];
|
||||
sprintf (c, "\033[%dm", bg + 39);
|
||||
colorOn += c;
|
||||
}
|
||||
|
||||
if (fg != Text::nocolor || bg != Text::nocolor)
|
||||
colorOff += "\033[0m";
|
||||
|
||||
for (int i = 0; i < padding; ++i)
|
||||
pad += " ";
|
||||
|
||||
// Place the data within the available space - justify.
|
||||
int gap = width - data.length ();
|
||||
|
||||
if (justification == left)
|
||||
{
|
||||
for (int i = 0; i < gap; ++i)
|
||||
postJust += " ";
|
||||
}
|
||||
else if (justification == right)
|
||||
{
|
||||
for (int i = 0; i < gap; ++i)
|
||||
preJust += " ";
|
||||
}
|
||||
else if (justification == center)
|
||||
{
|
||||
for (int i = 0; i < gap / 2; ++i)
|
||||
preJust += " ";
|
||||
|
||||
for (unsigned int i = 0; i < gap - preJust.length (); ++i)
|
||||
postJust += " ";
|
||||
}
|
||||
|
||||
if (col < (signed) mColumns.size () - 1)
|
||||
for (int i = 0; i < getIntraPadding (); ++i)
|
||||
intraPad += " ";
|
||||
|
||||
return colorOn +
|
||||
pad +
|
||||
preJust +
|
||||
data +
|
||||
postJust +
|
||||
pad +
|
||||
intraPad +
|
||||
colorOff;
|
||||
blank = Text::colorize (fg, bg, pad + intraPad);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -799,6 +659,12 @@ void Table::suppressWS ()
|
||||
mSuppressWS = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::setDateFormat (const std::string& dateFormat)
|
||||
{
|
||||
mDateFormat = dateFormat;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Table::rowCount ()
|
||||
{
|
||||
@@ -818,15 +684,15 @@ int Table::columnCount ()
|
||||
// - removal of redundant color codes:
|
||||
// ^[[31mName^[[0m ^[[31mValue^[[0m -> ^[[31mName Value^[[0m
|
||||
//
|
||||
// This method is a work in progress.
|
||||
void Table::optimize (std::string& output)
|
||||
{
|
||||
/*
|
||||
TODO Unoptimized length.
|
||||
int start = output.length ();
|
||||
*/
|
||||
|
||||
// \s\n -> \n
|
||||
unsigned int i = 0;
|
||||
size_t i = 0;
|
||||
while ((i = output.find (" \n")) != std::string::npos)
|
||||
{
|
||||
output = output.substr (0, i) +
|
||||
@@ -834,7 +700,6 @@ void Table::optimize (std::string& output)
|
||||
}
|
||||
|
||||
/*
|
||||
TODO This code displays the % reduction of the optimize function.
|
||||
std::cout << int ((100 * (start - output.length ()) / start))
|
||||
<< "%" << std::endl;
|
||||
*/
|
||||
@@ -869,52 +734,51 @@ void Table::sort (std::vector <int>& order)
|
||||
while (r + gap < (int) order.size ())
|
||||
{
|
||||
bool keepScanning = true;
|
||||
for (unsigned int c = 0; keepScanning && c < mSortColumns.size (); ++c)
|
||||
for (size_t c = 0; keepScanning && c < mSortColumns.size (); ++c)
|
||||
{
|
||||
keepScanning = false;
|
||||
|
||||
char left[16];
|
||||
sprintf (left, "cell:%d,%d", order[r], mSortColumns[c]);
|
||||
Grid::Cell* left = mData.byRow (order[r], mSortColumns[c]);
|
||||
Grid::Cell* right = mData.byRow (order[r + gap], mSortColumns[c]);
|
||||
if (left == NULL && right != NULL)
|
||||
SWAP
|
||||
|
||||
char right[16];
|
||||
sprintf (right, "cell:%d,%d", order[r + gap], mSortColumns[c]);
|
||||
|
||||
if (mData[left] != mData[right])
|
||||
if (left && right && *left != *right)
|
||||
{
|
||||
switch (mSortOrder[mSortColumns[c]])
|
||||
{
|
||||
case ascendingNumeric:
|
||||
if (::atoi (mData[left].c_str ()) > ::atoi (mData[right].c_str ()))
|
||||
if ((float)*left > (float)*right)
|
||||
SWAP
|
||||
break;
|
||||
|
||||
case descendingNumeric:
|
||||
if (::atoi (mData[left].c_str ()) < ::atoi (mData[right].c_str ()))
|
||||
if ((float)*left < (float)*right)
|
||||
SWAP
|
||||
break;
|
||||
|
||||
case ascendingCharacter:
|
||||
if (mData[left] > mData[right])
|
||||
if ((char)*left > (char)*right)
|
||||
SWAP
|
||||
break;
|
||||
|
||||
case descendingCharacter:
|
||||
if (mData[left] < mData[right])
|
||||
if ((char)*left < (char)*right)
|
||||
SWAP
|
||||
break;
|
||||
|
||||
case ascendingDate:
|
||||
{
|
||||
if (mData[left] != "" && mData[right] == "")
|
||||
if ((std::string)*left != "" && (std::string)*right == "")
|
||||
break;
|
||||
|
||||
else if (mData[left] == "" && mData[right] != "")
|
||||
else if ((std::string)*left == "" && (std::string)*right != "")
|
||||
SWAP
|
||||
|
||||
else
|
||||
{
|
||||
Date dl (mData[left]);
|
||||
Date dr (mData[right]);
|
||||
Date dl ((std::string)*left, mDateFormat);
|
||||
Date dr ((std::string)*right, mDateFormat);
|
||||
if (dl > dr)
|
||||
SWAP
|
||||
}
|
||||
@@ -923,16 +787,16 @@ void Table::sort (std::vector <int>& order)
|
||||
|
||||
case descendingDate:
|
||||
{
|
||||
if (mData[left] != "" && mData[right] == "")
|
||||
if ((std::string)*left != "" && (std::string)*right == "")
|
||||
break;
|
||||
|
||||
else if (mData[left] == "" && mData[right] != "")
|
||||
else if ((std::string)*left == "" && (std::string)*right != "")
|
||||
SWAP
|
||||
|
||||
else
|
||||
{
|
||||
Date dl (mData[left]);
|
||||
Date dr (mData[right]);
|
||||
Date dl ((std::string)*left, mDateFormat);
|
||||
Date dr ((std::string)*right, mDateFormat);
|
||||
if (dl < dr)
|
||||
SWAP
|
||||
}
|
||||
@@ -940,16 +804,16 @@ void Table::sort (std::vector <int>& order)
|
||||
break;
|
||||
|
||||
case ascendingPriority:
|
||||
if ((mData[left] == "" && mData[right] != "") ||
|
||||
(mData[left] == "M" && mData[right] == "L") ||
|
||||
(mData[left] == "H" && (mData[right] == "L" || mData[right] == "M")))
|
||||
if (((std::string)*left == "" && (std::string)*right != "") ||
|
||||
((std::string)*left == "M" && (std::string)*right == "L") ||
|
||||
((std::string)*left == "H" && ((std::string)*right == "L" || (std::string)*right == "M")))
|
||||
SWAP
|
||||
break;
|
||||
|
||||
case descendingPriority:
|
||||
if ((mData[left] == "" && mData[right] != "") ||
|
||||
(mData[left] == "L" && (mData[right] == "M" || mData[right] == "H")) ||
|
||||
(mData[left] == "M" && mData[right] == "H"))
|
||||
if (((std::string)*left == "" && (std::string)*right != "") ||
|
||||
((std::string)*left == "L" && ((std::string)*right == "M" || (std::string)*right == "H")) ||
|
||||
((std::string)*left == "M" && (std::string)*right == "H"))
|
||||
SWAP
|
||||
break;
|
||||
}
|
||||
@@ -968,8 +832,8 @@ void Table::sort (std::vector <int>& order)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Table::clean (std::string& value)
|
||||
{
|
||||
unsigned int start = 0;
|
||||
unsigned int pos;
|
||||
size_t start = 0;
|
||||
size_t pos;
|
||||
while ((pos = value.find ('\t', start)) != std::string::npos)
|
||||
{
|
||||
value.replace (pos, 1, " ");
|
||||
@@ -997,7 +861,7 @@ const std::string Table::render ()
|
||||
|
||||
// Print column headers in column order.
|
||||
std::string output;
|
||||
for (unsigned int col = 0; col < mColumns.size (); ++col)
|
||||
for (size_t col = 0; col < mColumns.size (); ++col)
|
||||
output += formatHeader (
|
||||
col,
|
||||
mCalculatedWidth[col],
|
||||
@@ -1020,8 +884,8 @@ const std::string Table::render ()
|
||||
std::vector <std::vector <std::string> > columns;
|
||||
std::vector <std::string> blanks;
|
||||
|
||||
unsigned int maxHeight = 0;
|
||||
for (unsigned int col = 0; col < mColumns.size (); ++col)
|
||||
size_t maxHeight = 0;
|
||||
for (size_t col = 0; col < mColumns.size (); ++col)
|
||||
{
|
||||
std::vector <std::string> lines;
|
||||
std::string blank;
|
||||
@@ -1041,9 +905,9 @@ const std::string Table::render ()
|
||||
|
||||
if (maxHeight)
|
||||
{
|
||||
for (unsigned int lines = 0; lines < maxHeight; ++lines)
|
||||
for (size_t lines = 0; lines < maxHeight; ++lines)
|
||||
{
|
||||
for (unsigned int col = 0; col < mColumns.size (); ++col)
|
||||
for (size_t col = 0; col < mColumns.size (); ++col)
|
||||
if (lines < columns[col].size ())
|
||||
output += columns[col][lines];
|
||||
else
|
||||
|
||||
60
src/Table.h
60
src/Table.h
@@ -1,8 +1,28 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// TODO Implement height
|
||||
// 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_TABLE
|
||||
#define INCLUDED_TABLE
|
||||
@@ -10,7 +30,8 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "color.h"
|
||||
#include <color.h>
|
||||
#include <Grid.h>
|
||||
|
||||
class Table
|
||||
{
|
||||
@@ -58,26 +79,26 @@ public:
|
||||
void setCellBg (int, int, Text::color);
|
||||
|
||||
void suppressWS ();
|
||||
void setDateFormat (const std::string&);
|
||||
|
||||
int rowCount ();
|
||||
int columnCount ();
|
||||
const std::string render ();
|
||||
|
||||
private:
|
||||
std::string getCell (int, int);
|
||||
Text::color getFg (int, int);
|
||||
Text::color getHeaderFg (int);
|
||||
Text::color getBg (int, int);
|
||||
Text::color getHeaderBg (int);
|
||||
Text::attr getHeaderUnderline (int);
|
||||
int getPadding (int);
|
||||
std::string getCell (const int, const int);
|
||||
Text::color getFg (const int, const int);
|
||||
Text::color getHeaderFg (const int);
|
||||
Text::color getBg (const int, const int);
|
||||
Text::color getHeaderBg (const int);
|
||||
Text::color getHeaderUnderline (const int);
|
||||
int getPadding (const int);
|
||||
int getIntraPadding ();
|
||||
void calculateColumnWidths ();
|
||||
just getJustification (int, int);
|
||||
just getHeaderJustification (int);
|
||||
const std::string formatHeader (int, int, int);
|
||||
const std::string formatCell (int, int, int, int);
|
||||
void formatCell (int, int, int, int, std::vector <std::string>&, std::string&);
|
||||
just getJustification (const int, const int);
|
||||
just getHeaderJustification (const int);
|
||||
const std::string formatHeader (const int, const int, const int);
|
||||
void formatCell (const int, const int, const int, const int, std::vector <std::string>&, std::string&);
|
||||
void optimize (std::string&);
|
||||
void sort (std::vector <int>&);
|
||||
void clean (std::string&);
|
||||
@@ -86,9 +107,9 @@ private:
|
||||
std::vector <std::string> mColumns;
|
||||
int mRows;
|
||||
int mIntraPadding;
|
||||
std::map <std::string, Text::color> mFg;
|
||||
std::map <std::string, Text::color> mBg;
|
||||
std::map <std::string, Text::attr> mUnderline;
|
||||
std::map <std::string, std::string> mFg;
|
||||
std::map <std::string, std::string> mBg;
|
||||
std::map <std::string, std::string> mUnderline;
|
||||
|
||||
// Padding...
|
||||
int mTablePadding;
|
||||
@@ -100,14 +121,15 @@ private:
|
||||
std::vector <int> mMaxDataWidth;
|
||||
std::vector <int> mCalculatedWidth;
|
||||
|
||||
std::map <std::string, just> mJustification;
|
||||
std::map <int, just> mJustification;
|
||||
std::map <int, bool> mCommify;
|
||||
std::map <std::string, std::string> mData;
|
||||
Grid mData;
|
||||
std::vector <int> mSortColumns;
|
||||
std::map <int, order> mSortOrder;
|
||||
|
||||
// Misc...
|
||||
bool mSuppressWS;
|
||||
std::string mDateFormat;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
253
src/color.cpp
253
src/color.cpp
@@ -1,64 +1,261 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <string>
|
||||
#include "color.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Text::colorName (Text::color c)
|
||||
namespace Text
|
||||
{
|
||||
|
||||
std::string colorName (color c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case black: return "black";
|
||||
case red: return "red";
|
||||
case green: return "green";
|
||||
case yellow: return "yellow";
|
||||
case blue: return "blue";
|
||||
case magenta: return "magenta";
|
||||
case cyan: return "cyan";
|
||||
case white: return "white";
|
||||
case nocolor: return "";
|
||||
case nocolor: return "";
|
||||
case off: return "off";
|
||||
|
||||
case bold: return "bold";
|
||||
case underline: return "underline";
|
||||
case bold_underline: return "bold_underline";
|
||||
|
||||
case black: return "black";
|
||||
case red: return "red";
|
||||
case green: return "green";
|
||||
case yellow: return "yellow";
|
||||
case blue: return "blue";
|
||||
case magenta: return "magenta";
|
||||
case cyan: return "cyan";
|
||||
case white: return "white";
|
||||
|
||||
case bold_black: return "bold_black";
|
||||
case bold_red: return "bold_red";
|
||||
case bold_green: return "bold_green";
|
||||
case bold_yellow: return "bold_yellow";
|
||||
case bold_blue: return "bold_blue";
|
||||
case bold_magenta: return "bold_magenta";
|
||||
case bold_cyan: return "bold_cyan";
|
||||
case bold_white: return "bold_white";
|
||||
|
||||
case underline_black: return "underline_black";
|
||||
case underline_red: return "underline_red";
|
||||
case underline_green: return "underline_green";
|
||||
case underline_yellow: return "underline_yellow";
|
||||
case underline_blue: return "underline_blue";
|
||||
case underline_magenta: return "underline_magenta";
|
||||
case underline_cyan: return "underline_cyan";
|
||||
case underline_white: return "underline_white";
|
||||
|
||||
case bold_underline_black: return "bold_underline_black";
|
||||
case bold_underline_red: return "bold_underline_red";
|
||||
case bold_underline_green: return "bold_underline_green";
|
||||
case bold_underline_yellow: return "bold_underline_yellow";
|
||||
case bold_underline_blue: return "bold_underline_blue";
|
||||
case bold_underline_magenta: return "bold_underline_magenta";
|
||||
case bold_underline_cyan: return "bold_underline_cyan";
|
||||
case bold_underline_white: return "bold_underline_white";
|
||||
|
||||
case on_black: return "on_black";
|
||||
case on_red: return "on_red";
|
||||
case on_green: return "on_green";
|
||||
case on_yellow: return "on_yellow";
|
||||
case on_blue: return "on_blue";
|
||||
case on_magenta: return "on_magenta";
|
||||
case on_cyan: return "on_cyan";
|
||||
case on_white: return "on_white";
|
||||
|
||||
case on_bright_black: return "on_bright_black";
|
||||
case on_bright_red: return "on_bright_red";
|
||||
case on_bright_green: return "on_bright_green";
|
||||
case on_bright_yellow: return "on_bright_yellow";
|
||||
case on_bright_blue: return "on_bright_blue";
|
||||
case on_bright_magenta: return "on_bright_magenta";
|
||||
case on_bright_cyan: return "on_bright_cyan";
|
||||
case on_bright_white: return "on_bright_white";
|
||||
|
||||
default: throw "Unknown Text::color value";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Text::color Text::colorCode (const std::string& c)
|
||||
color colorCode (const std::string& c)
|
||||
{
|
||||
if (c == "black") return black;
|
||||
if (c == "red") return red;
|
||||
if (c == "green") return green;
|
||||
if (c == "yellow") return yellow;
|
||||
if (c == "blue") return blue;
|
||||
if (c == "magenta") return magenta;
|
||||
if (c == "cyan") return cyan;
|
||||
if (c == "white") return white;
|
||||
if (c == "off") return off;
|
||||
else if (c == "bold") return bold;
|
||||
else if (c == "underline") return underline;
|
||||
else if (c == "bold_underline") return bold_underline;
|
||||
|
||||
else if (c == "black") return black;
|
||||
else if (c == "red") return red;
|
||||
else if (c == "green") return green;
|
||||
else if (c == "yellow") return yellow;
|
||||
else if (c == "blue") return blue;
|
||||
else if (c == "magenta") return magenta;
|
||||
else if (c == "cyan") return cyan;
|
||||
else if (c == "white") return white;
|
||||
|
||||
else if (c == "bold_black") return bold_black;
|
||||
else if (c == "bold_red") return bold_red;
|
||||
else if (c == "bold_green") return bold_green;
|
||||
else if (c == "bold_yellow") return bold_yellow;
|
||||
else if (c == "bold_blue") return bold_blue;
|
||||
else if (c == "bold_magenta") return bold_magenta;
|
||||
else if (c == "bold_cyan") return bold_cyan;
|
||||
else if (c == "bold_white") return bold_white;
|
||||
|
||||
else if (c == "underline_black") return underline_black;
|
||||
else if (c == "underline_red") return underline_red;
|
||||
else if (c == "underline_green") return underline_green;
|
||||
else if (c == "underline_yellow") return underline_yellow;
|
||||
else if (c == "underline_blue") return underline_blue;
|
||||
else if (c == "underline_magenta") return underline_magenta;
|
||||
else if (c == "underline_cyan") return underline_cyan;
|
||||
else if (c == "underline_white") return underline_white;
|
||||
|
||||
else if (c == "bold_underline_black") return bold_underline_black;
|
||||
else if (c == "bold_underline_red") return bold_underline_red;
|
||||
else if (c == "bold_underline_green") return bold_underline_green;
|
||||
else if (c == "bold_underline_yellow") return bold_underline_yellow;
|
||||
else if (c == "bold_underline_blue") return bold_underline_blue;
|
||||
else if (c == "bold_underline_magenta") return bold_underline_magenta;
|
||||
else if (c == "bold_underline_cyan") return bold_underline_cyan;
|
||||
else if (c == "bold_underline_white") return bold_underline_white;
|
||||
|
||||
else if (c == "on_black") return on_black;
|
||||
else if (c == "on_red") return on_red;
|
||||
else if (c == "on_green") return on_green;
|
||||
else if (c == "on_yellow") return on_yellow;
|
||||
else if (c == "on_blue") return on_blue;
|
||||
else if (c == "on_magenta") return on_magenta;
|
||||
else if (c == "on_cyan") return on_cyan;
|
||||
else if (c == "on_white") return on_white;
|
||||
|
||||
else if (c == "on_bright_black") return on_bright_black;
|
||||
else if (c == "on_bright_red") return on_bright_red;
|
||||
else if (c == "on_bright_green") return on_bright_green;
|
||||
else if (c == "on_bright_yellow") return on_bright_yellow;
|
||||
else if (c == "on_bright_blue") return on_bright_blue;
|
||||
else if (c == "on_bright_magenta") return on_bright_magenta;
|
||||
else if (c == "on_bright_cyan") return on_bright_cyan;
|
||||
else if (c == "on_bright_white") return on_bright_white;
|
||||
|
||||
return nocolor;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Text::attrName (Text::attr a)
|
||||
std::string decode (color c)
|
||||
{
|
||||
switch (a)
|
||||
switch (c)
|
||||
{
|
||||
case underline: return "underline";
|
||||
case normal: return "";
|
||||
case nocolor: return "";
|
||||
case off: return "\033[0m";
|
||||
|
||||
case bold: return "\033[1m";
|
||||
case underline: return "\033[4m";
|
||||
case bold_underline: return "\033[1;4m";
|
||||
|
||||
case black: return "\033[30m";
|
||||
case red: return "\033[31m";
|
||||
case green: return "\033[32m";
|
||||
case yellow: return "\033[33m";
|
||||
case blue: return "\033[34m";
|
||||
case magenta: return "\033[35m";
|
||||
case cyan: return "\033[36m";
|
||||
case white: return "\033[37m";
|
||||
|
||||
case bold_black: return "\033[90m";
|
||||
case bold_red: return "\033[91m";
|
||||
case bold_green: return "\033[92m";
|
||||
case bold_yellow: return "\033[93m";
|
||||
case bold_blue: return "\033[94m";
|
||||
case bold_magenta: return "\033[95m";
|
||||
case bold_cyan: return "\033[96m";
|
||||
case bold_white: return "\033[97m";
|
||||
|
||||
case underline_black: return "\033[4;30m";
|
||||
case underline_red: return "\033[4;31m";
|
||||
case underline_green: return "\033[4;32m";
|
||||
case underline_yellow: return "\033[4;33m";
|
||||
case underline_blue: return "\033[4;34m";
|
||||
case underline_magenta: return "\033[4;35m";
|
||||
case underline_cyan: return "\033[4;36m";
|
||||
case underline_white: return "\033[4;37m";
|
||||
|
||||
case bold_underline_black: return "\033[1;4;30m";
|
||||
case bold_underline_red: return "\033[1;4;31m";
|
||||
case bold_underline_green: return "\033[1;4;32m";
|
||||
case bold_underline_yellow: return "\033[1;4;33m";
|
||||
case bold_underline_blue: return "\033[1;4;34m";
|
||||
case bold_underline_magenta: return "\033[1;4;35m";
|
||||
case bold_underline_cyan: return "\033[1;4;36m";
|
||||
case bold_underline_white: return "\033[1;4;37m";
|
||||
|
||||
case on_black: return "\033[40m";
|
||||
case on_red: return "\033[41m";
|
||||
case on_green: return "\033[42m";
|
||||
case on_yellow: return "\033[43m";
|
||||
case on_blue: return "\033[44m";
|
||||
case on_magenta: return "\033[45m";
|
||||
case on_cyan: return "\033[46m";
|
||||
case on_white: return "\033[47m";
|
||||
|
||||
case on_bright_black: return "\033[100m";
|
||||
case on_bright_red: return "\033[101m";
|
||||
case on_bright_green: return "\033[102m";
|
||||
case on_bright_yellow: return "\033[103m";
|
||||
case on_bright_blue: return "\033[104m";
|
||||
case on_bright_magenta: return "\033[105m";
|
||||
case on_bright_cyan: return "\033[106m";
|
||||
case on_bright_white: return "\033[107m";
|
||||
|
||||
default: throw "Unknown Text::color value";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Text::attr Text::attrCode (const std::string& a)
|
||||
std::string colorize (color fg, color bg, const std::string& input)
|
||||
{
|
||||
if (a == "underline") return underline;
|
||||
|
||||
return normal;
|
||||
return decode (fg) + decode (bg) + input + decode (off);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string colorize (color fg, color bg)
|
||||
{
|
||||
return decode (fg) + decode (bg);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string colorize ()
|
||||
{
|
||||
return decode (off);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
48
src/color.h
48
src/color.h
@@ -1,21 +1,55 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2008, Paul Beckingham.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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_COLOR
|
||||
#define INCLUDED_COLOR
|
||||
|
||||
namespace Text
|
||||
{
|
||||
enum color {nocolor = 0, black, red, green, yellow, blue, magenta, cyan, white};
|
||||
enum attr {normal = 0, underline};
|
||||
enum color
|
||||
{
|
||||
nocolor = 0,
|
||||
off,
|
||||
bold, underline, bold_underline,
|
||||
black, bold_black, underline_black, bold_underline_black, on_black, on_bright_black,
|
||||
red, bold_red, underline_red, bold_underline_red, on_red, on_bright_red,
|
||||
green, bold_green, underline_green, bold_underline_green, on_green, on_bright_green,
|
||||
yellow, bold_yellow, underline_yellow, bold_underline_yellow, on_yellow, on_bright_yellow,
|
||||
blue, bold_blue, underline_blue, bold_underline_blue, on_blue, on_bright_blue,
|
||||
magenta, bold_magenta, underline_magenta, bold_underline_magenta, on_magenta, on_bright_magenta,
|
||||
cyan, bold_cyan, underline_cyan, bold_underline_cyan, on_cyan, on_bright_cyan,
|
||||
white, bold_white, underline_white, bold_underline_white, on_white, on_bright_white
|
||||
};
|
||||
|
||||
std::string colorName (Text::color);
|
||||
Text::color colorCode (const std::string&);
|
||||
std::string colorName (color);
|
||||
color colorCode (const std::string&);
|
||||
|
||||
std::string attrName (Text::attr);
|
||||
Text::attr attrCode (const std::string&);
|
||||
std::string colorize (color, color, const std::string& string);
|
||||
std::string colorize (color, color);
|
||||
std::string colorize ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2004 - 2008, Paul Beckingham. All rights reserved.
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_LIBRARY
|
||||
#define INCLUDED_LIBRARY
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "stlmacros.h"
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
// 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::wstring trimLeft (const std::wstring& in, const std::wstring& t = L" "); // UNICODE safe
|
||||
std::wstring trimRight (const std::wstring& in, const std::wstring& t = L" "); // UNICODE safe
|
||||
std::wstring trim (const std::wstring& in, const std::wstring& t = L" "); // UNICODE safe
|
||||
void extractParagraphs (const std::string&, std::vector<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&);
|
||||
|
||||
// misc.cpp
|
||||
void delay (float);
|
||||
|
||||
// list.cpp
|
||||
int autoComplete (const std::string&, const std::vector<std::string>&, std::vector<std::string>&);
|
||||
|
||||
// units.cpp
|
||||
void formatTimeDeltaDays (std::string&, time_t);
|
||||
std::string formatSeconds (time_t);
|
||||
|
||||
// uuid.cpp
|
||||
const std::string uuid ();
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
138
src/parse.cpp
138
src/parse.cpp
@@ -1,9 +1,31 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2006 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -13,20 +35,69 @@
|
||||
#include "T.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static char* colors[] =
|
||||
static const char* colors[] =
|
||||
{
|
||||
"bold",
|
||||
"underline",
|
||||
"bold_underline",
|
||||
|
||||
"black",
|
||||
"blue",
|
||||
"red",
|
||||
"green",
|
||||
"yellow",
|
||||
"blue",
|
||||
"magenta",
|
||||
"cyan",
|
||||
"yellow",
|
||||
"white",
|
||||
|
||||
"bold_black",
|
||||
"bold_red",
|
||||
"bold_green",
|
||||
"bold_yellow",
|
||||
"bold_blue",
|
||||
"bold_magenta",
|
||||
"bold_cyan",
|
||||
"bold_white",
|
||||
|
||||
"underline_black",
|
||||
"underline_red",
|
||||
"underline_green",
|
||||
"underline_yellow",
|
||||
"underline_blue",
|
||||
"underline_magenta",
|
||||
"underline_cyan",
|
||||
"underline_white",
|
||||
|
||||
"bold_underline_black",
|
||||
"bold_underline_red",
|
||||
"bold_underline_green",
|
||||
"bold_underline_yellow",
|
||||
"bold_underline_blue",
|
||||
"bold_underline_magenta",
|
||||
"bold_underline_cyan",
|
||||
"bold_underline_white",
|
||||
|
||||
"on_black",
|
||||
"on_red",
|
||||
"on_green",
|
||||
"on_yellow",
|
||||
"on_blue",
|
||||
"on_magenta",
|
||||
"on_cyan",
|
||||
"on_white",
|
||||
|
||||
"on_bright_black",
|
||||
"on_bright_red",
|
||||
"on_bright_green",
|
||||
"on_bright_yellow",
|
||||
"on_bright_blue",
|
||||
"on_bright_magenta",
|
||||
"on_bright_cyan",
|
||||
"on_bright_white",
|
||||
"",
|
||||
};
|
||||
|
||||
static char* attributes[] =
|
||||
static const char* attributes[] =
|
||||
{
|
||||
"project",
|
||||
"priority",
|
||||
@@ -39,21 +110,25 @@ static char* attributes[] =
|
||||
"",
|
||||
};
|
||||
|
||||
static char* commands[] =
|
||||
static const char* commands[] =
|
||||
{
|
||||
"active",
|
||||
"add",
|
||||
"calendar",
|
||||
"colors",
|
||||
"completed",
|
||||
"delete",
|
||||
"done",
|
||||
"export",
|
||||
"help",
|
||||
"history",
|
||||
"info",
|
||||
"list",
|
||||
"long",
|
||||
"ls",
|
||||
"newest",
|
||||
"next",
|
||||
"oldest",
|
||||
"overdue",
|
||||
"projects",
|
||||
"start",
|
||||
@@ -65,7 +140,7 @@ static char* commands[] =
|
||||
"",
|
||||
};
|
||||
|
||||
void guess (const std::string& type, char** list, std::string& candidate)
|
||||
void guess (const std::string& type, const char** list, std::string& candidate)
|
||||
{
|
||||
std::vector <std::string> options;
|
||||
for (int i = 0; list[i][0]; ++i)
|
||||
@@ -86,7 +161,7 @@ void guess (const std::string& type, char** list, std::string& candidate)
|
||||
error += " '";
|
||||
error += candidate;
|
||||
error += "' - could be either of ";
|
||||
for (unsigned int i = 0; i < matches.size (); ++i)
|
||||
for (size_t i = 0; i < matches.size (); ++i)
|
||||
{
|
||||
if (i)
|
||||
error += ", ";
|
||||
@@ -113,29 +188,13 @@ static bool isCommand (const std::string& candidate)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool validDate (std::string& date)
|
||||
bool validDate (std::string& date, Config& conf)
|
||||
{
|
||||
unsigned int firstSlash = date.find ("/");
|
||||
unsigned int secondSlash = date.find ("/", firstSlash + 1);
|
||||
if (firstSlash != std::string::npos &&
|
||||
secondSlash != std::string::npos)
|
||||
{
|
||||
int m = ::atoi (date.substr (0, firstSlash ).c_str ());
|
||||
int d = ::atoi (date.substr (firstSlash + 1, secondSlash - firstSlash).c_str ());
|
||||
int y = ::atoi (date.substr (secondSlash + 1, std::string::npos ).c_str ());
|
||||
if (!Date::valid (m, d, y))
|
||||
throw std::string ("\"") + date + "\" is not a valid date.";
|
||||
Date test (date, conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
// Convert to epoch form.
|
||||
Date dt (m, d, y);
|
||||
time_t t;
|
||||
dt.toEpoch (t);
|
||||
char converted[12];
|
||||
sprintf (converted, "%u", (unsigned int) t);
|
||||
date = converted;
|
||||
}
|
||||
else
|
||||
throw std::string ("Badly formed date - use the MM/DD/YYYY format");
|
||||
char epoch[12];
|
||||
sprintf (epoch, "%d", (int) test.toEpoch ());
|
||||
date = epoch;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -155,7 +214,7 @@ static bool validPriority (std::string& input)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static bool validAttribute (std::string& name, std::string& value)
|
||||
static bool validAttribute (std::string& name, std::string& value, Config& conf)
|
||||
{
|
||||
guess ("attribute", attributes, name);
|
||||
|
||||
@@ -163,7 +222,7 @@ static bool validAttribute (std::string& name, std::string& value)
|
||||
guess ("color", colors, value);
|
||||
|
||||
else if (name == "due" && value != "")
|
||||
validDate (value);
|
||||
validDate (value, conf);
|
||||
|
||||
else if (name == "priority")
|
||||
{
|
||||
@@ -186,7 +245,7 @@ static bool validAttribute (std::string& name, std::string& value)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static bool validId (const std::string& input)
|
||||
{
|
||||
for (unsigned int i = 0; i < input.length (); ++i)
|
||||
for (size_t i = 0; i < input.length (); ++i)
|
||||
if (!::isdigit (input[i]))
|
||||
return false;
|
||||
|
||||
@@ -225,13 +284,13 @@ static bool validSubstitution (
|
||||
std::string& from,
|
||||
std::string& to)
|
||||
{
|
||||
unsigned int first = input.find ('/');
|
||||
size_t first = input.find ('/');
|
||||
if (first != std::string::npos)
|
||||
{
|
||||
unsigned int second = input.find ('/', first + 1);
|
||||
size_t second = input.find ('/', first + 1);
|
||||
if (second != std::string::npos)
|
||||
{
|
||||
unsigned int third = input.find ('/', second + 1);
|
||||
size_t third = input.find ('/', second + 1);
|
||||
if (third != std::string::npos)
|
||||
{
|
||||
if (first == 0 &&
|
||||
@@ -263,15 +322,16 @@ static bool validSubstitution (
|
||||
void parse (
|
||||
std::vector <std::string>& args,
|
||||
std::string& command,
|
||||
T& task)
|
||||
T& task,
|
||||
Config& conf)
|
||||
{
|
||||
command = "";
|
||||
|
||||
std::string descCandidate = "";
|
||||
for (unsigned int i = 0; i < args.size (); ++i)
|
||||
for (size_t i = 0; i < args.size (); ++i)
|
||||
{
|
||||
std::string arg (args[i]);
|
||||
unsigned int colon; // Pointer to colon in argument.
|
||||
size_t colon; // Pointer to colon in argument.
|
||||
std::string from;
|
||||
std::string to;
|
||||
|
||||
@@ -297,7 +357,7 @@ void parse (
|
||||
std::string name = arg.substr (0, colon);
|
||||
std::string value = arg.substr (colon + 1, std::string::npos);
|
||||
|
||||
if (validAttribute (name, value))
|
||||
if (validAttribute (name, value, conf))
|
||||
task.setAttribute (name, value);
|
||||
}
|
||||
|
||||
|
||||
111
src/rules.cpp
111
src/rules.cpp
@@ -1,9 +1,31 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2006 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include "Config.h"
|
||||
#include "Table.h"
|
||||
#include "Date.h"
|
||||
@@ -16,8 +38,8 @@ static std::map <std::string, Text::color> gsBg;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// There are three supported variants:
|
||||
// 1) "fg"
|
||||
// 2) "on bg"
|
||||
// 3) "fg on bg"
|
||||
// 2) "bg"
|
||||
// 3) "fg bg"
|
||||
static void parseColorRule (
|
||||
const std::string& rule,
|
||||
Text::color& fg,
|
||||
@@ -25,41 +47,18 @@ static void parseColorRule (
|
||||
{
|
||||
fg = Text::nocolor;
|
||||
bg = Text::nocolor;
|
||||
bool error = false;
|
||||
|
||||
std::vector <std::string> words;
|
||||
split (words, rule, ' ');
|
||||
switch (words.size ())
|
||||
|
||||
std::vector <std::string>::iterator it;
|
||||
for (it = words.begin (); it != words.end (); ++it)
|
||||
{
|
||||
case 1: // "fg" - no spaces.
|
||||
fg = Text::colorCode (words[0]);
|
||||
break;
|
||||
|
||||
case 2: // "on bg" - one space, "on" before.
|
||||
if (words[0] == "on")
|
||||
bg = Text::colorCode (words[1]);
|
||||
if (it->substr (0, 3) == "on_")
|
||||
bg = Text::colorCode (*it);
|
||||
else
|
||||
error = true;
|
||||
break;
|
||||
|
||||
case 3: // "fg on bg" - two spaces, "on" between them.
|
||||
if (words[1] == "on")
|
||||
{
|
||||
fg = Text::colorCode (words[0]);
|
||||
bg = Text::colorCode (words[2]);
|
||||
}
|
||||
else
|
||||
error = true;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
error = true;
|
||||
break;
|
||||
fg = Text::colorCode (*it);
|
||||
}
|
||||
|
||||
if (error)
|
||||
std::cout << "Malformed color rule '" << rule << "'" << std::endl;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -83,8 +82,8 @@ void initializeColorRules (Config& conf)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void autoColorize (T& task, Text::color& fg, Text::color& bg)
|
||||
{
|
||||
fg = Text::nocolor;
|
||||
bg = Text::nocolor;
|
||||
// Note: fg, bg already contain colors specifically assigned via command.
|
||||
// TODO These rules form a hierarchy - the last rule is king.
|
||||
|
||||
// Colorization of the tagged.
|
||||
if (gsFg["color.tagged"] != Text::nocolor ||
|
||||
@@ -176,6 +175,50 @@ void autoColorize (T& task, Text::color& fg, Text::color& bg)
|
||||
bg = gsBg["color.due"];
|
||||
}
|
||||
}
|
||||
|
||||
// Colorization by tag value.
|
||||
std::map <std::string, Text::color>::iterator it;
|
||||
for (it = gsFg.begin (); it != gsFg.end (); ++it)
|
||||
{
|
||||
if (it->first.substr (0, 10) == "color.tag.")
|
||||
{
|
||||
std::string value = it->first.substr (10, std::string::npos);
|
||||
if (task.hasTag (value))
|
||||
{
|
||||
fg = gsFg[it->first];
|
||||
bg = gsBg[it->first];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Colorization by project name.
|
||||
for (it = gsFg.begin (); it != gsFg.end (); ++it)
|
||||
{
|
||||
if (it->first.substr (0, 14) == "color.project.")
|
||||
{
|
||||
std::string value = it->first.substr (14, std::string::npos);
|
||||
if (task.getAttribute ("project") == value)
|
||||
{
|
||||
fg = gsFg[it->first];
|
||||
bg = gsBg[it->first];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Colorization by keyword.
|
||||
for (it = gsFg.begin (); it != gsFg.end (); ++it)
|
||||
{
|
||||
if (it->first.substr (0, 14) == "color.keyword.")
|
||||
{
|
||||
std::string value = lowerCase (it->first.substr (14, std::string::npos));
|
||||
std::string desc = lowerCase (task.getDescription ());
|
||||
if (desc.find (value) != std::string::npos)
|
||||
{
|
||||
fg = gsFg[it->first];
|
||||
bg = gsBg[it->first];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2006 - 2008, Paul Beckingham. All rights reserved.
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_STLMACROS
|
||||
#define INCLUDED_STLMACROS
|
||||
|
||||
#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)
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
1796
src/task.cpp
1796
src/task.cpp
File diff suppressed because it is too large
Load Diff
47
src/task.h
47
src/task.h
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2006 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -13,16 +34,27 @@
|
||||
#include "color.h"
|
||||
#include "TDB.h"
|
||||
#include "T.h"
|
||||
#include "stlmacros.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>&, std::string&, T&);
|
||||
bool validDate (std::string&);
|
||||
void parse (std::vector <std::string>&, std::string&, T&, Config&);
|
||||
bool validDate (std::string&, Config&);
|
||||
|
||||
// task.cpp
|
||||
void handleAdd (const TDB&, T&, Config&);
|
||||
@@ -41,12 +73,15 @@ void handleReportCalendar (const TDB&, T&, Config&);
|
||||
void handleReportActive (const TDB&, T&, Config&);
|
||||
void handleReportOverdue (const TDB&, T&, Config&);
|
||||
void handleReportStats (const TDB&, T&, Config&);
|
||||
void handleReportOldest (const TDB&, T&, Config&);
|
||||
void handleReportNewest (const TDB&, T&, Config&);
|
||||
void handleVersion (Config&);
|
||||
void handleExport (const TDB&, T&, Config&);
|
||||
void handleDelete (const TDB&, T&, Config&);
|
||||
void handleStart (const TDB&, T&, Config&);
|
||||
void handleDone (const TDB&, T&, Config&);
|
||||
void handleModify (const TDB&, T&, Config&);
|
||||
void handleColor (Config&);
|
||||
void gatherNextTasks (const TDB&, T&, Config&, std::vector <T>&, std::vector <int>&);
|
||||
void nag (const TDB&, T&, Config&);
|
||||
|
||||
@@ -56,9 +91,6 @@ 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::wstring trimLeft (const std::wstring& in, const std::wstring& t = L" "); // UNICODE safe
|
||||
std::wstring trimRight (const std::wstring& in, const std::wstring& t = L" "); // UNICODE safe
|
||||
std::wstring trim (const std::wstring& in, const std::wstring& t = L" "); // UNICODE safe
|
||||
void extractParagraphs (const std::string&, std::vector<std::string>&);
|
||||
void extractLine (std::string&, std::string&, int);
|
||||
void split (std::vector<std::string>&, const std::string&, const char);
|
||||
@@ -71,6 +103,7 @@ int autoComplete (const std::string&, const std::vector<std::string>&, std::vect
|
||||
void formatTimeDeltaDays (std::string&, time_t);
|
||||
std::string formatSeconds (time_t);
|
||||
const std::string uuid ();
|
||||
const char* optionalBlankLine (Config&);
|
||||
|
||||
// rules.cpp
|
||||
void initializeColorRules (Config&);
|
||||
|
||||
1
src/tests/.gitignore
vendored
1
src/tests/.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
t.t
|
||||
tdb.t
|
||||
date.t
|
||||
pending.data
|
||||
completed.data
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
PROJECT = t.t tdb.t
|
||||
CFLAGS = -I.. -I../../../library/include -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib -L../../../library/lib -lcompany -lpcre -lncurses -lcurl
|
||||
PROJECT = t.t tdb.t date.t
|
||||
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib
|
||||
OBJECTS = ../TDB.o ../T.o ../parse.o ../text.o ../Date.o ../util.o ../Config.o
|
||||
|
||||
all: $(PROJECT)
|
||||
|
||||
@@ -16,9 +17,12 @@ clean:
|
||||
.cpp.o:
|
||||
g++ -c $(CFLAGS) $<
|
||||
|
||||
t.t: t.t.o ../T.o ../parse.o ../../../library/lib/libcompany.a
|
||||
g++ t.t.o ../T.o ../parse.o $(LFLAGS) -o t.t
|
||||
t.t: t.t.o $(OBJECTS) test.o
|
||||
g++ t.t.o $(OBJECTS) test.o $(LFLAGS) -o t.t
|
||||
|
||||
tdb.t: tdb.t.o ../TDB.o ../T.o ../parse.o ../../../library/lib/libcompany.a
|
||||
g++ tdb.t.o ../TDB.o ../T.o ../parse.o $(LFLAGS) -o tdb.t
|
||||
tdb.t: tdb.t.o $(OBJECTS) test.o
|
||||
g++ tdb.t.o $(OBJECTS) test.o $(LFLAGS) -o tdb.t
|
||||
|
||||
date.t: date.t.o $(OBJECTS) test.o
|
||||
g++ date.t.o $(OBJECTS) test.o $(LFLAGS) -o date.t
|
||||
|
||||
|
||||
113
src/tests/date.t.cpp
Normal file
113
src/tests/date.t.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2005 - 2008, Paul Beckingham. All rights reserved.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <Date.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
plan (63);
|
||||
|
||||
Date now;
|
||||
Date yesterday;
|
||||
yesterday -= 1;
|
||||
|
||||
ok (yesterday <= now, "yesterday <= now");
|
||||
ok (yesterday < now, "yesterday < now");
|
||||
notok (yesterday == now, "!(yesterday == now)");
|
||||
ok (yesterday != now, "yesterday != now");
|
||||
ok (now >= yesterday, "now >= yesterday");
|
||||
ok (now > yesterday, "now > yesterday");
|
||||
|
||||
ok (Date::valid (2, 29, 2008), "valid: 2/29/2008");
|
||||
notok (Date::valid (2, 29, 2007), "invalid: 2/29/2007");
|
||||
|
||||
ok (Date::leapYear (2008), "2008 is a leap year");
|
||||
notok (Date::leapYear (2007), "2007 is not a leap year");
|
||||
ok (Date::leapYear (2000), "2000 is a leap year");
|
||||
ok (Date::leapYear (1900), "1900 is a leap year");
|
||||
|
||||
is (Date::daysInMonth (2, 2008), 29, "29 days in February 2008");
|
||||
is (Date::daysInMonth (2, 2007), 28, "28 days in February 2007");
|
||||
|
||||
is (Date::monthName (1), "January", "1 = January");
|
||||
is (Date::monthName (2), "February", "2 = February");
|
||||
is (Date::monthName (3), "March", "3 = March");
|
||||
is (Date::monthName (4), "April", "4 = April");
|
||||
is (Date::monthName (5), "May", "5 = May");
|
||||
is (Date::monthName (6), "June", "6 = June");
|
||||
is (Date::monthName (7), "July", "7 = July");
|
||||
is (Date::monthName (8), "August", "8 = August");
|
||||
is (Date::monthName (9), "September", "9 = September");
|
||||
is (Date::monthName (10), "October", "10 = October");
|
||||
is (Date::monthName (11), "November", "11 = November");
|
||||
is (Date::monthName (12), "December", "12 = December");
|
||||
|
||||
is (Date::dayName (0), "Sunday", "0 == Sunday");
|
||||
is (Date::dayName (1), "Monday", "1 == Monday");
|
||||
is (Date::dayName (2), "Tuesday", "2 == Tuesday");
|
||||
is (Date::dayName (3), "Wednesday", "3 == Wednesday");
|
||||
is (Date::dayName (4), "Thursday", "4 == Thursday");
|
||||
is (Date::dayName (5), "Friday", "5 == Friday");
|
||||
is (Date::dayName (6), "Saturday", "6 == Saturday");
|
||||
|
||||
Date happyNewYear (1, 1, 2008);
|
||||
is (happyNewYear.dayOfWeek (), 2, "1/1/2008 == Tuesday");
|
||||
is (happyNewYear.month (), 1, "1/1/2008 == January");
|
||||
is (happyNewYear.day (), 1, "1/1/2008 == 1");
|
||||
is (happyNewYear.year (), 2008, "1/1/2008 == 2008");
|
||||
|
||||
is (now - yesterday, 1, "today - yesterday == 1");
|
||||
|
||||
is (happyNewYear.toString (), "1/1/2008", "toString 1/1/2008");
|
||||
|
||||
int m, d, y;
|
||||
happyNewYear.toMDY (m, d, y);
|
||||
is (m, 1, "1/1/2008 == January");
|
||||
is (d, 1, "1/1/2008 == 1");
|
||||
is (y, 2008, "1/1/2008 == 2008");
|
||||
|
||||
Date epoch (9, 8, 2001);
|
||||
ok ((int)epoch.toEpoch () < 1000000000, "9/8/2001 < 1,000,000,000");
|
||||
epoch += 86400;
|
||||
ok ((int)epoch.toEpoch () > 1000000000, "9/9/2001 > 1,000,000,000");
|
||||
|
||||
Date fromEpoch (epoch.toEpoch ());
|
||||
is (fromEpoch.toString (), epoch.toString (), "ctor (time_t)");
|
||||
|
||||
Date fromString1 ("1/1/2008");
|
||||
is (fromString1.month (), 1, "ctor (std::string) -> m");
|
||||
is (fromString1.day (), 1, "ctor (std::string) -> d");
|
||||
is (fromString1.year (), 2008, "ctor (std::string) -> y");
|
||||
|
||||
Date fromString2 ("1/1/2008", "m/d/Y");
|
||||
is (fromString2.month (), 1, "ctor (std::string) -> m");
|
||||
is (fromString2.day (), 1, "ctor (std::string) -> d");
|
||||
is (fromString2.year (), 2008, "ctor (std::string) -> y");
|
||||
|
||||
Date fromString3 ("20080101", "YMD");
|
||||
is (fromString3.month (), 1, "ctor (std::string) -> m");
|
||||
is (fromString3.day (), 1, "ctor (std::string) -> d");
|
||||
is (fromString3.year (), 2008, "ctor (std::string) -> y");
|
||||
|
||||
Date fromString4 ("12/31/2007");
|
||||
is (fromString4.month (), 12, "ctor (std::string) -> m");
|
||||
is (fromString4.day (), 31, "ctor (std::string) -> d");
|
||||
is (fromString4.year (), 2007, "ctor (std::string) -> y");
|
||||
|
||||
Date fromString5 ("12/31/2007", "m/d/Y");
|
||||
is (fromString5.month (), 12, "ctor (std::string) -> m");
|
||||
is (fromString5.day (), 31, "ctor (std::string) -> d");
|
||||
is (fromString5.year (), 2007, "ctor (std::string) -> y");
|
||||
|
||||
Date fromString6 ("20071231", "YMD");
|
||||
is (fromString6.month (), 12, "ctor (std::string) -> m");
|
||||
is (fromString6.day (), 31, "ctor (std::string) -> d");
|
||||
is (fromString6.year (), 2007, "ctor (std::string) -> y");
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,8 +1,32 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <T.h>
|
||||
#include <library.h>
|
||||
#include "../T.h"
|
||||
#include "../task.h"
|
||||
#include "test.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
|
||||
@@ -1,11 +1,35 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <TDB.h>
|
||||
#include <library.h>
|
||||
#include "../TDB.h"
|
||||
#include "../task.h"
|
||||
#include "test.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
@@ -116,10 +140,10 @@ int main (int argc, char** argv)
|
||||
return -2;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
unlink ("./pending.data");
|
||||
unlink ("./completed.data");
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
275
src/tests/test.cpp
Normal file
275
src/tests/test.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <task.h>
|
||||
|
||||
static int total = 0;
|
||||
static int counter = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static void check (void)
|
||||
{
|
||||
if (counter > total)
|
||||
std::cout << "# Warning: There are more tests than planned."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void plan (int quantity)
|
||||
{
|
||||
total = quantity;
|
||||
std::cout << "1.." << quantity << std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void ok (bool expression, const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
|
||||
if (expression)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void notok (bool expression, const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
|
||||
if (!expression)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void is (bool actual, bool expected, const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
if (actual == expected)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl
|
||||
<< "# expected: "
|
||||
<< expected
|
||||
<< std::endl
|
||||
<< "# got: "
|
||||
<< actual
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void is (size_t actual, size_t expected, const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
if (actual == expected)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl
|
||||
<< "# expected: "
|
||||
<< expected
|
||||
<< std::endl
|
||||
<< "# got: "
|
||||
<< actual
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void is (int actual, int expected, const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
if (actual == expected)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl
|
||||
<< "# expected: "
|
||||
<< expected
|
||||
<< std::endl
|
||||
<< "# got: "
|
||||
<< actual
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void is (double actual, double expected, const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
if (actual == expected)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl
|
||||
<< "# expected: "
|
||||
<< expected
|
||||
<< std::endl
|
||||
<< "# got: "
|
||||
<< actual
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void is (char actual, char expected, const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
if (actual == expected)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl
|
||||
<< "# expected: "
|
||||
<< expected
|
||||
<< std::endl
|
||||
<< "# got: "
|
||||
<< actual
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void is (
|
||||
const std::string& actual,
|
||||
const std::string& expected,
|
||||
const std::string& name)
|
||||
{
|
||||
++counter;
|
||||
if (actual == expected)
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl;
|
||||
else
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " - "
|
||||
<< name
|
||||
<< std::endl
|
||||
<< "# expected: '"
|
||||
<< expected
|
||||
<< "'"
|
||||
<< std::endl
|
||||
<< "# got: '"
|
||||
<< actual
|
||||
<< "'"
|
||||
<< std::endl;
|
||||
check ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void diag (const std::string& text)
|
||||
{
|
||||
std::string trimmed = trim (text, " \t\n\r\f");
|
||||
|
||||
std::cout << "# " << trimmed << std::endl;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void pass (const std::string& text)
|
||||
{
|
||||
++counter;
|
||||
std::cout << "ok "
|
||||
<< counter
|
||||
<< " "
|
||||
<< text
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void fail (const std::string& text)
|
||||
{
|
||||
++counter;
|
||||
std::cout << "not ok "
|
||||
<< counter
|
||||
<< " "
|
||||
<< text
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
46
src/tests/test.h
Normal file
46
src/tests/test.h
Normal file
@@ -0,0 +1,46 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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_TEST
|
||||
#define INCLUDED_TEST
|
||||
|
||||
#include <string>
|
||||
|
||||
void plan (int);
|
||||
void ok (bool, const std::string&);
|
||||
void notok (bool, const std::string&);
|
||||
void is (bool, bool, const std::string&);
|
||||
void is (int, int, const std::string&);
|
||||
void is (size_t, size_t, const std::string&);
|
||||
void is (double, double, const std::string&);
|
||||
void is (char, char, const std::string&);
|
||||
void is (const std::string&, const std::string&, const std::string&);
|
||||
void diag (const std::string&);
|
||||
void fail (const std::string&);
|
||||
void pass (const std::string&);
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
74
src/text.cpp
74
src/text.cpp
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2004 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
@@ -8,6 +29,9 @@
|
||||
#include <string>
|
||||
#include "task.h"
|
||||
|
||||
static const char* newline = "\n";
|
||||
static const char* noline = "";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void wrapText (
|
||||
std::vector <std::string>& lines,
|
||||
@@ -76,8 +100,8 @@ void extractParagraphs (const std::string& input, std::vector<std::string>& outp
|
||||
std::string copy = input;
|
||||
while (1)
|
||||
{
|
||||
unsigned int so = copy.find ("<p>");
|
||||
unsigned int eo = copy.find ("</p>");
|
||||
size_t so = copy.find ("<p>");
|
||||
size_t eo = copy.find ("</p>");
|
||||
|
||||
if (so == std::string::npos && eo == std::string::npos)
|
||||
break;
|
||||
@@ -99,13 +123,6 @@ std::string trimLeft (const std::string& in, const std::string& t /*= " "*/)
|
||||
return out.erase (0, in.find_first_not_of (t));
|
||||
}
|
||||
|
||||
// UNICODE safe
|
||||
std::wstring trimLeft (const std::wstring& in, const std::wstring& t /*= L" "*/)
|
||||
{
|
||||
std::wstring out = in;
|
||||
return out.erase (0, in.find_first_not_of (t));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string trimRight (const std::string& in, const std::string& t /*= " "*/)
|
||||
{
|
||||
@@ -113,13 +130,6 @@ std::string trimRight (const std::string& in, const std::string& t /*= " "*/)
|
||||
return out.erase (out.find_last_not_of (t) + 1);
|
||||
}
|
||||
|
||||
// UNICODE safe
|
||||
std::wstring trimRight (const std::wstring& in, const std::wstring& t /*= L" "*/)
|
||||
{
|
||||
std::wstring out = in;
|
||||
return out.erase (out.find_last_not_of (t) + 1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string trim (const std::string& in, const std::string& t /*= " "*/)
|
||||
{
|
||||
@@ -127,13 +137,6 @@ std::string trim (const std::string& in, const std::string& t /*= " "*/)
|
||||
return trimLeft (trimRight (out, t), t);
|
||||
}
|
||||
|
||||
// UNICODE safe
|
||||
std::wstring trim (const std::wstring& in, const std::wstring& t /*= L" "*/)
|
||||
{
|
||||
std::wstring out = in;
|
||||
return trimLeft (trimRight (out, t), t);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Remove enclosing balanced quotes. Assumes trimmed text.
|
||||
void unquoteText (std::string& text)
|
||||
@@ -147,7 +150,7 @@ void unquoteText (std::string& text)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void extractLine (std::string& text, std::string& line, int length)
|
||||
{
|
||||
unsigned int eol = text.find ("\n");
|
||||
size_t eol = text.find ("\n");
|
||||
|
||||
// Special case: found \n in first length characters.
|
||||
if (eol != std::string::npos && eol < (unsigned) length)
|
||||
@@ -183,8 +186,16 @@ void extractLine (std::string& text, std::string& line, int length)
|
||||
// If no space was found, hyphenate.
|
||||
else
|
||||
{
|
||||
line = text.substr (0, length - 1) + "-";
|
||||
text = text.substr (length - 1, std::string::npos);
|
||||
if (length > 1)
|
||||
{
|
||||
line = text.substr (0, length - 1) + "-";
|
||||
text = text.substr (length - 1, std::string::npos);
|
||||
}
|
||||
else
|
||||
{
|
||||
line = text.substr (0, 1);
|
||||
text = text.substr (length, std::string::npos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,3 +286,12 @@ std::string lowerCase (const std::string& input)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const char* optionalBlankLine (Config& conf)
|
||||
{
|
||||
if (conf.get ("blanklines", true) == true)
|
||||
return newline;
|
||||
|
||||
return noline;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
54
src/util.cpp
54
src/util.cpp
@@ -1,6 +1,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2006 - 2008, Paul Beckingham. All rights reserved.
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2008, 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
@@ -10,6 +31,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "Table.h"
|
||||
#include "task.h"
|
||||
#include "../auto.h"
|
||||
@@ -58,19 +80,19 @@ void formatTimeDeltaDays (std::string& output, time_t delta)
|
||||
if (days > 365)
|
||||
sprintf (formatted, "%.1f yrs", (days / 365.2422));
|
||||
else if (days > 84)
|
||||
sprintf (formatted, "%1d mths", (int) (days / 30.6));
|
||||
sprintf (formatted, "%1d mth%s", (int) (days / 30.6), ((int) (days / 30.6) == 1 ? "" : "s"));
|
||||
else if (days > 13)
|
||||
sprintf (formatted, "%d wks", (int) (days / 7.0));
|
||||
sprintf (formatted, "%d wk%s", (int) (days / 7.0), ((int) (days / 7.0) == 1 ? "" : "s"));
|
||||
else if (days > 5.0)
|
||||
sprintf (formatted, "%d days", (int) days);
|
||||
sprintf (formatted, "%d day%s", (int) days, ((int) days == 1 ? "" : "s"));
|
||||
else if (days > 1.0)
|
||||
sprintf (formatted, "%.1f days", days);
|
||||
else if (days * 24 > 1.0)
|
||||
sprintf (formatted, "%d hrs", (int) (days * 24.0));
|
||||
sprintf (formatted, "%d hr%s", (int) (days * 24.0), ((int) (days * 24.0) == 1 ? "" : "s"));
|
||||
else if (days * 24 * 60 > 1)
|
||||
sprintf (formatted, "%d mins", (int) (days * 24 * 60));
|
||||
sprintf (formatted, "%d min%s", (int) (days * 24 * 60), ((int) (days * 24 * 60) == 1 ? "" : "s"));
|
||||
else if (days * 24 * 60 * 60 > 1)
|
||||
sprintf (formatted, "%d secs", (int) (days * 24 * 60 * 60));
|
||||
sprintf (formatted, "%d sec%s", (int) (days * 24 * 60 * 60), ((int) (days * 24 * 60 * 60) == 1 ? "" : "s"));
|
||||
else
|
||||
strcpy (formatted, "-");
|
||||
|
||||
@@ -86,19 +108,19 @@ std::string formatSeconds (time_t delta)
|
||||
if (days > 365)
|
||||
sprintf (formatted, "%.1f yrs", (days / 365.2422));
|
||||
else if (days > 84)
|
||||
sprintf (formatted, "%1d mths", (int) (days / 30.6));
|
||||
sprintf (formatted, "%1d mth%s", (int) (days / 30.6), ((int) (days / 30.6) == 1 ? "" : "s"));
|
||||
else if (days > 13)
|
||||
sprintf (formatted, "%d wks", (int) (days / 7.0));
|
||||
sprintf (formatted, "%d wk%s", (int) (days / 7.0), ((int) (days / 7.0) == 1 ? "" : "s"));
|
||||
else if (days > 5.0)
|
||||
sprintf (formatted, "%d days", (int) days);
|
||||
sprintf (formatted, "%d day%s", (int) days, ((int) days == 1 ? "" : "s"));
|
||||
else if (days > 1.0)
|
||||
sprintf (formatted, "%.1f days", days);
|
||||
else if (days * 24 > 1.0)
|
||||
sprintf (formatted, "%d hrs", (int) (days * 24.0));
|
||||
sprintf (formatted, "%d hr%s", (int) (days * 24.0), ((int) (days * 24) == 1 ? "" : "s"));
|
||||
else if (days * 24 * 60 > 1)
|
||||
sprintf (formatted, "%d mins", (int) (days * 24 * 60));
|
||||
sprintf (formatted, "%d min%s", (int) (days * 24 * 60), ((int) (days * 24 * 60) == 1 ? "" : "s"));
|
||||
else if (days * 24 * 60 * 60 > 1)
|
||||
sprintf (formatted, "%d secs", (int) (days * 24 * 60 * 60));
|
||||
sprintf (formatted, "%d sec%s", (int) (days * 24 * 60 * 60), ((int) (days * 24 * 60 * 60) == 1 ? "" : "s"));
|
||||
else
|
||||
strcpy (formatted, "-");
|
||||
|
||||
@@ -160,14 +182,18 @@ const std::string uuid ()
|
||||
static char randomHexDigit ()
|
||||
{
|
||||
static char digits[] = "0123456789abcdef";
|
||||
#ifdef HAVE_RANDOM
|
||||
return digits[random () % 16];
|
||||
#else
|
||||
return digits[rand () % 16];
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string uuid ()
|
||||
{
|
||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
char id [37];
|
||||
char id [48] = {0};
|
||||
id[0] = randomHexDigit ();
|
||||
id[1] = randomHexDigit ();
|
||||
id[2] = randomHexDigit ();
|
||||
|
||||
Reference in New Issue
Block a user