mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement
- Began detailed implementation of commands and columns objects.
This commit is contained in:
parent
1c23b28514
commit
120562a7e9
9 changed files with 148 additions and 21 deletions
|
@ -32,15 +32,15 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include "Context.h"
|
#include <Context.h>
|
||||||
#include "Directory.h"
|
#include <Directory.h>
|
||||||
#include "File.h"
|
#include <File.h>
|
||||||
#include "Timer.h"
|
#include <Timer.h>
|
||||||
#include "text.h"
|
#include <text.h>
|
||||||
#include "util.h"
|
#include <util.h>
|
||||||
#include "main.h"
|
#include <main.h>
|
||||||
#include "i18n.h"
|
#include <i18n.h>
|
||||||
#include "../cmake.h"
|
#include <../cmake.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Context::Context ()
|
Context::Context ()
|
||||||
|
@ -75,10 +75,17 @@ void Context::initialize2 (int argc, char** argv)
|
||||||
// TODO Scan for rc:<file> overrides --> apply.
|
// TODO Scan for rc:<file> overrides --> apply.
|
||||||
// TODO Combine command line into one string.
|
// TODO Combine command line into one string.
|
||||||
// TODO Load relevant rc file.
|
// TODO Load relevant rc file.
|
||||||
|
|
||||||
// TODO Instantiate built-in command objects.
|
// TODO Instantiate built-in command objects.
|
||||||
|
commands.push_back (Command::factory ("install"));
|
||||||
|
|
||||||
// TODO Instantiate extension command objects.
|
// TODO Instantiate extension command objects.
|
||||||
// TODO Instantiate default command object.
|
// 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;
|
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); }
|
if (cmd.command == "projects") { rc = handleProjects (out); }
|
||||||
else if (cmd.command == "tags") { rc = handleTags (out); }
|
else if (cmd.command == "tags") { rc = handleTags (out); }
|
||||||
else if (cmd.command == "colors") { rc = handleColor (out); }
|
else if (cmd.command == "colors") { rc = handleColor (out); }
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#define INCLUDED_CONTEXT
|
#define INCLUDED_CONTEXT
|
||||||
|
|
||||||
#include <Command.h>
|
#include <Command.h>
|
||||||
|
#include <Column.h>
|
||||||
#include <Filter.h>
|
#include <Filter.h>
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <Sequence.h>
|
#include <Sequence.h>
|
||||||
|
@ -101,6 +102,7 @@ public:
|
||||||
std::vector <std::string> debugMessages;
|
std::vector <std::string> debugMessages;
|
||||||
bool inShadow;
|
bool inShadow;
|
||||||
|
|
||||||
|
std::vector <Column*> columns;
|
||||||
std::vector <Command*> commands;
|
std::vector <Command*> commands;
|
||||||
|
|
||||||
int terminal_width;
|
int terminal_width;
|
||||||
|
|
|
@ -4,7 +4,8 @@ include_directories (${CMAKE_SOURCE_DIR}/src
|
||||||
${CMAKE_SOURCE_DIR}/src/columns
|
${CMAKE_SOURCE_DIR}/src/columns
|
||||||
${TASK_INCLUDE_DIRS})
|
${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})
|
add_library (columns STATIC ${columns_SRCS})
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,13 @@ Column* Column::factory (const std::string& name)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Column::Column ()
|
Column::Column ()
|
||||||
: _name ("")
|
: _name ("")
|
||||||
|
/*
|
||||||
, _minimum (0)
|
, _minimum (0)
|
||||||
, _maximum (0)
|
, _maximum (0)
|
||||||
, _wrap (false)
|
, _wrap (false)
|
||||||
, _just (left)
|
, _just (left)
|
||||||
, _sizing (minimal)
|
, _sizing (minimal)
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,11 +59,13 @@ Column::Column ()
|
||||||
Column::Column (const Column& other)
|
Column::Column (const Column& other)
|
||||||
{
|
{
|
||||||
_name = other._name;
|
_name = other._name;
|
||||||
|
/*
|
||||||
_minimum = other._minimum;
|
_minimum = other._minimum;
|
||||||
_maximum = other._maximum;
|
_maximum = other._maximum;
|
||||||
_wrap = other._wrap;
|
_wrap = other._wrap;
|
||||||
_just = other._just;
|
_just = other._just;
|
||||||
_sizing = other._sizing;
|
_sizing = other._sizing;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -70,11 +74,13 @@ Column& Column::operator= (const Column& other)
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
_name = other._name;
|
_name = other._name;
|
||||||
|
/*
|
||||||
_minimum = other._minimum;
|
_minimum = other._minimum;
|
||||||
_maximum = other._maximum;
|
_maximum = other._maximum;
|
||||||
_wrap = other._wrap;
|
_wrap = other._wrap;
|
||||||
_just = other._just;
|
_just = other._just;
|
||||||
_sizing = other._sizing;
|
_sizing = other._sizing;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -83,12 +89,12 @@ Column& Column::operator= (const Column& other)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Column::operator== (const Column& other) const
|
bool Column::operator== (const Column& other) const
|
||||||
{
|
{
|
||||||
return _name == other._name &&
|
return _name == other._name /*&&
|
||||||
_minimum == other._minimum &&
|
_minimum == other._minimum &&
|
||||||
_maximum == other._maximum &&
|
_maximum == other._maximum &&
|
||||||
_wrap == other._wrap &&
|
_wrap == other._wrap &&
|
||||||
_just == other._just &&
|
_just == other._just &&
|
||||||
_sizing == other._sizing;
|
_sizing == other._sizing*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -28,12 +28,15 @@
|
||||||
#define INCLUDED_COLUMN
|
#define INCLUDED_COLUMN
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <Task.h>
|
||||||
|
|
||||||
class Column
|
class Column
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/*
|
||||||
enum just {right = 0, left, center};
|
enum just {right = 0, left, center};
|
||||||
enum sizing {minimal = 0, fixed, proportional, maximal};
|
enum sizing {minimal = 0, fixed, proportional, maximal};
|
||||||
|
*/
|
||||||
|
|
||||||
static Column* factory (const std::string&);
|
static Column* factory (const std::string&);
|
||||||
|
|
||||||
|
@ -43,17 +46,19 @@ public:
|
||||||
bool operator== (const Column&) const; // TODO Is this necessary?
|
bool operator== (const Column&) const; // TODO Is this necessary?
|
||||||
~Column ();
|
~Column ();
|
||||||
|
|
||||||
void setName (const std::string&);
|
virtual void setName (const std::string&);
|
||||||
std::string render (Task*, int, int, const std::string style = "default");
|
virtual std::string render (Task*, int, int, const std::string style = "default") = 0;
|
||||||
std::string type () const;
|
virtual std::string type () const = 0;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
/*
|
||||||
int _minimum;
|
int _minimum;
|
||||||
int _maximum;
|
int _maximum;
|
||||||
bool _wrap;
|
bool _wrap;
|
||||||
just _just;
|
just _just;
|
||||||
sizing _sizing;
|
sizing _sizing;
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
59
src/columns/ID.cpp
Normal file
59
src/columns/ID.cpp
Normal file
|
@ -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 <Context.h>
|
||||||
|
#include <ID.h>
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
47
src/columns/ID.h
Normal file
47
src/columns/ID.h
Normal file
|
@ -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 <string>
|
||||||
|
#include <Column.h>
|
||||||
|
#include <Task.h>
|
||||||
|
|
||||||
|
class ColumnID : public Column
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ColumnID ();
|
||||||
|
~ColumnID ();
|
||||||
|
|
||||||
|
std::string render (Task*, int, int, const std::string style = "default");
|
||||||
|
std::string type () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <Command.h>
|
#include <Command.h>
|
||||||
|
#include <Install.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -34,11 +35,9 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Command* Command::factory (const std::string& name)
|
Command* Command::factory (const std::string& name)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (name == "install") return new Install ();
|
if (name == "install") return new Install ();
|
||||||
|
|
||||||
throw std::string ("Unrecognized command '") + name + "'";
|
throw std::string ("Unrecognized command '") + name + "'";
|
||||||
*/
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Command.h>
|
#include <Command.h>
|
||||||
|
|
||||||
class Install : Command
|
class Install : public Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Install ();
|
Install ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue