GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 /*- 00003 * G_clicker() 00004 * 00005 * Print a clock hand (one of '|', '/', '-', '\') to stderr. 00006 * Used in place of G_percent for unknown number of iterations 00007 * 00008 */ 00009 #include <stdio.h> 00010 00011 static int G_clicker_prev = 0; 00012 00013 int G_clicker(void) 00014 { 00015 int x; 00016 static char clicks[] = "|/-\\"; 00017 00018 if (G_clicker_prev == -1 || G_clicker_prev == 3) 00019 x = 0; 00020 00021 else 00022 x = G_clicker_prev + 1; 00023 00024 fprintf(stderr, "%1c\b", clicks[x]); 00025 fflush(stderr); 00026 G_clicker_prev = x; 00027 00028 return 0; 00029 }