diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index 91d7ee6a2..a6405e08d 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -6,12 +6,14 @@ include_directories (${CMAKE_SOURCE_DIR} ${TASK_INCLUDE_DIRS}) set (columns_SRCS Column.cpp Column.h + ColBg.cpp ColBg.h ColDate.cpp ColDate.h ColDepends.cpp ColDepends.h ColDescription.cpp ColDescription.h ColDue.cpp ColDue.h ColEnd.cpp ColEnd.h ColEntry.cpp ColEntry.h + ColFg.cpp ColFg.h ColID.cpp ColID.h ColIMask.cpp ColIMask.h ColMask.cpp ColMask.h diff --git a/src/columns/ColBg.cpp b/src/columns/ColBg.cpp new file mode 100644 index 000000000..4a8a444cc --- /dev/null +++ b/src/columns/ColBg.cpp @@ -0,0 +1,88 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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 +// +//////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + +#include +#include +#include +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +ColumnBg::ColumnBg () +{ + _name = "bg"; + _type = "string"; + _style = "default"; + _label = STRING_COLUMN_LABEL_BG; + + _styles.push_back ("default"); + + _examples.push_back ("'on red'"); +} + +//////////////////////////////////////////////////////////////////////////////// +ColumnBg::~ColumnBg () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +bool ColumnBg::validate (std::string& value) +{ + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the minimum and maximum widths for the value. +void ColumnBg::measure (Task& task, int& minimum, int& maximum) +{ + std::string bg = task.get (_name); + + minimum = longestWord (bg); + maximum = bg.length (); +} + +//////////////////////////////////////////////////////////////////////////////// +void ColumnBg::render ( + std::vector & lines, + Task& task, + int width, + Color& color) +{ + std::string bg = task.get (_name); + + std::vector raw; + wrapText (raw, bg, width, _hyphenate); + + std::vector ::iterator i; + for (i = raw.begin (); i != raw.end (); ++i) + lines.push_back (color.colorize (leftJustify (*i, width))); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColBg.h b/src/columns/ColBg.h new file mode 100644 index 000000000..2ff95d5ac --- /dev/null +++ b/src/columns/ColBg.h @@ -0,0 +1,52 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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_COLBG +#define INCLUDED_COLBG +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +class ColumnBg : public Column +{ +public: + ColumnBg (); + ~ColumnBg (); + + bool validate (std::string&); + void measure (Task&, int&, int&); + void render (std::vector &, Task&, int, Color&); + +private: + bool _hyphenate; +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColFg.cpp b/src/columns/ColFg.cpp new file mode 100644 index 000000000..b2cefd1dc --- /dev/null +++ b/src/columns/ColFg.cpp @@ -0,0 +1,88 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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 +// +//////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + +#include +#include +#include +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +ColumnFg::ColumnFg () +{ + _name = "fg"; + _type = "string"; + _style = "default"; + _label = STRING_COLUMN_LABEL_FG; + + _styles.push_back ("default"); + + _examples.push_back ("red"); +} + +//////////////////////////////////////////////////////////////////////////////// +ColumnFg::~ColumnFg () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +bool ColumnFg::validate (std::string& value) +{ + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the minimum and maximum widths for the value. +void ColumnFg::measure (Task& task, int& minimum, int& maximum) +{ + std::string fg = task.get (_name); + + minimum = longestWord (fg); + maximum = fg.length (); +} + +//////////////////////////////////////////////////////////////////////////////// +void ColumnFg::render ( + std::vector & lines, + Task& task, + int width, + Color& color) +{ + std::string fg = task.get (_name); + + std::vector raw; + wrapText (raw, fg, width, _hyphenate); + + std::vector ::iterator i; + for (i = raw.begin (); i != raw.end (); ++i) + lines.push_back (color.colorize (leftJustify (*i, width))); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColFg.h b/src/columns/ColFg.h new file mode 100644 index 000000000..b47705891 --- /dev/null +++ b/src/columns/ColFg.h @@ -0,0 +1,52 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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_COLFG +#define INCLUDED_COLFG +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +class ColumnFg : public Column +{ +public: + ColumnFg (); + ~ColumnFg (); + + bool validate (std::string&); + void measure (Task&, int&, int&); + void render (std::vector &, Task&, int, Color&); + +private: + bool _hyphenate; +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index bd9e83dfc..2ab957612 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -29,11 +29,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -77,11 +79,13 @@ Column* Column::factory (const std::string& name, const std::string& report) } Column* c; - if (column_name == "depends") c = new ColumnDepends (); + if (column_name == "bg") c = new ColumnBg (); + else if (column_name == "depends") c = new ColumnDepends (); else if (column_name == "description") c = new ColumnDescription (); else if (column_name == "due") c = new ColumnDue (); else if (column_name == "end") c = new ColumnEnd (); else if (column_name == "entry") c = new ColumnEntry (); + else if (column_name == "fg") c = new ColumnFg (); else if (column_name == "id") c = new ColumnID (); else if (column_name == "imask") c = new ColumnIMask (); else if (column_name == "mask") c = new ColumnMask (); @@ -113,11 +117,13 @@ void Column::factory (std::map & all) { Column* c; + c = new ColumnBg (); all[c->_name] = c; c = new ColumnDepends (); all[c->_name] = c; c = new ColumnDescription (); all[c->_name] = c; c = new ColumnDue (); all[c->_name] = c; c = new ColumnEnd (); all[c->_name] = c; c = new ColumnEntry (); all[c->_name] = c; + c = new ColumnFg (); all[c->_name] = c; c = new ColumnID (); all[c->_name] = c; c = new ColumnIMask (); all[c->_name] = c; c = new ColumnMask (); all[c->_name] = c;