mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Columns - 'fg' and 'bg'
- Added columns 'fg' and 'bg', despite their being deprecated. Can't remove capabilities without appropriate forewarning.
This commit is contained in:
parent
17dfbabb39
commit
1c98544380
6 changed files with 289 additions and 1 deletions
|
@ -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
|
||||
|
|
88
src/columns/ColBg.cpp
Normal file
88
src/columns/ColBg.cpp
Normal file
|
@ -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 <Context.h>
|
||||
#include <ColBg.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
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 <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
std::string bg = task.get (_name);
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, bg, width, _hyphenate);
|
||||
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = raw.begin (); i != raw.end (); ++i)
|
||||
lines.push_back (color.colorize (leftJustify (*i, width)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
52
src/columns/ColBg.h
Normal file
52
src/columns/ColBg.h
Normal file
|
@ -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 <vector>
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Color.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnBg : public Column
|
||||
{
|
||||
public:
|
||||
ColumnBg ();
|
||||
~ColumnBg ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
bool _hyphenate;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
88
src/columns/ColFg.cpp
Normal file
88
src/columns/ColFg.cpp
Normal file
|
@ -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 <Context.h>
|
||||
#include <ColFg.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
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 <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
std::string fg = task.get (_name);
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, fg, width, _hyphenate);
|
||||
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = raw.begin (); i != raw.end (); ++i)
|
||||
lines.push_back (color.colorize (leftJustify (*i, width)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
52
src/columns/ColFg.h
Normal file
52
src/columns/ColFg.h
Normal file
|
@ -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 <vector>
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Color.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnFg : public Column
|
||||
{
|
||||
public:
|
||||
ColumnFg ();
|
||||
~ColumnFg ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
bool _hyphenate;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -29,11 +29,13 @@
|
|||
|
||||
#include <Context.h>
|
||||
#include <Column.h>
|
||||
#include <ColBg.h>
|
||||
#include <ColDepends.h>
|
||||
#include <ColDescription.h>
|
||||
#include <ColDue.h>
|
||||
#include <ColEnd.h>
|
||||
#include <ColEntry.h>
|
||||
#include <ColFg.h>
|
||||
#include <ColID.h>
|
||||
#include <ColIMask.h>
|
||||
#include <ColMask.h>
|
||||
|
@ -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 <std::string, Column*>& 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue