[hud] use ncmetric for elapsed time

pull/2333/head
nick black 3 years ago committed by nick black
parent 0231768406
commit 51e90ca7e9

@ -392,9 +392,13 @@ hud_print_finished(elem* list){
if(ncplane_printf_yx(hud, line, 1, "%d", e->frames) < 0){
return -1;
}
if(ncplane_printf_yx(hud, line, 7, "%"PRIu64".%03"PRIu64"s",
e->totalns / NANOSECS_IN_SEC,
(e->totalns % NANOSECS_IN_SEC) / 1000000) < 0){
char buf[PREFIXCOLUMNS];
ncmetric(e->totalns, NANOSECS_IN_SEC, buf, 0, 1000, '\0');
for(size_t x = 6 ; x < 14 - strlen(buf) ; ++x){
nccell ci = CELL_TRIVIAL_INITIALIZER;
ncplane_putc_yx(hud, 1, x, &ci);
}
if(ncplane_printf_yx(hud, line, 14 - strlen(buf), "%ss", buf) < 0){
return -1;
}
if(ncplane_putstr_yx(hud, line, 16, e->name) < 0){
@ -608,8 +612,13 @@ int demo_render(struct notcurses* nc){
if(ncplane_printf_yx(hud, 1, 1, "%d", elems->frames) < 0){
return -1;
}
if(ncplane_printf_yx(hud, 1, 7, "%"PRIu64".%03"PRIu64"s", ns / NANOSECS_IN_SEC,
(ns % NANOSECS_IN_SEC) / 1000000) < 0){
char buf[PREFIXCOLUMNS];
ncmetric(ns, NANOSECS_IN_SEC, buf, 0, 1000, '\0');
for(size_t x = 6 ; x < 14 - strlen(buf) ; ++x){
nccell ci = CELL_TRIVIAL_INITIALIZER;
ncplane_putc_yx(hud, 1, x, &ci);
}
if(ncplane_printf_yx(hud, 1, 14 - strlen(buf), "%ss", buf) < 0){
return -1;
}
if(ncplane_putstr_yx(hud, 1, 16, elems->name) < 0){

@ -3,7 +3,7 @@
static int y;
static int targy;
static int xstart;
static unsigned xstart;
static struct ncplane* on;
struct ncvisual_options vopts;
@ -114,7 +114,7 @@ videothread(void* vnc){
}
static struct ncplane*
outro_message(struct notcurses* nc, int* rows, int* cols){
outro_message(struct notcurses* nc, unsigned* rows, unsigned* cols){
const char str0[] = " ATL, baby! ATL! ";
const char str1[] = " throw your hands in the air ";
const char* str2 = notcurses_canutf8(nc) ? " hack on! —dank❤ " : " hack on! --dank ";
@ -207,7 +207,7 @@ int outro(struct notcurses* nc){
ncplane_set_name(vopts.n, "bnnr");
}
xstart = cols;
int ystart = rows;
unsigned ystart = rows;
on = outro_message(nc, &ystart, &xstart);
if(on == NULL){
return -1;

@ -192,7 +192,7 @@ ncreel_demo_core(struct notcurses* nc){
tabletctx* tctxs = NULL;
bool aborted = false;
int x = 8, y = 4;
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
struct ncplane_options nopts = {
.y = y,

@ -25,7 +25,7 @@ fade_block(struct notcurses* nc, struct ncplane* nn, const struct timespec* subd
// negative row will result in vertical pbar on the left side
static struct ncprogbar*
pbar_make(struct notcurses* nc, int row){
int dimx, dimy;
unsigned dimx, dimy;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
struct ncplane_options nopts = {
.y = row < 0 ? 4 : row,
@ -42,8 +42,9 @@ pbar_make(struct notcurses* nc, int row){
uint64_t channels = 0;
ncchannels_set_bg_rgb(&channels, 0);
ncplane_set_base(pbar, "", 0, channels);
int posy, posx, pdimy, pdimx;
int posy, posx;
ncplane_yx(pbar, &posy, &posx);
unsigned pdimy, pdimx;
ncplane_dim_yx(pbar, &pdimy, &pdimx);
ncplane_cursor_move_yx(std, posy - 1, posx - 1);
channels = 0;
@ -66,7 +67,7 @@ pbar_make(struct notcurses* nc, int row){
static int
draw_block(struct ncplane* nn, uint32_t blockstart){
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(nn, &dimy, &dimx);
nccell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
nccell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
@ -207,7 +208,7 @@ int unicodeblocks_demo(struct notcurses* nc){
return 0;
}
ncplane_greyscale(notcurses_stdplane(nc));
int pbarrow = 4 + BLOCKSIZE / CHUNKSIZE + 4;
unsigned pbarrow = 4 + BLOCKSIZE / CHUNKSIZE + 4;
if(pbarrow > maxy - 2){
pbarrow = -1;
}

@ -319,7 +319,7 @@ unicodedumper(struct ncplane* n, const char* indent){
uint64_t ul = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0x19, 0x19, 0x70);
uint64_t ll = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0x19, 0x19, 0x70);
ncplane_cursor_move_yx(n, y - 15, 0);
ncplane_stain(n, -1, -1, y - 1, 79, ul, ur, ll, lr);
ncplane_stain(n, -1, -1, 15, 80, ul, ur, ll, lr);
ncplane_set_styles(n, NCSTYLE_BOLD | NCSTYLE_ITALIC);
ncplane_cursor_move_yx(n, y - 12, 54);
wviz(n, L"🯁🯂🯃https://notcurses.com");

@ -24,7 +24,7 @@ typedef struct ncvisual {
uint32_t* data; // (scaled) RGBA image data, rowstride bytes per row
unsigned pixx, pixy; // pixel geometry, *not* cell geometry
// lines are sometimes padded. this many true bytes per row in data.
int rowstride;
unsigned rowstride;
bool owndata; // we own data iff owndata == true
} ncvisual;

Loading…
Cancel
Save