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

Offset history #9591

Merged
merged 12 commits into from Mar 8, 2018
15 changes: 15 additions & 0 deletions libr/cons/dietline.c
Expand Up @@ -313,6 +313,13 @@ static int r_line_hist_up() {
if (!I.history.data) {
inithist ();
}
if (strcmp(r_line_get_prompt(), "[offset]> ") == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ! Instead of ==0 and add space before (

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm this strcmp is kind of a hack, prompt shouldnt change the behaviour

while (I.history.index > 0 && I.history.data[--I.history.index][0] != 's' );
int skip_whitespace = I.history.data[I.history.index][1] == ' ' ? 2 : 1;
strncpy (I.buffer.data, I.history.data[I.history.index] + skip_whitespace, 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);
Expand All @@ -338,6 +345,14 @@ static int r_line_hist_down() {
I.buffer.index = I.buffer.length = 0;
return false;
}
if (strcmp(r_line_get_prompt(), "[offset]> ") == 0) {
while (I.history.index != I.history.top && I.history.data[I.history.index++][0] != 's' );
I.history.index--;
int skip_whitespace = I.history.data[I.history.index][1] == ' ' ? 2 : 1;
strncpy (I.buffer.data, I.history.data[I.history.index] + skip_whitespace, R_LINE_BUFSIZE - 1);
I.buffer.index = I.buffer.length = strlen (I.buffer.data);
return true;
}
if (I.history.data[I.history.index]) {
strncpy (I.buffer.data, I.history.data[I.history.index], R_LINE_BUFSIZE - 1);
I.buffer.index = I.buffer.length = strlen (I.buffer.data);
Expand Down