radare2/libr/cons
2019-05-05 01:11:12 +03:00
..
d Improve the bold theme a bit more after testing on another projector 2019-04-30 21:00:48 +03:00
2048.c Add braces to if, else, for, while ... (#11504) 2018-09-13 10:17:26 +02:00
canvas_line.c Move Palette to RConsContext to make RCoreTask less racy ##cons 2019-01-18 11:58:49 +01:00
canvas.c Avoid passing fixed size buffers in RAnal.fcn, reducing the use of anal.bb.maxsz ##anal 2019-03-16 10:20:20 +01:00
cons.c Print "Task finished" only if interactive ##core 2019-04-04 14:59:27 +02:00
dietline.c Fix warnings on Windows (#13954) 2019-05-05 01:11:12 +03:00
editor.c Various build compiler warning fixes attempts. (#12468) 2018-12-12 22:04:11 +01:00
grep.c Fix env. vars. not being parsed in !! in Windows (#12956) 2019-01-31 13:39:32 -06:00
hud.c Fix va_arg issue in r_str_newf and r_str_appendf ##core 2019-02-28 16:56:14 +01:00
input.c Refresh on resize and fix mouse input on visual foor Windows ##windows 2019-04-01 14:34:41 +02:00
less.c Fix few more clang warnings (#12429) 2018-12-11 10:28:01 +01:00
line.c Decouple Autocompletion from RLine 2019-04-25 19:01:12 +02:00
Makefile Fix #11552 - Implemlent r_cons_more and refactor some less.c ##visual 2018-11-14 13:15:50 +01:00
meson.build Do not use reversed keyword of meson ##build 2019-01-10 14:15:50 +01:00
more.c Fix few more clang warnings (#12429) 2018-12-11 10:28:01 +01:00
output.c Update output.c (#12314) 2018-11-25 01:47:11 +01:00
pager_private.h Fix #11552 - Implemlent r_cons_more and refactor some less.c ##visual 2018-11-14 13:15:50 +01:00
pager.c Fix #11552 - Implemlent r_cons_more and refactor some less.c ##visual 2018-11-14 13:15:50 +01:00
pal.c ec* shows bgcolor too for fgbg color (#13602) 2019-04-01 14:31:12 +02:00
pipe.c Initial implementation of alias files ##core (#13489) 2019-03-25 01:06:53 +01:00
README
rgb.c Copy pal when creating a new task (#12835) 2019-01-19 01:29:30 +01:00
utf8.c Completely kill the msvc/ directory and the unix-specific includes workarounds 2019-03-19 17:34:02 +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;
}