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
Offset history #9591
Offset history #9591
Changes from 9 commits
23999ed
349da7e
cc68dc4
32f711c
511f834
0efed08
7380086
a6757c3
11c6840
3e98cda
b0c593c
03b12d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,6 +313,19 @@ static int r_line_hist_up() { | |
if (!I.history.data) { | ||
inithist (); | ||
} | ||
if (I.offset_prompt) { | ||
RCore *core = I.user; | ||
RIOUndo *undo = &core->io->undo; | ||
/*char line[R_LINE_BUFSIZE - 1];*/ | ||
if (I.offset_index <= -undo->undos) { | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong indentation |
||
} | ||
I.offset_index--; | ||
char *line = r_str_newf("0x%"PFMT64x, undo->seek[undo->idx + I.offset_index].off); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use space before ( |
||
strncpy(I.buffer.data, line, R_LINE_BUFSIZE - 1); | ||
I.buffer.index = I.buffer.length = strlen (I.buffer.data); | ||
return true; | ||
} | ||
if (I.history.index > 0) { | ||
strncpy (I.buffer.data, I.history.data[--I.history.index], R_LINE_BUFSIZE - 1); | ||
I.buffer.index = I.buffer.length = strlen (I.buffer.data); | ||
|
@@ -325,6 +338,23 @@ static int r_line_hist_down() { | |
if (I.hist_down) { | ||
return I.hist_down (I.user); | ||
} | ||
if (I.offset_prompt) { | ||
RCore *core = I.user; | ||
RIOUndo *undo = &core->io->undo; | ||
if (I.offset_index >= undo->redos) { | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong indentation |
||
} | ||
I.offset_index++; | ||
if (I.offset_index == undo->redos) { | ||
I.buffer.data[0] = '\0'; | ||
I.buffer.index = I.buffer.length = 0; | ||
return false; | ||
} | ||
char *line = r_str_newf("0x%"PFMT64x, undo->seek[undo->idx + I.offset_index].off); | ||
strncpy(I.buffer.data, line, R_LINE_BUFSIZE - 1); | ||
I.buffer.index = I.buffer.length = strlen (I.buffer.data); | ||
return true; | ||
} | ||
I.buffer.index = 0; | ||
if (!I.history.data) { | ||
inithist (); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -845,13 +845,16 @@ static void reset_print_cur(RPrint *p) { | |
static void visual_offset(RCore *core) { | ||
char buf[256]; | ||
r_line_set_prompt ("[offset]> "); | ||
core->cons->line->offset_prompt = true; | ||
core->cons->line->offset_index = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about doing: r_line_set_history_callback() and implement the logic of offset_prompt in here? |
||
strcpy (buf, "s "); | ||
if (r_cons_fgets (buf + 2, sizeof (buf) - 3, 0, NULL) > 0) { | ||
if (buf[2] == '.') { | ||
buf[1] = '.'; | ||
} | ||
r_core_cmd0 (core, buf); | ||
reset_print_cur (core->print); | ||
core->cons->line->offset_prompt = false; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not used - remove it.