Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

implement some prettyping-inspired display alongside textual data. #3

Closed
wants to merge 17 commits into from

3 participants

@anarcat

this is a first stab at porting "prettyping.sh" into noping. the idea is to show a histogram of the ping history.

it is a little rough for now:

  • it should fallback when the terminal is not unicode-capable

  • the scaling logic is not fully automatic, which will degenerate (ie. all red or all green) in cases where the latency is close to 255 ms or 1ms with little stddev

this requires switching to the ncursesw library and other unicode ncurses hackery described in this post:

http://newsgroups.derkeiler.com/Archive/Rec/rec.games.roguelike.development/2010-09/msg00050.html

pretty ping is a awk/bash script, MIT-licensed, available here:

https://bitbucket.org/denilsonsa/small_scripts/src/tip/prettyping.sh

Antoine Beaupré added some commits
Antoine Beaupré implement some prettyping-inspired display instead of textual
this is a first stab at porting "prettyping.sh" into noping. the idea
is to show a histogram of ping times instead of numerical values. with
some work, we could actually show both, but this focuses on
implementing the hard part (the histogram) properly.

it is very rudimentary for now:

 * the math may be wrong for the size of the bar, I was mostly in a
   rush to make unicode work and have something pretty quickly.

 * all hosts are on the same line: each should have its own line

 * the histogram should be displayed in a separate window

 * it should use background colors as well

 * it should fallback when the terminal is not unicode-capable

 * the scaling logic is fully automatic, which necessarily gives weird
   results at first

this requires switching to the ncursesw library and other unicode
ncurses hackery described in this post:

http://newsgroups.derkeiler.com/Archive/Rec/rec.games.roguelike.development/2010-09/msg00050.html

pretty ping is a awk/bash script, MIT-licensed, available here:

https://bitbucket.org/denilsonsa/small_scripts/src/tip/prettyping.sh
68d713e
Antoine Beaupré put histograms into the independent window, to eventually restore pin…
…g times display
d64c113
Antoine Beaupré restore usual ping display, now that histograms are in a different wi…
…ndow
3603703
Antoine Beaupré make histogram colors with a nicer background f379d7a
Antoine Beaupré remove a little quirk i introduced by mistake
this was breaking the border
d5a3fc9
Antoine Beaupré wrap around the window once the histogram grows too big 00c587b
Antoine Beaupré cleanup safety checks
make sure that if we go beyond the max ratio, we just mark it as one
3885683
Antoine Beaupré rework scaling algorithm so it covers the whole range
i did this after some stress testing, now it covers the whole range on input
faa01e5
Antoine Beaupré better wrapping: add a cursor and respect inner borders 59786b9
Antoine Beaupré switch to ncursesw in the build chain 317c34a
@anarcat

Note that prettyping falls back to regular ASCII characters (_.oO) if unicode is disabled (on the commandline).

Now the questions are:

  1. how do we detect a unicode-capable terminal?
  2. if we can't, how do we disable/enable that feature? another noping binary? nopingu?
  3. what characters do we use in the fallback? _.oO is cute, but I am sure it could be improved with ncurses and ASCII escape codes...

For example, the following program:

#include <ncurses.h>
int main(void)
        {
        int counter;
        initscr();
        attron(A_UNDERLINE);
        mvprintw(0,7,"Progress bar testing\n\n");
        attroff(A_UNDERLINE);
        for (counter=115; counter >= 111; counter--)
          {
            addch(counter | A_ALTCHARSET);
          }
        refresh();
        getch();
        endwin();
        return 0;
        }

... outputs:

       Progress bar testing

⎽⎼─⎻⎺

It renders better on the terminal than here - it progresses actually quite nicely in 5 steps. Not bad!

More information:

@octo
Owner
  1. I've sent an email to my favorite terminal expert and CC'ed you. nl_langinfo(3) looks promising.
  2. I guess a command line argument would be best. People and / or distributions who want to have a different command can use aliases and stuff, though I doubt that this will be priority.
  3. I don't have a strong preference. I like you suggestions, both, the cute and the liney one ;) Code page 437 also has some suitable characters, although not as many as Unicode. No idea how portable / universal that would be.

Thanks again and best regards,
—octo

@anarcat

Awesome, let's see what's the magic incantation then we can finish this. :) If you have pointers on how to name the commandline option, it would be appreciated. prettyping uses --unicode, but I feel we should assume unicode and have a flag to turn it off if necessary. so --nounicode / -n?

