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
27 time_t now; /* yeah! */
31 075557, 011111, 071747, 071717, 055711,
32 074717, 074757, 071111, 075757, 075717, 002020
34 long old[6], next[6], new[6], mask;
36 volatile sig_atomic_t sigtermed;
65 while ((ch = getopt(argc, argv, "s")) != -1)
90 signal(SIGINT,sighndl);
91 signal(SIGTERM,sighndl);
92 signal(SIGHUP,sighndl);
98 hascolor = has_colors();
102 init_pair(1, COLOR_BLACK, COLOR_RED);
103 init_pair(2, COLOR_RED, COLOR_BLACK);
104 init_pair(3, COLOR_WHITE, COLOR_BLACK);
105 attrset(COLOR_PAIR(2));
112 attrset(COLOR_PAIR(3));
114 mvaddch(YBASE - 2, XBASE - 3, ACS_ULCORNER);
115 hline(ACS_HLINE, XLENGTH);
116 mvaddch(YBASE - 2, XBASE - 2 + XLENGTH, ACS_URCORNER);
118 mvaddch(YBASE + YDEPTH - 1, XBASE - 3, ACS_LLCORNER);
119 hline(ACS_HLINE, XLENGTH);
120 mvaddch(YBASE + YDEPTH - 1, XBASE - 2 + XLENGTH, ACS_LRCORNER);
122 move(YBASE - 1, XBASE - 3);
123 vline(ACS_VLINE, YDEPTH);
125 move(YBASE - 1, XBASE - 2 + XLENGTH);
126 vline(ACS_VLINE, YDEPTH);
128 attrset(COLOR_PAIR(2));
133 tm = localtime(&now);
134 set(tm->tm_sec%10, 0);
135 set(tm->tm_sec/10, 4);
136 set(tm->tm_min%10, 10);
137 set(tm->tm_min/10, 14);
138 set(tm->tm_hour%10, 20);
139 set(tm->tm_hour/10, 24);
145 new[i] = (new[i]&~mask) | (new[i+1]&mask);
146 new[5] = (new[5]&~mask) | (next[k]&mask);
148 new[k] = (new[k]&~mask) | (next[k]&mask);
150 for(s=1; s>=0; s--) {
153 if((a = (new[i]^old[i])&(s ? new : old)[i]) != 0) {
154 for(j=0,t=1<<26; t; t>>=1,j++) {
157 movto(YBASE + i, XBASE + 2*j);
180 errx(1, "terminated by signal %d", (int)sigtermed);
197 next[i] |= ((disp[t]>>(4-i)*3)&07)<<n;
198 mask |= (next[i]^old[i])&m;
209 attron(COLOR_PAIR(1));
215 attron(COLOR_PAIR(2));
223 movto(int line, int col)
232 (void)fprintf(stderr, "usage: grdc [-s] [n]\n");