radare2/libr/cons
2018-03-14 15:37:37 +01:00
..
d Improve white theme 2018-03-07 01:52:11 +01:00
2048.c Fix code indentation in libr_cons 2016-06-29 12:33:31 +02:00
canvas_line.c cons/canvas_line: fix back and straight edges (#9630) 2018-03-08 10:50:36 +01:00
canvas.c Fix asan issue with graph initialization 2018-03-07 12:47:39 +01:00
cons.c Minor improvement in r_cons_set_raw 2018-03-09 03:01:05 +01:00
dietline.c removed incorrect return (#9685) 2018-03-14 11:09:27 +08:00
editor.c Add wfs and wff, and help for wf? 2018-03-07 10:55:45 +01:00
grep.c Killed cons->truecolor in favor of cons->color 2018-02-24 11:47:38 +01:00
hud.c Killed cons->truecolor in favor of cons->color 2018-02-24 11:47:38 +01:00
input.c Some fixups for #9682 (#9688) 2018-03-14 13:08:01 +01:00
less.c Update coding style rules for braces 2018-02-28 01:24:03 +01:00
line.c Fix RCons regression causing entry0 to be printed on start 2017-04-09 00:29:44 +02:00
Makefile Bring back the old edge style in the aa graph. Fix self loops 2015-02-15 21:34:12 +01:00
meson.build Fix meson indentation (#9567) 2018-03-03 22:08:37 +01:00
output.c Fix build 2018-01-02 19:31:02 +01:00
pal.c Fix leak in RConsPal.rainbow 2018-03-14 15:37:37 +01:00
pipe.c Fix #6236 - > ~/foo 2016-11-22 00:28:15 +01:00
README * Rename MALLOC_STRUCT into R_NEW and deprecate it. 2010-03-12 13:35:10 +01:00
rgb.c Fix a heap overflow (non-null terminated string) in RCons.rgb_str() 2018-03-07 18:08:19 +01:00
utf8.c Reorganize string macros 2017-02-06 00:00:03 +01: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;
}