diff options
author | Aaron Gyes <me@aaron.gy> | 2016-06-23 21:10:31 -0700 |
---|---|---|
committer | Aaron Gyes <me@aaron.gy> | 2016-06-23 21:10:31 -0700 |
commit | 9c53019d95c7b73f14c8bb39cddadacab16d0bf9 (patch) | |
tree | be51017299dde1ce89ad37e24e1c2c1025b2622c | |
parent | 7a4065eb9f1a31ff61f2c8034ce68457307998e3 (diff) |
fish_key_reader: ms were off by factor of ten.
Improve output.
-rw-r--r-- | src/fish_key_reader.cpp | 15 |
1 files 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<long double>::quiet_NaN(); +double prev_tstamp = std::numeric_limits<double>::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"); } |