radare2/libr/cons
2018-09-03 10:37:35 +02:00
..
d A better version of white theme (#11200) 2018-08-23 00:36:24 +02:00
2048.c Fix code indentation in libr_cons 2016-06-29 12:33:31 +02:00
canvas_line.c Fix: coverities 1394583 1394582 1394447 2018-08-01 17:52:06 +02:00
canvas.c Reland #11181: replace sort_attrs (insertion sort) with a single insertion (#11201) 2018-08-23 01:35:18 +02:00
cons.c Fix #11067 - uaf in ~ 2018-08-13 16:31:42 +02:00
dietline.c Fix #11306 - Coverity fixes 2018-08-30 12:32:46 +08:00
editor.c Initial work on supporting pauseable CoreTasks (#9921) 2018-04-20 00:25:33 +02:00
grep.c Parse grep line only if there is a digit afterward : 2018-07-16 21:04:41 +02:00
hud.c Fix #11363 - Make ~... work with dos-style line-breaks 2018-09-03 10:37:35 +02:00
input.c Fix sleeping for readchar on Windows (#10549) 2018-06-30 02:45:17 +02:00
less.c Fix crash in ii~../at (#11177) 2018-08-22 03:29:12 +02:00
line.c Fix for issue #11024 (#11055) 2018-08-12 20:27:05 +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 Meson private (#11331) 2018-09-03 10:07:28 +02:00
output.c r_cons_singleton() 🠊 r_cons_singleton () 2018-05-02 21:36:08 +08:00
pal.c Vim-like autocompletion in visual offset prompt (#10912) 2018-08-05 20:53:12 +02: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 Vim-like autocompletion in visual offset prompt (#10912) 2018-08-05 20:53:12 +02:00
utf8.c Add parentheses in macros where needed for safety (#11290) 2018-08-30 13:16:50 +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;
}