@octo
Owner

We're not using getopt_long for portability at the moment. I think a convention is to use upper case and lower case for boolean options, though not consistently: ssh -X enables X forwarding, -x disables it. ssh -t forces (enables) a TTY, -T prevents (disables) one … I'd prefer -u to mean "(force) use Unicode", -U to mean "disable Unicode" and neither to mean "automatically figure it out". Does that sound like a plan?

@anarcat

sounds like a plan to me! now if we could only figure out how to auto-detect now ;)

Florian Forster Refactor the graph printing into its own function.
This makes it much easier and cleaner to add a second, non-Unicode
implementation and possibly even a non-color version.
ae1a4da
@octo
Owner

Also, I just pushed an update to the ab/prettyping branch of my repository which does some refactoring of the code into its own function. I'd be great if you could merge or pick that into the PR.

Thanks :)
—octo

@anarcat

About unicode detection, what do we have?

  • stackexchange suggests locale charmap which returns UTF-8 here
  • rosettacode suggests (basically) grepping LANG for utf (case insensitive)
  • ncurses mailing list says you need to import the user's locale (LC_ALL) and deal with it from there
  • POSIX seems to say we should use:

    #include <langinfo.h>
    char const *codeset = nl_langinfo (CODESET);
    

    then i guess we need to grep for utf there?

It's unclear what are the expectations (of ncurses?) here - do we expect a "unicode" or "utf-8" terminal? And if the locale is set, that's one thing, but it doesn't mean the terminal supports it.

But I guess we could assume that if the locale is set to unicode and the terminal doesn't support it, that's some serious foot-shooting from the user and failure is expected. That is my expectation is a unicode user anyways so far.

@anarcat

Another note - from what I understand, ncurses itself relies on nl_getinfo() to detect the locale to display (say) unicode or borders properly. (I base this on the claim done by python.)

I am not sure what that means, but there you go. :)

@anarcat

I added the refactoring in - one thing though: it seems now the code runs only if has_colors() - however, we could still display a (more limited) progressbar without colors, so I feel we should push that check further down the stack...

@anarcat

Here's the unicode-detection code in ncurses:

/*
 * Check if we are running in a UTF-8 locale.
 */
NCURSES_EXPORT(int)
_nc_unicode_locale(void)
{
    int result = 0;
#if defined(__MINGW32__) && USE_WIDEC_SUPPORT
    result = 1;
#elif HAVE_LANGINFO_CODESET
    char *env = nl_langinfo(CODESET);
    result = !strcmp(env, "UTF-8");
    T(("_nc_unicode_locale(%s) ->%d", env, result));
#else
    char *env = _nc_get_locale();
    if (env != 0) {
    if (strstr(env, ".UTF-8") != 0) {
        result = 1;
        T(("_nc_unicode_locale(%s) ->%d", env, result));
    }
    }
#endif
    return result;
}

This function is used as such:

    sp->_screen_unicode = _nc_unicode_locale();

Maybe we can use that? the screen object doesn't seem accessible unfortunately...

Antoine Beaupré autodetect unicode, and fallback to ACS scancodes on failure
this is fairly ugly - we use a hidden ncurses function to detect
unicode (but at least we don't reimplement it), then we mess around
with the character arrays to display the rights symbols

i am not sure i like this, but i prefer to braindump than to stall, so
let's move forward.
5901ec3
@anarcat

alright, that commit (5901ec3) adds some crude autodetection magic (based on that hidden ncurses function, _nc_unicode_locale) and messes around with my rotten C brain to display the right thing.

we're just missing a commandline option now and we're good, although a second pair of eyes on that ugly mess I just pushed should be applied.

obligatory screenshot:

unset $LANG or $LC_ALL (or whatever env | grep -i utf tells you to) to test.

Antoine Beaupré added some commits
Antoine Beaupré move unicode detection to a separate function
this will ease transition to a commandline option override
b59778b
Antoine Beaupré add commandline flag for forcing or disabling unicode
note that "forcing" may not work: ncurses still expects your locale to
be correct, so maybe the force flag should also explicitely set a utf8
locale?
32ec0e8
@anarcat

done for the night. :)

Florian Forster added some commits
Florian Forster src/oping.h: Don't use the ncurses internal _nc_unicode_locale() func…
…tion.

