Add sj and s= commands

This commit is contained in:
pancake 2016-05-09 10:39:19 +02:00
parent 351df0c2b7
commit 7676272b18
3 changed files with 41 additions and 10 deletions

View File

@ -287,7 +287,9 @@ static int cmd_seek(void *data, const char *input) {
r_core_seek_base (core, input);
break;
case '*':
r_io_sundo_list (core->io);
case '=':
case 'j':
r_io_sundo_list (core->io, input[0]);
break;
case '+':
if (input[1]!='\0') {

View File

@ -427,7 +427,7 @@ R_API ut64 r_io_sundo(RIO *io, ut64 offset);
R_API ut64 r_io_sundo_redo(RIO *io);
R_API void r_io_sundo_push(RIO *io, ut64 off);
R_API void r_io_sundo_reset(RIO *io);
R_API void r_io_sundo_list(RIO *io);
R_API void r_io_sundo_list(RIO *io, int mode);
/* write undo */
R_API void r_io_wundo_new(RIO *io, ut64 off, const ut8 *data, int len);
R_API void r_io_wundo_apply_all(RIO *io, int set);

View File

@ -87,7 +87,7 @@ R_API void r_io_sundo_reset(RIO *io) {
io->undo.redos = 0;
}
R_API void r_io_sundo_list(RIO *io) {
R_API void r_io_sundo_list(RIO *io, int mode) {
int idx, undos, redos, i, j, start, end;
if (!io->undo.s_enable)
@ -104,16 +104,45 @@ R_API void r_io_sundo_list(RIO *io) {
end = (idx + redos + 1) % R_IO_UNDOS;
j = 0;
for (i = start; i != end || j == 0; i = (i + 1) % R_IO_UNDOS) {
if (j < undos) {
io->cb_printf ("f undo_%d @ 0x%"PFMT64x"\n", undos - j - 1, io->undo.seek[i]);
} else if (j == undos && j != 0 && redos != 0) {
io->cb_printf ("# Current undo/redo position.\n");
} else if (j != undos) {
io->cb_printf ("f redo_%d @ 0x%"PFMT64x"\n", j - undos - 1, io->undo.seek[i]);
switch (mode) {
case 'j':
io->cb_printf ("[");
break;
}
for (i = start; i < end || j == 0; i = (i + 1) % R_IO_UNDOS) {
int idx = (j< undos)? undos - j - 1: j - undos - 1;
ut64 addr = io->undo.seek[i];
ut64 notLast = j+1<undos && (i != end - 1);
switch (mode) {
case '=':
if (j < undos) {
io->cb_printf ("0x%"PFMT64x"%s", addr, notLast? " > ": "");
}
break;
case 'j':
if (j < undos) {
io->cb_printf ("%"PFMT64d"%s", addr, notLast? ",": "");
}
break;
case '*':
if (j < undos) {
io->cb_printf ("f undo_%d @ 0x%"PFMT64x"\n", idx, addr);
} else if (j == undos && j != 0 && redos != 0) {
io->cb_printf ("# Current undo/redo position.\n");
} else if (j != undos) {
io->cb_printf ("f redo_%d @ 0x%"PFMT64x"\n", idx, addr);
}
}
j++;
}
switch (mode) {
case '=':
io->cb_printf ("\n");
break;
case 'j':
io->cb_printf ("]\n");
break;
}
}
/* undo writez */