You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
notcurses/src/demo/demo.h

63 lines
1.5 KiB
C

#ifndef NOTCURSES_DEMO
#define NOTCURSES_DEMO
#include <time.h>
#include <notcurses.h>
#ifdef __cplusplus
extern "C" {
#endif
// configured via command line option -- the base number of ns between demos
extern struct timespec demodelay;
int unicodeblocks_demo(struct notcurses* nc);
int widecolor_demo(struct notcurses* nc);
int box_demo(struct notcurses* nc);
int maxcolor_demo(struct notcurses* nc);
5 years ago
int grid_demo(struct notcurses* nc);
int sliding_puzzle_demo(struct notcurses* nc);
5 years ago
int view_demo(struct notcurses* nc);
int panelreel_demo(struct notcurses* nc);
int luigi_demo(struct notcurses* nc);
5 years ago
int outro(struct notcurses* nc);
int timespec_subtract(struct timespec *result, const struct timespec *time1,
struct timespec *time0);
#define GIG 1000000000ul
static inline uint64_t
timespec_to_ns(const struct timespec* ts){
return ts->tv_sec * GIG + ts->tv_nsec;
}
static inline struct timespec*
ns_to_timespec(uint64_t ns, struct timespec* ts){
ts->tv_sec = ns / GIG;
ts->tv_nsec = ns % GIG;
return ts;
}
static inline int64_t
timespec_subtract_ns(const struct timespec* time1, const struct timespec* time0){
int64_t ns = timespec_to_ns(time1);
ns -= timespec_to_ns(time0);
return ns;
}
// divide the provided timespec 'ts' by 'divisor' into 'quots'
static inline void
timespec_div(const struct timespec* ts, unsigned divisor, struct timespec* quots){
uint64_t ns = timespec_to_ns(ts);
ns /= divisor;
quots->tv_nsec = ns % GIG;
quots->tv_sec = ns / GIG;
}
#ifdef __cplusplus
}
#endif
#endif