notcurses-view: %jd + intmax_t for 32-bit

This commit is contained in:
nick black 2020-05-14 01:05:36 -04:00
parent 2588baa7db
commit 2c73162c62
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -51,7 +51,7 @@ auto perframe([[maybe_unused]] struct notcurses* _nc, struct ncvisual* ncv, void
stdn->set_fg(0x80c080); stdn->set_fg(0x80c080);
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
int64_t ns = timespec_to_ns(&now) - timespec_to_ns(start); intmax_t ns = timespec_to_ns(&now) - timespec_to_ns(start);
stdn->erase(); stdn->erase();
stdn->printf(0, NCAlign::Left, "frame %06d\u2026", *framecount); stdn->printf(0, NCAlign::Left, "frame %06d\u2026", *framecount);
char* subtitle = ncvisual_subtitle(ncv); char* subtitle = ncvisual_subtitle(ncv);
@ -73,13 +73,13 @@ auto perframe([[maybe_unused]] struct notcurses* _nc, struct ncvisual* ncv, void
ncplane_printf_yx(subtitle_plane, 0, 0, "%s", subtitle); ncplane_printf_yx(subtitle_plane, 0, 0, "%s", subtitle);
free(subtitle); free(subtitle);
} }
const int64_t h = ns / (60 * 60 * NANOSECS_IN_SEC); const intmax_t h = ns / (60 * 60 * NANOSECS_IN_SEC);
ns -= h * (60 * 60 * NANOSECS_IN_SEC); ns -= h * (60 * 60 * NANOSECS_IN_SEC);
const int64_t m = ns / (60 * NANOSECS_IN_SEC); const intmax_t m = ns / (60 * NANOSECS_IN_SEC);
ns -= m * (60 * NANOSECS_IN_SEC); ns -= m * (60 * NANOSECS_IN_SEC);
const int64_t s = ns / NANOSECS_IN_SEC; const intmax_t s = ns / NANOSECS_IN_SEC;
ns -= s * NANOSECS_IN_SEC; ns -= s * NANOSECS_IN_SEC;
stdn->printf(0, NCAlign::Right, "%02ld:%02ld:%02ld.%04ld", stdn->printf(0, NCAlign::Right, "%02jd:%02jd:%02jd.%04jd",
h, m, s, ns / 1000000); h, m, s, ns / 1000000);
if(!nc.render()){ if(!nc.render()){
return -1; return -1;