/* * bigtime.c - display big textmode date * * Copyright (C) 2001 Nathan Laredo (laredo@gnu.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include static char *digits[13] = { " 000000 " "00000000" "00 00" "00 00" "00 00" "00 00" "00000000" " 000000 ", " 11 " " 1111 " " 11 " " 11 " " 11 " " 11 " " 111111 " " 111111 ", " 222222 " "22222222" " 22" " 2222222" "2222222 " "22 " "22222222" "22222222", " 333333 " "33333333" " 33" " 33333 " " 33333 " " 33" "33333333" " 333333 ", " 44 44" " 44 44" "44 44" "44444444" "44444444" " 44" " 44" " 44", "55555555" "55555555" "55 " "5555555 " "55555555" " 55" "55555555" " 555555 ", " 6666666" "66666666" "66 " "6666666 " "66666666" "66 66" "66666666" " 666666 ", "77777777" "77777777" " 77" " 77 " " 77 " " 77 " " 77 " " 77 ", " 888888 " "88888888" "88 88" " 888888 " " 888888 " "88 88" "88888888" " 888888 ", " 999999 " "99999999" "99 99" "99999999" " 9999999" " 99" " 9999999" " 999999 ", " " " :: " " :: " " " " " " :: " " :: " " ", " " " " " " " " " " " " " " " ", " " " " " " " ------ " " ------ " " " " " " " }; static void paintchar(char *ch, int x, int y) { int i; char line[9]; line[8] = '\0'; for (i = 0; i < 8; i++) { fprintf(stderr, "\E[%d;%dH", y + i + 1, x + 1); strncpy(line, ch + i * 8, 8); fprintf(stderr, line); } } int main(int argc, char **argv) { time_t now; struct tm *tmp; int val[16], oldval[16]; int i; fprintf(stderr, "\E[H\E[2J"); for (i = 0; i < 16; i++) { oldval[i] = 117; } val[10] = val[13] = 10; val[2] = val[5] = 12; while (1) { now = time(NULL); tmp = localtime(&now); val[0] = (tmp->tm_mon + 1) / 10; val[1] = (tmp->tm_mon + 1) % 10; val[3] = tmp->tm_mday / 10; val[4] = tmp->tm_mday % 10; val[6] = (tmp->tm_year % 100) / 10; val[7] = tmp->tm_year % 10; val[8] = tmp->tm_hour / 10; val[9] = tmp->tm_hour % 10; val[11] = tmp->tm_min / 10; val[12] = tmp->tm_min % 10; val[14] = tmp->tm_sec / 10; val[15] = tmp->tm_sec % 10; //val[10] ^= 1; //val[13] ^= 1; for (i = 0; i < 8; i++) { if (val[i] != oldval[i]) { paintchar(digits[val[i]], i * 9, 0); } } for (i = 8; i < 16; i++) { if (val[i] != oldval[i]) { paintchar(digits[val[i]], (i - 8) * 9, 9); } } sleep(1); memcpy(oldval, val, sizeof(val)); } exit(0); }