-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
31 lines (26 loc) · 676 Bytes
/
Copy pathutils.c
File metadata and controls
31 lines (26 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "utils.h"
#include <ncurses.h>
#include <time.h>
int msbetween(struct timespec *past, struct timespec *future) {
return (future->tv_sec - past->tv_sec) * 1000 +
(future->tv_nsec - past->tv_nsec) / 1000000;
}
void setdroptime(struct timespec *droptime) {
clock_gettime(CLOCK_MONOTONIC, droptime);
droptime->tv_nsec += 750000000;
}
void custom_sleep(WINDOW *win, int ms) {
struct timespec time1, time2;
while (ms > 0) {
clock_gettime(CLOCK_MONOTONIC, &time1);
wtimeout(win, ms);
wgetch(win);
clock_gettime(CLOCK_MONOTONIC, &time2);
ms -= msbetween(&time1, &time2);
}
}
void swapints(int *a, int *b) {
int tmp = *a;
*a = *b;
*b = tmp;
}