From c8593cd0a750f36139f18dc8573028f6369f03a1 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 11 Apr 2009 21:58:42 +0200 Subject: [PATCH] Add keybind [0;7] to change color! --- README | 2 +- ttyclock.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README b/README index 83ec2a9..a84bc9b 100755 --- a/README +++ b/README @@ -1,7 +1,7 @@ tty-clock usage : tty-clock [-option] -s Show seconds -c Set the clock at the center of the terminal - -C Set the clock color. + -C Set the clock color -t Set the hour in 12h format -r Do rebound the clock -f Set the date format diff --git a/ttyclock.c b/ttyclock.c index 6017870..598fa49 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -316,10 +316,11 @@ set_center(Bool b) void key_event(void) { + int i, c; halfdelay(1); - switch(getch()) + switch((c = getch())) { case KEY_UP: case 'k': @@ -382,6 +383,14 @@ key_event(void) if(ttyclock->option.rebound && ttyclock->option.center) ttyclock->option.center = False; break; + default: + for(i = 0; i < 8; ++i) + if(c == (i + '0')) + { + ttyclock->option.color = i; + init(); + } + break; } return; @@ -411,7 +420,7 @@ main(int argc, char **argv) printf("tty-clock usage : tty-clock [-option] \n" " -s Show seconds \n" " -c Set the clock at the center of the terminal \n" - " -C Set the clock color. \n" + " -C Set the clock color \n" " -t Set the hour in 12h format \n" " -r Do rebound the clock \n" " -f Set the date format \n"