当前位置: 首页>>代码示例>>C++>>正文


C++ r_cons_gotoxy函数代码示例

本文整理汇总了C++中r_cons_gotoxy函数的典型用法代码示例。如果您正苦于以下问题:C++ r_cons_gotoxy函数的具体用法?C++ r_cons_gotoxy怎么用?C++ r_cons_gotoxy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了r_cons_gotoxy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: strlen

// TODO: Add fmt support
R_API char *r_cons_message(const char *msg) {
	int cols, rows;
	int len = strlen (msg);
	cols = r_cons_get_size (&rows);

	r_cons_clear ();
	r_cons_gotoxy ((cols-len)/2, rows/2); // XXX
	/// TODO: add square, or talking clip here
	r_cons_printf ("%s\n", msg);
	r_cons_flush ();
	r_cons_gotoxy (0, rows-2); // XXX
	r_cons_any_key ();
	return NULL;
}
开发者ID:commiebstrd,项目名称:radare2,代码行数:15,代码来源:hud.c

示例2: r_core_visual_xrefs_x

R_API int r_core_visual_xrefs_x (RCore *core) {
	int ret = 0;
#if FCN_OLD
	char ch;
	int count = 0;
	RList *xrefs = NULL;
	RAnalRef *refi;
	RListIter *iter;
	RAnalFunction *fun;

	if ((xrefs = r_anal_xref_get (core->anal, core->offset))) {
		r_cons_gotoxy (1, 1);
		r_cons_printf ("[GOTO XREF]> \n");
		if (r_list_empty (xrefs)) {
			r_cons_printf ("\tNo XREF found at 0x%"PFMT64x"\n", core->offset);
			r_cons_any_key (NULL);
			r_cons_clear00 ();
		} else {
			r_list_foreach (xrefs, iter, refi) {
				fun = r_anal_get_fcn_in (core->anal, refi->addr, R_ANAL_FCN_TYPE_NULL);
				r_cons_printf (" [%i] 0x%08"PFMT64x" %s XREF 0x%08"PFMT64x" (%s)                      \n", count,
					refi->at,
					      refi->type==R_ANAL_REF_TYPE_CODE?"CODE (JMP)":
					      refi->type==R_ANAL_REF_TYPE_CALL?"CODE (CALL)":"DATA", refi->addr,
					      fun?fun->name:"unk");
				if (++count > 9) break;
			}
		}
开发者ID:xuwenbo,项目名称:radare2,代码行数:28,代码来源:visual.c

示例3: r_core_visual_seek_animation

R_API void r_core_visual_seek_animation (RCore *core, ut64 addr) {
	if (r_config_get_i (core->config, "scr.feedback")<1)
		return;
#if 0
	int i, ns = 90000;
	const char *scmd = (addr > core->offset)? "so": "s-4";
	for (i=0;i<5;i++) {
		r_core_cmd0 (core, scmd);
		r_core_visual_refresh (core);
		r_cons_flush();
		r_sys_usleep (ns);
		ns -= 1000;
	}
	r_core_seek (core, addr, 1);
#else
	if (core->offset == addr)
		return;
	r_cons_gotoxy (1, 2);
	if (addr>core->offset) {
		r_cons_printf (".----.\n");
		r_cons_printf ("| \\/ |\n");
		r_cons_printf ("'----'\n");
	} else {
		r_cons_printf (".----.\n");
		r_cons_printf ("| /\\ |\n");
		r_cons_printf ("'----'\n");
	}
	r_cons_flush();
	r_sys_usleep (90000);
#endif
	r_core_seek (core, addr, 1);
}
开发者ID:xuwenbo,项目名称:radare2,代码行数:32,代码来源:visual.c

示例4: r_cons_column

R_API void r_cons_column(int c) {
	char *b = malloc (I.buffer_len+1);
	memcpy (b, I.buffer, I.buffer_len);
	b[I.buffer_len] = 0;
	r_cons_reset ();
	// align current buffer N chars right
	r_cons_strcat_justify (b, c, 0);
	r_cons_gotoxy (0, 0);
}
开发者ID:jevinskie,项目名称:radare2,代码行数:9,代码来源:cons.c

示例5: r_core_visual_show_char

R_API void r_core_visual_show_char (RCore *core, char ch) {
	if (r_config_get_i (core->config, "scr.feedback")<2)
		return;
	if (!IS_PRINTABLE (ch))
		return;
	r_cons_gotoxy (1, 2);
	r_cons_printf (".---.\n");
	r_cons_printf ("| %c |\n", ch);
	r_cons_printf ("'---'\n");
	r_cons_flush ();
	r_sys_sleep (1);
}
开发者ID:xuwenbo,项目名称:radare2,代码行数:12,代码来源:visual.c

示例6: visual_repeat_thread

static int visual_repeat_thread(RThread *th) {
	RCore *core = th->user;
	int i = 0;
	for (;;) {
		if (core->cons->breaked)
			break;
		r_core_visual_refresh (core);
		r_cons_flush ();
		r_cons_gotoxy (0, 0);
		r_cons_printf ("[@%d] ", i++);
		r_cons_flush ();
		r_sys_sleep (1);
	}
	r_th_kill (th, 1);
	return 0;
}
开发者ID:xuwenbo,项目名称:radare2,代码行数:16,代码来源:visual.c

示例7: parseMouseEvent

static int parseMouseEvent() {
	int ch = r_cons_readchar ();
	/* Skip the x/y coordinates */
#if USE_CLICK
	int x = r_cons_readchar() - 33;
	int y = r_cons_readchar() - 33;
#else
	(void) r_cons_readchar ();
	(void) r_cons_readchar ();
#endif
#if USE_CLICK
	if (ch == 35) {
		/* handle click  */
#define CLICK_DEBUG 1
#if CLICK_DEBUG
		r_cons_gotoxy (0, 0);
		r_cons_printf ("Click at %d %d\n", x, y);
		r_cons_flush ();
#endif
		RCons *cons = r_cons_singleton ();
		if (cons->onclick) {
			cons->onclick (cons->data, x, y);
		}
		r_cons_enable_mouse (false);
		(void)r_cons_readchar ();
		return 0;
	}
#endif
	if (ch != 0x20 && ch >= 64 + 32) {
		/* Grab wheel events only */
		I->mouse_event = 1;
		return "kj"[(ch - (64 + 32))&1];
	}

	// temporary disable the mouse wheel to allow select
	r_cons_enable_mouse (false);
	(void)r_cons_readchar ();
	return 0;
}
开发者ID:xarkes,项目名称:radare2,代码行数:39,代码来源:input.c

示例8: r_core_visual_prompt_input

R_API void r_core_visual_prompt_input (RCore *core) {
	int ret;
	ut64 addr = core->offset;
	ut64 bsze = core->blocksize;
	int h;
	(void)r_cons_get_size (&h);
	r_cons_gotoxy (0, h-2);
	r_cons_reset_colors();
	r_cons_printf("\nPress <enter> to return to Visual mode.\n");

	r_cons_show_cursor (true);
	core->vmode = false;
	ut64 newaddr = addr;
	if (curset) {
		if (ocursor != -1) {
			newaddr = core->offset + ocursor;
			r_core_block_size (core, cursor-ocursor);
		} else newaddr = core->offset + cursor;
		r_core_seek (core, newaddr, 1);
	}
	do {
		ret = r_core_visual_prompt (core);
		if (core->offset != newaddr) {
			// do not restore seek anymore
			newaddr = addr;
		}
	} while (ret);
	if (curset) {
		if (addr != newaddr) {
			r_core_seek (core, addr, 1);
			r_core_block_size (core, bsze);
		}
	}
	r_cons_show_cursor (false);
	core->vmode = true;
}
开发者ID:AitorATuin,项目名称:radare2,代码行数:36,代码来源:visual.c

示例9: r_strbuf_new

// TODO: move into r_util/str
R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
	const char *str = ptr;
	int esc = 0;
	int len = 0;
	int inv = 0;
	int tmp;
	bool tag_font = false;
	if (!ptr) {
		return NULL;
	}
	RStrBuf *res = r_strbuf_new ("");
	if (!res) {
		return NULL;
	}
	for (; ptr[0]; ptr = ptr + 1) {
		if (ptr[0] == '\n') {
			tmp = (int) (size_t) (ptr - str);
			r_strbuf_append_n (res, str, tmp);
			if (!ptr[1]) {
				// write new line if it's the end of the output
				r_strbuf_append (res, "\n");
			} else {
				r_strbuf_append (res, "<br />");
			}
			str = ptr + 1;
			continue;
		} else if (ptr[0] == '<') {
			tmp = (int) (size_t) (ptr - str);
			r_strbuf_append_n (res, str, tmp);
			r_strbuf_append (res, "&lt;");
			str = ptr + 1;
			continue;
		} else if (ptr[0] == '>') {
			tmp = (int) (size_t) (ptr - str);
			r_strbuf_append_n (res, str, tmp);
			r_strbuf_append (res, "&gt;");
			str = ptr + 1;
			continue;
		} else if (ptr[0] == ' ') {
			tmp = (int) (size_t) (ptr - str);
			r_strbuf_append_n (res, str, tmp);
			r_strbuf_append (res, "&nbsp;");
			str = ptr + 1;
			continue;
		}
		if (ptr[0] == 0x1b) {
			esc = 1;
			tmp = (int) (size_t) (ptr - str);
			r_strbuf_append_n (res, str, tmp);
			if (tag_font) {
				r_strbuf_append (res, "</font>");
				tag_font = false;
			}
			str = ptr + 1;
			continue;
		}
		if (esc == 1) {
			// \x1b[2J
			if (ptr[0] != '[') {
				eprintf ("Oops invalid escape char\n");
				esc = 0;
				str = ptr + 1;
				continue;
			}
			esc = 2;
			continue;
		} else if (esc == 2) {
			// TODO: use dword comparison here
			if (ptr[0] == '2' && ptr[1] == 'J') {
				r_strbuf_append (res, "<hr />");
				ptr++;
				esc = 0;
				str = ptr;
				continue;
			} else if (!strncmp (ptr, "48;5;", 5) || !strncmp (ptr, "48;2;", 5)) {
				char *end = strchr (ptr, 'm');
				r_strbuf_appendf (res, "<font style='background-color:%s'>", gethtmlrgb (ptr));
				tag_font = true;
				ptr = end;
				str = ptr + 1;
				esc = 0;
			} else if (!strncmp (ptr, "38;5;", 5) || !strncmp (ptr, "38;2;", 5)) {
				char *end = strchr (ptr, 'm');
				r_strbuf_appendf (res, "<font color='%s'>", gethtmlrgb (ptr));
				tag_font = true;
				ptr = end;
				str = ptr + 1;
				esc = 0;
			} else if (ptr[0] == '0' && ptr[1] == ';' && ptr[2] == '0') {
				// wtf ?
				r_cons_gotoxy (0, 0);
				ptr += 4;
				esc = 0;
				str = ptr;
				continue;
			} else if (ptr[0] == '0' && ptr[1] == 'm') {
				str = (++ptr) + 1;
				esc = inv = 0;
				continue;
//.........这里部分代码省略.........
开发者ID:tutamuniz,项目名称:radare2,代码行数:101,代码来源:grep.c

示例10: r_cons_html_print

// XXX: rename char *r_cons_filter_html(const char *ptr)
R_API int r_cons_html_print(const char *ptr) {
	const char *str = ptr;
	int esc = 0;
	int len = 0;
	int inv = 0;
	int tmp;

	if (!ptr)
		return 0;
	for (;ptr[0]; ptr = ptr + 1) {
		if (0 && ptr[0] == '\n') {
			printf ("<br />");
			fflush (stdout);
		}
		if (ptr[0] == 0x1b) {
			esc = 1;
			tmp = (int) (size_t) (ptr-str);
			if (write (1, str, tmp) != tmp)
				eprintf ("r_cons_html_print: write: error\n");
			str = ptr + 1;
			continue;
		}
		if (esc == 1) {
			// \x1b[2J
			if (ptr[0] != '[') {
				eprintf ("Oops invalid escape char\n");
				esc = 0;
				str = ptr + 1;
				continue;
			}
			esc = 2;
			continue;
		} else 
		if (esc == 2) {
			// TODO: use dword comparison here
			if (ptr[0]=='2' && ptr[1]=='J') {
				printf ("<hr />\n"); fflush(stdout);
				ptr++;
				esc = 0;
				str = ptr;
				continue;
			} else
			if (ptr[0]=='0' && ptr[1]==';' && ptr[2]=='0') {
				r_cons_gotoxy (0, 0);
				ptr += 4;
				esc = 0;
				str = ptr;
				continue;
			} else
			if (ptr[0]=='0' && ptr[1]=='m') {
				str = (++ptr) + 1;
				esc = inv = 0;
				continue;
				// reset color
			} else
			if (ptr[0]=='7' && ptr[1]=='m') {
				str = (++ptr) +1;
				inv = 128;
				esc = 0;
				continue;
				// reset color
			} else
			if (ptr[0]=='3' && ptr[2]=='m') {
				// TODO: honor inv here
				printf ("<font color='%s'>", gethtmlcolor (ptr[1], "#000"));
				fflush(stdout);
				ptr = ptr + 1;
				str = ptr + 2;
				esc = 0;
				continue;
			} else
			if (ptr[0]=='4' && ptr[2]=='m') {
				// TODO: USE INV HERE
				printf ("<font style='background-color:%s'>", gethtmlcolor (ptr[1], "#fff"));
				fflush(stdout);
			}
		} 
		len++;
	}
	write (1, str, ptr-str);
	return len;
}
开发者ID:uKZqmf6e32,项目名称:radare2,代码行数:83,代码来源:grep.c

示例11: r_core_visual_cmd


//.........这里部分代码省略.........
            r_flag_unset_i (core->flags, core->offset + cursor, NULL);
            break;
        case 'n':
            r_core_seek_next (core, r_config_get (core->config, "scr.nkey"));
            break;
        case 'N':
            r_core_seek_previous (core, r_config_get (core->config, "scr.nkey"));
            break;
        case 'i':
        case 'I':
            if (core->file && !(core->file->rwx & 2)) {
                r_cons_printf ("\nFile has been opened in read-only mode. Use -w flag\n");
                r_cons_any_key ();
                return R_TRUE;
            }
            showcursor (core, R_TRUE);
            r_cons_flush ();
            r_cons_set_raw (0);
            if (ch=='I') {
                strcpy (buf, "wow ");
                r_line_set_prompt ("insert hexpair block: ");
                if (r_cons_fgets (buf+4, sizeof (buf)-5, 0, NULL) <0)
                    buf[0]='\0';
                char *p = strdup (buf);
                int cur = core->print->cur;
                if (cur>=core->blocksize)
                    cur = core->print->cur-1;
                snprintf (buf, sizeof (buf), "%s @ $$0!%i", p,
                          core->blocksize-cursor);
                r_core_cmd (core, buf, 0);
                free (p);
                break;
            }
            delta = (ocursor!=-1)? R_MIN (cursor, ocursor): cursor;
            if (core->print->col==2) {
                strcpy (buf, "\"w ");
                r_line_set_prompt ("insert string: ");
                if (r_cons_fgets (buf+3, sizeof (buf)-4, 0, NULL) <0)
                    buf[0]='\0';
                strcat (buf, "\"");
            } else {
                r_line_set_prompt ("insert hex: ");
                if (ocursor != -1) {
                    int bs = R_ABS (cursor-ocursor)+1;
                    core->blocksize = bs;
                    strcpy (buf, "wow ");
                } else {
                    strcpy (buf, "wx ");
                }
                if (r_cons_fgets (buf+strlen (buf), sizeof (buf)-strlen (buf), 0, NULL) <0)
                    buf[0]='\0';
            }
            if (curset) r_core_seek (core, core->offset + delta, 0);
            r_core_cmd (core, buf, 1);
            if (curset) r_core_seek (core, offset, 1);
            r_cons_set_raw (1);
            showcursor (core, R_FALSE);
            break;
        case 'R':
            r_core_cmd0 (core, "ecr");
            break;
        case 'e':
            r_core_visual_config (core);
            break;
        case 'E':
            r_core_visual_colors (core);
            break;
        case 'M':
            r_core_visual_mounts (core);
            break;
        case 't':
            r_core_visual_trackflags (core);
            break;
        case 'x':
        {
            int count = 0;
            RList *xrefs = NULL;
            RAnalRef *refi;
            RListIter *iter;
            RAnalFunction *fun;

            if ((xrefs = r_anal_xref_get (core->anal, core->offset))) {
                r_cons_gotoxy (1, 1);
                r_cons_printf ("[GOTO XREF]> \n");
                if (r_list_empty (xrefs)) {
                    r_cons_printf ("\tNo XREF found at 0x%"PFMT64x"\n", core->offset);
                    r_cons_any_key ();
                    r_cons_clear00 ();
                } else {
                    r_list_foreach (xrefs, iter, refi) {
                        fun = r_anal_fcn_find (core->anal, refi->addr, R_ANAL_FCN_TYPE_NULL);
                        r_cons_printf (" [%i] 0x%08"PFMT64x" %s XREF 0x%08"PFMT64x" (%s)                      \n", count,
                                       refi->at,
                                       refi->type==R_ANAL_REF_TYPE_CODE?"CODE (JMP)":
                                       refi->type==R_ANAL_REF_TYPE_CALL?"CODE (CALL)":"DATA", refi->addr,
                                       fun?fun->name:"unk");
                        if (++count > 9) break;
                    }
                }
            } else xrefs = NULL;
开发者ID:revskills,项目名称:radare2,代码行数:101,代码来源:visual.c

示例12: r_cons_clear

R_API char *r_cons_hud(RList *list, const char *prompt) {
	int ch, nch, first, n, j, i = 0;
	int choose = 0;
	char *p, buf[128];
	RListIter *iter;
	char *match = NULL;
	void *pos;
	buf[0] = 0;
	r_cons_clear ();
	for (;;) {
		first = 1;
		r_cons_gotoxy (0, 0);
		n = 0;
		match = NULL;
		if (prompt && *prompt)
			r_cons_printf (">> %s\n", prompt);
		r_cons_printf ("> %s|\n", buf);
		r_list_foreach (list, iter, pos) {
			if (!buf[0] || strmatch (pos, buf)) {
				char *x = strchr (pos, '\t');
				// remove \t.*
				if (!choose || n>=choose) {
					if (x) *x = 0;
					p = strdup (pos);
					for (j=0; p[j]; j++) {
						if (strchr (buf, p[j]))
							p[j] = toupper ((unsigned char)p[j]);
					}
					r_cons_printf (" %c %s\n", first?'-':' ', p);
					free (p);
					if (x) *x = '\t';
					if (first) match = pos;
					first = 0;
				}
				n++;
			}
		}
		r_cons_visual_flush ();
		ch = r_cons_readchar ();
		nch = r_cons_arrow_to_hjkl (ch);
		if (nch == 'j' && ch != 'j') {
			if (choose+1 < n)
				choose++;
		} else if (nch == 'k' && ch != 'k') {
			if (choose>=0)
				choose--;
		} else
		switch (ch) {
		case 9: // \t
			if (choose+1 < n)
				choose++;
			else choose = 0;
			break;
		case 10: // \n
		case 13: // \r
			choose = 0;
	//		if (!*buf)
	//			return NULL;
			if (n >= 1) {
				//eprintf ("%s\n", buf);
				//i = buf[0] = 0;
				return strdup (match);
			} // no match!
			break;
		case 23: // ^w
			choose = 0;
			i = buf[0] = 0;
			break;
		case 0x1b: // ESC
			return NULL;
		case 8: // bs
		case 127: // bs
			choose = 0;
			if (i<1) return NULL;
			buf[--i] = 0;
			break;
		default:
			if (IS_PRINTABLE (ch)) {
				choose = 0;
				buf[i++] = ch;
				buf[i] = 0;
			}
			break;
		}
	}
	return NULL;
}
开发者ID:commiebstrd,项目名称:radare2,代码行数:87,代码来源:hud.c

示例13: r_cons_clear00

R_API void r_cons_clear00() {
	r_cons_clear ();
	r_cons_gotoxy (0, 0);
}
开发者ID:NightOfTwelve,项目名称:radare2,代码行数:4,代码来源:cons.c

示例14: r_cons_clear

// Display a list of entries in the hud, filtered and emphasized based
// on the user input.
R_API char *r_cons_hud(RList *list, const char *prompt, const bool usecolor) {
	const int buf_size = 128;
	int ch, nch, first_line, current_entry_n, j, i = 0;
	char *p, *x, user_input[buf_size], mask[buf_size];
	int last_color_change, top_entry_n = 0;
	char *selected_entry = NULL;
	char tmp, last_mask = 0;
	void *current_entry;
	RListIter *iter;

	user_input[0] = 0;
	r_cons_clear ();
	// Repeat until the user exits the hud
	for (;;) {
		first_line = 1;
		r_cons_gotoxy (0, 0);
		current_entry_n = 0;
		selected_entry = NULL;
		if (prompt && *prompt)
			r_cons_printf (">> %s\n", prompt);
		r_cons_printf ("> %s|\n", user_input);
		// Iterate over each entry in the list
		r_list_foreach (list, iter, current_entry) {
			memset (mask, 0, buf_size);
			if (!user_input[0] || strmatch (current_entry, user_input, mask, buf_size)) {
				// if the user scrolled down the list, do not print the first entries
				if (!top_entry_n || current_entry_n >= top_entry_n) {
					// remove everything after a tab (in ??, it contains the commands)
					x = strchr (current_entry, '\t');
					if (x) *x = 0;
					p = strdup (current_entry);
					// if the filter is empty, print the entry and move on
					if (!user_input[0]) {
						r_cons_printf (" %c %s\n", first_line? '-': ' ', current_entry);
					} else {
						// otherwise we need to emphasize the matching part
						if (usecolor) {
							last_color_change = 0;
							last_mask = 0;
							r_cons_printf (" %c ", first_line? '-': ' ');
							// Instead of printing one char at the time
							// (which would be slow), we group substrings of the same color
							for (j = 0; p[j]; j++) {
								if (mask[j] != last_mask) {
									tmp = p[j];
									p[j] = 0;
									if (mask[j]) {
										r_cons_printf (Color_RESET"%s", p + last_color_change);
									} else {
										r_cons_printf (Color_GREEN"%s", p + last_color_change);
									}
									p[j] = tmp;
									last_color_change = j;
									last_mask = mask[j];
								} 
							}
							if (last_mask) {
								r_cons_printf (Color_GREEN"%s\n"Color_RESET, p + last_color_change);
							} else {
								r_cons_printf (Color_RESET"%s\n", p + last_color_change);
							}
						} else {
							// Otherwise we print the matching characters uppercase
							for (j = 0; p[j]; j++) {
								if (mask[j])
									p[j] = toupper ((unsigned char)p[j]);
							}
							r_cons_printf (" %c %s\n", first_line? '-': ' ', p);
						}
					}
					// Clean up and restore the tab character (if any)
					free (p);
					if (x) *x = '\t';
					if (first_line) 
						selected_entry = current_entry;
					first_line = 0;
				}
				current_entry_n++;
			}
		}

		r_cons_visual_flush ();
		ch = r_cons_readchar ();
		nch = r_cons_arrow_to_hjkl (ch);
		if (nch == 'j' && ch != 'j') {
			if (top_entry_n + 1 < current_entry_n)
				top_entry_n++;
		} else if (nch == 'k' && ch != 'k') {
			if (top_entry_n >= 0)
				top_entry_n--;
		} else switch (ch) {
			case 9: // \t
				if (top_entry_n + 1 < current_entry_n)
					top_entry_n++;
				else top_entry_n = 0;
				break;
			case 10: // \n
			case 13: // \r
//.........这里部分代码省略.........
开发者ID:Darredevil,项目名称:radare2,代码行数:101,代码来源:hud.c

示例15: r_cons_html_print

// XXX: rename char *r_cons_filter_html(const char *ptr)
R_API int r_cons_html_print(const char *ptr) {
	const char *str = ptr;
	int esc = 0;
	int len = 0;
	int inv = 0;
	int tmp;
	bool tag_font = false;

	if (!ptr) {
		return 0;
	}
	for (;ptr[0]; ptr = ptr + 1) {
		if (0 && ptr[0] == '\n') {
			printf ("<br />");
			fflush (stdout);
		}
		if (ptr[0] == '<') {
			tmp = (int) (size_t) (ptr-str);
			if (write (1, str, tmp) != tmp) {
				eprintf ("r_cons_html_print: write: error\n");
			}
			printf ("&lt;");
			fflush (stdout);
			str = ptr + 1;
			continue;
		} else if (ptr[0] == '>') {
			tmp = (int) (size_t) (ptr-str);
			if (write (1, str, tmp) != tmp) {
				eprintf ("r_cons_html_print: write: error\n");
			}
			printf ("&gt;");
			fflush (stdout);
			str = ptr + 1;
			continue;
		}
		if (ptr[0] == 0x1b) {
			esc = 1;
			tmp = (int) (size_t) (ptr-str);
			if (write (1, str, tmp) != tmp) {
				eprintf ("r_cons_html_print: write: error\n");
			}
			if (tag_font) {
				printf ("</font>");
				fflush (stdout);
				tag_font = false;
			}
			str = ptr + 1;
			continue;
		}
		if (esc == 1) {
			// \x1b[2J
			if (ptr[0] != '[') {
				eprintf ("Oops invalid escape char\n");
				esc = 0;
				str = ptr + 1;
				continue;
			}
			esc = 2;
			continue;
		} else if (esc == 2) {
			// TODO: use dword comparison here
			if (ptr[0] == '2' && ptr[1] == 'J') {
				printf ("<hr />\n");
				fflush (stdout);
				ptr++;
				esc = 0;
				str = ptr;
				continue;
			} else if (!strncmp (ptr, "38;5;", 5)) {
				char *end = strchr (ptr, 'm');
				printf ("<font color='%s'>", gethtmlrgb (ptr));
				fflush (stdout);
				tag_font = true;
				ptr = end;
				str = ptr + 1;
				esc = 0;
			} else if (ptr[0] == '0' && ptr[1] == ';' && ptr[2] == '0') {
				r_cons_gotoxy (0, 0);
				ptr += 4;
				esc = 0;
				str = ptr;
				continue;
			} else if (ptr[0] == '0' && ptr[1] == 'm') {
				str = (++ptr) + 1;
				esc = inv = 0;
				continue;
				// reset color
			} else if (ptr[0] == '7' && ptr[1] == 'm') {
				str = (++ptr) + 1;
				inv = 128;
				esc = 0;
				continue;
				// reset color
			} else if (ptr[0] == '3' && ptr[2] == 'm') {
				printf ("<font color='%s'>", gethtmlcolor (ptr[1], inv ? "#fff" : "#000"));
				fflush (stdout);
				tag_font = true;
				ptr = ptr + 1;
				str = ptr + 2;
//.........这里部分代码省略.........
开发者ID:j123123,项目名称:radare2,代码行数:101,代码来源:grep.c


注:本文中的r_cons_gotoxy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。