diff --git a/src/Context.cpp b/src/Context.cpp index cc9b0d8dd..7e9ac7384 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -32,15 +32,15 @@ #include #include #include -#include "Context.h" -#include "Directory.h" -#include "File.h" -#include "Timer.h" -#include "text.h" -#include "util.h" -#include "main.h" -#include "i18n.h" -#include "../cmake.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include <../cmake.h> //////////////////////////////////////////////////////////////////////////////// Context::Context () @@ -75,10 +75,17 @@ void Context::initialize2 (int argc, char** argv) // TODO Scan for rc: overrides --> apply. // TODO Combine command line into one string. // TODO Load relevant rc file. + // TODO Instantiate built-in command objects. + commands.push_back (Command::factory ("install")); + // TODO Instantiate extension command objects. // TODO Instantiate default command object. - // TODO Chain-of-command pattern dispatch. + // TODO Instantiate column objects. + // TODO Instantiate UDA objects. + // TODO Instantiate format objects. + // TODO Instantiate extension format objects. + // TODO Hook: on-launch } //////////////////////////////////////////////////////////////////////////////// @@ -237,7 +244,8 @@ int Context::dispatch (std::string &out) std::cout << "]0;task " << title << "" << std::endl; } - // TODO Just look at this thing. It cries out for a dispatch table. + // TODO Chain-of-command pattern dispatch. + if (cmd.command == "projects") { rc = handleProjects (out); } else if (cmd.command == "tags") { rc = handleTags (out); } else if (cmd.command == "colors") { rc = handleColor (out); } diff --git a/src/Context.h b/src/Context.h index 536f94d9d..45d19ac27 100644 --- a/src/Context.h +++ b/src/Context.h @@ -28,6 +28,7 @@ #define INCLUDED_CONTEXT #include +#include #include #include #include @@ -101,6 +102,7 @@ public: std::vector debugMessages; bool inShadow; + std::vector columns; std::vector commands; int terminal_width; diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index 797d4e084..2bd63b248 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -4,7 +4,8 @@ include_directories (${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/columns ${TASK_INCLUDE_DIRS}) -set (columns_SRCS Column.cpp Column.h) +set (columns_SRCS Column.cpp Column.h + ID.cpp ID.h) add_library (columns STATIC ${columns_SRCS}) diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index 9cd423784..8f1551011 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -45,11 +45,13 @@ Column* Column::factory (const std::string& name) //////////////////////////////////////////////////////////////////////////////// Column::Column () : _name ("") +/* , _minimum (0) , _maximum (0) , _wrap (false) , _just (left) , _sizing (minimal) +*/ { } @@ -57,11 +59,13 @@ Column::Column () Column::Column (const Column& other) { _name = other._name; +/* _minimum = other._minimum; _maximum = other._maximum; _wrap = other._wrap; _just = other._just; _sizing = other._sizing; +*/ } //////////////////////////////////////////////////////////////////////////////// @@ -70,11 +74,13 @@ Column& Column::operator= (const Column& other) if (this != &other) { _name = other._name; +/* _minimum = other._minimum; _maximum = other._maximum; _wrap = other._wrap; _just = other._just; _sizing = other._sizing; +*/ } return *this; @@ -83,12 +89,12 @@ Column& Column::operator= (const Column& other) //////////////////////////////////////////////////////////////////////////////// bool Column::operator== (const Column& other) const { - return _name == other._name && + return _name == other._name /*&& _minimum == other._minimum && _maximum == other._maximum && _wrap == other._wrap && _just == other._just && - _sizing == other._sizing; + _sizing == other._sizing*/; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.h b/src/columns/Column.h index c6887bab4..d811d8a82 100644 --- a/src/columns/Column.h +++ b/src/columns/Column.h @@ -28,12 +28,15 @@ #define INCLUDED_COLUMN #include +#include class Column { public: +/* enum just {right = 0, left, center}; enum sizing {minimal = 0, fixed, proportional, maximal}; +*/ static Column* factory (const std::string&); @@ -43,17 +46,19 @@ public: bool operator== (const Column&) const; // TODO Is this necessary? ~Column (); - void setName (const std::string&); - std::string render (Task*, int, int, const std::string style = "default"); - std::string type () const; + virtual void setName (const std::string&); + virtual std::string render (Task*, int, int, const std::string style = "default") = 0; + virtual std::string type () const = 0; -private: +protected: std::string _name; +/* int _minimum; int _maximum; bool _wrap; just _just; sizing _sizing; +*/ }; #endif diff --git a/src/columns/ID.cpp b/src/columns/ID.cpp new file mode 100644 index 000000000..a5dbb1aea --- /dev/null +++ b/src/columns/ID.cpp @@ -0,0 +1,59 @@ +//////////////////////////////////////////////////////////////////////////////// +// taskwarrior - a command line task list manager. +// +// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +// 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 +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +ColumnID::ColumnID () +{ + setName ("id"); +} + +//////////////////////////////////////////////////////////////////////////////// +ColumnID::~ColumnID () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +std::string ColumnID::render ( + Task* task, + int width, + int height, + const std::string style) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +std::string ColumnID::type () const +{ + return "number"; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ID.h b/src/columns/ID.h new file mode 100644 index 000000000..f055d98fd --- /dev/null +++ b/src/columns/ID.h @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// +// taskwarrior - a command line task list manager. +// +// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +// 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_ID +#define INCLUDED_ID + +#include +#include +#include + +class ColumnID : public Column +{ +public: + ColumnID (); + ~ColumnID (); + + std::string render (Task*, int, int, const std::string style = "default"); + std::string type () const; + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 4345d9d42..6e07e9db1 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -27,6 +27,7 @@ #include #include +#include #include extern Context context; @@ -34,11 +35,9 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// Command* Command::factory (const std::string& name) { -/* if (name == "install") return new Install (); throw std::string ("Unrecognized command '") + name + "'"; -*/ return NULL; } diff --git a/src/commands/Install.h b/src/commands/Install.h index c440b7942..525ec1de5 100644 --- a/src/commands/Install.h +++ b/src/commands/Install.h @@ -30,7 +30,7 @@ #include #include -class Install : Command +class Install : public Command { public: Install ();