- if (latency > 0.0)
- {
- if (has_colors () == TRUE)
- {
- int color = OPING_GREEN_HIST;
- float ratio = 0;
- int index = 0;
-
- ratio = latency / PING_DEF_TTL;
- if (ratio > 1) {
- ratio = 1.0;
- }
- index = (int) ((ratio * BARS_LEN * 3) -1); /* 3 colors */
- if (index >= BARS_LEN) {
- color = OPING_YELLOW_HIST;
- }
- if (index >= 2*BARS_LEN) {
- color = OPING_RED_HIST;
- }
- /* HOST_PRINTF ("%%r%f-ia%d-", ratio, index); */
- index = index % BARS_LEN;
- /* HOST_PRINTF ("im%d-", index); */
- if (index < 0) {
- index = 0; /* safety check */
- }
- if (index >= BARS_LEN) {
- index = BARS_LEN - 1; /* safety check */
- }
- wattron (ctx->window, COLOR_PAIR(color));
- mvwprintw (ctx->window,
- /* y = */ 3,
- /* x = */ ( (sequence - 1) % (maxx - 4) ) + 2,
- bars[index]);
- wattroff (ctx->window, COLOR_PAIR(color));
- wprintw (ctx->window, " ");
- }
- else
- {
- }
- }
- else {
- wattron (ctx->window, COLOR_PAIR(OPING_RED) | A_BOLD);
- mvwprintw (ctx->window,
- /* y = */ 3,
- /* x = */ ( (sequence - 1) % (maxx - 4) ) + 2,
- "!");
- wattroff (ctx->window, COLOR_PAIR(OPING_RED) | A_BOLD);
- wprintw (ctx->window, " ");
- }