diff --git a/libr/core/cmd_seek.c b/libr/core/cmd_seek.c index 62307078aa..00d1cbe59a 100644 --- a/libr/core/cmd_seek.c +++ b/libr/core/cmd_seek.c @@ -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') { diff --git a/libr/include/r_io.h b/libr/include/r_io.h index d2c5e03098..87e571ec49 100644 --- a/libr/include/r_io.h +++ b/libr/include/r_io.h @@ -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); diff --git a/libr/io/undo.c b/libr/io/undo.c index 5a06ee80df..4b3dd6308d 100644 --- a/libr/io/undo.c +++ b/libr/io/undo.c @@ -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+1cb_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 */