mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdChart: Parameterized day rendering
This commit is contained in:
parent
1adaf07181
commit
def58af8e5
1 changed files with 26 additions and 17 deletions
|
@ -37,11 +37,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
int renderChart (const std::string&, Interval&, Rules&, Database&);
|
int renderChart (const std::string&, Interval&, Rules&, Database&);
|
||||||
static void renderAxis (const std::string&, const Rules&, Palette&, const std::string&, int, int);
|
static void renderAxis (const std::string&, const Rules&, Palette&, const std::string&, int, int);
|
||||||
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, Palette&, const Datetime&, int, int, const std::vector <Range>&);
|
static std::string renderDayName (Datetime&, Color&);
|
||||||
static void renderInterval (const std::string&, const Rules&, std::vector <Composite>&, const Datetime&, const Interval&, Palette&, std::map <std::string, Color>&, time_t&);
|
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, Palette&, const Datetime&, int, int, const std::vector <Range>&);
|
||||||
static void renderSummary (const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&);
|
static void renderInterval (const std::string&, const Rules&, std::vector <Composite>&, const Datetime&, const Interval&, Palette&, std::map <std::string, Color>&, time_t&);
|
||||||
|
static void renderSummary (const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdChartDay (
|
int CmdChartDay (
|
||||||
|
@ -154,18 +155,9 @@ int renderChart (
|
||||||
<< (previous.week () != day.week () ? leftJustify (format ("W{1} ", day.week ()), 4) : " ");
|
<< (previous.week () != day.week () ? leftJustify (format ("W{1} ", day.week ()), 4) : " ");
|
||||||
|
|
||||||
// Today should be highlighted.
|
// Today should be highlighted.
|
||||||
if (day.sameDay (Datetime ()))
|
std::cout << renderDayName (day, colorToday)
|
||||||
std::cout << colorToday.colorize (day.dayNameShort (day.dayOfWeek ()))
|
<< ' '
|
||||||
<< ' '
|
<< lines[0].str ();
|
||||||
<< colorToday.colorize (rightJustify (day.day (), 2))
|
|
||||||
<< ' ';
|
|
||||||
else
|
|
||||||
std::cout << day.dayNameShort (day.dayOfWeek ())
|
|
||||||
<< ' '
|
|
||||||
<< rightJustify (day.day (), 2)
|
|
||||||
<< ' ';
|
|
||||||
|
|
||||||
std::cout << lines[0].str ();
|
|
||||||
|
|
||||||
if (lines.size () > 1)
|
if (lines.size () > 1)
|
||||||
{
|
{
|
||||||
|
@ -228,6 +220,23 @@ static void renderAxis (
|
||||||
std::cout << " " << colorLabel.colorize ("Total") << "\n";
|
std::cout << " " << colorLabel.colorize ("Total") << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
static std::string renderDayName (Datetime& day, Color& color)
|
||||||
|
{
|
||||||
|
std::stringstream out;
|
||||||
|
if (day.sameDay (Datetime ()))
|
||||||
|
out << color.colorize (day.dayNameShort (day.dayOfWeek ()))
|
||||||
|
<< ' '
|
||||||
|
<< color.colorize (rightJustify (day.day (), 2));
|
||||||
|
|
||||||
|
else
|
||||||
|
out << day.dayNameShort (day.dayOfWeek ())
|
||||||
|
<< ' '
|
||||||
|
<< rightJustify (day.day (), 2);
|
||||||
|
|
||||||
|
return out.str ();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static void renderExclusionBlocks (
|
static void renderExclusionBlocks (
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue