rizin/libr/cons
Riccardo Schirone 72ffe1bd0f cons/dietline: show the same number of items per line
It fixes a bug when showing options for autocompletion, where the first
row has less items than the others. With this patch every line, except
the last, should have the same number of elements.
2016-02-13 09:23:17 +01:00
..
d build cleanup focused on possibility to control the lib directories with the build parameters 2015-10-27 03:26:45 +01:00
t
2048.c Fix some of the warnings in #4013 2016-01-27 03:14:19 +01:00
canvas.c More whitelisted auto-indented files 2015-12-08 13:24:21 +01:00
canvas_line.c core/graph: quick fix for 1-level back-edges and self-referenced blocks 2015-10-18 15:52:34 +02:00
cons.c libr/cons/cons.c::palloc() : add some sanity checks: 2016-01-17 19:24:53 +01:00
dietline.c cons/dietline: show the same number of items per line 2016-02-13 09:23:17 +01:00
editor.c More whitelisted auto-indented files 2015-12-08 13:24:21 +01:00
grep.c Fix #3557 - V_ is the new VF_, old one is in V?? 2015-10-29 12:54:19 +01:00
hud.c Initial work on automatic indent whitelisting 2015-12-08 12:55:29 +01:00
input.c Fixes for #3846 - agg help messages 2016-01-05 00:47:41 +01:00
Jamroot
less.c Fix some of the warnings in #4013 2016-01-27 03:14:19 +01:00
line.c Initial work on automatic indent whitelisting 2015-12-08 12:55:29 +01:00
Makefile Bring back the old edge style in the aa graph. Fix self loops 2015-02-15 21:34:12 +01:00
output.c Fix #3926 - Fix color wrap for long lines in visual mode 2016-01-10 23:46:33 +01:00
pal.c fix #3566 (third try) 2015-10-23 18:02:05 +00:00
pipe.c
README
rgb.c Fixed coding style in libr/cons/pal.c and libr/cons/rgb.c , 2015-10-22 23:38:33 +02:00
TODO
utf8.c Fix iOS build, crashes in reflines, analysis issues on OSX debugger and more! 2015-06-21 00:50:53 +02:00

+--------+
| r_cons |
+--------+

r_cons_fb

r_cons_frame
r_cons_frame_add
r_cons_frame_del

struct r_cons_frame_t {
	int w, h; // should be the same as text|draw->w and text|draw->h 
	int rw, rh;
	struct r_cons_buffer_t *text;
	struct r_cons_buffer_t *draw;
	struct
};

struct r_cons_buffer_t {
	int alpha; /* ' ' chars in buffers are not written */
	int w, h;
	ut8 *buf;
};

struct r_cons_t {
	struct r_cons_buffer_t *b;
	int w, h;
	struct list_head frames;
};

struct r_cons_frame_t *r_cons_frame_new(int x, int y, int w, int h)
{
	struct r_cons_frame_t *f = R_NEW(struct r_cons_frame_t);
	f->text = r_cons_buffer_new(w, h);
	f->draw = r_cons_buffer_new(w, h);
	f->w = w;
	f->h = h;
	return f;
}

void r_cons_frame_add(struct r_cons_t *cons, struct r_cons_frame_t *f, int head)
{
	if (head) list_add(&(f->list), &cons->frames);
	else list_add_tail(&(f->list), &cons->frames);
}


int r_cons_frame_render(struct r_cons_frame_t *frame, struct r_cons_buffer_t *buf)
{
	/* foreach pixel resolve matching frame (Z-ordered) and draw */
}

/* <{:api-prefix r_cons_}> */
/* <{:doc Draws a line between two points in a buffer}> */
/* <{:api int,buffer_line,int,int,int,int}> */
void r_cons_buffer_line(struct r_cons_buffer_t *buf, int x0, int y0, int x1, int y1)
{
	/* XXX PURE SHIT */
	char onechars[9] = {
		'.', '_',',',
		'\\', '|','/',
		'\'', '^','\'',
	};
	double x = x0;
	double y = y0;
	double xi = x1-x0;
	double yi = y1-y0;
	for(;x<x1;x++) {
		r_cons_buffer_putch(buf, x, y, '.');
		x+=xi;
	}
}

/* buffers */

struct r_cons_buffer *r_cons_buffer_new(int w, int h)
{
	struct r_cons_buffer_t *buf = R_NEW(struct r_cons_buffer_t);
	if (w<1) w=1;
	if (h<1) h=1;
	buf->rw = buf->w = w;
	buf->rh = buf->h = h;
	buf->buf = (ut8*)malloc(w*h);
	return buf;
}

int r_cons_buffer_set_size(struct r_cons_buffer *buf, int w, int h)
{
	struct r_cons_buffer_t *buf = R_NEW(struct r_cons_buffer_t);
	if (w<1) w=1;
	if (h<1) h=1;
	if (w>buf->rw) {
		/* must resize internal buffer */
		buf->rw = w;
		buf->buf = (ut8*) realloc(buf->buf, w*h);
	}
	buf->rw = buf->w = w;
	buf->rh = buf->h = h;
	buf->buf = (ut8*)malloc(w*h);
	return buf;
}