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
|
@ -39,6 +39,7 @@
|
|||
|
||||
int renderChart (const std::string&, Interval&, Rules&, Database&);
|
||||
static void renderAxis (const std::string&, const Rules&, Palette&, const std::string&, int, int);
|
||||
static std::string renderDayName (Datetime&, Color&);
|
||||
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, Palette&, const Datetime&, int, int, const std::vector <Range>&);
|
||||
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>&);
|
||||
|
@ -154,18 +155,9 @@ int renderChart (
|
|||
<< (previous.week () != day.week () ? leftJustify (format ("W{1} ", day.week ()), 4) : " ");
|
||||
|
||||
// Today should be highlighted.
|
||||
if (day.sameDay (Datetime ()))
|
||||
std::cout << colorToday.colorize (day.dayNameShort (day.dayOfWeek ()))
|
||||
std::cout << renderDayName (day, colorToday)
|
||||
<< ' '
|
||||
<< colorToday.colorize (rightJustify (day.day (), 2))
|
||||
<< ' ';
|
||||
else
|
||||
std::cout << day.dayNameShort (day.dayOfWeek ())
|
||||
<< ' '
|
||||
<< rightJustify (day.day (), 2)
|
||||
<< ' ';
|
||||
|
||||
std::cout << lines[0].str ();
|
||||
<< lines[0].str ();
|
||||
|
||||
if (lines.size () > 1)
|
||||
{
|
||||
|
@ -228,6 +220,23 @@ static void renderAxis (
|
|||
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 (
|
||||
const std::string& type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue