---
cal.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/cal.c b/cal.c
index 740dc02..b9eb1b9 100644
--- a/cal.c
+++ b/cal.c
_AT_@ -3,10 +3,14 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <term.h>
#include <time.h>
+#include <unistd.h>
#include "util.h"
+static struct {size_t y; int m, d;} today;
+
enum { JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC };
enum caltype { JULIAN, GREGORIAN };
enum { TRANS_YEAR = 1752, TRANS_MONTH = SEP, TRANS_DAY = 2 };
_AT_@ -56,6 +60,15 @@ printgrid(size_t year, int month, int fday, int line)
{
enum caltype cal;
int offset, dom, d = 0, trans; /* are we in the transition from Julian to Gregorian? */
+ char *term_so, *term_se;
+ char tbuf[1024], cbuf[512], *b;
+
+ term_se = term_so = "";
+ if (isatty(STDOUT_FILENO) && tgetent(tbuf, NULL) == 1) {
+ b = cbuf;
+ term_so = tgetstr("so", &b);
+ term_se = tgetstr("se", &b);
+ }
cal = (year < TRANS_YEAR || (year == TRANS_YEAR && month <= TRANS_MONTH)) ? JULIAN : GREGORIAN;
trans = (year == TRANS_YEAR && month == TRANS_MONTH);
_AT_@ -73,7 +86,10 @@ printgrid(size_t year, int month, int fday, int line)
dom += 11;
}
for (; d < 7 && dom <= monthlength(year, month, cal); ++d, ++dom) {
- printf("%2d ", dom);
+ if (dom == today.d && month == today.m && year == today.y)
+ printf("%s%2d%s ", term_so, dom, term_se);
+ else
+ printf("%2d ", dom);
if (trans && dom == TRANS_DAY)
dom += 11;
}
_AT_@ -145,6 +161,9 @@ main(int argc, char *argv[])
ltime = localtime(&now);
year = ltime->tm_year + 1900;
month = ltime->tm_mon + 1;
+ today.y = year;
+ today.m = month - 1;
+ today.d = ltime->tm_mday;
fday = 0;
ncols = 3;
--
1.9.1
--------------010009050605030702010408--
Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Fri Nov 20 2015 - 19:00:12 CET