The "-u" and "-U" options are now handled in a single variable so that the
last option "wins".
3ee0169
Florian Forster Add documentation for the "-u" and "-U" options. 65e6e0f
Florian Forster Add support for both, ncurses and ncursesw. fd42a5b
@anarcat

Alright, so we now have a commandline option, proper toolchain hooks, everything seems to be in order and I use this in production on a daily basis. In fact, I have had this code (65e6e0f, to be more precise) running for over 7 days straight over 6 targets now, so I'd say it works well. :)

Can we merge this in already? The debian package already picked it up as well: http://packages.qa.debian.org/libo/liboping/news/20131226T164825Z.html :)

@anarcat

ping?

@anarcat

ping

@schweikert schweikert referenced this pull request in schweikert/fping
Open

ncurses / "prettyping" feature #63

@anarcat

can we get this show on the road? this is working now, i have ran the code in a test to multiple hosts until i rebooted my workstation, about a week ago - so basically 4 months, without a crash.

@anarcat

ping

@PierrePaul

Any updates on this?

@octo
Owner

Sorry for losing track of this :\ I've just merged this to the master branch (4710e54) and will create a new liboping version soon now :)

Best regards,
—octo

@octo octo closed this
@anarcat

alas! thank you very much for this!

@anarcat anarcat deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 3, 2013
  1. implement some prettyping-inspired display instead of textual

    Antoine Beaupré authored
    this is a first stab at porting "prettyping.sh" into noping. the idea
    is to show a histogram of ping times instead of numerical values. with
    some work, we could actually show both, but this focuses on
    implementing the hard part (the histogram) properly.
    
    it is very rudimentary for now:
    
     * the math may be wrong for the size of the bar, I was mostly in a
       rush to make unicode work and have something pretty quickly.
    
     * all hosts are on the same line: each should have its own line
    
     * the histogram should be displayed in a separate window
    
     * it should use background colors as well
    
     * it should fallback when the terminal is not unicode-capable
    
     * the scaling logic is fully automatic, which necessarily gives weird
       results at first
    
    this requires switching to the ncursesw library and other unicode
    ncurses hackery described in this post:
    
    http://newsgroups.derkeiler.com/Archive/Rec/rec.games.roguelike.development/2010-09/msg00050.html
    
    pretty ping is a awk/bash script, MIT-licensed, available here:
    
    https://bitbucket.org/denilsonsa/small_scripts/src/tip/prettyping.sh
  2. put histograms into the independent window, to eventually restore pin…

    Antoine Beaupré authored
    …g times display
  3. make histogram colors with a nicer background

    Antoine Beaupré authored
  4. remove a little quirk i introduced by mistake

    Antoine Beaupré authored
    this was breaking the border
  5. wrap around the window once the histogram grows too big

    Antoine Beaupré authored
  6. cleanup safety checks

    Antoine Beaupré authored
    make sure that if we go beyond the max ratio, we just mark it as one
  7. rework scaling algorithm so it covers the whole range

    Antoine Beaupré authored
    i did this after some stress testing, now it covers the whole range on input
  8. better wrapping: add a cursor and respect inner borders

    Antoine Beaupré authored
Commits on Dec 4, 2013
  1. switch to ncursesw in the build chain

    Antoine Beaupré authored
Commits on Dec 5, 2013
  1. Refactor the graph printing into its own function.

    Florian Forster authored
    This makes it much easier and cleaner to add a second, non-Unicode
    implementation and possibly even a non-color version.
