diff options
| author | Josh F <josh@vector35.com> | 2022-07-04 19:29:48 -0400 |
|---|---|---|
| committer | Josh F <josh@vector35.com> | 2022-07-04 19:29:48 -0400 |
| commit | 9d35fc4b596df313b99d0c4924f54228f5910f32 (patch) | |
| tree | a6399409f81cb3b9404a8fa078174bdbee2a42f2 | |
| parent | 1c436100642605add5f746ee1c31590f8328b270 (diff) | |
Add CanUndo,CanRedo,GetRedoEntries
| -rw-r--r-- | binaryninjaapi.h | 5 | ||||
| -rw-r--r-- | binaryninjacore.h | 4 | ||||
| -rw-r--r-- | binaryview.cpp | 12 | ||||
| -rw-r--r-- | filemetadata.cpp | 38 |
4 files changed, 59 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 8433b1d1..8c3c8a1a 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1071,11 +1071,14 @@ namespace BinaryNinja { void BeginUndoActions(); void CommitUndoActions(); + bool CanUndo(); bool Undo(); + bool CanRedo(); bool Redo(); std::vector<Ref<User>> GetUsers(); std::vector<UndoEntry> GetUndoEntries(); + std::vector<UndoEntry> GetRedoEntries(); void ClearUndoEntries(); bool OpenProject(); @@ -1870,7 +1873,9 @@ namespace BinaryNinja { void AddUndoAction(UndoAction* action); void CommitUndoActions(); + bool CanUndo(); bool Undo(); + bool CanRedo(); bool Redo(); std::string GetCurrentView(); diff --git a/binaryninjacore.h b/binaryninjacore.h index 4788bc90..acbcb0e3 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3150,10 +3150,14 @@ extern "C" BINARYNINJACOREAPI void BNBeginUndoActions(BNFileMetadata* file); BINARYNINJACOREAPI void BNCommitUndoActions(BNFileMetadata* file); + + BINARYNINJACOREAPI bool BNCanUndo(BNFileMetadata* file); BINARYNINJACOREAPI bool BNUndo(BNFileMetadata* file); + BINARYNINJACOREAPI bool BNCanRedo(BNFileMetadata* file); BINARYNINJACOREAPI bool BNRedo(BNFileMetadata* file); BINARYNINJACOREAPI BNUndoEntry* BNGetUndoEntries(BNFileMetadata* file, size_t* count); + BINARYNINJACOREAPI BNUndoEntry* BNGetRedoEntries(BNFileMetadata* file, size_t* count); BINARYNINJACOREAPI void BNFreeUndoEntries(BNUndoEntry* entries, size_t count); BINARYNINJACOREAPI void BNClearUndoEntries(BNFileMetadata* file); diff --git a/binaryview.cpp b/binaryview.cpp index 24058619..330a1412 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -1195,12 +1195,24 @@ void BinaryView::CommitUndoActions() } +bool BinaryView::CanUndo() +{ + return m_file->CanUndo(); +} + + bool BinaryView::Undo() { return m_file->Undo(); } +bool BinaryView::CanRedo() +{ + return m_file->CanRedo(); +} + + bool BinaryView::Redo() { return m_file->Redo(); diff --git a/filemetadata.cpp b/filemetadata.cpp index cdcee292..9d9b2a3a 100644 --- a/filemetadata.cpp +++ b/filemetadata.cpp @@ -317,12 +317,24 @@ void FileMetadata::CommitUndoActions() } +bool FileMetadata::CanUndo() +{ + return BNCanUndo(m_object); +} + + bool FileMetadata::Undo() { return BNUndo(m_object); } +bool FileMetadata::CanRedo() +{ + return BNCanRedo(m_object); +} + + bool FileMetadata::Redo() { return BNRedo(m_object); @@ -369,6 +381,32 @@ vector<UndoEntry> FileMetadata::GetUndoEntries() } +vector<UndoEntry> FileMetadata::GetRedoEntries() +{ + size_t numEntries; + BNUndoEntry* entries = BNGetRedoEntries(m_object, &numEntries); + + vector<UndoEntry> result; + result.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + UndoEntry temp; + temp.timestamp = entries[i].timestamp; + temp.hash = entries[i].hash; + temp.user = new User(BNNewUserReference(entries[i].user)); + size_t actionCount = entries[i].actionCount; + for (size_t actionIndex = 0; actionIndex < actionCount; actionIndex++) + { + temp.actions.emplace_back(entries[i].actions[actionIndex]); + } + result.push_back(temp); + } + + // BNFreeUndoEntries(entries, count); + return result; +} + + void FileMetadata::ClearUndoEntries() { BNClearUndoEntries(m_object); |
