2014-03-27 15:34:17 +00:00
|
|
|
#ifndef R2_CONS_H
|
|
|
|
#define R2_CONS_H
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2012-10-03 23:20:00 +00:00
|
|
|
#define HAVE_DIETLINE 1
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2013-06-18 10:09:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-06-26 21:49:11 +00:00
|
|
|
#include <r_types.h>
|
|
|
|
#include <r_util.h>
|
2013-05-22 02:22:49 +00:00
|
|
|
#include <sdb.h>
|
2011-06-26 21:49:11 +00:00
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
2015-04-04 22:39:05 +00:00
|
|
|
#if __UNIX__ || __CYGWIN__ && !defined(MINGW32)
|
2010-01-30 13:02:53 +00:00
|
|
|
#include <termios.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
2015-04-04 22:39:05 +00:00
|
|
|
#if __WINDOWS__ && !defined(__CYGWIN__)
|
2010-01-30 13:02:53 +00:00
|
|
|
#include <windows.h>
|
2011-07-06 09:48:16 +00:00
|
|
|
#include <wincon.h>
|
2010-01-30 13:02:53 +00:00
|
|
|
#endif
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2010-01-30 13:02:53 +00:00
|
|
|
/* constants */
|
2009-02-27 00:18:19 +00:00
|
|
|
#define CONS_MAX_USER 102400
|
2009-02-05 21:08:46 +00:00
|
|
|
#define CONS_BUFSZ 0x4f00
|
|
|
|
#define STR_IS_NULL(x) (!x || !x[0])
|
|
|
|
|
2010-01-30 13:02:53 +00:00
|
|
|
/* palette */
|
|
|
|
#define CONS_PALETTE_SIZE 22
|
|
|
|
#define CONS_COLORS_SIZE 21
|
|
|
|
|
2012-08-09 16:19:00 +00:00
|
|
|
#define R_CONS_GREP_WORDS 10
|
|
|
|
#define R_CONS_GREP_WORD_SIZE 64
|
2015-09-23 21:00:14 +00:00
|
|
|
#define R_CONS_GREP_TOKENS 64
|
2012-08-09 16:19:00 +00:00
|
|
|
|
2013-06-14 00:51:33 +00:00
|
|
|
R_LIB_VERSION_HEADER(r_cons);
|
|
|
|
|
2016-05-10 20:15:24 +00:00
|
|
|
typedef int (*RConsGetSize)(int *rows);
|
|
|
|
typedef int (*RConsGetCursor)(int *rows);
|
|
|
|
|
|
|
|
typedef struct r_cons_bind_t {
|
|
|
|
RConsGetSize get_size;
|
|
|
|
RConsGetCursor get_cursor;
|
|
|
|
} RConsBind;
|
|
|
|
|
2010-01-30 13:02:53 +00:00
|
|
|
typedef struct r_cons_grep_t {
|
2012-08-09 16:19:00 +00:00
|
|
|
char strings[R_CONS_GREP_WORDS][R_CONS_GREP_WORD_SIZE];
|
2010-01-30 13:02:53 +00:00
|
|
|
int nstrings;
|
|
|
|
char *str;
|
|
|
|
int counter;
|
2016-11-23 11:52:36 +00:00
|
|
|
bool charCounter;
|
2014-02-11 01:32:37 +00:00
|
|
|
int less;
|
2014-11-22 00:51:51 +00:00
|
|
|
int json;
|
2017-01-17 12:38:42 +00:00
|
|
|
char *json_path;
|
2016-10-19 14:18:04 +00:00
|
|
|
int range_line;
|
2010-01-30 13:02:53 +00:00
|
|
|
int line;
|
2016-10-25 10:03:55 +00:00
|
|
|
int sort;
|
2016-10-25 12:37:25 +00:00
|
|
|
int sort_row;
|
2016-10-25 10:39:36 +00:00
|
|
|
bool sort_invert;
|
2016-10-19 14:18:04 +00:00
|
|
|
int f_line; //first line
|
|
|
|
int l_line; //last line
|
2015-09-23 21:00:14 +00:00
|
|
|
int tokens[R_CONS_GREP_TOKENS];
|
|
|
|
int tokens_used;
|
2012-08-09 16:19:00 +00:00
|
|
|
int amp;
|
2010-01-30 13:02:53 +00:00
|
|
|
int neg;
|
2012-06-21 08:12:02 +00:00
|
|
|
int begin;
|
|
|
|
int end;
|
2010-01-30 13:02:53 +00:00
|
|
|
} RConsGrep;
|
|
|
|
|
2013-05-22 02:22:49 +00:00
|
|
|
typedef struct r_cons_palette_t {
|
2013-05-23 00:26:48 +00:00
|
|
|
char *b0x00;
|
|
|
|
char *b0x7f;
|
|
|
|
char *b0xff;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *args;
|
2013-05-23 10:37:40 +00:00
|
|
|
char *bin;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *btext;
|
2013-05-23 00:26:48 +00:00
|
|
|
char *call;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *cjmp;
|
2013-05-23 00:26:48 +00:00
|
|
|
char *cmp;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *comment;
|
2014-06-04 15:23:58 +00:00
|
|
|
char *creg;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *flag;
|
|
|
|
char *fline;
|
|
|
|
char *floc;
|
|
|
|
char *flow;
|
2017-01-15 23:41:31 +00:00
|
|
|
char *flow2;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *fname;
|
|
|
|
char *help;
|
|
|
|
char *input;
|
2013-07-17 21:06:06 +00:00
|
|
|
char *invalid;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *jmp;
|
|
|
|
char *label;
|
|
|
|
char *math;
|
|
|
|
char *mov;
|
|
|
|
char *nop;
|
|
|
|
char *num;
|
|
|
|
char *offset;
|
|
|
|
char *other;
|
|
|
|
char *pop;
|
|
|
|
char *prompt;
|
|
|
|
char *push;
|
2015-10-21 11:04:55 +00:00
|
|
|
char *crypto;
|
2014-06-21 16:00:11 +00:00
|
|
|
char *reg;
|
|
|
|
char *reset;
|
|
|
|
char *ret;
|
|
|
|
char *swi;
|
|
|
|
char *trap;
|
2014-10-27 10:55:52 +00:00
|
|
|
char *ai_read;
|
|
|
|
char *ai_write;
|
|
|
|
char *ai_exec;
|
|
|
|
char *ai_seq;
|
|
|
|
char *ai_ascii;
|
2014-12-06 11:25:02 +00:00
|
|
|
char *gui_cflow;
|
|
|
|
char *gui_dataoffset;
|
|
|
|
char *gui_background;
|
|
|
|
char *gui_alt_background;
|
|
|
|
char *gui_border;
|
2015-07-15 13:54:20 +00:00
|
|
|
|
|
|
|
/* graph colors */
|
|
|
|
char *graph_box;
|
|
|
|
char *graph_box2;
|
|
|
|
char *graph_box3;
|
2016-05-03 22:50:33 +00:00
|
|
|
char *graph_box4;
|
2015-07-15 13:54:20 +00:00
|
|
|
char *graph_true;
|
|
|
|
char *graph_false;
|
|
|
|
char *graph_trufae;
|
2016-05-03 22:50:33 +00:00
|
|
|
char *graph_traced;
|
|
|
|
char *graph_current;
|
2015-07-15 13:54:20 +00:00
|
|
|
|
2014-09-07 23:33:50 +00:00
|
|
|
#define R_CONS_PALETTE_LIST_SIZE 8
|
|
|
|
char *list[R_CONS_PALETTE_LIST_SIZE];
|
2013-05-22 02:22:49 +00:00
|
|
|
} RConsPalette;
|
|
|
|
|
2011-01-23 12:12:16 +00:00
|
|
|
typedef void (*RConsEvent)(void *);
|
|
|
|
|
Initial support for colors in RConsCanvas
started on cons_canvas color support. Still a bit buggy, working out the kinks.
Yanked my old line drawing algo from ward, still working on colors.
Still incomplete, Changed the way that attributes work, still lots of strange behavior, It appears that most attributes aren't where they belong.
still not finished. Ok now the lines and colors are working, but the colors are overwriting other sections. Working on preventing that.
colors are now working, but they are _so. slow._
woops, removed the debugging printf
Figured out the big evil function that has to be optimized, attr_at takes aprox 91% of the cpu, so he needs to be fixed
Signed-off-by: r0nk <r00nk@simplecpu.com>
Signed-off-by: r0nk <r00nk@simplecpu.com>
2015-02-10 22:06:27 +00:00
|
|
|
#define CONS_MAX_ATTR_SZ 15
|
|
|
|
typedef struct r_cons_canvas_attr_t {
|
|
|
|
//TODO add support for 256 colors.
|
|
|
|
int loc;
|
2015-02-15 20:48:46 +00:00
|
|
|
const char * a;
|
Initial support for colors in RConsCanvas
started on cons_canvas color support. Still a bit buggy, working out the kinks.
Yanked my old line drawing algo from ward, still working on colors.
Still incomplete, Changed the way that attributes work, still lots of strange behavior, It appears that most attributes aren't where they belong.
still not finished. Ok now the lines and colors are working, but the colors are overwriting other sections. Working on preventing that.
colors are now working, but they are _so. slow._
woops, removed the debugging printf
Figured out the big evil function that has to be optimized, attr_at takes aprox 91% of the cpu, so he needs to be fixed
Signed-off-by: r0nk <r00nk@simplecpu.com>
Signed-off-by: r0nk <r00nk@simplecpu.com>
2015-02-10 22:06:27 +00:00
|
|
|
} RConsCanvasAttr;
|
|
|
|
|
2013-08-25 22:51:36 +00:00
|
|
|
typedef struct r_cons_canvas_t {
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
char *b;
|
|
|
|
int blen;
|
2015-02-15 20:48:46 +00:00
|
|
|
const char * attr;//The current attr (inserted on each write)
|
Initial support for colors in RConsCanvas
started on cons_canvas color support. Still a bit buggy, working out the kinks.
Yanked my old line drawing algo from ward, still working on colors.
Still incomplete, Changed the way that attributes work, still lots of strange behavior, It appears that most attributes aren't where they belong.
still not finished. Ok now the lines and colors are working, but the colors are overwriting other sections. Working on preventing that.
colors are now working, but they are _so. slow._
woops, removed the debugging printf
Figured out the big evil function that has to be optimized, attr_at takes aprox 91% of the cpu, so he needs to be fixed
Signed-off-by: r0nk <r00nk@simplecpu.com>
Signed-off-by: r0nk <r00nk@simplecpu.com>
2015-02-10 22:06:27 +00:00
|
|
|
RConsCanvasAttr * attrs;// all the different attributes
|
|
|
|
int attrslen;
|
2014-05-05 01:15:28 +00:00
|
|
|
int sx; // scrollx
|
|
|
|
int sy; // scrolly
|
2015-02-14 03:50:29 +00:00
|
|
|
int color;
|
2015-02-15 20:34:12 +00:00
|
|
|
int linemode; // 0 = diagonal , 1 = square
|
2013-08-25 22:51:36 +00:00
|
|
|
} RConsCanvas;
|
|
|
|
|
2016-10-20 23:24:40 +00:00
|
|
|
#define RUNECODE_MIN 0xc8 // 200
|
|
|
|
#define RUNECODE_LINE_VERT 0xc8
|
|
|
|
#define RUNECODE_LINE_CROSS 0xc9
|
|
|
|
#define RUNECODE_CORNER_BR 0xca
|
|
|
|
#define RUNECODE_CORNER_BL 0xcb
|
|
|
|
#define RUNECODE_ARROW_RIGHT 0xcc
|
|
|
|
#define RUNECODE_ARROW_LEFT 0xcd
|
|
|
|
#define RUNECODE_LINE_HORIZ 0xce
|
|
|
|
#define RUNECODE_CORNER_TL 0xcf
|
|
|
|
#define RUNECODE_CORNER_TR 0xd0
|
|
|
|
#define RUNECODE_LINE_UP 0xd1
|
|
|
|
#define RUNECODE_MAX 0xd2
|
|
|
|
|
|
|
|
#define RUNECODESTR_MIN 0xc8 // 200
|
|
|
|
#define RUNECODESTR_LINE_VERT "\xc8"
|
|
|
|
#define RUNECODESTR_LINE_CROSS "\xc9"
|
|
|
|
#define RUNECODESTR_CORNER_BR "\xca"
|
|
|
|
#define RUNECODESTR_CORNER_BL "\xcb"
|
|
|
|
#define RUNECODESTR_ARROW_RIGHT "\xcc"
|
|
|
|
#define RUNECODESTR_ARROW_LEFT "\xcd"
|
|
|
|
#define RUNECODESTR_LINE_HORIZ "\xce"
|
|
|
|
#define RUNECODESTR_CORNER_TL "\xcf"
|
|
|
|
#define RUNECODESTR_CORNER_TR "\xd0"
|
|
|
|
#define RUNECODESTR_LINE_UP "\xd1"
|
|
|
|
#define RUNECODESTR_MAX 0xd1
|
|
|
|
|
|
|
|
#define RUNE_LINE_VERT "│"
|
|
|
|
#define RUNE_LINE_CROSS "┼" /* ├ */
|
|
|
|
#define RUNE_LINE_HORIZ "─"
|
|
|
|
#define RUNE_LINE_UP "↑"
|
|
|
|
#define RUNE_CORNER_BR "┘"
|
|
|
|
#define RUNE_CORNER_BL "└"
|
|
|
|
#define RUNE_CORNER_TL "┌"
|
|
|
|
#define RUNE_CORNER_TR "┐"
|
|
|
|
#define RUNE_ARROW_RIGHT ">"
|
|
|
|
#define RUNE_ARROW_LEFT "<"
|
|
|
|
|
2014-12-19 02:17:28 +00:00
|
|
|
typedef char *(*RConsEditorCallback)(void *core, const char *file, const char *str);
|
2015-05-27 21:46:03 +00:00
|
|
|
typedef int (*RConsClickCallback)(void *core, int x, int y);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
r_cons_click_begin();
|
|
|
|
r_cons_click_end();
|
|
|
|
r_cons_click_clear();
|
|
|
|
#endif
|
2014-12-19 02:17:28 +00:00
|
|
|
|
2010-01-27 00:50:26 +00:00
|
|
|
typedef struct r_cons_t {
|
2010-01-30 13:02:53 +00:00
|
|
|
RConsGrep grep;
|
2016-10-18 21:15:51 +00:00
|
|
|
RStack *cons_stack;
|
2016-11-20 18:20:14 +00:00
|
|
|
RStack *break_stack;
|
2010-01-30 13:02:53 +00:00
|
|
|
char *buffer;
|
2013-08-28 01:06:10 +00:00
|
|
|
//int line;
|
2010-01-30 13:02:53 +00:00
|
|
|
int buffer_len;
|
|
|
|
int buffer_sz;
|
|
|
|
char *lastline;
|
2010-01-27 00:50:26 +00:00
|
|
|
int is_html;
|
2010-01-30 13:02:53 +00:00
|
|
|
int is_interactive;
|
|
|
|
int lines;
|
2010-01-27 00:50:26 +00:00
|
|
|
int rows;
|
2014-10-30 21:58:51 +00:00
|
|
|
int echo; // dump to stdout in realtime
|
2014-02-24 15:10:12 +00:00
|
|
|
int fps;
|
2010-01-27 00:50:26 +00:00
|
|
|
int columns;
|
2013-07-04 23:45:45 +00:00
|
|
|
int force_rows;
|
|
|
|
int force_columns;
|
2014-01-08 23:29:00 +00:00
|
|
|
int fix_rows;
|
|
|
|
int fix_columns;
|
2015-09-25 16:38:07 +00:00
|
|
|
bool breaked;
|
2010-01-30 13:02:53 +00:00
|
|
|
int noflush;
|
|
|
|
FILE *fdin; // FILE? and then int ??
|
|
|
|
int fdout; // only used in pipe.c :?? remove?
|
2011-03-01 18:06:22 +00:00
|
|
|
const char *teefile;
|
2010-01-30 13:02:53 +00:00
|
|
|
int (*user_fgets)(char *buf, int len);
|
2011-01-23 12:12:16 +00:00
|
|
|
RConsEvent event_interrupt;
|
|
|
|
RConsEvent event_resize;
|
|
|
|
void *data;
|
2013-04-01 03:28:34 +00:00
|
|
|
void *event_data;
|
2015-02-10 23:13:04 +00:00
|
|
|
int mouse_event;
|
2014-12-19 02:17:28 +00:00
|
|
|
|
|
|
|
RConsEditorCallback editor;
|
|
|
|
void *user; // Used by <RCore*>
|
2015-04-04 22:45:58 +00:00
|
|
|
#if __UNIX__ || __CYGWIN__ && !defined(MINGW32)
|
2010-01-30 13:02:53 +00:00
|
|
|
struct termios term_raw, term_buf;
|
|
|
|
#elif __WINDOWS__
|
|
|
|
LPDWORD term_raw, term_buf;
|
|
|
|
#endif
|
2011-06-26 21:49:11 +00:00
|
|
|
RNum *num;
|
2012-02-05 01:39:04 +00:00
|
|
|
/* Pager (like more or less) to use if the output doesn't fit on the
|
|
|
|
* current window. If NULL or "" no pager is used. */
|
|
|
|
char *pager;
|
2012-11-14 02:25:32 +00:00
|
|
|
int blankline;
|
2013-10-14 21:48:18 +00:00
|
|
|
int truecolor; // 0 = ansi, 1 = rgb 256), 2 = truecolor (16M)
|
2014-09-27 01:48:54 +00:00
|
|
|
char *highlight;
|
2014-01-08 22:44:05 +00:00
|
|
|
int null; // if set, does not show anything
|
2014-03-01 23:31:35 +00:00
|
|
|
int mouse;
|
2015-01-14 22:31:29 +00:00
|
|
|
int is_wine;
|
2013-05-22 02:22:49 +00:00
|
|
|
RConsPalette pal;
|
2013-08-28 01:06:10 +00:00
|
|
|
struct r_line_t *line;
|
2013-09-04 00:01:42 +00:00
|
|
|
const char **vline;
|
2015-01-21 17:06:06 +00:00
|
|
|
int refcnt;
|
2015-05-27 21:46:03 +00:00
|
|
|
RConsClickCallback onclick;
|
2015-09-28 22:42:31 +00:00
|
|
|
bool newline;
|
2015-11-01 04:10:49 +00:00
|
|
|
#if __WINDOWS__ && !__CYGWIN__
|
|
|
|
bool ansicon;
|
|
|
|
#endif
|
2016-09-19 22:11:59 +00:00
|
|
|
bool flush;
|
2016-10-20 23:24:40 +00:00
|
|
|
bool use_utf8; // use utf8 features
|
2016-10-26 21:04:55 +00:00
|
|
|
int linesleep;
|
|
|
|
int pagesize;
|
2016-12-17 09:42:15 +00:00
|
|
|
char *break_word;
|
|
|
|
int break_word_len;
|
2016-12-12 22:57:04 +00:00
|
|
|
ut64 timeout;
|
2010-01-27 00:50:26 +00:00
|
|
|
} RCons;
|
2010-01-30 13:02:53 +00:00
|
|
|
|
|
|
|
// XXX THIS MUST BE A SINGLETON AND WRAPPED INTO RCons */
|
|
|
|
/* XXX : global variables? or a struct with a singleton? */
|
|
|
|
//extern FILE *stdin_fd;
|
|
|
|
//extern FILE *r_cons_stdin_fd;
|
|
|
|
//extern int r_cons_stdout_fd;
|
|
|
|
//extern int r_cons_stdout_file;
|
|
|
|
//extern char *r_cons_filterline;
|
|
|
|
//extern char *r_cons_teefile;
|
|
|
|
// not needed anymoar
|
2010-02-11 23:43:11 +00:00
|
|
|
//extern int (*r_cons_user_fgets)(char *buf, int len);
|
2010-01-30 13:02:53 +00:00
|
|
|
|
2011-06-05 18:36:22 +00:00
|
|
|
#define R_CONS_KEY_F1 0xf1
|
|
|
|
#define R_CONS_KEY_F2 0xf2
|
|
|
|
#define R_CONS_KEY_F3 0xf3
|
|
|
|
#define R_CONS_KEY_F4 0xf4
|
|
|
|
#define R_CONS_KEY_F5 0xf5
|
|
|
|
#define R_CONS_KEY_F6 0xf6
|
|
|
|
#define R_CONS_KEY_F7 0xf7
|
|
|
|
#define R_CONS_KEY_F8 0xf8
|
|
|
|
#define R_CONS_KEY_F9 0xf9
|
|
|
|
#define R_CONS_KEY_F10 0xfa
|
|
|
|
#define R_CONS_KEY_F11 0xfb
|
|
|
|
#define R_CONS_KEY_F12 0xfc
|
|
|
|
|
|
|
|
#define R_CONS_KEY_ESC 0x1b
|
|
|
|
|
2012-06-07 01:41:21 +00:00
|
|
|
#define Color_BLINK "\x1b[5m"
|
|
|
|
#define Color_INVERT "\x1b[7m"
|
|
|
|
#define Color_INVERT_RESET "\x1b[27m"
|
2009-02-05 21:08:46 +00:00
|
|
|
/* plain colors */
|
2013-05-22 02:22:49 +00:00
|
|
|
#define Color_RESET "\x1b[0m"
|
|
|
|
#define Color_BLACK "\x1b[30m"
|
|
|
|
#define Color_BGBLACK "\x1b[40m"
|
|
|
|
#define Color_RED "\x1b[31m"
|
|
|
|
#define Color_BGRED "\x1b[41m"
|
|
|
|
#define Color_WHITE "\x1b[37m"
|
|
|
|
#define Color_BGWHITE "\x1b[47m"
|
|
|
|
#define Color_GREEN "\x1b[32m"
|
|
|
|
#define Color_BGGREEN "\x1b[42m"
|
|
|
|
#define Color_MAGENTA "\x1b[35m"
|
|
|
|
#define Color_BGMAGENTA "\x1b[45m"
|
|
|
|
#define Color_YELLOW "\x1b[33m"
|
|
|
|
#define Color_BGYELLOW "\x1b[43m"
|
2013-05-23 01:03:40 +00:00
|
|
|
#define Color_CYAN "\x1b[36m"
|
|
|
|
#define Color_BGCYAN "\x1b[46m"
|
2013-05-22 02:22:49 +00:00
|
|
|
#define Color_BLUE "\x1b[34m"
|
|
|
|
#define Color_BGBLUE "\x1b[44m"
|
|
|
|
#define Color_GRAY "\x1b[38m"
|
|
|
|
#define Color_BGGRAY "\x1b[48m"
|
2009-02-05 21:08:46 +00:00
|
|
|
/* bold colors */
|
2010-01-27 00:50:26 +00:00
|
|
|
#define Color_BBLACK "\x1b[1;30m"
|
|
|
|
#define Color_BRED "\x1b[1;31m"
|
|
|
|
#define Color_BBGRED "\x1b[1;41m"
|
|
|
|
#define Color_BWHITE "\x1b[1;37m"
|
|
|
|
#define Color_BGREEN "\x1b[1;32m"
|
|
|
|
#define Color_BMAGENTA "\x1b[1;35m"
|
|
|
|
#define Color_BYELLOW "\x1b[1;33m"
|
2013-05-23 01:03:40 +00:00
|
|
|
#define Color_BCYAN "\x1b[1;36m"
|
2010-01-27 00:50:26 +00:00
|
|
|
#define Color_BBLUE "\x1b[1;34m"
|
|
|
|
#define Color_BGRAY "\x1b[1;38m"
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2016-05-03 22:50:33 +00:00
|
|
|
|
2014-08-27 21:08:32 +00:00
|
|
|
#define Colors_PLAIN { \
|
|
|
|
Color_BLACK, Color_RED, Color_WHITE, \
|
|
|
|
Color_GREEN, Color_MAGENTA, Color_YELLOW, \
|
|
|
|
Color_CYAN, Color_BLUE, Color_GRAY}
|
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
enum {
|
|
|
|
PAL_PROMPT = 0,
|
|
|
|
PAL_ADDRESS,
|
|
|
|
PAL_DEFAULT,
|
|
|
|
PAL_CHANGED,
|
|
|
|
PAL_JUMP,
|
|
|
|
PAL_CALL,
|
|
|
|
PAL_PUSH,
|
|
|
|
PAL_TRAP,
|
|
|
|
PAL_CMP,
|
|
|
|
PAL_RET,
|
|
|
|
PAL_NOP,
|
|
|
|
PAL_METADATA,
|
|
|
|
PAL_HEADER,
|
|
|
|
PAL_PRINTABLE,
|
|
|
|
PAL_LINES0,
|
|
|
|
PAL_LINES1,
|
|
|
|
PAL_LINES2,
|
|
|
|
PAL_00,
|
|
|
|
PAL_7F,
|
|
|
|
PAL_FF
|
|
|
|
};
|
|
|
|
|
2015-07-26 11:26:08 +00:00
|
|
|
/* canvas line colors */
|
|
|
|
enum {
|
|
|
|
LINE_NONE = 0,
|
|
|
|
LINE_TRUE,
|
|
|
|
LINE_FALSE,
|
|
|
|
LINE_UNCJMP,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct r_cons_canvas_line_style_t {
|
|
|
|
int color;
|
|
|
|
int symbol;
|
|
|
|
} RCanvasLineStyle;
|
|
|
|
|
2013-07-18 20:20:23 +00:00
|
|
|
// UTF-8 symbols indexes
|
2016-10-20 23:24:40 +00:00
|
|
|
// XXX. merge with RUNE/RUNECODE/RUNECODESTR
|
2016-10-24 08:48:25 +00:00
|
|
|
#if 0
|
2013-07-18 20:20:23 +00:00
|
|
|
#define LINE_VERT 0
|
|
|
|
#define LINE_CROSS 1
|
2016-10-20 23:24:40 +00:00
|
|
|
#define LINE_HORIZ 2
|
|
|
|
#define LINE_UP 3
|
|
|
|
#define CORNER_BR 4
|
|
|
|
#define CORNER_BL 5
|
|
|
|
#define CORNER_TL 6
|
|
|
|
#define CORNER_TR 7
|
|
|
|
#define ARROW_RIGHT 8
|
|
|
|
#define ARROW_LEFT 9
|
2016-10-24 08:48:25 +00:00
|
|
|
#else
|
|
|
|
#define LINE_VERT 0
|
|
|
|
#define LINE_CROSS 1
|
|
|
|
#define LINE_HORIZ 2
|
|
|
|
#define LINE_UP 3
|
2016-10-24 09:54:03 +00:00
|
|
|
#define CORNER_TL 6
|
2016-10-24 08:48:25 +00:00
|
|
|
#define CORNER_BR 4
|
2016-10-24 09:54:03 +00:00
|
|
|
#define CORNER_BL 5
|
|
|
|
#define CORNER_TR 6
|
2016-10-24 08:48:25 +00:00
|
|
|
#define ARROW_RIGHT 8
|
|
|
|
#define ARROW_LEFT 9
|
|
|
|
#endif
|
2013-07-18 20:20:23 +00:00
|
|
|
|
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
#ifdef R_API
|
2013-08-25 22:51:36 +00:00
|
|
|
R_API RConsCanvas* r_cons_canvas_new (int w, int h);
|
|
|
|
R_API void r_cons_canvas_free (RConsCanvas *c);
|
2014-05-05 01:15:28 +00:00
|
|
|
R_API void r_cons_canvas_clear (RConsCanvas *c);
|
2013-08-25 22:51:36 +00:00
|
|
|
R_API void r_cons_canvas_print(RConsCanvas *c);
|
2015-06-11 01:55:15 +00:00
|
|
|
R_API void r_cons_canvas_print_region(RConsCanvas *c);
|
2013-08-25 22:51:36 +00:00
|
|
|
R_API char *r_cons_canvas_to_string(RConsCanvas *c);
|
Initial support for colors in RConsCanvas
started on cons_canvas color support. Still a bit buggy, working out the kinks.
Yanked my old line drawing algo from ward, still working on colors.
Still incomplete, Changed the way that attributes work, still lots of strange behavior, It appears that most attributes aren't where they belong.
still not finished. Ok now the lines and colors are working, but the colors are overwriting other sections. Working on preventing that.
colors are now working, but they are _so. slow._
woops, removed the debugging printf
Figured out the big evil function that has to be optimized, attr_at takes aprox 91% of the cpu, so he needs to be fixed
Signed-off-by: r0nk <r00nk@simplecpu.com>
Signed-off-by: r0nk <r00nk@simplecpu.com>
2015-02-10 22:06:27 +00:00
|
|
|
R_API void r_cons_canvas_attr(RConsCanvas *c,const char * attr);
|
2013-08-25 22:51:36 +00:00
|
|
|
R_API void r_cons_canvas_write(RConsCanvas *c, const char *_s);
|
2016-10-20 23:24:40 +00:00
|
|
|
R_API bool r_cons_canvas_gotoxy(RConsCanvas *c, int x, int y);
|
2015-02-15 20:34:12 +00:00
|
|
|
R_API void r_cons_canvas_goto_write(RConsCanvas *c,int x,int y, const char * s);
|
2015-02-15 20:48:46 +00:00
|
|
|
R_API void r_cons_canvas_box(RConsCanvas *c, int x, int y, int w, int h, const char *color);
|
2015-07-26 11:26:08 +00:00
|
|
|
R_API void r_cons_canvas_line (RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style);
|
|
|
|
R_API void r_cons_canvas_line_diagonal (RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style);
|
|
|
|
R_API void r_cons_canvas_line_square (RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style);
|
2014-05-05 01:15:28 +00:00
|
|
|
R_API int r_cons_canvas_resize(RConsCanvas *c, int w, int h);
|
|
|
|
R_API void r_cons_canvas_fill(RConsCanvas *c, int x, int y, int w, int h, char ch, int replace);
|
2013-08-25 22:51:36 +00:00
|
|
|
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API RCons *r_cons_new (void);
|
|
|
|
R_API RCons *r_cons_singleton (void);
|
|
|
|
R_API RCons *r_cons_free (void);
|
2017-01-23 21:42:27 +00:00
|
|
|
R_API char *r_cons_lastline (int *size);
|
2010-02-11 23:43:11 +00:00
|
|
|
|
2014-06-22 12:57:54 +00:00
|
|
|
typedef void (*RConsBreak)(void *);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_break_end(void);
|
2015-09-25 16:38:07 +00:00
|
|
|
R_API bool r_cons_is_breaked();
|
2016-12-12 22:57:04 +00:00
|
|
|
R_API void r_cons_break_timeout(int timeout);
|
2016-12-17 09:42:15 +00:00
|
|
|
R_API void r_cons_breakword(const char *s);
|
2010-01-12 01:12:18 +00:00
|
|
|
|
|
|
|
/* pipe */
|
2013-11-29 16:27:46 +00:00
|
|
|
R_API int r_cons_pipe_open(const char *file, int fdn, int append);
|
2010-01-12 01:12:18 +00:00
|
|
|
R_API void r_cons_pipe_close(int fd);
|
|
|
|
|
2010-06-27 20:14:06 +00:00
|
|
|
#if __WINDOWS__
|
2015-01-09 11:47:40 +00:00
|
|
|
R_API int r_cons_w32_print(const ut8 *ptr, int len, int empty);
|
2010-06-27 20:14:06 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-30 22:44:14 +00:00
|
|
|
R_API void r_cons_push();
|
|
|
|
R_API void r_cons_pop();
|
2016-11-20 18:20:14 +00:00
|
|
|
R_API void r_cons_break_pop();
|
|
|
|
R_API void r_cons_break_push(RConsBreak cb, void*user);
|
|
|
|
R_API void r_cons_break_clear();
|
2015-03-30 22:44:14 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
/* control */
|
2014-12-19 02:17:28 +00:00
|
|
|
R_API char *r_cons_editor (const char *file, const char *str);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_reset(void);
|
|
|
|
R_API void r_cons_reset_colors(void);
|
|
|
|
R_API void r_cons_print_clear(void);
|
|
|
|
R_API void r_cons_zero(void);
|
2014-09-27 01:48:54 +00:00
|
|
|
R_API void r_cons_highlight (const char *word);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_clear(void);
|
|
|
|
R_API void r_cons_clear00(void);
|
2014-03-08 01:56:04 +00:00
|
|
|
R_API void r_cons_clear_line(int err);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_fill_line(void);
|
2009-12-24 02:17:53 +00:00
|
|
|
R_API void r_cons_stdout_open(const char *file, int append);
|
|
|
|
R_API int r_cons_stdout_set_fd(int fd);
|
|
|
|
R_API void r_cons_gotoxy(int x, int y);
|
2011-12-02 00:58:34 +00:00
|
|
|
R_API void r_cons_show_cursor (int cursor);
|
2015-03-22 15:16:51 +00:00
|
|
|
R_API char *r_cons_swap_ground(const char *col);
|
2015-10-30 02:07:22 +00:00
|
|
|
R_API bool r_cons_drop (int n);
|
|
|
|
R_API void r_cons_chop ();
|
2009-12-24 02:17:53 +00:00
|
|
|
R_API void r_cons_set_raw(int b);
|
2012-02-05 00:25:40 +00:00
|
|
|
R_API void r_cons_set_interactive(int b);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_set_last_interactive(void);
|
2009-12-24 02:17:53 +00:00
|
|
|
|
|
|
|
/* output */
|
|
|
|
R_API void r_cons_printf(const char *format, ...);
|
2016-12-24 17:12:04 +00:00
|
|
|
R_API void r_cons_printf_list(const char *format, va_list ap);
|
2009-12-24 02:17:53 +00:00
|
|
|
R_API void r_cons_strcat(const char *str);
|
2016-06-25 17:49:58 +00:00
|
|
|
#define r_cons_print(x) r_cons_strcat (x)
|
2016-06-26 04:16:37 +00:00
|
|
|
R_API void r_cons_println(const char* str);
|
2011-05-21 13:45:43 +00:00
|
|
|
R_API void r_cons_strcat_justify (const char *str, int j, char c);
|
2017-01-29 22:05:02 +00:00
|
|
|
R_API int r_cons_memcat(const char *str, int len);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_newline(void);
|
|
|
|
R_API void r_cons_filter(void);
|
|
|
|
R_API void r_cons_flush(void);
|
2015-10-29 11:54:19 +00:00
|
|
|
R_API int r_cons_less_str(const char *str, const char *exitkeys);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_less(void);
|
2016-05-26 14:58:02 +00:00
|
|
|
R_API void r_cons_2048(bool color);
|
2011-05-21 12:27:46 +00:00
|
|
|
R_API void r_cons_memset(char ch, int len);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_visual_flush(void);
|
2010-02-28 13:49:26 +00:00
|
|
|
R_API void r_cons_visual_write (char *buffer);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API int r_cons_is_utf8(void);
|
2009-12-24 02:17:53 +00:00
|
|
|
|
|
|
|
/* input */
|
2010-02-11 23:43:11 +00:00
|
|
|
//R_API int r_cons_fgets(char *buf, int len, int argc, const char **argv);
|
2014-11-19 21:25:17 +00:00
|
|
|
R_API int r_cons_controlz(int ch);
|
2015-03-05 22:33:28 +00:00
|
|
|
R_API int r_cons_readchar(void);
|
|
|
|
R_API int r_cons_any_key(const char *msg);
|
|
|
|
R_API int r_cons_eof(void);
|
2009-12-24 02:17:53 +00:00
|
|
|
|
|
|
|
R_API int r_cons_palette_init(const unsigned char *pal);
|
2013-05-23 00:26:48 +00:00
|
|
|
R_API int r_cons_pal_set (const char *key, const char *val);
|
2015-04-10 09:22:45 +00:00
|
|
|
R_API void r_cons_pal_free(void);
|
2013-07-17 17:34:27 +00:00
|
|
|
R_API void r_cons_pal_init(const char *foo);
|
2014-08-18 23:47:02 +00:00
|
|
|
R_API char *r_cons_pal_parse(const char *str);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_pal_random(void);
|
2013-07-03 15:43:20 +00:00
|
|
|
R_API const char *r_cons_pal_get (const char *key);
|
2013-07-17 01:51:53 +00:00
|
|
|
R_API const char *r_cons_pal_get_i (int n);
|
|
|
|
R_API const char *r_cons_pal_get_color(int n);
|
|
|
|
R_API int r_cons_rgb_parse (const char *p, ut8 *r, ut8 *g, ut8 *b, int *is_bg);
|
2016-03-31 00:03:44 +00:00
|
|
|
R_API char *r_cons_rgb_tostring(ut8 r, ut8 g, ut8 b);
|
2016-07-03 18:56:44 +00:00
|
|
|
R_API void r_cons_pal_list (int rad, const char *arg);
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_cons_pal_show (void);
|
2010-01-26 00:28:33 +00:00
|
|
|
R_API int r_cons_get_size(int *rows);
|
2016-06-02 10:45:11 +00:00
|
|
|
R_API bool r_cons_isatty();
|
2014-09-23 07:35:37 +00:00
|
|
|
R_API int r_cons_get_cursor(int *rows);
|
2010-01-30 13:02:53 +00:00
|
|
|
R_API int r_cons_arrow_to_hjkl(int ch);
|
2009-12-24 02:17:53 +00:00
|
|
|
R_API int r_cons_html_print(const char *ptr);
|
|
|
|
|
2010-10-27 22:55:07 +00:00
|
|
|
// TODO: use gets() .. MUST BE DEPRECATED
|
2010-03-11 00:04:59 +00:00
|
|
|
R_API int r_cons_fgets(char *buf, int len, int argc, const char **argv);
|
2016-04-24 16:53:36 +00:00
|
|
|
R_API char *r_cons_hud(RList *list, const char *prompt, const bool usecolor);
|
|
|
|
R_API char *r_cons_hud_path(const char *path, int dir, const bool usecolor);
|
|
|
|
R_API char *r_cons_hud_string(const char *s, const bool usecolor);
|
|
|
|
R_API char *r_cons_hud_file(const char *f, const bool usecolor);
|
2010-03-11 00:04:59 +00:00
|
|
|
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API const char *r_cons_get_buffer(void);
|
2009-12-24 02:17:53 +00:00
|
|
|
R_API void r_cons_grep(const char *str);
|
2010-06-24 23:44:15 +00:00
|
|
|
R_API int r_cons_grep_line(char *buf, int len); // must be static
|
2009-12-24 02:17:53 +00:00
|
|
|
R_API int r_cons_grepbuf(char *buf, int len);
|
|
|
|
|
2013-04-01 02:42:14 +00:00
|
|
|
R_API void r_cons_rgb (ut8 r, ut8 g, ut8 b, int is_bg);
|
|
|
|
R_API void r_cons_rgb_fgbg (ut8 r, ut8 g, ut8 b, ut8 R, ut8 G, ut8 B);
|
|
|
|
R_API void r_cons_rgb_init (void);
|
|
|
|
R_API char *r_cons_rgb_str (char *outstr, ut8 r, ut8 g, ut8 b, int is_bg);
|
2013-01-22 04:06:12 +00:00
|
|
|
R_API void r_cons_color (int fg, int r, int g, int b);
|
2013-10-14 21:48:18 +00:00
|
|
|
R_API char *r_cons_color_random(int bg);
|
2015-08-31 15:06:59 +00:00
|
|
|
R_API char *r_cons_color_random_string(int bg);
|
2009-12-24 02:17:53 +00:00
|
|
|
R_API void r_cons_invert(int set, int color);
|
|
|
|
R_API int r_cons_yesno(int def, const char *fmt, ...);
|
2015-08-31 03:06:01 +00:00
|
|
|
R_API char *r_cons_input(const char *msg);
|
2011-05-15 23:47:01 +00:00
|
|
|
R_API void r_cons_set_cup(int enable);
|
2011-05-21 12:27:46 +00:00
|
|
|
R_API void r_cons_column(int c);
|
2013-04-01 02:42:14 +00:00
|
|
|
R_API int r_cons_get_column (void);
|
2012-02-01 01:22:43 +00:00
|
|
|
R_API char *r_cons_message(const char *msg);
|
2014-02-23 23:38:53 +00:00
|
|
|
R_API void r_cons_set_title(const char *str);
|
2016-06-29 10:33:31 +00:00
|
|
|
R_API bool r_cons_enable_mouse(const bool enable);
|
2016-05-10 20:15:24 +00:00
|
|
|
R_API void r_cons_bind(RConsBind *bind);
|
2016-10-20 23:24:40 +00:00
|
|
|
R_API const char* r_cons_get_rune(const ut8 ch);
|
2009-12-24 02:17:53 +00:00
|
|
|
#endif
|
|
|
|
|
2012-10-03 23:20:00 +00:00
|
|
|
/* r_line */
|
|
|
|
#define R_LINE_BUFSIZE 4096
|
|
|
|
#define R_LINE_HISTSIZE 256
|
|
|
|
|
|
|
|
typedef struct r_line_hist_t {
|
|
|
|
char **data;
|
|
|
|
int size;
|
|
|
|
int index;
|
|
|
|
int top;
|
|
|
|
int autosave;
|
|
|
|
} RLineHistory;
|
|
|
|
|
|
|
|
typedef struct r_line_buffer_t {
|
|
|
|
char data[R_LINE_BUFSIZE];
|
|
|
|
int index;
|
|
|
|
int length;
|
|
|
|
} RLineBuffer;
|
|
|
|
|
|
|
|
typedef struct r_line_t RLine; // forward declaration
|
|
|
|
|
|
|
|
typedef int (*RLineCallback)(RLine *line);
|
|
|
|
|
|
|
|
typedef struct r_line_comp_t {
|
|
|
|
int argc;
|
|
|
|
const char **argv;
|
|
|
|
RLineCallback run;
|
|
|
|
} RLineCompletion;
|
|
|
|
|
2013-09-18 15:24:43 +00:00
|
|
|
typedef char* (*RLineEditorCb)(void *core, const char *str);
|
|
|
|
|
2012-10-03 23:20:00 +00:00
|
|
|
struct r_line_t {
|
|
|
|
RLineCompletion completion;
|
|
|
|
RLineHistory history;
|
|
|
|
RLineBuffer buffer;
|
2013-09-18 15:24:43 +00:00
|
|
|
RLineEditorCb editor_cb;
|
2012-10-03 23:20:00 +00:00
|
|
|
int echo;
|
|
|
|
int has_echo;
|
|
|
|
char *prompt;
|
|
|
|
char *clipboard;
|
|
|
|
int disable;
|
|
|
|
void *user;
|
2013-08-28 01:06:10 +00:00
|
|
|
int (*hist_up)(void *user);
|
|
|
|
int (*hist_down)(void *user);
|
|
|
|
char *contents;
|
2015-10-24 21:25:56 +00:00
|
|
|
bool zerosep;
|
2012-10-03 23:20:00 +00:00
|
|
|
}; /* RLine */
|
|
|
|
|
|
|
|
#ifdef R_API
|
|
|
|
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API RLine *r_line_new(void);
|
|
|
|
R_API RLine *r_line_singleton(void);
|
|
|
|
R_API void r_line_free(void);
|
|
|
|
R_API char *r_line_get_prompt (void);
|
2012-10-03 23:20:00 +00:00
|
|
|
R_API void r_line_set_prompt(const char *prompt);
|
2015-12-08 12:03:38 +00:00
|
|
|
R_API int r_line_dietline_init();
|
|
|
|
R_API void r_line_hist_free();
|
2012-10-03 23:20:00 +00:00
|
|
|
|
2012-12-22 03:28:19 +00:00
|
|
|
typedef int (RLineReadCallback) (void *user, const char *line);
|
2015-01-30 23:50:05 +00:00
|
|
|
R_API const char *r_line_readline(void);
|
|
|
|
R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user);
|
2012-12-22 01:37:01 +00:00
|
|
|
|
|
|
|
R_API int r_line_hist_load(const char *file);
|
2012-10-03 23:20:00 +00:00
|
|
|
R_API int r_line_hist_add(const char *line);
|
|
|
|
R_API int r_line_hist_save(const char *file);
|
|
|
|
R_API int r_line_hist_label(const char *label, void (*cb)(const char*));
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API void r_line_label_show(void);
|
|
|
|
R_API int r_line_hist_list(void);
|
2013-03-14 01:32:53 +00:00
|
|
|
R_API const char *r_line_hist_get(int n);
|
2012-10-03 23:20:00 +00:00
|
|
|
|
2013-01-22 04:06:12 +00:00
|
|
|
#define R_CONS_INVERT(x,y) (y? (x?Color_INVERT: Color_INVERT_RESET): (x?"[":"]"))
|
2012-10-03 23:20:00 +00:00
|
|
|
|
2013-01-22 04:06:12 +00:00
|
|
|
#endif
|
2012-10-03 23:20:00 +00:00
|
|
|
|
2015-07-08 11:34:00 +00:00
|
|
|
/* r_agraph */
|
|
|
|
|
|
|
|
typedef struct r_ascii_node_t {
|
2015-07-08 20:34:11 +00:00
|
|
|
RGraphNode *gnode;
|
2015-07-17 22:59:27 +00:00
|
|
|
char *title;
|
|
|
|
char *body;
|
2015-07-08 20:34:11 +00:00
|
|
|
|
2015-07-08 11:34:00 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int w;
|
|
|
|
int h;
|
2015-07-08 20:34:11 +00:00
|
|
|
|
2015-07-08 11:34:00 +00:00
|
|
|
int layer;
|
|
|
|
int pos_in_layer;
|
|
|
|
int is_dummy;
|
|
|
|
int is_reversed;
|
2015-07-13 12:43:13 +00:00
|
|
|
int klass;
|
2016-12-19 00:33:54 +00:00
|
|
|
bool mini;
|
2015-07-08 11:34:00 +00:00
|
|
|
} RANode;
|
|
|
|
|
2015-10-25 11:43:35 +00:00
|
|
|
#define R_AGRAPH_MODE_NORMAL 0
|
|
|
|
#define R_AGRAPH_MODE_OFFSET 1
|
2016-05-04 08:16:26 +00:00
|
|
|
#define R_AGRAPH_MODE_MINI 2
|
|
|
|
#define R_AGRAPH_MODE_SUMMARY 3
|
|
|
|
#define R_AGRAPH_MODE_MAX 4
|
2015-10-25 11:43:35 +00:00
|
|
|
|
2015-10-15 07:00:53 +00:00
|
|
|
typedef void (*RANodeCallback)(RANode *n, void *user);
|
|
|
|
typedef void (*RAEdgeCallback)(RANode *from, RANode *to, void *user);
|
|
|
|
|
2015-07-08 11:34:00 +00:00
|
|
|
typedef struct r_ascii_graph_t {
|
|
|
|
RConsCanvas *can;
|
|
|
|
RGraph *graph;
|
|
|
|
const RGraphNode *curnode;
|
2015-07-18 10:49:09 +00:00
|
|
|
char *title;
|
2015-07-19 12:32:00 +00:00
|
|
|
Sdb *db;
|
2015-10-02 17:28:49 +00:00
|
|
|
Sdb *nodes; // Sdb with title(key)=RANode*(value)
|
2015-07-08 11:34:00 +00:00
|
|
|
|
2017-01-14 00:14:50 +00:00
|
|
|
int layout;
|
2015-07-08 11:34:00 +00:00
|
|
|
int is_instep;
|
2015-10-25 11:43:35 +00:00
|
|
|
int mode;
|
|
|
|
int is_callgraph;
|
2015-07-08 11:34:00 +00:00
|
|
|
int zoom;
|
|
|
|
int movspeed;
|
|
|
|
|
|
|
|
RANode *update_seek_on;
|
2016-12-19 00:33:54 +00:00
|
|
|
bool need_reload_nodes;
|
|
|
|
bool need_set_layout;
|
2015-07-08 11:34:00 +00:00
|
|
|
int need_update_dim;
|
|
|
|
int force_update_seek;
|
|
|
|
|
2015-10-15 07:00:53 +00:00
|
|
|
/* events */
|
|
|
|
RANodeCallback on_curnode_change;
|
|
|
|
void *on_curnode_change_data;
|
|
|
|
|
2015-07-08 11:34:00 +00:00
|
|
|
int x, y;
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
/* layout algorithm info */
|
|
|
|
RList *back_edges;
|
|
|
|
RList *long_edges;
|
|
|
|
struct layer_t *layers;
|
|
|
|
int n_layers;
|
|
|
|
RList *dists; /* RList<struct dist_t> */
|
2015-07-25 11:55:31 +00:00
|
|
|
RList *edges; /* RList<AEdge> */
|
2015-10-15 07:00:53 +00:00
|
|
|
|
|
|
|
/* colors */
|
2015-07-15 13:54:20 +00:00
|
|
|
const char *color_box;
|
|
|
|
const char *color_box2;
|
|
|
|
const char *color_box3;
|
|
|
|
const char *color_true;
|
|
|
|
const char *color_false;
|
2015-07-08 11:34:00 +00:00
|
|
|
} RAGraph;
|
|
|
|
|
|
|
|
#ifdef R_API
|
2015-10-02 17:28:49 +00:00
|
|
|
R_API RAGraph *r_agraph_new(RConsCanvas *can);
|
|
|
|
R_API void r_agraph_free(RAGraph *g);
|
|
|
|
R_API void r_agraph_reset(RAGraph *g);
|
|
|
|
R_API void r_agraph_set_title(RAGraph *g, const char *title);
|
2016-01-04 22:00:01 +00:00
|
|
|
R_API RANode *r_agraph_get_first_node(const RAGraph *g);
|
2015-10-02 17:28:49 +00:00
|
|
|
R_API RANode *r_agraph_get_node(const RAGraph *g, const char *title);
|
|
|
|
R_API RANode *r_agraph_add_node(const RAGraph *g, const char *title, const char *body);
|
|
|
|
R_API bool r_agraph_del_node(const RAGraph *g, const char *title);
|
|
|
|
R_API void r_agraph_add_edge(const RAGraph *g, RANode *a, RANode *b);
|
|
|
|
R_API void r_agraph_add_edge_at(const RAGraph *g, RANode *a, RANode *b, int nth);
|
|
|
|
R_API void r_agraph_del_edge(const RAGraph *g, RANode *a, RANode *b);
|
|
|
|
R_API void r_agraph_print(RAGraph *g);
|
|
|
|
R_API Sdb *r_agraph_get_sdb(RAGraph *g);
|
2015-10-15 07:00:53 +00:00
|
|
|
R_API void r_agraph_foreach(RAGraph *g, RANodeCallback cb, void *user);
|
|
|
|
R_API void r_agraph_foreach_edge(RAGraph *g, RAEdgeCallback cb, void *user);
|
2016-01-04 22:00:01 +00:00
|
|
|
R_API void r_agraph_set_curnode(RAGraph *g, RANode *node);
|
2015-07-08 11:34:00 +00:00
|
|
|
#endif
|
|
|
|
|
2013-06-18 10:09:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
#endif
|