Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,7 +1,6 @@
|
|||||||
Makefile.in
|
Makefile.in
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
conf.defs
|
|
||||||
auto.h*
|
auto.h*
|
||||||
config.h.in
|
config.h.in
|
||||||
config.status
|
config.status
|
||||||
|
|||||||
11
AUTHORS
11
AUTHORS
@@ -1,7 +1,10 @@
|
|||||||
Principal Author
|
Principal Author:
|
||||||
Paul Beckingham, paul@beckingham.net
|
Paul Beckingham, paul@beckingham.net
|
||||||
|
|
||||||
Contributing Authors
|
With thanks to:
|
||||||
|
Eugene Kramer
|
||||||
Testers
|
SK
|
||||||
|
Damian Glenny
|
||||||
|
Richard Querin
|
||||||
|
Bruce Israel
|
||||||
|
|
||||||
|
|||||||
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.
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
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.
|
|
||||||
|
|||||||
66
ChangeLog
66
ChangeLog
@@ -1,15 +1,60 @@
|
|||||||
|
Version numbers are of the form:
|
||||||
|
|
||||||
1.0.0 (?)
|
x.y.z
|
||||||
- Bug: assertion fails on mobile for t v
|
|
||||||
|
|
||||||
0.9.9 (?)
|
where the x represents a major version number, or architecture. The y
|
||||||
- Autoconf/autmake behaving properly.
|
represents a feature release, and the z represents a patch.
|
||||||
- All bugs fixed.
|
|
||||||
|
------ plans -------------------------------------
|
||||||
|
|
||||||
|
Configurable columns in reports
|
||||||
|
|
||||||
------ reality -----------------------------------
|
------ reality -----------------------------------
|
||||||
|
|
||||||
|
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)
|
0.9.8 (5/25/2008)
|
||||||
+ Color command.
|
+ Added "task color" command.
|
||||||
+ Removed unnecessary files.
|
+ Removed unnecessary files.
|
||||||
+ Completed documentation.
|
+ Completed documentation.
|
||||||
|
|
||||||
@@ -57,10 +102,18 @@
|
|||||||
+ Initial commit.
|
+ Initial commit.
|
||||||
|
|
||||||
0.9.3 (4/6/2008)
|
0.9.3 (4/6/2008)
|
||||||
|
+ Added "task completed" command.
|
||||||
|
+ Properly recognizes ncurses.
|
||||||
|
|
||||||
0.9.2 (4/3/2008)
|
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)
|
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)
|
0.9.0 (3/23/2008)
|
||||||
+ flat source directory
|
+ flat source directory
|
||||||
@@ -85,6 +138,7 @@
|
|||||||
+ File locking
|
+ File locking
|
||||||
+ retain deleted tasks
|
+ retain deleted tasks
|
||||||
+ "task info ID" report showing all metadata
|
+ "task info ID" report showing all metadata
|
||||||
|
+ File format v2
|
||||||
|
|
||||||
[Development hiatus while planning for T, TDB API, new features and the future
|
[Development hiatus while planning for T, TDB API, new features and the future
|
||||||
of the project. Seeded to two testers for feedback, suggestions.]
|
of the project. Seeded to two testers for feedback, suggestions.]
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ included.
|
|||||||
color.cpp Color support functions.
|
color.cpp Color support functions.
|
||||||
rules.cpp Auto-colorization rules.
|
rules.cpp Auto-colorization rules.
|
||||||
|
|
||||||
Don't forget, please send patches to task@beckingham.net
|
Don't forget, please send bugs, patches to task@beckingham.net
|
||||||
|
|
||||||
|
|||||||
19
NEWS
19
NEWS
@@ -1,13 +1,22 @@
|
|||||||
|
Welcome to Task 1.2.0.
|
||||||
|
|
||||||
Welcome to Task 1.0.0.
|
Task has been built and tested on the following configurations:
|
||||||
|
|
||||||
While Task has undergone much testing, bugs are sure to remain. If you
|
- OS X 10.4 Tiger
|
||||||
encounter a bug, please contact me at bugs@beckingham.net. Here is what you
|
- OS X 10.5 Leopard
|
||||||
could do, in order of increasing effort (to you) and usefulness (to me):
|
- 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.
|
- Do nothing. Bug probably won't get fixed.
|
||||||
|
|
||||||
- Send an email to bugs@beckingham.net, explaining what you saw. The bug
|
- 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.
|
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
|
- Send an email, and a reproducible test case in the form of the few commands
|
||||||
|
|||||||
12
README
12
README
@@ -4,6 +4,7 @@ Thank you for taking a look at task. Task is a GTD utility featuring:
|
|||||||
- Tags
|
- Tags
|
||||||
- Colorful, tabular output
|
- Colorful, tabular output
|
||||||
- Reports
|
- Reports
|
||||||
|
- Lots of commands
|
||||||
- Low-level API
|
- Low-level API
|
||||||
- Abbreviations for all commands, options
|
- Abbreviations for all commands, options
|
||||||
- Multi-user file locking
|
- Multi-user file locking
|
||||||
@@ -14,12 +15,14 @@ frequently, with best practices and useful reports evolving from usage patterns.
|
|||||||
|
|
||||||
Task is scope-limited to GTD functionality only.
|
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
|
||||||
|
|
||||||
You may want to jump straight to the TUTORIAL file, or perhaps watch the task
|
or the new improved one:
|
||||||
movie on YouTube:
|
|
||||||
|
|
||||||
http://?????????????????
|
http://www.youtube.com/watch?v=D2Kn4DMOVSw
|
||||||
|
|
||||||
Either will give you a fairly good idea of what task is capable of, and whether
|
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
|
it fits in to your way of working. As a command line application, task is not
|
||||||
@@ -40,3 +43,6 @@ All feedback is welcome, in addition to any bug reports or patches to:
|
|||||||
|
|
||||||
Got an idea for an enhancement? Send a message!
|
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.
|
||||||
|
|
||||||
|
|||||||
106
TUTORIAL
106
TUTORIAL
@@ -1,4 +1,4 @@
|
|||||||
Task program tutorial, for version 1.0.0
|
Task program tutorial, for version 1.2.0
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
This guide shows how to quickly set up the task program, and become proficient
|
This guide shows how to quickly set up the task program, and become proficient
|
||||||
@@ -21,15 +21,15 @@ Build the task program according to the directions in the INSTALL file. This
|
|||||||
transcript illustrates a typical installation:
|
transcript illustrates a typical installation:
|
||||||
|
|
||||||
% ls
|
% ls
|
||||||
task-1.0.0.tar.gz
|
task-1.2.0.tar.gz
|
||||||
% gunzip task-1.0.0.tar.gz
|
% gunzip task-1.2.0.tar.gz
|
||||||
% tar xf task-1.0.0.tar
|
% tar xf task-1.2.0.tar
|
||||||
% cd task-1.0.0
|
% cd task-1.2.0
|
||||||
% ./configure
|
% ./configure
|
||||||
...
|
...
|
||||||
% make
|
% 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
|
You need to make sure that the installed task program is in your PATH
|
||||||
environment variable.
|
environment variable.
|
||||||
@@ -107,8 +107,42 @@ 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
|
id numbers will remain valid until the next 'ls' command is run. You should
|
||||||
only use the ids from the most recent 'ls' command. The ids change, because
|
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
|
task is always trying to use small numbers so that it is easy for you to enter
|
||||||
them correctly. Now that projects are assigned, we can look at just the Wedding
|
them correctly.
|
||||||
project tasks:
|
|
||||||
|
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
|
% task ls project:Wedding
|
||||||
|
|
||||||
@@ -554,8 +588,27 @@ Interacting with the Shell
|
|||||||
background) attributes determines the colors used to represent the task.
|
background) attributes determines the colors used to represent the task.
|
||||||
Valid foreground colors are:
|
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:
|
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
|
Note that these are not just colors, but combinations of colors and
|
||||||
attributes.
|
attributes.
|
||||||
|
|
||||||
@@ -602,6 +655,38 @@ Configuring Task
|
|||||||
curses Determines whether task uses ncurses to establish the
|
curses Determines whether task uses ncurses to establish the
|
||||||
size of the window you are using, for text wrapping.
|
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:
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
color May be "on" or "off". Determines whether task uses
|
color May be "on" or "off". Determines whether task uses
|
||||||
color.
|
color.
|
||||||
|
|
||||||
@@ -617,6 +702,11 @@ Configuring Task
|
|||||||
|
|
||||||
bold_red on_bright_yellow
|
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
|
Colors
|
||||||
|
|||||||
12
adsense.html
Normal file
12
adsense.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<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>
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -2,11 +2,10 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.61)
|
AC_PREREQ(2.61)
|
||||||
AC_INIT(task, 0.9.8, bugs@beckingham.net)
|
AC_INIT(task, 1.2.0, bugs@beckingham.net)
|
||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
AC_CONFIG_SRCDIR([src/task.cpp])
|
AC_CONFIG_SRCDIR([src/task.cpp])
|
||||||
AC_CONFIG_HEADER([auto.h])
|
AC_CONFIG_HEADER([auto.h])
|
||||||
#AC_CONFIG_SUBDIRS([src])
|
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
@@ -14,7 +13,6 @@ AC_PROG_CC
|
|||||||
AC_LANG(C++)
|
AC_LANG(C++)
|
||||||
|
|
||||||
# Checks for libraries.
|
# 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,initscr)
|
||||||
AC_CHECK_LIB(ncurses,endwin)
|
AC_CHECK_LIB(ncurses,endwin)
|
||||||
|
|
||||||
@@ -37,6 +35,8 @@ AC_FUNC_SELECT_ARGTYPES
|
|||||||
AC_CHECK_FUNCS([select])
|
AC_CHECK_FUNCS([select])
|
||||||
AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])])
|
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(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 src/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
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.
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ Config.o Config.o: Config.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_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.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 \
|
/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
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -402,6 +402,4 @@ TDB.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|||||||
@@ -95,8 +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_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.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 \
|
/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 \
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h ../auto.h Date.h
|
||||||
Date.h
|
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -388,8 +387,6 @@ TDB.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|
||||||
Date.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_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.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 \
|
/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
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -387,6 +387,4 @@ TDB.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.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_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.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 \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h Config.h Table.h color.h \
|
||||||
Grid.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:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -403,6 +403,4 @@ TDB.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ Table.o Table.o: Table.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||||
/usr/include/c++/4.0.0/bits/vector.tcc color.h Grid.h Date.h task.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 \
|
/usr/include/sys/types.h Config.h Table.h color.h TDB.h T.h T.h \
|
||||||
stlmacros.h ../auto.h
|
../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -394,6 +394,4 @@ T.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ parse.o parse.o: parse.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_map.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/c++/4.0.0/bits/stl_multimap.h Date.h task.h \
|
||||||
/usr/include/sys/types.h Config.h Table.h color.h Grid.h color.h TDB.h \
|
/usr/include/sys/types.h Config.h Table.h color.h Grid.h color.h TDB.h \
|
||||||
T.h stlmacros.h ../auto.h
|
T.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -390,6 +390,4 @@ TDB.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ rules.o rules.o: rules.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.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/stl_bvector.h \
|
||||||
/usr/include/c++/4.0.0/bits/vector.tcc Table.h color.h Grid.h Date.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 stlmacros.h ../auto.h
|
T.h task.h /usr/include/sys/types.h color.h TDB.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -389,6 +389,4 @@ color.h:
|
|||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ task.o task.o: task.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.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/stl_bvector.h \
|
||||||
/usr/include/c++/4.0.0/bits/vector.tcc Date.h Table.h color.h Grid.h \
|
/usr/include/c++/4.0.0/bits/vector.tcc Date.h Table.h color.h Grid.h \
|
||||||
stlmacros.h TDB.h T.h task.h color.h ../auto.h /usr/include/ncurses.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/ncurses_dll.h /usr/include/unctrl.h /usr/include/curses.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
@@ -398,8 +398,6 @@ color.h:
|
|||||||
|
|
||||||
Grid.h:
|
Grid.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.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/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_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.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
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -387,6 +387,4 @@ TDB.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ util.o util.o: util.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_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h color.h Grid.h task.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 stlmacros.h ../auto.h \
|
Config.h color.h TDB.h T.h ../auto.h /usr/include/uuid/uuid.h
|
||||||
/usr/include/uuid/uuid.h
|
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -391,8 +390,6 @@ TDB.h:
|
|||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
stlmacros.h:
|
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|
||||||
/usr/include/uuid/uuid.h:
|
/usr/include/uuid/uuid.h:
|
||||||
|
|||||||
2
src/.gitignore
vendored
2
src/.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
Makefile
|
./Makefile
|
||||||
*.o
|
*.o
|
||||||
|
|||||||
@@ -1,12 +1,34 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// 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 <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
@@ -35,7 +57,7 @@ bool Config::load (const std::string& file)
|
|||||||
while (getline (in, line))
|
while (getline (in, line))
|
||||||
{
|
{
|
||||||
// Remove comments.
|
// Remove comments.
|
||||||
unsigned int pound = line.find ("#");
|
size_type pound = line.find ("#");
|
||||||
if (pound != std::string::npos)
|
if (pound != std::string::npos)
|
||||||
line = line.substr (0, pound);
|
line = line.substr (0, pound);
|
||||||
|
|
||||||
@@ -44,7 +66,7 @@ bool Config::load (const std::string& file)
|
|||||||
// Skip empty lines.
|
// Skip empty lines.
|
||||||
if (line.length () > 0)
|
if (line.length () > 0)
|
||||||
{
|
{
|
||||||
unsigned int equal = line.find ("=");
|
size_type equal = line.find ("=");
|
||||||
if (equal != std::string::npos)
|
if (equal != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string key = trim (line.substr (0, equal), " \t");
|
std::string key = trim (line.substr (0, equal), " \t");
|
||||||
@@ -85,6 +107,7 @@ void Config::createDefault (const std::string& file)
|
|||||||
|
|
||||||
if (taskDir != "")
|
if (taskDir != "")
|
||||||
{
|
{
|
||||||
|
// Create a sample .taskrc file.
|
||||||
FILE* out;
|
FILE* out;
|
||||||
if ((out = fopen (file.c_str (), "w")))
|
if ((out = fopen (file.c_str (), "w")))
|
||||||
{
|
{
|
||||||
@@ -96,20 +119,24 @@ void Config::createDefault (const std::string& file)
|
|||||||
fprintf (out, "curses=on\n");
|
fprintf (out, "curses=on\n");
|
||||||
fprintf (out, "color=on\n");
|
fprintf (out, "color=on\n");
|
||||||
|
|
||||||
fprintf (out, "color.overdue=red\n");
|
fprintf (out, "color.overdue=bold_red\n");
|
||||||
fprintf (out, "#color.due=on yellow\n");
|
fprintf (out, "#color.due=on_bright_yellow\n");
|
||||||
fprintf (out, "#color.pri.H=on_red\n");
|
fprintf (out, "#color.pri.H=on_red\n");
|
||||||
fprintf (out, "#color.pri.M=on_yellow\n");
|
fprintf (out, "#color.pri.M=on_yellow\n");
|
||||||
fprintf (out, "#color.pri.L=on_green\n");
|
fprintf (out, "#color.pri.L=on_green\n");
|
||||||
fprintf (out, "color.active=cyan\n");
|
fprintf (out, "color.active=bold_cyan\n");
|
||||||
fprintf (out, "color.tagged=yellow\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);
|
fclose (out);
|
||||||
|
|
||||||
|
// Now set the live values.
|
||||||
set ("data.location", taskDir);
|
set ("data.location", taskDir);
|
||||||
set ("command.logging", "off");
|
set ("command.logging", "off");
|
||||||
set ("confirmation", "yes");
|
set ("confirmation", "yes");
|
||||||
set ("next", 2);
|
set ("next", 1);
|
||||||
set ("curses", "on");
|
set ("curses", "on");
|
||||||
set ("color", "on");
|
set ("color", "on");
|
||||||
set ("color.overdue", "red");
|
set ("color.overdue", "red");
|
||||||
|
|||||||
23
src/Config.h
23
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
|
#ifndef INCLUDED_CONFIG
|
||||||
|
|||||||
252
src/Date.cpp
252
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 <iostream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "Date.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 ("/");
|
int month = 0;
|
||||||
unsigned int secondSlash = mdy.find ("/", firstSlash + 1);
|
int day = 0;
|
||||||
if (firstSlash != std::string::npos &&
|
int year = 0;
|
||||||
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.";
|
|
||||||
|
|
||||||
// Duplicate Date::Date (const int, const int, const int);
|
unsigned int i = 0; // Index into mdy.
|
||||||
struct tm t = {0};
|
|
||||||
t.tm_mday = d;
|
for (unsigned int f = 0; f < format.length (); ++f)
|
||||||
t.tm_mon = m - 1;
|
{
|
||||||
t.tm_year = y - 1900;
|
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);
|
mT = mktime (&t);
|
||||||
}
|
|
||||||
else
|
|
||||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -93,20 +221,68 @@ void Date::toMDY (int& m, int& d, int& y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Date::toString (std::string& output)
|
std::string Date::toString (const std::string& format /*= "m/d/Y"*/)
|
||||||
{
|
{
|
||||||
output = toString ();
|
std::string formatted;
|
||||||
}
|
for (unsigned int i = 0; i < format.length (); ++i)
|
||||||
|
{
|
||||||
|
switch (format[i])
|
||||||
|
{
|
||||||
|
case 'm':
|
||||||
|
{
|
||||||
|
char m[3];
|
||||||
|
sprintf (m, "%d", this->month ());
|
||||||
|
formatted += m;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
case 'M':
|
||||||
std::string Date::toString (void)
|
{
|
||||||
{
|
char m[3];
|
||||||
int m, d, y;
|
sprintf (m, "%02d", this->month ());
|
||||||
toMDY (m, d, y);
|
formatted += m;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
char formatted [11];
|
case 'd':
|
||||||
sprintf (formatted, "%d/%d/%d", m, d, y);
|
{
|
||||||
return std::string (formatted);
|
char d[3];
|
||||||
|
sprintf (d, "%d", this->day ());
|
||||||
|
formatted += d;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
{
|
||||||
|
char d[3];
|
||||||
|
sprintf (d, "%02d", this->day ());
|
||||||
|
formatted += d;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'y':
|
||||||
|
{
|
||||||
|
char y[3];
|
||||||
|
sprintf (y, "%02d", this->year () % 100);
|
||||||
|
formatted += y;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Y':
|
||||||
|
{
|
||||||
|
char y[5];
|
||||||
|
sprintf (y, "%d", this->year ());
|
||||||
|
formatted += y;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
formatted += format[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -155,7 +331,7 @@ int Date::daysInMonth (int month, int year)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Date::monthName (int month)
|
std::string Date::monthName (int month)
|
||||||
{
|
{
|
||||||
static char* months[12] =
|
static const char* months[12] =
|
||||||
{
|
{
|
||||||
"January",
|
"January",
|
||||||
"February",
|
"February",
|
||||||
@@ -179,7 +355,7 @@ std::string Date::monthName (int month)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Date::dayName (int dow, std::string& name)
|
void Date::dayName (int dow, std::string& name)
|
||||||
{
|
{
|
||||||
static char* days[7] =
|
static const char* days[7] =
|
||||||
{
|
{
|
||||||
"Sunday",
|
"Sunday",
|
||||||
"Monday",
|
"Monday",
|
||||||
@@ -196,7 +372,7 @@ void Date::dayName (int dow, std::string& name)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Date::dayName (int dow)
|
std::string Date::dayName (int dow)
|
||||||
{
|
{
|
||||||
static char* days[7] =
|
static const char* days[7] =
|
||||||
{
|
{
|
||||||
"Sunday",
|
"Sunday",
|
||||||
"Monday",
|
"Monday",
|
||||||
@@ -211,28 +387,28 @@ std::string Date::dayName (int dow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Date::dayOfWeek ()
|
int Date::dayOfWeek () const
|
||||||
{
|
{
|
||||||
struct tm* t = localtime (&mT);
|
struct tm* t = localtime (&mT);
|
||||||
return t->tm_wday;
|
return t->tm_wday;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Date::month ()
|
int Date::month () const
|
||||||
{
|
{
|
||||||
struct tm* t = localtime (&mT);
|
struct tm* t = localtime (&mT);
|
||||||
return t->tm_mon + 1;
|
return t->tm_mon + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Date::day ()
|
int Date::day () const
|
||||||
{
|
{
|
||||||
struct tm* t = localtime (&mT);
|
struct tm* t = localtime (&mT);
|
||||||
return t->tm_mday;
|
return t->tm_mday;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Date::year ()
|
int Date::year () const
|
||||||
{
|
{
|
||||||
struct tm* t = localtime (&mT);
|
struct tm* t = localtime (&mT);
|
||||||
return t->tm_year + 1900;
|
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
|
#ifndef INCLUDED_DATE
|
||||||
@@ -16,15 +37,14 @@ public:
|
|||||||
Date ();
|
Date ();
|
||||||
Date (time_t);
|
Date (time_t);
|
||||||
Date (const int, const int, const int);
|
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&);
|
Date (const Date&);
|
||||||
virtual ~Date ();
|
virtual ~Date ();
|
||||||
|
|
||||||
void toEpoch (time_t&);
|
void toEpoch (time_t&);
|
||||||
time_t toEpoch ();
|
time_t toEpoch ();
|
||||||
void toMDY (int&, int&, int&);
|
void toMDY (int&, int&, int&);
|
||||||
void toString (std::string&);
|
std::string toString (const std::string& format = "m/d/Y");
|
||||||
std::string toString (void);
|
|
||||||
static bool valid (const int, const int, const int);
|
static bool valid (const int, const int, const int);
|
||||||
|
|
||||||
static bool leapYear (int);
|
static bool leapYear (int);
|
||||||
@@ -32,11 +52,11 @@ public:
|
|||||||
static std::string monthName (int);
|
static std::string monthName (int);
|
||||||
static void dayName (int, std::string&);
|
static void dayName (int, std::string&);
|
||||||
static std::string dayName (int);
|
static std::string dayName (int);
|
||||||
int dayOfWeek ();
|
int dayOfWeek () const;
|
||||||
|
|
||||||
int month ();
|
int month () const;
|
||||||
int day ();
|
int day () const;
|
||||||
int year ();
|
int year () const;
|
||||||
|
|
||||||
bool operator== (const Date&);
|
bool operator== (const Date&);
|
||||||
bool operator!= (const Date&);
|
bool operator!= (const Date&);
|
||||||
|
|||||||
64
src/Grid.cpp
64
src/Grid.cpp
@@ -1,5 +1,29 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// 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
|
||||||
|
//
|
||||||
|
//
|
||||||
//
|
//
|
||||||
// Grid implements a sparse 2D array of Cell objects. Grid makes every effort
|
// 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,
|
// to perform well on cell insertion and retrieval. A Cell is a variant type,
|
||||||
@@ -145,9 +169,9 @@ unsigned int Grid::height () const
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Grid::Cell* Grid::byRow (const unsigned int row, const unsigned int col) const
|
Grid::Cell* Grid::byRow (const unsigned int row, const unsigned int col) const
|
||||||
{
|
{
|
||||||
if (row <= mRows.size () &&
|
if (row < mRows.size () &&
|
||||||
mRows[row] != NULL &&
|
mRows[row] != NULL &&
|
||||||
col <= mRows[row]->size ())
|
col < mRows[row]->size ())
|
||||||
return (*mRows[row])[col];
|
return (*mRows[row])[col];
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -155,9 +179,9 @@ Grid::Cell* Grid::byRow (const unsigned int row, const unsigned int col) const
|
|||||||
|
|
||||||
Grid::Cell* Grid::byColumn (const unsigned int row, const unsigned int col) const
|
Grid::Cell* Grid::byColumn (const unsigned int row, const unsigned int col) const
|
||||||
{
|
{
|
||||||
if (col <= mColumns.size () &&
|
if (col < mColumns.size () &&
|
||||||
mColumns[col] != NULL &&
|
mColumns[col] != NULL &&
|
||||||
row <= mColumns[col]->size ())
|
row < mColumns[col]->size ())
|
||||||
return (*mColumns[col])[row];
|
return (*mColumns[col])[row];
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -166,36 +190,25 @@ Grid::Cell* Grid::byColumn (const unsigned int row, const unsigned int col) cons
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Grid::expandGrid (const unsigned int row, const unsigned int col)
|
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
|
// If the new row is outside the bounds of the current grid, add blank rows to
|
||||||
// pad, then a new row vector.
|
// pad, then a new row vector.
|
||||||
if (row >= mRows.size ())
|
if (row >= mRows.size ())
|
||||||
{
|
{
|
||||||
for (unsigned int r = mRows.size (); r <= row; ++r)
|
for (unsigned int r = mRows.size (); r <= row; ++r)
|
||||||
if (r < row)
|
if (r < row)
|
||||||
// {
|
|
||||||
// std::cout << "additional mRows[" << r << "] = NULL" << std::endl;
|
|
||||||
mRows.push_back (NULL);
|
mRows.push_back (NULL);
|
||||||
// }
|
|
||||||
else
|
else
|
||||||
// {
|
|
||||||
// std::cout << "additional mRows[" << r << "] = new std::vector <Cell*>" << std::endl;
|
|
||||||
mRows.push_back (new std::vector <Cell*>);
|
mRows.push_back (new std::vector <Cell*>);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// If the new row is within the bounds of the current grid, ensure that the
|
// If the new row is within the bounds of the current grid, ensure that the
|
||||||
// row points to a vector of cells.
|
// row points to a vector of cells.
|
||||||
else if (mRows[row] == NULL)
|
else if (mRows[row] == NULL)
|
||||||
// {
|
|
||||||
// std::cout << "existing mRows[" << row << "] = new std::vector <Cell*>" << std::endl;
|
|
||||||
mRows[row] = new std::vector <Cell*>;
|
mRows[row] = new std::vector <Cell*>;
|
||||||
// }
|
|
||||||
|
|
||||||
if (col >= mRows[row]->size ())
|
if (col >= mRows[row]->size ())
|
||||||
for (unsigned int c = mRows[row]->size (); c <= col; ++c)
|
for (unsigned int c = mRows[row]->size (); c <= col; ++c)
|
||||||
// {
|
|
||||||
// std::cout << "additional mRows[" << row << "][" << c << "] = NULL" << std::endl;
|
|
||||||
mRows[row]->push_back (NULL);
|
mRows[row]->push_back (NULL);
|
||||||
// }
|
|
||||||
|
|
||||||
// If the new col is outside the bounds of the current grid, add blank cols to
|
// If the new col is outside the bounds of the current grid, add blank cols to
|
||||||
// pad, then a new col vector.
|
// pad, then a new col vector.
|
||||||
@@ -203,30 +216,18 @@ void Grid::expandGrid (const unsigned int row, const unsigned int col)
|
|||||||
{
|
{
|
||||||
for (unsigned int c = mColumns.size (); c <= col; ++c)
|
for (unsigned int c = mColumns.size (); c <= col; ++c)
|
||||||
if (c < col)
|
if (c < col)
|
||||||
// {
|
|
||||||
// std::cout << "additional mColumns[" << c << "] = NULL" << std::endl;
|
|
||||||
mColumns.push_back (NULL);
|
mColumns.push_back (NULL);
|
||||||
// }
|
|
||||||
else
|
else
|
||||||
// {
|
|
||||||
// std::cout << "additional mColumns[" << c << "] = new std::vector <Cell*>" << std::endl;
|
|
||||||
mColumns.push_back (new std::vector <Cell*>);
|
mColumns.push_back (new std::vector <Cell*>);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// If the new col is within the bounds of the current grid, ensure that the
|
// If the new col is within the bounds of the current grid, ensure that the
|
||||||
// col points to a vector of cells.
|
// col points to a vector of cells.
|
||||||
else if (mColumns[col] == NULL)
|
else if (mColumns[col] == NULL)
|
||||||
// {
|
|
||||||
// std::cout << "existing mColumns[" << col << "] = new std::vector <Cell*>" << std::endl;
|
|
||||||
mColumns[col] = new std::vector <Cell*>;
|
mColumns[col] = new std::vector <Cell*>;
|
||||||
// }
|
|
||||||
|
|
||||||
if (row >= mColumns[col]->size ())
|
if (row >= mColumns[col]->size ())
|
||||||
for (unsigned int r = mColumns[col]->size (); r <= row; ++r)
|
for (unsigned int r = mColumns[col]->size (); r <= row; ++r)
|
||||||
// {
|
|
||||||
// std::cout << "additional mColumns[" << col << "][" << r << "] = NULL" << std::endl;
|
|
||||||
mColumns[col]->push_back (NULL);
|
mColumns[col]->push_back (NULL);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -237,15 +238,10 @@ void Grid::insertCell (
|
|||||||
{
|
{
|
||||||
// Delete any existing cell, because cells are owned by rows, not columns.
|
// Delete any existing cell, because cells are owned by rows, not columns.
|
||||||
if ((*mRows[row])[col] != NULL)
|
if ((*mRows[row])[col] != NULL)
|
||||||
// {
|
|
||||||
// std::cout << "deleted old cell mRows[" << row << "][" << col << "]" << std::endl;
|
|
||||||
delete (*mRows[row])[col];
|
delete (*mRows[row])[col];
|
||||||
// }
|
|
||||||
|
|
||||||
(*mRows[row])[col] = cell;
|
(*mRows[row])[col] = cell;
|
||||||
(*mColumns[col])[row] = cell;
|
(*mColumns[col])[row] = cell;
|
||||||
// std::cout << "assigned new cell mRows[" << row << "][" << col << "]" << std::endl;
|
|
||||||
// std::cout << "assigned new cell mColumns[" << col << "][" << row << "]" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
23
src/Grid.h
23
src/Grid.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_GRID
|
#ifndef INCLUDED_GRID
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
bin_PROGRAMS = task
|
bin_PROGRAMS = task
|
||||||
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 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
|
AM_CPPFLAGS = -Wall -pedantic -ggdb3 -fno-rtti
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ sysconfdir = @sysconfdir@
|
|||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
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 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
|
AM_CPPFLAGS = -Wall -pedantic -ggdb3 -fno-rtti
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
|
|||||||
65
src/T.cpp
65
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>
|
#include <iostream>
|
||||||
@@ -115,7 +136,7 @@ void T::addTag (const std::string& tag)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void T::addTags (const std::vector <std::string>& tags)
|
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)
|
if (tags[i].find (' ') != std::string::npos)
|
||||||
throw std::string ("T::addTags - tags may not contain spaces");
|
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)
|
void T::removeTag (const std::string& tag)
|
||||||
{
|
{
|
||||||
std::vector <std::string> copy;
|
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)
|
if (mTags[i] != tag)
|
||||||
copy.push_back (mTags[i]);
|
copy.push_back (mTags[i]);
|
||||||
|
|
||||||
@@ -242,7 +263,7 @@ const std::string T::compose () const
|
|||||||
else if (mStatus == deleted) line += "X [";
|
else if (mStatus == deleted) line += "X [";
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
for (unsigned int i = 0; i < mTags.size (); ++i)
|
for (size_t i = 0; i < mTags.size (); ++i)
|
||||||
{
|
{
|
||||||
line += (i > 0 ? " " : "");
|
line += (i > 0 ? " " : "");
|
||||||
line += mTags[i];
|
line += mTags[i];
|
||||||
@@ -254,20 +275,8 @@ const std::string T::compose () const
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (i, mAttributes)
|
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 += (count > 0 ? " " : "");
|
||||||
line += i->first + ":" + converted;
|
line += i->first + ":" + i->second;
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@@ -297,7 +306,7 @@ const std::string T::composeCSV ()
|
|||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
line += "'";
|
line += "'";
|
||||||
for (unsigned int i = 0; i < mTags.size (); ++i)
|
for (size_t i = 0; i < mTags.size (); ++i)
|
||||||
{
|
{
|
||||||
line += (i > 0 ? " " : "");
|
line += (i > 0 ? " " : "");
|
||||||
line += mTags[i];
|
line += mTags[i];
|
||||||
@@ -364,13 +373,13 @@ void T::parse (const std::string& line)
|
|||||||
if (line[0] == 'X')
|
if (line[0] == 'X')
|
||||||
setStatus (deleted);
|
setStatus (deleted);
|
||||||
|
|
||||||
unsigned int openTagBracket = line.find ("[");
|
size_t openTagBracket = line.find ("[");
|
||||||
unsigned int closeTagBracket = line.find ("]", openTagBracket);
|
size_t closeTagBracket = line.find ("]", openTagBracket);
|
||||||
if (openTagBracket != std::string::npos &&
|
if (openTagBracket != std::string::npos &&
|
||||||
closeTagBracket != std::string::npos)
|
closeTagBracket != std::string::npos)
|
||||||
{
|
{
|
||||||
unsigned int openAttrBracket = line.find ("[", closeTagBracket);
|
size_t openAttrBracket = line.find ("[", closeTagBracket);
|
||||||
unsigned int closeAttrBracket = line.find ("]", openAttrBracket);
|
size_t closeAttrBracket = line.find ("]", openAttrBracket);
|
||||||
if (openAttrBracket != std::string::npos &&
|
if (openAttrBracket != std::string::npos &&
|
||||||
closeAttrBracket != std::string::npos)
|
closeAttrBracket != std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -383,7 +392,7 @@ void T::parse (const std::string& line)
|
|||||||
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
|
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
|
||||||
std::vector <std::string> pairs;
|
std::vector <std::string> pairs;
|
||||||
split (pairs, attributes, ' ');
|
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;
|
std::vector <std::string> pair;
|
||||||
split (pair, pairs[i], ':');
|
split (pair, pairs[i], ':');
|
||||||
@@ -415,13 +424,13 @@ void T::parse (const std::string& line)
|
|||||||
: line[37] == 'X' ? deleted
|
: line[37] == 'X' ? deleted
|
||||||
: pending;
|
: pending;
|
||||||
|
|
||||||
unsigned int openTagBracket = line.find ("[");
|
size_t openTagBracket = line.find ("[");
|
||||||
unsigned int closeTagBracket = line.find ("]", openTagBracket);
|
size_t closeTagBracket = line.find ("]", openTagBracket);
|
||||||
if (openTagBracket != std::string::npos &&
|
if (openTagBracket != std::string::npos &&
|
||||||
closeTagBracket != std::string::npos)
|
closeTagBracket != std::string::npos)
|
||||||
{
|
{
|
||||||
unsigned int openAttrBracket = line.find ("[", closeTagBracket);
|
size_t openAttrBracket = line.find ("[", closeTagBracket);
|
||||||
unsigned int closeAttrBracket = line.find ("]", openAttrBracket);
|
size_t closeAttrBracket = line.find ("]", openAttrBracket);
|
||||||
if (openAttrBracket != std::string::npos &&
|
if (openAttrBracket != std::string::npos &&
|
||||||
closeAttrBracket != std::string::npos)
|
closeAttrBracket != std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -434,7 +443,7 @@ void T::parse (const std::string& line)
|
|||||||
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
|
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
|
||||||
std::vector <std::string> pairs;
|
std::vector <std::string> pairs;
|
||||||
split (pairs, attributes, ' ');
|
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;
|
std::vector <std::string> pair;
|
||||||
split (pair, pairs[i], ':');
|
split (pair, pairs[i], ':');
|
||||||
|
|||||||
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
|
#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 <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "TDB.h"
|
#include "TDB.h"
|
||||||
@@ -221,7 +243,6 @@ bool TDB::addT (const T& t) const
|
|||||||
std::vector <std::string> tags;
|
std::vector <std::string> tags;
|
||||||
task.getTags (tags);
|
task.getTags (tags);
|
||||||
|
|
||||||
// TODO This logic smells funny.
|
|
||||||
// +tag or -tag are both considered valid tags to add to a new pending task.
|
// +tag or -tag are both considered valid tags to add to a new pending task.
|
||||||
// Generating an error here would not be friendly.
|
// Generating an error here would not be friendly.
|
||||||
for (unsigned int i = 0; i < tags.size (); ++i)
|
for (unsigned int i = 0; i < tags.size (); ++i)
|
||||||
@@ -306,7 +327,7 @@ bool TDB::logCommand (int argc, char** argv) const
|
|||||||
delay (0.25);
|
delay (0.25);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fprintf (out, command.c_str ());
|
fputs (command.c_str (), out);
|
||||||
|
|
||||||
fclose (out);
|
fclose (out);
|
||||||
return true;
|
return true;
|
||||||
@@ -341,7 +362,7 @@ bool TDB::overwritePending (std::vector <T>& all) const
|
|||||||
|
|
||||||
std::vector <T>::iterator it;
|
std::vector <T>::iterator it;
|
||||||
for (it = all.begin (); it != all.end (); ++it)
|
for (it = all.begin (); it != all.end (); ++it)
|
||||||
fprintf (out, it->compose ().c_str ());
|
fputs (it->compose ().c_str (), out);
|
||||||
|
|
||||||
fclose (out);
|
fclose (out);
|
||||||
return true;
|
return true;
|
||||||
@@ -363,7 +384,7 @@ bool TDB::writePending (const T& t) const
|
|||||||
delay (0.25);
|
delay (0.25);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fprintf (out, t.compose ().c_str ());
|
fputs (t.compose ().c_str (), out);
|
||||||
|
|
||||||
fclose (out);
|
fclose (out);
|
||||||
return true;
|
return true;
|
||||||
@@ -385,7 +406,7 @@ bool TDB::writeCompleted (const T& t) const
|
|||||||
delay (0.25);
|
delay (0.25);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fprintf (out, t.compose ().c_str ());
|
fputs (t.compose ().c_str (), out);
|
||||||
|
|
||||||
fclose (out);
|
fclose (out);
|
||||||
return true;
|
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
|
#ifndef INCLUDED_TDB
|
||||||
|
|||||||
121
src/Table.cpp
121
src/Table.cpp
@@ -1,7 +1,29 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// task - a command line task list manager.
|
||||||
|
//
|
||||||
// Copyright 2006 - 2008, Paul Beckingham.
|
// Copyright 2006 - 2008, Paul Beckingham.
|
||||||
// All rights reserved.
|
// 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
|
// Attributes Table Row Column Cell
|
||||||
// ----------------------------------------------------
|
// ----------------------------------------------------
|
||||||
@@ -22,10 +44,11 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <Table.h>
|
#include <Table.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <task.h>
|
#include <task.h>
|
||||||
#include <stlmacros.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Table::Table ()
|
Table::Table ()
|
||||||
@@ -415,7 +438,7 @@ void Table::calculateColumnWidths ()
|
|||||||
std::vector <int> ideal = mMaxDataWidth;
|
std::vector <int> ideal = mMaxDataWidth;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int countFlexible = 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)
|
if (mSpecifiedWidth[c] == flexible)
|
||||||
++countFlexible;
|
++countFlexible;
|
||||||
@@ -440,7 +463,7 @@ void Table::calculateColumnWidths ()
|
|||||||
{
|
{
|
||||||
ideal = mMaxDataWidth;
|
ideal = mMaxDataWidth;
|
||||||
width = 0;
|
width = 0;
|
||||||
for (unsigned int c = 0; c < mColumns.size (); ++c)
|
for (size_t c = 0; c < mColumns.size (); ++c)
|
||||||
{
|
{
|
||||||
if (mSpecifiedWidth[c] > 0)
|
if (mSpecifiedWidth[c] > 0)
|
||||||
ideal[c] = mSpecifiedWidth[c];
|
ideal[c] = mSpecifiedWidth[c];
|
||||||
@@ -462,7 +485,7 @@ void Table::calculateColumnWidths ()
|
|||||||
int remainder = available % countFlexible;
|
int remainder = available % countFlexible;
|
||||||
|
|
||||||
int lastFlexible = mColumns.size () - 1;
|
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)
|
if (mSpecifiedWidth[c] == flexible)
|
||||||
{
|
{
|
||||||
@@ -593,7 +616,7 @@ void Table::formatCell (
|
|||||||
std::string postJust;
|
std::string postJust;
|
||||||
std::vector <std::string> chunks;
|
std::vector <std::string> chunks;
|
||||||
wrapText (chunks, data, width);
|
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.
|
// Place the data within the available space - justify.
|
||||||
int gap = width - chunks[chunk].length ();
|
int gap = width - chunks[chunk].length ();
|
||||||
@@ -614,7 +637,7 @@ void Table::formatCell (
|
|||||||
for (int i = 0; i < gap / 2; ++i)
|
for (int i = 0; i < gap / 2; ++i)
|
||||||
preJust += " ";
|
preJust += " ";
|
||||||
|
|
||||||
for (unsigned int i = 0; i < gap - preJust.length (); ++i)
|
for (size_t i = 0; i < gap - preJust.length (); ++i)
|
||||||
postJust += " ";
|
postJust += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,63 +653,18 @@ void Table::formatCell (
|
|||||||
blank = Text::colorize (fg, bg, pad + intraPad);
|
blank = Text::colorize (fg, bg, pad + intraPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
const std::string Table::formatCell (
|
|
||||||
const int row,
|
|
||||||
const int col,
|
|
||||||
const int width,
|
|
||||||
const 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 pad = "";
|
|
||||||
std::string intraPad = "";
|
|
||||||
std::string preJust = "";
|
|
||||||
std::string postJust = "";
|
|
||||||
|
|
||||||
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 Text::colorize (fg, bg, pad + preJust + data + postJust + pad + intraPad);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::suppressWS ()
|
void Table::suppressWS ()
|
||||||
{
|
{
|
||||||
mSuppressWS = true;
|
mSuppressWS = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Table::setDateFormat (const std::string& dateFormat)
|
||||||
|
{
|
||||||
|
mDateFormat = dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Table::rowCount ()
|
int Table::rowCount ()
|
||||||
{
|
{
|
||||||
@@ -706,15 +684,15 @@ int Table::columnCount ()
|
|||||||
// - removal of redundant color codes:
|
// - removal of redundant color codes:
|
||||||
// ^[[31mName^[[0m ^[[31mValue^[[0m -> ^[[31mName Value^[[0m
|
// ^[[31mName^[[0m ^[[31mValue^[[0m -> ^[[31mName Value^[[0m
|
||||||
//
|
//
|
||||||
|
// This method is a work in progress.
|
||||||
void Table::optimize (std::string& output)
|
void Table::optimize (std::string& output)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
TODO Unoptimized length.
|
|
||||||
int start = output.length ();
|
int start = output.length ();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// \s\n -> \n
|
// \s\n -> \n
|
||||||
unsigned int i = 0;
|
size_t i = 0;
|
||||||
while ((i = output.find (" \n")) != std::string::npos)
|
while ((i = output.find (" \n")) != std::string::npos)
|
||||||
{
|
{
|
||||||
output = output.substr (0, i) +
|
output = output.substr (0, i) +
|
||||||
@@ -722,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::cout << int ((100 * (start - output.length ()) / start))
|
||||||
<< "%" << std::endl;
|
<< "%" << std::endl;
|
||||||
*/
|
*/
|
||||||
@@ -757,7 +734,7 @@ void Table::sort (std::vector <int>& order)
|
|||||||
while (r + gap < (int) order.size ())
|
while (r + gap < (int) order.size ())
|
||||||
{
|
{
|
||||||
bool keepScanning = true;
|
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;
|
keepScanning = false;
|
||||||
|
|
||||||
@@ -800,8 +777,8 @@ void Table::sort (std::vector <int>& order)
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Date dl ((std::string)*left);
|
Date dl ((std::string)*left, mDateFormat);
|
||||||
Date dr ((std::string)*right);
|
Date dr ((std::string)*right, mDateFormat);
|
||||||
if (dl > dr)
|
if (dl > dr)
|
||||||
SWAP
|
SWAP
|
||||||
}
|
}
|
||||||
@@ -818,8 +795,8 @@ void Table::sort (std::vector <int>& order)
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Date dl ((std::string)*left);
|
Date dl ((std::string)*left, mDateFormat);
|
||||||
Date dr ((std::string)*right);
|
Date dr ((std::string)*right, mDateFormat);
|
||||||
if (dl < dr)
|
if (dl < dr)
|
||||||
SWAP
|
SWAP
|
||||||
}
|
}
|
||||||
@@ -855,8 +832,8 @@ void Table::sort (std::vector <int>& order)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::clean (std::string& value)
|
void Table::clean (std::string& value)
|
||||||
{
|
{
|
||||||
unsigned int start = 0;
|
size_t start = 0;
|
||||||
unsigned int pos;
|
size_t pos;
|
||||||
while ((pos = value.find ('\t', start)) != std::string::npos)
|
while ((pos = value.find ('\t', start)) != std::string::npos)
|
||||||
{
|
{
|
||||||
value.replace (pos, 1, " ");
|
value.replace (pos, 1, " ");
|
||||||
@@ -884,7 +861,7 @@ const std::string Table::render ()
|
|||||||
|
|
||||||
// Print column headers in column order.
|
// Print column headers in column order.
|
||||||
std::string output;
|
std::string output;
|
||||||
for (unsigned int col = 0; col < mColumns.size (); ++col)
|
for (size_t col = 0; col < mColumns.size (); ++col)
|
||||||
output += formatHeader (
|
output += formatHeader (
|
||||||
col,
|
col,
|
||||||
mCalculatedWidth[col],
|
mCalculatedWidth[col],
|
||||||
@@ -907,8 +884,8 @@ const std::string Table::render ()
|
|||||||
std::vector <std::vector <std::string> > columns;
|
std::vector <std::vector <std::string> > columns;
|
||||||
std::vector <std::string> blanks;
|
std::vector <std::string> blanks;
|
||||||
|
|
||||||
unsigned int maxHeight = 0;
|
size_t maxHeight = 0;
|
||||||
for (unsigned int col = 0; col < mColumns.size (); ++col)
|
for (size_t col = 0; col < mColumns.size (); ++col)
|
||||||
{
|
{
|
||||||
std::vector <std::string> lines;
|
std::vector <std::string> lines;
|
||||||
std::string blank;
|
std::string blank;
|
||||||
@@ -928,9 +905,9 @@ const std::string Table::render ()
|
|||||||
|
|
||||||
if (maxHeight)
|
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 ())
|
if (lines < columns[col].size ())
|
||||||
output += columns[col][lines];
|
output += columns[col][lines];
|
||||||
else
|
else
|
||||||
|
|||||||
25
src/Table.h
25
src/Table.h
@@ -1,8 +1,28 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// task - a command line task list manager.
|
||||||
|
//
|
||||||
// Copyright 2006 - 2008, Paul Beckingham.
|
// Copyright 2006 - 2008, Paul Beckingham.
|
||||||
// All rights reserved.
|
// 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
|
#ifndef INCLUDED_TABLE
|
||||||
#define INCLUDED_TABLE
|
#define INCLUDED_TABLE
|
||||||
@@ -59,6 +79,7 @@ public:
|
|||||||
void setCellBg (int, int, Text::color);
|
void setCellBg (int, int, Text::color);
|
||||||
|
|
||||||
void suppressWS ();
|
void suppressWS ();
|
||||||
|
void setDateFormat (const std::string&);
|
||||||
|
|
||||||
int rowCount ();
|
int rowCount ();
|
||||||
int columnCount ();
|
int columnCount ();
|
||||||
@@ -77,7 +98,6 @@ private:
|
|||||||
just getJustification (const int, const int);
|
just getJustification (const int, const int);
|
||||||
just getHeaderJustification (const int);
|
just getHeaderJustification (const int);
|
||||||
const std::string formatHeader (const int, const int, const int);
|
const std::string formatHeader (const int, const int, const int);
|
||||||
const std::string formatCell (const int, const int, const int, const int);
|
|
||||||
void formatCell (const int, const int, const int, const int, std::vector <std::string>&, std::string&);
|
void formatCell (const int, const int, const int, const int, std::vector <std::string>&, std::string&);
|
||||||
void optimize (std::string&);
|
void optimize (std::string&);
|
||||||
void sort (std::vector <int>&);
|
void sort (std::vector <int>&);
|
||||||
@@ -109,6 +129,7 @@ private:
|
|||||||
|
|
||||||
// Misc...
|
// Misc...
|
||||||
bool mSuppressWS;
|
bool mSuppressWS;
|
||||||
|
std::string mDateFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,27 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// 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 <string>
|
||||||
|
|||||||
23
src/color.h
23
src/color.h
@@ -1,7 +1,28 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright 2008, Paul Beckingham.
|
// task - a command line task list manager.
|
||||||
|
//
|
||||||
|
// Copyright 2006 - 2008, Paul Beckingham.
|
||||||
// All rights reserved.
|
// 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
|
#ifndef INCLUDED_COLOR
|
||||||
#define INCLUDED_COLOR
|
#define INCLUDED_COLOR
|
||||||
|
|||||||
@@ -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 <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -13,7 +35,7 @@
|
|||||||
#include "T.h"
|
#include "T.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static char* colors[] =
|
static const char* colors[] =
|
||||||
{
|
{
|
||||||
"bold",
|
"bold",
|
||||||
"underline",
|
"underline",
|
||||||
@@ -75,7 +97,7 @@ static char* colors[] =
|
|||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* attributes[] =
|
static const char* attributes[] =
|
||||||
{
|
{
|
||||||
"project",
|
"project",
|
||||||
"priority",
|
"priority",
|
||||||
@@ -88,7 +110,7 @@ static char* attributes[] =
|
|||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* commands[] =
|
static const char* commands[] =
|
||||||
{
|
{
|
||||||
"active",
|
"active",
|
||||||
"add",
|
"add",
|
||||||
@@ -115,7 +137,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;
|
std::vector <std::string> options;
|
||||||
for (int i = 0; list[i][0]; ++i)
|
for (int i = 0; list[i][0]; ++i)
|
||||||
@@ -136,7 +158,7 @@ void guess (const std::string& type, char** list, std::string& candidate)
|
|||||||
error += " '";
|
error += " '";
|
||||||
error += candidate;
|
error += candidate;
|
||||||
error += "' - could be either of ";
|
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)
|
if (i)
|
||||||
error += ", ";
|
error += ", ";
|
||||||
@@ -163,29 +185,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 ("/");
|
Date test (date, conf.get ("dateformat", "m/d/Y"));
|
||||||
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.";
|
|
||||||
|
|
||||||
// Convert to epoch form.
|
char epoch[12];
|
||||||
Date dt (m, d, y);
|
sprintf (epoch, "%d", (int) test.toEpoch ());
|
||||||
time_t t;
|
date = epoch;
|
||||||
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");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -205,7 +211,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);
|
guess ("attribute", attributes, name);
|
||||||
|
|
||||||
@@ -213,7 +219,7 @@ static bool validAttribute (std::string& name, std::string& value)
|
|||||||
guess ("color", colors, value);
|
guess ("color", colors, value);
|
||||||
|
|
||||||
else if (name == "due" && value != "")
|
else if (name == "due" && value != "")
|
||||||
validDate (value);
|
validDate (value, conf);
|
||||||
|
|
||||||
else if (name == "priority")
|
else if (name == "priority")
|
||||||
{
|
{
|
||||||
@@ -236,7 +242,7 @@ static bool validAttribute (std::string& name, std::string& value)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static bool validId (const std::string& input)
|
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]))
|
if (!::isdigit (input[i]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -275,13 +281,13 @@ static bool validSubstitution (
|
|||||||
std::string& from,
|
std::string& from,
|
||||||
std::string& to)
|
std::string& to)
|
||||||
{
|
{
|
||||||
unsigned int first = input.find ('/');
|
size_t first = input.find ('/');
|
||||||
if (first != std::string::npos)
|
if (first != std::string::npos)
|
||||||
{
|
{
|
||||||
unsigned int second = input.find ('/', first + 1);
|
size_t second = input.find ('/', first + 1);
|
||||||
if (second != std::string::npos)
|
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 (third != std::string::npos)
|
||||||
{
|
{
|
||||||
if (first == 0 &&
|
if (first == 0 &&
|
||||||
@@ -313,15 +319,16 @@ static bool validSubstitution (
|
|||||||
void parse (
|
void parse (
|
||||||
std::vector <std::string>& args,
|
std::vector <std::string>& args,
|
||||||
std::string& command,
|
std::string& command,
|
||||||
T& task)
|
T& task,
|
||||||
|
Config& conf)
|
||||||
{
|
{
|
||||||
command = "";
|
command = "";
|
||||||
|
|
||||||
std::string descCandidate = "";
|
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]);
|
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 from;
|
||||||
std::string to;
|
std::string to;
|
||||||
|
|
||||||
@@ -347,7 +354,7 @@ void parse (
|
|||||||
std::string name = arg.substr (0, colon);
|
std::string name = arg.substr (0, colon);
|
||||||
std::string value = arg.substr (colon + 1, std::string::npos);
|
std::string value = arg.substr (colon + 1, std::string::npos);
|
||||||
|
|
||||||
if (validAttribute (name, value))
|
if (validAttribute (name, value, conf))
|
||||||
task.setAttribute (name, value);
|
task.setAttribute (name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
@@ -61,6 +83,7 @@ void initializeColorRules (Config& conf)
|
|||||||
void autoColorize (T& task, Text::color& fg, Text::color& bg)
|
void autoColorize (T& task, Text::color& fg, Text::color& bg)
|
||||||
{
|
{
|
||||||
// Note: fg, bg already contain colors specifically assigned via command.
|
// 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.
|
// Colorization of the tagged.
|
||||||
if (gsFg["color.tagged"] != Text::nocolor ||
|
if (gsFg["color.tagged"] != Text::nocolor ||
|
||||||
@@ -152,6 +175,50 @@ void autoColorize (T& task, Text::color& fg, Text::color& bg)
|
|||||||
bg = gsBg["color.due"];
|
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
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
611
src/task.cpp
611
src/task.cpp
File diff suppressed because it is too large
Load Diff
37
src/task.h
37
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,23 @@
|
|||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "TDB.h"
|
#include "TDB.h"
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
#include "stlmacros.h"
|
|
||||||
#include "../auto.h"
|
#include "../auto.h"
|
||||||
|
|
||||||
#ifndef max
|
#ifndef max
|
||||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define foreach(i, c) \
|
||||||
|
for (typeof (c) *foreach_p = & (c); \
|
||||||
|
foreach_p; \
|
||||||
|
foreach_p = 0) \
|
||||||
|
for (typeof (foreach_p->begin()) i = foreach_p->begin(); \
|
||||||
|
i != foreach_p->end(); \
|
||||||
|
++i)
|
||||||
|
|
||||||
// parse.cpp
|
// parse.cpp
|
||||||
void parse (std::vector <std::string>&, std::string&, T&);
|
void parse (std::vector <std::string>&, std::string&, T&, Config&);
|
||||||
bool validDate (std::string&);
|
bool validDate (std::string&, Config&);
|
||||||
|
|
||||||
// task.cpp
|
// task.cpp
|
||||||
void handleAdd (const TDB&, T&, Config&);
|
void handleAdd (const TDB&, T&, Config&);
|
||||||
@@ -69,6 +97,7 @@ int autoComplete (const std::string&, const std::vector<std::string>&, std::vect
|
|||||||
void formatTimeDeltaDays (std::string&, time_t);
|
void formatTimeDeltaDays (std::string&, time_t);
|
||||||
std::string formatSeconds (time_t);
|
std::string formatSeconds (time_t);
|
||||||
const std::string uuid ();
|
const std::string uuid ();
|
||||||
|
const char* optionalBlankLine (Config&);
|
||||||
|
|
||||||
// rules.cpp
|
// rules.cpp
|
||||||
void initializeColorRules (Config&);
|
void initializeColorRules (Config&);
|
||||||
|
|||||||
1
src/tests/.gitignore
vendored
1
src/tests/.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
t.t
|
t.t
|
||||||
tdb.t
|
tdb.t
|
||||||
|
date.t
|
||||||
pending.data
|
pending.data
|
||||||
completed.data
|
completed.data
|
||||||
|
|
||||||
|
|||||||
28
src/tests/Makefile
Normal file
28
src/tests/Makefile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
install: $(PROJECT)
|
||||||
|
@echo unimplemented
|
||||||
|
|
||||||
|
test: $(PROJECT)
|
||||||
|
@echo unimplemented
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm *.o $(PROJECT)
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
g++ -c $(CFLAGS) $<
|
||||||
|
|
||||||
|
t.t: t.t.o $(OBJECTS) test.o
|
||||||
|
g++ t.t.o $(OBJECTS) test.o $(LFLAGS) -o t.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,4 +1,27 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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 "../T.h"
|
||||||
|
|||||||
@@ -1,4 +1,27 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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 <iostream>
|
||||||
|
|||||||
@@ -1,11 +1,32 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// 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 <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <library.h>
|
#include <task.h>
|
||||||
|
|
||||||
static int total = 0;
|
static int total = 0;
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
|||||||
@@ -1,5 +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_TEST
|
#ifndef INCLUDED_TEST
|
||||||
|
|||||||
41
src/text.cpp
41
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>
|
#include <iostream>
|
||||||
@@ -8,6 +29,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
|
static const char* newline = "\n";
|
||||||
|
static const char* noline = "";
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void wrapText (
|
void wrapText (
|
||||||
std::vector <std::string>& lines,
|
std::vector <std::string>& lines,
|
||||||
@@ -76,8 +100,8 @@ void extractParagraphs (const std::string& input, std::vector<std::string>& outp
|
|||||||
std::string copy = input;
|
std::string copy = input;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
unsigned int so = copy.find ("<p>");
|
size_t so = copy.find ("<p>");
|
||||||
unsigned int eo = copy.find ("</p>");
|
size_t eo = copy.find ("</p>");
|
||||||
|
|
||||||
if (so == std::string::npos && eo == std::string::npos)
|
if (so == std::string::npos && eo == std::string::npos)
|
||||||
break;
|
break;
|
||||||
@@ -126,7 +150,7 @@ void unquoteText (std::string& text)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void extractLine (std::string& text, std::string& line, int length)
|
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.
|
// Special case: found \n in first length characters.
|
||||||
if (eol != std::string::npos && eol < (unsigned) length)
|
if (eol != std::string::npos && eol < (unsigned) length)
|
||||||
@@ -262,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;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
30
src/util.cpp
30
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>
|
#include <iostream>
|
||||||
@@ -10,6 +31,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "../auto.h"
|
#include "../auto.h"
|
||||||
@@ -160,14 +182,18 @@ const std::string uuid ()
|
|||||||
static char randomHexDigit ()
|
static char randomHexDigit ()
|
||||||
{
|
{
|
||||||
static char digits[] = "0123456789abcdef";
|
static char digits[] = "0123456789abcdef";
|
||||||
|
#ifdef HAVE_RANDOM
|
||||||
return digits[random () % 16];
|
return digits[random () % 16];
|
||||||
|
#else
|
||||||
|
return digits[rand () % 16];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const std::string uuid ()
|
const std::string uuid ()
|
||||||
{
|
{
|
||||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||||
char id [37];
|
char id [48] = {0};
|
||||||
id[0] = randomHexDigit ();
|
id[0] = randomHexDigit ();
|
||||||
id[1] = randomHexDigit ();
|
id[1] = randomHexDigit ();
|
||||||
id[2] = randomHexDigit ();
|
id[2] = randomHexDigit ();
|
||||||
|
|||||||
Reference in New Issue
Block a user