|
|
|
@@ -1,11 +1,17 @@
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <iterator>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include <Alepha/Enum.h>
|
|
|
|
|
#include <Alepha/ProgramOptions.h>
|
|
|
|
|
|
|
|
|
|
#include <Alepha/IOStreams/IStreamable.h>
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
namespace C
|
|
|
|
@@ -13,14 +19,27 @@ namespace
|
|
|
|
|
int startHour= 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using namespace Alepha::literals;
|
|
|
|
|
auto init= Alepha::Utility::enroll <=[]
|
|
|
|
|
{
|
|
|
|
|
using namespace Alepha::literals;
|
|
|
|
|
--"start-hour"_option << C::startHour << "Selects a starting hour other than 6AM. Times are 24H and errors are not checked.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum Color : int { red= 1, green= 2, yellow= 3, blue= 4, magenta= 5, cyan= 6, white= 7 };
|
|
|
|
|
struct Appointment
|
|
|
|
|
//enum Color : int { red= 1, green= 2, yellow= 3, blue= 4, magenta= 5, cyan= 6, white= 7 };
|
|
|
|
|
using Color= Alepha::Enum
|
|
|
|
|
<
|
|
|
|
|
"black"_value,
|
|
|
|
|
"red"_value,
|
|
|
|
|
"green"_value,
|
|
|
|
|
"yellow"_value,
|
|
|
|
|
"blue"_value,
|
|
|
|
|
"magenta"_value,
|
|
|
|
|
"cyan"_value,
|
|
|
|
|
"white"_value
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
template< typename= Alepha::Capabilities< Alepha::IOStreams::IStreamable > >
|
|
|
|
|
struct Appointment_core
|
|
|
|
|
{
|
|
|
|
|
std::string name;
|
|
|
|
|
int startHour;
|
|
|
|
@@ -28,8 +47,10 @@ namespace
|
|
|
|
|
int duration; // Quarter hours
|
|
|
|
|
int day;
|
|
|
|
|
Color color;
|
|
|
|
|
};
|
|
|
|
|
using Appointment= Appointment_core<>;
|
|
|
|
|
|
|
|
|
|
friend std::ostream &
|
|
|
|
|
std::ostream &
|
|
|
|
|
operator << ( std::ostream &os, const Appointment &appointment )
|
|
|
|
|
{
|
|
|
|
|
const int baseLine= 1 + ( appointment.startHour - C::startHour ) * 4 + appointment.startQuarter;
|
|
|
|
@@ -47,7 +68,7 @@ namespace
|
|
|
|
|
|
|
|
|
|
os << "[" << 10 * appointment.day << "G[1000000A["
|
|
|
|
|
<< line
|
|
|
|
|
<< "B[4" << appointment.color
|
|
|
|
|
<< "B[4" << appointment.color.get_index()
|
|
|
|
|
<< ";1m";
|
|
|
|
|
if( i == 0 )
|
|
|
|
|
{
|
|
|
|
@@ -74,15 +95,8 @@ namespace
|
|
|
|
|
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Appointment appointments[]=
|
|
|
|
|
{
|
|
|
|
|
{ "Wakeup", 6, 0, 1, 3, red },
|
|
|
|
|
{ "Wakeup", 7, 1, 2, 2, red },
|
|
|
|
|
{ "Meeting", 9, 1, 5, 5, blue },
|
|
|
|
|
{ "Long Meeting Name", 8, 1, 8, 6, cyan },
|
|
|
|
|
};
|
|
|
|
|
std::vector< Appointment > appointments;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
printHourGrid( int hour )
|
|
|
|
@@ -116,6 +130,12 @@ namespace
|
|
|
|
|
{
|
|
|
|
|
using namespace std::literals::string_literals;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::ifstream data{ "appointments.csv" };
|
|
|
|
|
std::copy( std::istream_iterator< Appointment >{ data }, std::istream_iterator< Appointment >{}, std::back_inserter( appointments ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
auto header= "| Time | Mon | Tue | Wed | Thu | Fri | Sat | Sun |";
|
|
|
|
|
std::cout << "[m[H[2J" << header;
|
|
|
|
@@ -127,7 +147,7 @@ namespace
|
|
|
|
|
|
|
|
|
|
for( auto &appt: appointments )
|
|
|
|
|
{
|
|
|
|
|
std::cout << appt;
|
|
|
|
|
std::cout << appt << std::endl;;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::cout << "[?25l" << std::flush;
|
|
|
|
|