2 * Grand digital clock for curses compatible terminals
3 * Usage: grdc [-s] [n] -- run for n seconds (default infinity)
6 * modified 10-18-89 for curses (jrl)
7 * 10-18-89 added signal handling
9 * $FreeBSD: src/games/grdc/grdc.c,v 1.8.2.1 2001/10/02 11:51:49 ru Exp $
10 * $DragonFly: src/games/grdc/grdc.c,v 1.2 2003/06/17 04:25:24 dillon Exp $
28 time_t now; /* yeah! */
32 075557, 011111, 071747, 071717, 055711,
33 074717, 074757, 071111, 075757, 075717, 002020
35 long old[6], next[6], new[6], mask;
37 volatile sig_atomic_t sigtermed;
66 while ((ch = getopt(argc, argv, "s")) != -1)
91 signal(SIGINT,sighndl);
92 signal(SIGTERM,sighndl);
93 signal(SIGHUP,sighndl);
99 hascolor = has_colors();
103 init_pair(1, COLOR_BLACK, COLOR_RED);
104 init_pair(2, COLOR_RED, COLOR_BLACK);
105 init_pair(3, COLOR_WHITE, COLOR_BLACK);
106 attrset(COLOR_PAIR(2));
113 attrset(COLOR_PAIR(3));
115 mvaddch(YBASE - 2, XBASE - 3, ACS_ULCORNER);
116 hline(ACS_HLINE, XLENGTH);
117 mvaddch(YBASE - 2, XBASE - 2 + XLENGTH, ACS_URCORNER);
119 mvaddch(YBASE + YDEPTH - 1, XBASE - 3, ACS_LLCORNER);
120 hline(ACS_HLINE, XLENGTH);
121 mvaddch(YBASE + YDEPTH - 1, XBASE - 2 + XLENGTH, ACS_LRCORNER);
123 move(YBASE - 1, XBASE - 3);
124 vline(ACS_VLINE, YDEPTH);
126 move(YBASE - 1, XBASE - 2 + XLENGTH);
127 vline(ACS_VLINE, YDEPTH);
129 attrset(COLOR_PAIR(2));
134 tm = localtime(&now);
135 set(tm->tm_sec%10, 0);
136 set(tm->tm_sec/10, 4);
137 set(tm->tm_min%10, 10);
138 set(tm->tm_min/10, 14);
139 set(tm->tm_hour%10, 20);
140 set(tm->tm_hour/10, 24);
146 new[i] = (new[i]&~mask) | (new[i+1]&mask);
147 new[5] = (new[5]&~mask) | (next[k]&mask);
149 new[k] = (new[k]&~mask) | (next[k]&mask);
151 for(s=1; s>=0; s--) {
154 if((a = (new[i]^old[i])&(s ? new : old)[i]) != 0) {
155 for(j=0,t=1<<26; t; t>>=1,j++) {
158 movto(YBASE + i, XBASE + 2*j);
181 errx(1, "terminated by signal %d", (int)sigtermed);
198 next[i] |= ((disp[t]>>(4-i)*3)&07)<<n;
199 mask |= (next[i]^old[i])&m;
210 attron(COLOR_PAIR(1));
216 attron(COLOR_PAIR(2));
224 movto(int line, int col)
233 (void)fprintf(stderr, "usage: grdc [-s] [n]\n");