Add Alepha and dynamically generate much of the view.
This commit is contained in:
@@ -1,2 +1,20 @@
|
||||
all: calx
|
||||
CXXFLAGS+= -std=c++26
|
||||
CXXFLAGS+= -std=c++26 -Oz
|
||||
CPPFLAGS+= -I .
|
||||
|
||||
LDFLAGS+= -Wl,-rpath,'$$ORIGIN/'
|
||||
|
||||
PROGRAMS=calx
|
||||
|
||||
all: ${PROGRAMS}
|
||||
|
||||
${PROGRAMS}: libalepha.so
|
||||
|
||||
|
||||
libalepha.so:
|
||||
mkdir -p build_alepha
|
||||
cd build_alepha; cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../Alepha; cp ../Alepha/helpful-things/Makefile .; make
|
||||
cp build_alepha/libalepha.so .
|
||||
|
||||
clean:
|
||||
rm -f ${PROGRAMS}
|
||||
rm -fR build_alepha libalepha.so
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <Alepha/ProgramOptions.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
namespace C
|
||||
{
|
||||
const int startHour= 6;
|
||||
int startHour= 6;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
@@ -25,14 +32,21 @@ namespace
|
||||
friend std::ostream &
|
||||
operator << ( std::ostream &os, const Appointment &appointment )
|
||||
{
|
||||
if( false )
|
||||
{
|
||||
std::cout << "[10G[1000000A[1B[44;1m Wakeup [m[H";
|
||||
}
|
||||
const int baseLine= 1 + ( appointment.startHour - C::startHour ) * 4 + appointment.startQuarter;
|
||||
bool skippedTop= false;
|
||||
bool skippedBottom= false;
|
||||
|
||||
if( appointment.startHour < C::startHour and appointment.duration <= 4 ) return os;
|
||||
if( appointment.startHour > C::startHour + 6 ) return os;
|
||||
|
||||
for( int i= 0; i < appointment.duration; ++i )
|
||||
{
|
||||
const int line= baseLine + i;
|
||||
if( line < 1 ) { skippedTop= true; continue; }
|
||||
if( line > 24 ) { skippedBottom= true; continue; }
|
||||
|
||||
os << "[" << 10 * appointment.day << "G[1000000A["
|
||||
<< ( 1 + ( appointment.startHour - 6 ) * 4 + appointment.startQuarter + i )
|
||||
<< line
|
||||
<< "B[4" << appointment.color
|
||||
<< ";1m";
|
||||
if( i == 0 )
|
||||
@@ -43,6 +57,21 @@ namespace
|
||||
else os << std::setw( 9 ) << "";
|
||||
os << "[m[H";
|
||||
}
|
||||
|
||||
if( skippedTop and not skippedBottom )
|
||||
{
|
||||
os << "[" << 10 * appointment.day
|
||||
<< "G[1000000A[B[4" << appointment.color
|
||||
<< ";1m^^^^^^^^^[m";
|
||||
}
|
||||
|
||||
if( skippedBottom and not skippedTop )
|
||||
{
|
||||
os << "[" << 10 * appointment.day
|
||||
<< "G[1000000A[24B[4" << appointment.color
|
||||
<< ";1mvvvvvvvvv[m";
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
@@ -54,66 +83,46 @@ namespace
|
||||
{ "Meeting", 9, 1, 5, 5, blue },
|
||||
{ "Long Meeting Name", 8, 1, 8, 6, cyan },
|
||||
};
|
||||
|
||||
void
|
||||
printHourGrid( int hour )
|
||||
{
|
||||
for( int line= 0; line < 4; ++line )
|
||||
{
|
||||
std::cout << '\n';
|
||||
|
||||
if( line == 0 )
|
||||
{
|
||||
std::cout << "| " << std::setw( 2 ) << std::setfill( '0' ) << hour << std::setfill( ' ' ) << ":00 |";
|
||||
}
|
||||
else if( line == 3 )
|
||||
{
|
||||
std::cout << "|-------|";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "| |";
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
for( int i= 0; i < 7; ++i )
|
||||
{
|
||||
std::cout << " |";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
program()
|
||||
{
|
||||
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();
|
||||
auto header= "| Time | Mon | Tue | Wed | Thu | Fri | Sat | Sun |";
|
||||
std::cout << "[m[H[2J" << header;
|
||||
|
||||
std::cout << "[m[H[2J" << example;
|
||||
|
||||
if( false )
|
||||
for( int hour= C::startHour; hour < C::startHour + 6; ++hour )
|
||||
{
|
||||
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";
|
||||
printHourGrid( hour );
|
||||
}
|
||||
|
||||
for( auto &appt: appointments )
|
||||
@@ -121,10 +130,18 @@ main()
|
||||
std::cout << appt;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "[?25l" << std::flush;
|
||||
|
||||
|
||||
sleep( 20 );
|
||||
std::cout << "[?25h" << std::flush;
|
||||
std::cout << "[2J[H[?25h" << std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main( const int argcnt, const char *const argvec[])
|
||||
{
|
||||
std::ignore= Alepha::handleOptions( argcnt, argvec );
|
||||
::program();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user