From 9c53019d95c7b73f14c8bb39cddadacab16d0bf9 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Thu, 23 Jun 2016 21:10:31 -0700 Subject: fish_key_reader: ms were off by factor of ten. Improve output. --- src/fish_key_reader.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/fish_key_reader.cpp b/src/fish_key_reader.cpp index 2d9076e2..8df01394 100644 --- a/src/fish_key_reader.cpp +++ b/src/fish_key_reader.cpp @@ -29,7 +29,7 @@ struct config_paths_t determine_config_directory_paths(const char *argv0); -long double prev_tstamp = std::numeric_limits::quiet_NaN(); +double prev_tstamp = std::numeric_limits::quiet_NaN(); static const char *ctrl_equivalents[] = {"\\000", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\014", "\\015", @@ -85,12 +85,11 @@ void process_input(bool continuous_mode) { return; } - - long double delta_tstamp = (timef() - prev_tstamp) * 100; - + double delta_tstamp = (timef() - prev_tstamp); + // double timef() is time in seconds since unix epoch with ~microsecondish precision prev_tstamp = timef(); - if (delta_tstamp > 20000) { + if (delta_tstamp > 20) { printf("Type 'exit' or 'quit' to terminate this program.\n"); printf("\n"); } @@ -102,7 +101,7 @@ void process_input(bool continuous_mode) { printf("dec: %3u hex: %2x char: %s (aka \\c%c)", c, c, ctrl_equivalents[c], c + 64); } else { - printf("dec: %3u hex: %2x char: \\c%c", c, c, c + 64); + printf("dec: %3u hex: %2x char: \\c%c\t", c, c, c + 64); } } else if (c == 32) { // The space character. @@ -115,11 +114,11 @@ void process_input(bool continuous_mode) { printf("dec: %3u hex: %2x char: non-ASCII", c, c); } else { // ASCII characters that are not control characters. - printf("dec: %3u hex: %2x char: %c", c, c, c); + printf("dec: %3u hex: %2x char: %c\t", c, c, c); } if (!std::isnan(delta_tstamp)) { - printf(" (%.2Lf ms)\n", delta_tstamp); + printf("\t(%6.lf ms)\n", delta_tstamp * 1000); } else { printf("\n"); } -- cgit v1.2.3