This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gui_lay_row(ctx, 3, (int[]) { 30, -90, -1 }, 0); | |
/* Layout */ | |
enum gui_lay_dir { | |
GUI_ROW, | |
GUI_COL, | |
}; | |
struct gui_lay_sol { | |
int fix_siz; | |
int fix_cnt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct gui_bnd {int min, mid, max, ext;}; | |
struct gui_box { | |
struct gui_bnd x; | |
struct gui_bnd y; | |
}; | |
#define gui_box(x,y,w,h) (struct gui_box){{x,x+(w>>1),x+w,w},{y,y+(h>>1),y+h,h}} | |
#define gui_min_max(a,b) (struct gui_bnd){a,a+((b-a)>>1),b,b-a} | |
#define gui_min_ext(m,e) (struct gui_bnd){m,m+(e>>1),m+e,e} | |
#define gui_max_ext(m,e) (struct gui_bnd){m-e,m-(e>>1),m,e} | |
#define gui_mid_min(c,m) (struct gui_bnd){m,c,m+c-m,(m-c)<<1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static unsigned | |
wang_hash(unsigned u) | |
{ | |
u = ((u ^ 61) ^ (u >> 16)) * 9; | |
u = (u ^ (u >> 4)) * 0x27d4eb2d; | |
return u ^ (u >> 15); | |
} | |
static unsigned | |
rand_lcg(unsigned *rng) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#define UTF_INVALID 0xFFFD | |
static const char* | |
utf_dec(unsigned *dst, const char *p, const char *e) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
#include <assert.h> | |
static int | |
str_fzy(const char *str, const char *ptn) | |
{ | |
const char *pat = ptn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static float | |
scalbnf(float x, int n) | |
{ | |
union {float f; unsigned i;} u; | |
float y = x; | |
if (n > 127) { | |
y *= 0x1p127f; | |
n -= 127; | |
if (n > 127) { | |
y *= 0x1p127f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static char* | |
sys_clip_get(struct sys *s, Atom selection, Atom target) | |
{ | |
assert(s); | |
struct sys_x11 *x11 = s->platform; | |
/* blocking wait for clipboard data */ | |
XEvent notify; | |
XConvertSelection(x11->dpy, selection, target, selection, x11->helper, CurrentTime); | |
while (!XCheckTypedWindowEvent(x11->dpy, x11->helper, SelectionNotify, ¬ify)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
#define op(r,e,a,p,b,i,s) ((r) e (a) p ((b) i (s))) | |
#define lerp(r,a,b,t) ((r)=(a)+(t)*((b)-(a))) | |
#define rad(x) ((x)*3.141592653f/180.0f) | |
#define op3(r,e,a,p,b,i,s)\ | |
do{op((r)[0],e,(a)[0],p,(b)[0],i,s), op((r)[1],e,(a)[1],p,(b)[1],i,s),\ | |
op((r)[2],e,(a)[2],p,(b)[2],i,s);} while(0) | |
#define op3s(r,e,a,p,s)\ | |
do{op((r)[0],e,(0),+,(a)[0],p,s), op((r)[1],e,(0),+,(a)[1],p,s),\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <assert.h> | |
#include <string.h> | |
#include <stdarg.h> | |
#include <limits.h> | |
#define cast(t,p) ((t)(p)) | |
#define szof(a) ((int)sizeof(a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct lzw { | |
int bitcnt; | |
int bits, off; | |
}; | |
static int | |
lzw_compressed_size(int size) | |
{ | |
return size*2; | |
} | |
static unsigned char* |