From 346ce8081ba8ac4460d4da27abd9fe6701ab7dcb Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Tue, 1 Feb 2022 11:01:08 -0800 Subject: [PATCH] time: use box drawing characterts for the separator This spruces up output slightly to render a solid line instead of a bunch of dashes for the horizontal rule shown in time output. --- src/timer.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/timer.cpp b/src/timer.cpp index 6f2f0e25f..1fac5feaf 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -11,6 +11,19 @@ #include #include +#if HAVE_CURSES_H +#include +#elif HAVE_NCURSES_H +#include +#elif HAVE_NCURSES_CURSES_H +#include +#endif +#if HAVE_TERM_H +#include +#elif HAVE_NCURSES_TERM_H +#include +#endif + #include "builtin.h" #include "common.h" #include "exec.h" @@ -122,7 +135,7 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s return L"microseconds"; } // GCC does not recognize the exhaustive switch above - return ""; + return L""; }; auto unit_short_name = [](tunit unit) { @@ -137,7 +150,7 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s return L"μs"; } // GCC does not recognize the exhaustive switch above - return ""; + return L""; }; auto convert = [](int64_t micros, tunit unit) { @@ -163,10 +176,9 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s wcstring output; if (!verbose) { - append_format(output, L"\n_______________________________" - L"\nExecuted in %6.2F %s" - L"\n usr time %6.2F %s" - L"\n sys time %6.2F %s" + append_format(output, L"\nExecuted in %6.2F %ls" + L"\n usr time %6.2F %ls" + L"\n sys time %6.2F %ls" L"\n", wall_time, unit_name(wall_unit), usr_time, unit_name(cpu_unit), @@ -180,16 +192,16 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s double child_sys_time = convert(child_sys_micros, child_unit); int column2_unit_len = std::max(wcslen(unit_short_name(wall_unit)), - strlen(unit_short_name(cpu_unit))); - // TODO: improve layout and use standard two char units + wcslen(unit_short_name(cpu_unit))); + // TODO: improve layout append_format(output, - L"\n________________________________________________________" + L"%s%s%s" L"\nExecuted in %6.2F %-*ls %-*s %s" L"\n usr time %6.2F %-*ls %6.2F %ls %6.2F %ls" - L"\n sys time %6.2F %-*ls %6.2F %ls %6.2F %ls" - L"\n", + L"\n sys time %6.2F %-*ls %6.2F %ls %6.2F %ls", + enter_alt_charset_mode, std::string(45, 'q').c_str(), exit_alt_charset_mode, wall_time, column2_unit_len, unit_short_name(wall_unit), - static_cast(strlen(unit_short_name(fish_unit))) + 7, "fish", "external", + static_cast(wcslen(unit_short_name(fish_unit))) + 7, "fish", "external", usr_time, column2_unit_len, unit_short_name(cpu_unit), fish_usr_time, unit_short_name(fish_unit), child_usr_time, unit_short_name(child_unit), sys_time, column2_unit_len, unit_short_name(cpu_unit), fish_sys_time,