Simple mock-up starting point.
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
namespace C
|
||||
{
|
||||
const int startHour= 6;
|
||||
}
|
||||
|
||||
enum Color : int { red= 1, green= 2, yellow= 3, blue= 4, magenta= 5, cyan= 6, white= 7 };
|
||||
struct Appointment
|
||||
{
|
||||
std::string name;
|
||||
int startHour;
|
||||
int startQuarter;
|
||||
int duration; // Quarter hours
|
||||
int day;
|
||||
Color color;
|
||||
|
||||
friend std::ostream &
|
||||
operator << ( std::ostream &os, const Appointment &appointment )
|
||||
{
|
||||
if( false )
|
||||
{
|
||||
std::cout << "[10G[1000000A[1B[44;1m Wakeup [m[H";
|
||||
}
|
||||
for( int i= 0; i < appointment.duration; ++i )
|
||||
{
|
||||
os << "[" << 10 * appointment.day << "G[1000000A["
|
||||
<< ( 1 + ( appointment.startHour - 6 ) * 4 + appointment.startQuarter + i )
|
||||
<< "B[4" << appointment.color
|
||||
<< ";1m";
|
||||
if( i == 0 )
|
||||
{
|
||||
if( appointment.name.size() <= 9 ) os << std::left << std::setw( 9 ) << appointment.name;
|
||||
else os << std::setw( 6 ) << appointment.name.substr(0,6) << "...";
|
||||
}
|
||||
else os << std::setw( 9 ) << "";
|
||||
os << "[m[H";
|
||||
}
|
||||
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 },
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* */
|
||||
auto example= R"(
|
||||
| Time | Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|
||||
| 06:00 | | | | | | | |
|
||||
| | | | | | | | |
|
||||
| | | | | | | | |
|
||||
|_______| | | | | | | |
|
||||
| 07:00 | | | | | | | |
|
||||
| | | | | | | | |
|
||||
| | | | | | | | |
|
||||
|_______| | | | | | | |
|
||||
| 08:00 | | | | | | | |
|
||||
| | | | | | | | |
|
||||
| | | | | | | | |
|
||||
|_______| | | | | | | |
|
||||
| 09:00 | | | | | | | |
|
||||
| | | | | | | | |
|
||||
| | | | | | | | |
|
||||
|_______| | | | | | | |
|
||||
| 10:00 | | | | | | | |
|
||||
| | | | | | | | |
|
||||
| | | | | | | | |
|
||||
|_______| | | | | | | |
|
||||
| 11:00 | | | | | | | |
|
||||
| | | | | | | | |
|
||||
| | | | | | | | |
|
||||
|_______| | | | | | | |
|
||||
)"s.substr( 1 );
|
||||
example.pop_back(); example.pop_back();
|
||||
|
||||
std::cout << "[m[H[2J" << example;
|
||||
|
||||
if( false )
|
||||
{
|
||||
std::cout << "[10G[1000000A[1B[44;1m Wakeup [m[H";
|
||||
std::cout << "[10G[1000000A[2B[44;1m [m[H";
|
||||
std::cout << "[10G[1000000A[3B[44;1m [m[H";
|
||||
|
||||
|
||||
std::cout << "[20G[1000000A[6B[44;1m Wakeup [m[H";
|
||||
std::cout << "[20G[1000000A[7B[44;1m [m[H";
|
||||
std::cout << "[20G[1000000A[8B[44;1m [m[H";
|
||||
std::cout << "[20G[1000000A[9B[44;1m [m[H";
|
||||
|
||||
|
||||
std::cout << "[40G[1000000A[19B[41;1m Meeting [m[H";
|
||||
std::cout << "[40G[1000000A[20B[41;1m [m[H";
|
||||
std::cout << "[40G[1000000A[21B[41;1m [m[H";
|
||||
std::cout << "[40G[1000000A[22B[41;1m [m[H";
|
||||
}
|
||||
|
||||
for( auto &appt: appointments )
|
||||
{
|
||||
std::cout << appt;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "[?25l" << std::flush;
|
||||
|
||||
|
||||
sleep( 20 );
|
||||
std::cout << "[?25h" << std::flush;
|
||||
}
|
||||
Reference in New Issue
Block a user