From e3ae076fe472e96e037f2997d9b8c6f29c4f4fce Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Thu, 15 Feb 2024 15:58:14 -0500 Subject: Add UI callback for On(Data)ViewReplaced for rebase --- python/examples/ui_notifications.py | 6 ++++++ ui/uicontext.h | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/python/examples/ui_notifications.py b/python/examples/ui_notifications.py index 94959217..c6809a32 100644 --- a/python/examples/ui_notifications.py +++ b/python/examples/ui_notifications.py @@ -66,6 +66,12 @@ class UINotification(UIContextNotification): def OnAfterCloseFile(self, context, file, frame): print(f"py OnAfterCloseFile {file.getFilename()} {frame.getShortFileName()}") + def OnViewReplaced(self, context, file, oldFrame, newFrame): + print(f"py OnViewReplaced {file.getFilename()} {oldFrame.getShortFileName()} -> {newFrame.getShortFileName()}") + + def OnDataViewReplaced(self, context, file, oldData, newData): + print(f"py OnDataViewReplaced {file.getFilename()} {oldData.file.filename} -> {newData.file.filename}") + def OnViewChange(self, context, frame, type): if frame: print(f"py OnViewChange {frame.getShortFileName()} / {type}") diff --git a/ui/uicontext.h b/ui/uicontext.h index 9d65ac90..db013320 100644 --- a/ui/uicontext.h +++ b/ui/uicontext.h @@ -191,7 +191,39 @@ class BINARYNINJAUIAPI UIContextNotification (void)file; (void)frame; } - + /*! + Callback after a ViewFrame is replaced in an open file (e.g. on Rebase or Sync) + \param context Context which replaced the view + \param file Context with the file and ui views + \param oldFrame Old ViewFrame being deleted + \param newFrame New ViewFrame being created + */ + virtual void OnViewReplaced( + UIContext* context, + FileContext* file, + ViewFrame* oldFrame, + ViewFrame* newFrame + ) + { + (void)context; + (void)file; + (void)oldFrame; + (void)newFrame; + } + /*! + Callback after a BinaryView is replaced in an open file (e.g. on Rebase) + \param context Context which replaced the view + \param file Context with the file and ui views + \param oldData Old BinaryView with that name + \param newData New BinaryView with that name + */ + virtual void OnDataViewReplaced(UIContext* context, FileContext* file, BinaryViewRef oldData, BinaryViewRef newData) + { + (void)context; + (void)file; + (void)oldData; + (void)newData; + } /*! Callback when the ui changes views \param context Context changing views @@ -486,6 +518,8 @@ public: void NotifyOnAfterSaveFile(FileContext* file, ViewFrame* frame); bool NotifyOnBeforeCloseFile(FileContext* file, ViewFrame* frame); void NotifyOnAfterCloseFile(FileContext* file, ViewFrame* frame); + void NotifyOnViewReplaced(FileContext* file, ViewFrame* oldFrame, ViewFrame* newFrame); + void NotifyOnDataViewReplaced(FileContext* file, BinaryViewRef oldView, BinaryViewRef newView); void NotifyOnViewChange(ViewFrame* frame, const QString& type); void NotifyOnAddressChange(ViewFrame* frame, View* view, const ViewLocation& location); -- cgit v1.3.1