本文整理汇总了C++中ViewText::intraPadding方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewText::intraPadding方法的具体用法?C++ ViewText::intraPadding怎么用?C++ ViewText::intraPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewText
的用法示例。
在下文中一共展示了ViewText::intraPadding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
int CmdStatistics::execute (std::string& output)
{
int rc = 0;
std::stringstream out;
std::string dateformat = context.config.get ("dateformat");
// Go get the file sizes.
size_t dataSize = context.tdb2.pending._file.size ()
+ context.tdb2.completed._file.size ()
+ context.tdb2.undo._file.size ()
/*
// TODO Re-enable this once 2.1 has taskd support.
+ context.tdb2.backlog._file.size ()
+ context.tdb2.synch_key._file.size ()
*/
;
// Count the undo transactions.
std::vector <std::string> undoTxns = context.tdb2.undo.get_lines ();
int undoCount = 0;
std::vector <std::string>::iterator tx;
for (tx = undoTxns.begin (); tx != undoTxns.end (); ++tx)
if (*tx == "---")
++undoCount;
// Get all the tasks.
std::vector <Task> all = context.tdb2.all_tasks ();
std::vector <Task> filtered;
filter (all, filtered);
Date now;
time_t earliest = time (NULL);
time_t latest = 1;
int totalT = 0;
int deletedT = 0;
int pendingT = 0;
int completedT = 0;
int waitingT = 0;
int taggedT = 0;
int annotationsT = 0;
int recurringT = 0;
float daysPending = 0.0;
int descLength = 0;
std::map <std::string, int> allTags;
std::map <std::string, int> allProjects;
std::vector <Task>::iterator task;
for (task = filtered.begin (); task != filtered.end (); ++task)
{
++totalT;
Task::status status = task->getStatus ();
switch (status)
{
case Task::deleted: ++deletedT; break;
case Task::pending: ++pendingT; break;
case Task::completed: ++completedT; break;
case Task::recurring: ++recurringT; break;
case Task::waiting: ++waitingT; break;
}
time_t entry = strtol (task->get ("entry").c_str (), NULL, 10);
if (entry < earliest) earliest = entry;
if (entry > latest) latest = entry;
if (status == Task::completed)
{
time_t end = strtol (task->get ("end").c_str (), NULL, 10);
daysPending += (end - entry) / 86400.0;
}
if (status == Task::pending)
daysPending += (now.toEpoch () - entry) / 86400.0;
descLength += task->get ("description").length ();
std::map <std::string, std::string> annotations;
task->getAnnotations (annotations);
annotationsT += annotations.size ();
std::vector <std::string> tags;
task->getTags (tags);
if (tags.size ()) ++taggedT;
std::vector <std::string>::iterator t;
for (t = tags.begin (); t != tags.end (); ++t)
allTags[*t] = 0;
std::string project = task->get ("project");
if (project != "")
allProjects[project] = 0;
}
// Create a table for output.
ViewText view;
view.width (context.getWidth ());
view.intraPadding (2);
view.add (Column::factory ("string", STRING_CMD_STATS_CATEGORY));
view.add (Column::factory ("string", STRING_CMD_STATS_DATA));
//.........这里部分代码省略.........
示例2: lastChange
void TDB2::show_diff (
const std::string& current,
const std::string& prior,
const std::string& when)
{
ISO8601d lastChange (strtol (when.c_str (), NULL, 10));
// Set the colors.
Color color_red (context.color () ? context.config.get ("color.undo.before") : "");
Color color_green (context.color () ? context.config.get ("color.undo.after") : "");
if (context.config.get ("undo.style") == "side")
{
std::cout << "\n"
<< format (STRING_TDB2_LAST_MOD, lastChange.toString ())
<< "\n";
// Attributes are all there is, so figure the different attribute names
// between before and after.
ViewText view;
view.width (context.getWidth ());
view.intraPadding (2);
view.add (Column::factory ("string", ""));
view.add (Column::factory ("string", STRING_TDB2_UNDO_PRIOR));
view.add (Column::factory ("string", STRING_TDB2_UNDO_CURRENT));
Color label (context.config.get ("color.label"));
view.colorHeader (label);
Task after (current);
if (prior != "")
{
Task before (prior);
std::vector <std::string> beforeAtts;
for (auto& att : before)
beforeAtts.push_back (att.first);
std::vector <std::string> afterAtts;
for (auto& att : after)
afterAtts.push_back (att.first);
std::vector <std::string> beforeOnly;
std::vector <std::string> afterOnly;
listDiff (beforeAtts, afterAtts, beforeOnly, afterOnly);
int row;
for (auto& name : beforeOnly)
{
row = view.addRow ();
view.set (row, 0, name);
view.set (row, 1, renderAttribute (name, before.get (name)), color_red);
}
for (auto& att : before)
{
std::string priorValue = before.get (att.first);
std::string currentValue = after.get (att.first);
if (currentValue != "")
{
row = view.addRow ();
view.set (row, 0, att.first);
view.set (row, 1, renderAttribute (att.first, priorValue),
(priorValue != currentValue ? color_red : Color ()));
view.set (row, 2, renderAttribute (att.first, currentValue),
(priorValue != currentValue ? color_green : Color ()));
}
}
for (auto& name : afterOnly)
{
row = view.addRow ();
view.set (row, 0, name);
view.set (row, 2, renderAttribute (name, after.get (name)), color_green);
}
}
else
{
int row;
for (auto& att : after)
{
row = view.addRow ();
view.set (row, 0, att.first);
view.set (row, 2, renderAttribute (att.first, after.get (att.first)), color_green);
}
}
std::cout << "\n"
<< view.render ()
<< "\n";
}
// This style looks like this:
// --- before 2009-07-04 00:00:25.000000000 +0200
// +++ after 2009-07-04 00:00:45.000000000 +0200
//
// - name: old // att deleted
// + name:
//.........这里部分代码省略.........