From 4478fcf65e46d4d1746859187be5eab7df54e6e6 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 20 Nov 2014 14:35:53 +0100 Subject: [PATCH] src/oping.c: Fix pretty ping graph movement. Fixed the wrap-around case and adds support for windows larger than the history size. --- src/oping.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/oping.c b/src/oping.c index a74cd42..debe237 100644 --- a/src/oping.c +++ b/src/oping.c @@ -979,12 +979,19 @@ static int update_graph_prettyping (ping_context_t *ctx, /* {{{ */ /* Determine the first index in the history we need to draw * the graph. */ history_offset = 0; - if (((size_t) x_max) < ctx->history_size) + if (((size_t) x_max) < ctx->history_size) /* window is smaller than history */ { if (ctx->history_index > x_max) history_offset = ctx->history_index - x_max; else /* wrap around */ - history_offset = ctx->history_index + x_max - ctx->history_size; + history_offset = ctx->history_index + ctx->history_size - x_max; + } + else /* window is larger than history */ + { + if (ctx->history_index != ctx->history_size) /* no longer growing. */ + history_offset = ctx->history_index; + else /* start-up */ + history_offset = 0; } for (x = 0; x < x_max; x++) -- 2.11.0