radare2/libr/cons
2017-11-26 02:25:57 +01:00
..
d Add usrcmt on all themes 2017-11-16 11:48:15 -05:00
2048.c
canvas_line.c added curved corners (#8660) 2017-10-08 13:09:27 +02:00
canvas.c Bring back the canvas trimming and fix again visual glitch with 1 node graphs 2017-11-26 02:25:57 +01:00
cons.c Oops scr.fps was already there :D show it in graph view too 2017-11-24 00:55:18 +01:00
dietline.c Fix whitespace issue, when using the tab complete 2017-11-26 01:35:58 +01:00
editor.c
grep.c Fix regression in feat_grep 2017-11-04 16:15:50 +01:00
hud.c Honor MMX and SSE op.family for x86.cs 2017-05-22 00:56:24 +02:00
input.c Fix #8340 - shift-tab in V! is working again 2017-08-27 19:31:30 +02:00
less.c Pressing _ in RCons.less enters the HUD mode 2017-09-26 11:53:16 +02:00
line.c
Makefile
meson.build support for static build (#7822) 2017-06-28 22:54:40 +02:00
output.c
pal.c Fix colors in asm.cmtright=0 and honor fc in disasm offsets and flag colors 2017-11-24 23:52:22 +01:00
pipe.c
README
rgb.c Fixed Bold color ascii parsing 2017-10-15 10:45:25 +02:00
utf8.c

+--------+
| 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;
}