Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove scr.rainbow option #4199

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions librz/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,6 @@ static bool cb_scr_wideoff(void *user, void *data) {
return true;
}

static bool cb_scrrainbow(void *user, void *data) {
RzCore *core = (RzCore *)user;
RzConfigNode *node = (RzConfigNode *)data;
if (node->i_value) {
core->print->flags |= RZ_PRINT_FLAGS_RAINBOW;
rz_cons_pal_random();
} else {
core->print->flags &= (~RZ_PRINT_FLAGS_RAINBOW);
rz_core_theme_load(core, rz_core_theme_get(core));
}
rz_print_set_flags(core->print, core->print->flags);
return true;
}

static bool cb_asmpseudo(void *user, void *data) {
RzCore *core = (RzCore *)user;
RzConfigNode *node = (RzConfigNode *)data;
Expand Down Expand Up @@ -3147,7 +3133,6 @@ RZ_API int rz_core_config_init(RzCore *core) {
SETCB("scr.prompt.vi", "false", &cb_scr_vi, "Use vi mode for input prompt");
SETCB("scr.prompt.mode", "false", &cb_scr_prompt_mode, "Set prompt color based on vi mode");
SETCB("scr.wideoff", "false", &cb_scr_wideoff, "Adjust offsets to match asm.bits");
SETCB("scr.rainbow", "false", &cb_scrrainbow, "Shows rainbow colors depending of address");
SETCB("scr.last", "true", &cb_scrlast, "Cache last output after flush to make _ command work (disable for performance)");
SETBPREF("asm.reloff", "false", "Show relative offsets instead of absolute address in disasm");
SETBPREF("asm.reloff.flags", "false", "Show relative offsets to flags (not only functions)");
Expand Down
4 changes: 0 additions & 4 deletions librz/core/cmd/cmd_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -3119,12 +3119,8 @@ RZ_API void rz_print_offset_sg(RzPrint *p, ut64 off, int invert, int offseg, int
const char *reset = p->resetbg ? Color_RESET : Color_RESET_NOBG;
bool show_color = p->flags & RZ_PRINT_FLAGS_COLOR;
if (show_color) {
char rgbstr[32];
const char *k = rz_cons_singleton()->context->pal.offset; // TODO etooslow. must cache
const char *inv = invert ? RZ_CONS_INVERT(true, true) : "";
if (p->flags & RZ_PRINT_FLAGS_RAINBOW) {
k = rz_cons_rgb_str_off(rgbstr, sizeof(rgbstr), off);
}
if (offseg) {
ut32 s, a;
a = off & 0xffff;
Expand Down
1 change: 0 additions & 1 deletion librz/include/rz_util/rz_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extern "C" {
#define RZ_PRINT_FLAGS_COMPACT 0x00000800
#define RZ_PRINT_FLAGS_NONHEX 0x00001000
#define RZ_PRINT_FLAGS_SECSUB 0x00002000
#define RZ_PRINT_FLAGS_RAINBOW 0x00004000
XVilka marked this conversation as resolved.
Show resolved Hide resolved
#define RZ_PRINT_FLAGS_HDROFF 0x00008000
#define RZ_PRINT_FLAGS_STYLE 0x00010000
#define RZ_PRINT_FLAGS_NONASCII 0x00020000
Expand Down
4 changes: 4 additions & 0 deletions librz/util/float/float.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
*/
#define define_types_gen_nan(fname, ftype) \
RZ_API ftype rz_types_gen_##fname##_nan() { \
/* The static modifier is on purpose and necessary for all compilers \
* to avoid optimizing them and generate NaN values portably */ \
static ftype zero = 0; \
ftype ret = zero / zero; \
feclearexcept(FE_ALL_EXCEPT); \
Expand All @@ -35,6 +37,8 @@

#define define_types_gen_inf(fname, ftype) \
RZ_API ftype rz_types_gen_##fname##_inf() { \
/* The static modifier is on purpose and necessary for all compilers \
* to avoid optimizing them and generate INF values portably */ \
static ftype zero = 0; \
static ftype one = 1.0; \
ftype ret = one / zero; \
Expand Down
14 changes: 0 additions & 14 deletions librz/util/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,8 @@ RZ_API char *rz_print_hexpair(RzPrint *p, const char *str, int n) {
return dst;
}

static char colorbuffer[64];
#define P(x) (p->cons && p->cons->context->pal.x) ? p->cons->context->pal.x
RZ_API const char *rz_print_byte_color(RzPrint *p, int ch) {
if (p->flags & RZ_PRINT_FLAGS_RAINBOW) {
// EXPERIMENTAL
int bg = (p->flags & RZ_PRINT_FLAGS_NONHEX) ? 48 : 38;
snprintf(colorbuffer, sizeof(colorbuffer), "\033[%d;5;%dm", bg, ch);
return colorbuffer;
}
const bool use_color = p->flags & RZ_PRINT_FLAGS_COLOR;
if (!use_color) {
return NULL;
Expand Down Expand Up @@ -452,16 +445,9 @@ static inline void print_addr(RzStrBuf *sb, RzPrint *p, ut64 addr) {
white = allocated = rz_str_pad(' ', w);
}
if (use_color) {
char rgbstr[32] = { 0 };
const char *pre = PREOFF(offset)
: Color_GREEN;
const char *fin = Color_RESET;
if (p && p->flags & RZ_PRINT_FLAGS_RAINBOW) {
// pre = rz_cons_rgb_str_off (rgbstr, addr);
if (p->cons && p->cons->rgbstr) {
pre = p->cons->rgbstr(rgbstr, sizeof(rgbstr), addr);
}
}
if (dec) {
rz_strbuf_appendf(sb, "%s%s%" PFMT64d "%s%c", pre, white, addr, fin, ch);
} else {
Expand Down
12 changes: 6 additions & 6 deletions test/db/cmd/cmd_eval
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ RUN
NAME=multiple assignments
FILE==
CMDS=<<EOF
e scr.highlight=" scr.highlight.grep =scr.rainbow =true"
e scr.highlight=" scr.highlight.grep =scr.utf8 =true"
e scr.highlight
e scr.highlight.grep
e scr.rainbow
e scr.utf8
EOF
EXPECT=<<EOF
scr.highlight.grep =scr.rainbow =true
scr.highlight.grep =scr.utf8 =true
false
false
EOF
Expand All @@ -97,12 +97,12 @@ RUN
NAME=multiple assignments with quotes
FILE==
CMDS=<<EOF
e cmd.prompt='scr.highlight = "e cmd.prompt = "e scr.highlight = cmd.prompt ="e scr.rainbow = true """'
e cmd.prompt='scr.highlight = "e cmd.prompt = "e scr.highlight = cmd.prompt ="e scr.utf8 = true """'
e cmd.prompt
e scr.highlight
EOF
EXPECT=<<EOF
scr.highlight = "e cmd.prompt = "e scr.highlight = cmd.prompt ="e scr.rainbow = true """
scr.highlight = "e cmd.prompt = "e scr.highlight = cmd.prompt ="e scr.utf8 = true """

EOF
RUN
Expand Down Expand Up @@ -135,4 +135,4 @@ zoom.in=io.map
zoom.maxsz=512
zoom.to=0
EOF
RUN
RUN
Loading