radare2/libr/cons
2019-07-31 05:34:48 +02:00
..
d Fix projects, add of help and improve gb again 2019-07-31 05:34:48 +02:00
2048.c Add braces to if, else, for, while ... (#11504) 2018-09-13 10:17:26 +02:00
canvas_line.c Honor utf8 in diagonal graph lines ##graph 2019-07-18 03:54:15 +02:00
canvas.c Fix crash in canvas 2019-07-31 05:34:48 +02:00
cons.c Improve RConsBind and use it from RBin via iz^C ##bin 2019-07-25 14:37:46 +02:00
dietline.c Fix scrolling directions in the hud ##cons 2019-07-30 02:15:22 +02:00
editor.c Various build compiler warning fixes attempts. (#12468) 2018-12-12 22:04:11 +01:00
grep.c Fix some leaks found by ASAN 2019-07-28 19:08:24 +02:00
hud.c Fixes #14652: Fixes visual hud regressions 2019-07-28 01:32:17 +02:00
input.c Fix #12921 - Impl. r_cons_arrow_to_hjkl for Windows ##cons 2019-07-30 23:21:18 +02:00
less.c More spelling fixes in the code 2019-06-20 13:36:02 +08:00
line.c All emacs dietline keybindings are implemented (#14664) 2019-07-27 15:40:52 +08:00
Makefile Add pri command to print raw images in RGB (using stiv code) ##cons 2019-07-11 07:00:41 +02:00
meson.build Add pri command to print raw images in RGB (using stiv code) ##cons 2019-07-11 07:00:41 +02:00
more.c More spelling fixes in the code 2019-06-20 13:36:02 +08:00
output.c Fix missing title line in Visual mode when under scr.ansicon=0 (#14490) 2019-07-05 14:39:53 +02:00
pager_private.h Code cleanup in RCons 2019-06-09 18:50:36 +02:00
pager.c Code cleanup in RCons 2019-06-09 18:50:36 +02:00
pal.c Fix ec* wrt attributes (#14421) 2019-06-25 19:38:03 +02:00
pipe.c Code cleanup in RCons 2019-06-09 18:50:36 +02:00
README * Rename MALLOC_STRUCT into R_NEW and deprecate it. 2010-03-12 13:35:10 +01:00
rgb.c Complete R_CONS_ATTR_ series (#14411) 2019-06-24 17:10:12 +02:00
stiv.c Add pri command to print raw images in RGB (using stiv code) ##cons 2019-07-11 07:00:41 +02:00
utf8.c More spelling fixes in the code 2019-06-20 13:36:02 +08: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;
}