Commits on Dec 6, 2013
  1. autodetect unicode, and fallback to ACS scancodes on failure

    Antoine Beaupré authored
    this is fairly ugly - we use a hidden ncurses function to detect
    unicode (but at least we don't reimplement it), then we mess around
    with the character arrays to display the rights symbols
    
    i am not sure i like this, but i prefer to braindump than to stall, so
    let's move forward.
  2. move unicode detection to a separate function

    Antoine Beaupré authored
    this will ease transition to a commandline option override
  3. add commandline flag for forcing or disabling unicode

    Antoine Beaupré authored
    note that "forcing" may not work: ncurses still expects your locale to
    be correct, so maybe the force flag should also explicitely set a utf8
    locale?
  4. src/oping.h: Don't use the ncurses internal _nc_unicode_locale() func…

    Florian Forster authored
    …tion.
    
    The "-u" and "-U" options are now handled in a single variable so that the
    last option "wins".
  5. Add documentation for the "-u" and "-U" options.

    Florian Forster authored
Commits on Jan 10, 2014
  1. Add support for both, ncurses and ncursesw.

    Florian Forster authored
This page is out of date. Refresh to see the latest.
Showing with 208 additions and 16 deletions.
  1. +18 −4 configure.ac
  2. +1 −1  src/Makefile.am
  3. +5 −0 src/mans/oping.pod
  4. +184 −11 src/oping.c
View
22 configure.ac
@@ -48,7 +48,7 @@ LT_INIT([dlopen])
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
-AC_CHECK_HEADERS([math.h signal.h fcntl.h inttypes.h netdb.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
+AC_CHECK_HEADERS([math.h signal.h fcntl.h inttypes.h netdb.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h locale.h langinfo.h])
# This sucks, but what can I do..?
AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
@@ -185,11 +185,25 @@ AC_CHECK_FUNCS(nanosleep, [],
AC_MSG_ERROR(cannot find nanosleep)))
AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
-with_ncurses="yes"
-AC_CHECK_HEADERS(ncurses.h, [with_ncurses="yes"], [with_ncurses="no"])
+with_ncurses="no"
+AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses.h, [with_ncurses="yes"], [])
if test "x$with_ncurses" = "xyes"
then
- AC_CHECK_LIB(ncurses, mvwprintw, [with_ncurses="yes"], [with_ncurses="no"])
+ have_ncursesw="no"
+ have_ncurses="no"
+ NCURSES_LIB=""
+
+ AC_CHECK_LIB(ncursesw, mvwprintw, [have_ncursesw="yes"], [have_ncursesw="no"])
+ AC_CHECK_LIB(ncurses, mvwprintw, [have_ncurses="yes"], [have_ncurses="no"])
+
+ if test "x$have_ncursesw" = "xyes"; then
+ NCURSES_LIB="-lncursesw"
+ else if test "x$have_ncurses" = "xyes"; then
+ NCURSES_LIB="-lncurses"
+ else
+ with_ncurses="no"
+ fi; fi
+ AC_SUBST(NCURSES_LIB)
fi
AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$with_ncurses" = "xyes")
View
2  src/Makefile.am
@@ -46,7 +46,7 @@ bin_PROGRAMS += noping
noping_SOURCES = oping.c
noping_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_NCURSES=1
-noping_LDADD = liboping.la -lm -lncurses
+noping_LDADD = liboping.la -lm $(NCURSES_LIB)
if BUILD_WITH_LIBRT
noping_LDADD += -lrt
endif
View
5 src/mans/oping.pod
@@ -166,6 +166,11 @@ I<Explicit Congestion Notification> (ECN), even if the deprecated
I<Type of Service> (ToS) aliases were used to specify the bits of outgoing
packets.
+=item B<-u>|B<-U>
+
+I<noping only> B<-u> forces UTF-8 output, B<-U> disables UTF-8 output. If
+neither is given, the codeset is automatically determined from the locale.
+
=back
=head1 COLORS
View
195 src/oping.c
@@ -74,13 +74,52 @@
#include <sys/types.h>
#endif
+#include <locale.h>
+#include <langinfo.h>
+
#if USE_NCURSES
# define NCURSES_OPAQUE 1
-# include <ncurses.h>
+/* http://newsgroups.derkeiler.com/Archive/Rec/rec.games.roguelike.development/2010-09/msg00050.html */
+# define _X_OPEN_SOURCE_EXTENDED
+
+# if HAVE_NCURSESW_NCURSES_H
+# include <ncursesw/ncurses.h>
+# elif HAVE_NCURSES_H
+# include <ncurses.h>
+# endif
# define OPING_GREEN 1
# define OPING_YELLOW 2
# define OPING_RED 3
+# define OPING_GREEN_HIST 4
+# define OPING_YELLOW_HIST 5
+# define OPING_RED_HIST 6
+
+static char const * const hist_symbols_utf8[] = {
+ "", "", "", "", "", "", "", "" };
+static size_t const hist_symbols_utf8_num = sizeof (hist_symbols_utf8)
+ / sizeof (hist_symbols_utf8[0]);
+
+/* scancodes for 6 levels of horizontal bars, ncurses-specific */
+/* those are not the usual constants because those are not constant */
+static int const hist_symbols_acs[] = {
+ 115, /* ACS_S9 "⎽" */
+ 114, /* ACS_S7 "⎼" */
+ 113, /* ACS_S5 "─" */
+ 112, /* ACS_S3 "⎻" */
+ 111 /* ACS_S1 "⎺" */
+};
+static size_t const hist_symbols_acs_num = sizeof (hist_symbols_acs)
+ / sizeof (hist_symbols_acs[0]);
+
+/* use different colors without a background for scancodes */
+static int const hist_colors_utf8[] = {
+ OPING_GREEN_HIST, OPING_YELLOW_HIST, OPING_RED_HIST };
+static int const hist_colors_acs[] = {
+ OPING_GREEN, OPING_YELLOW, OPING_RED };
+/* assuming that both arrays are the same size */
+static size_t const hist_colors_num = sizeof (hist_colors_utf8)
+ / sizeof (hist_colors_utf8[0]);
#endif
#include "oping.h"
@@ -121,6 +160,9 @@ static char *opt_filename = NULL;
static int opt_count = -1;
static int opt_send_ttl = 64;
static uint8_t opt_send_qos = 0;
+#if USE_NCURSES
+static int opt_utf8 = 0;
+#endif
static int host_num = 0;
@@ -265,6 +307,9 @@ static void usage_exit (const char *name, int status) /* {{{ */
" -I srcaddr source address\n"
" -D device outgoing interface name\n"
" -f filename filename to read hosts from\n"
+#if USE_NCURSES
+ " -u / -U force / disable UTF-8 output\n"
+#endif
"\noping "PACKAGE_VERSION", http://verplant.org/liboping/\n"
"by Florian octo Forster <octo@verplant.org>\n"
@@ -467,7 +512,11 @@ static int read_options (int argc, char **argv) /* {{{ */
while (1)
{
- optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:");
+ optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:"
+#if USE_NCURSES
+ "uU"
+#endif
+ );
if (optchar == -1)
break;
@@ -538,6 +587,15 @@ static int read_options (int argc, char **argv) /* {{{ */
set_opt_send_qos (optarg);
break;
+#if USE_NCURSES
+ case 'u':
+ opt_utf8 = 2;
+ break;
+ case 'U':
+ opt_utf8 = 1;
+ break;
+#endif
+
case 'h':
usage_exit (argv[0], 0);
break;
@@ -597,12 +655,120 @@ static void time_calc (struct timespec *ts_dest, /* {{{ */
} /* }}} void time_calc */
#if USE_NCURSES
-static int update_stats_from_context (ping_context_t *ctx) /* {{{ */
+static _Bool has_utf8() /* {{{ */
+{
+# if HAVE_NCURSESW_NCURSES_H
+ if (!opt_utf8)
+ {
+ /* Automatically determine */
+ if (strcasecmp ("UTF-8", nl_langinfo (CODESET)) == 0)
+ opt_utf8 = 2;
+ else
+ opt_utf8 = 1;
+ }
+ return ((_Bool) (opt_utf8 - 1));
+# else
+ return (0);
+# endif
+} /* }}} _Bool has_utf8 */
+
+static int update_prettyping_graph (ping_context_t *ctx, /* {{{ */
+ double latency, unsigned int sequence)
+{
+ int color = OPING_RED;
+ char const *symbol = "!";
+ int symbolc = '!';
+ size_t hist_symbols_num;
+ size_t index_symbols;
+
+ int x_max;
+ int x_pos;
+
+ x_max = getmaxx (ctx->window);
+ x_pos = ((sequence - 1) % (x_max - 4)) + 2;
+
+ if (has_utf8())
+ {
+ hist_symbols_num = hist_symbols_utf8_num;
+ }
+ else {
+ hist_symbols_num = hist_symbols_acs_num;
+ }
+
+ if (latency >= 0.0)
+ {
+ double ratio;
+ size_t intensity;
+ size_t index_colors;
+
+ ratio = latency / PING_DEF_TTL;
+ if (ratio > 1) {
+ ratio = 1.0;
+ }
+
+ intensity = (size_t) ((ratio * hist_symbols_num
+ * hist_colors_num) - 1);
+
+ index_colors = intensity / hist_symbols_num;
+ assert (index_colors < hist_colors_num);
+
+ index_symbols = intensity % hist_symbols_num;
+ if (has_utf8())
+ {
+ color = hist_colors_utf8[index_colors];
+ symbol = hist_symbols_utf8[index_symbols];
+ }
+ else
+ {
+ color = hist_colors_acs[index_colors];
+ symbolc = hist_symbols_acs[index_symbols] | A_ALTCHARSET;
+ }
+ }
+ else /* if (!(latency >= 0.0)) */
+ wattron (ctx->window, A_BOLD);
+
+ wattron (ctx->window, COLOR_PAIR(color));
+ if (has_utf8())
+ {
+ mvwprintw (ctx->window,
+ /* y = */ 3,
+ /* x = */ x_pos,
+ symbol);
+ }
+ else {
+ mvwaddch (ctx->window,
+ /* y = */ 3,
+ /* x = */ x_pos,
+ symbolc);
+ }
+ wattroff (ctx->window, COLOR_PAIR(color));
+
+ /* Use negation here to handle NaN correctly. */
+ if (!(latency >= 0.0))
+ wattroff (ctx->window, A_BOLD);
+
+ wprintw (ctx->window, " ");
+ return (0);
+} /* }}} int update_prettyping_graph */
+
+static int update_stats_from_context (ping_context_t *ctx, pingobj_iter_t *iter) /* {{{ */
{
+ double latency = -1.0;
+ size_t buffer_len = sizeof (latency);
+
+ ping_iterator_get_info (iter, PING_INFO_LATENCY,
+ &latency, &buffer_len);
+
+ unsigned int sequence = 0;
+ buffer_len = sizeof (sequence);
+ ping_iterator_get_info (iter, PING_INFO_SEQUENCE,
+ &sequence, &buffer_len);
+
+
if ((ctx == NULL) || (ctx->window == NULL))
return (EINVAL);
- werase (ctx->window);
+ /* werase (ctx->window); */
box (ctx->window, 0, 0);
wattron (ctx->window, A_BOLD);
@@ -632,6 +798,9 @@ static int update_stats_from_context (ping_context_t *ctx) /* {{{ */
deviation);
}
+ if (has_colors () == TRUE)
+ update_prettyping_graph (ctx, latency, sequence);
+
wrefresh (ctx->window);
return (0);
@@ -648,7 +817,7 @@ static int on_resize (pingobj_t *ping) /* {{{ */
if ((height < 1) || (width < 1))
return (EINVAL);
- main_win_height = height - (4 * host_num);
+ main_win_height = height - (5 * host_num);
wresize (main_win, main_win_height, /* width = */ width);
/* Allow scrolling */
scrollok (main_win, TRUE);
@@ -672,9 +841,9 @@ static int on_resize (pingobj_t *ping) /* {{{ */
delwin (context->window);
context->window = NULL;
}
- context->window = newwin (/* height = */ 4,
+ context->window = newwin (/* height = */ 5,
/* width = */ width,
- /* y = */ main_win_height + (4 * context->index),
+ /* y = */ main_win_height + (5 * context->index),
/* x = */ 0);
}
@@ -722,9 +891,12 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */
init_pair (OPING_GREEN, COLOR_GREEN, /* default = */ 0);
init_pair (OPING_YELLOW, COLOR_YELLOW, /* default = */ 0);
init_pair (OPING_RED, COLOR_RED, /* default = */ 0);
+ init_pair (OPING_GREEN_HIST, COLOR_GREEN, COLOR_BLACK);
+ init_pair (OPING_YELLOW_HIST, COLOR_YELLOW, COLOR_GREEN);
+ init_pair (OPING_RED_HIST, COLOR_RED, COLOR_YELLOW);
}
- main_win_height = height - (4 * host_num);
+ main_win_height = height - (5 * host_num);
main_win = newwin (/* height = */ main_win_height,
/* width = */ width,
/* y = */ 0, /* x = */ 0);
@@ -751,9 +923,9 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */
delwin (context->window);
context->window = NULL;
}
- context->window = newwin (/* height = */ 4,
+ context->window = newwin (/* height = */ 5,
/* width = */ width,
- /* y = */ main_win_height + (4 * context->index),
+ /* y = */ main_win_height + (5 * context->index),
/* x = */ 0);
}
@@ -946,7 +1118,7 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */
}
#if USE_NCURSES
- update_stats_from_context (context);
+ update_stats_from_context (context, iter);
wrefresh (main_win);
#endif
} /* }}} void update_host_hook */
@@ -1026,6 +1198,7 @@ int main (int argc, char **argv) /* {{{ */
}
#endif
+ setlocale(LC_ALL, "");
optind = read_options (argc, argv);
#if !_POSIX_SAVED_IDS
Something went wrong with that request. Please try again.