GRASS GIS 8 Programmer's Manual 8.2.1(2023)-exported
clicker.c
Go to the documentation of this file.
1
2/*-
3 * G_clicker()
4 *
5 * Print a clock hand (one of '|', '/', '-', '\') to stderr.
6 * Used in place of G_percent for unknown number of iterations
7 *
8 */
9#include <stdio.h>
10#include <grass/gis.h>
11
12static struct state {
13 int prev;
14} state;
15
16static struct state *st = &state;
17
18void G_clicker(void)
19{
20 static const char clicks[] = "|/-\\";
21 int format = G_info_format();
22
23 if (format == G_INFO_FORMAT_SILENT || G_verbose() < 1)
24 return;
25
26 st->prev++;
27 st->prev %= 4;
28
29 fprintf(stderr, "%1c\b", clicks[st->prev]);
30 fflush(stderr);
31}
void G_clicker(void)
Definition: clicker.c:18
int G_info_format(void)
Get current message format.
Definition: gis/error.c:532
struct state state
Definition: parser.c:103
struct state * st
Definition: parser.c:104
int G_verbose(void)
Get current verbosity level.
Definition: verbose.c:55