Skip to content

Instantly share code, notes, and snippets.

@xenogenesi
Last active December 14, 2019 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xenogenesi/eb2d8a8344bd1ed138b761cfd7236fdf to your computer and use it in GitHub Desktop.
Save xenogenesi/eb2d8a8344bd1ed138b761cfd7236fdf to your computer and use it in GitHub Desktop.
diff --git a/src/HexEditor.cpp b/src/HexEditor.cpp
index 365d904..e2bfb24 100644
--- a/src/HexEditor.cpp
+++ b/src/HexEditor.cpp
@@ -922,6 +922,14 @@ void HexEditor::OnKeyboardInput( wxKeyEvent& event ) {
*/
break;
+ case (0x52):
+ if( event.ControlDown() ){
+ DoLoadTAGS();
+ wxUpdateUIEvent eventx( TAG_CHANGE_EVENT );
+ GetEventHandler()->ProcessEvent( eventx );
+ }
+ break;
+
//Not working?
//case (WXK_CONTROL_T):
case (0x54):
@@ -1458,6 +1466,17 @@ void HexEditor::GotoDialog( void ) {
mygoto->Destroy();
}
+bool HexEditor::DoLoadTAGS( void ) {
+ wxFileName myfilename = GetFileName();
+ std::cout << "myfilename: " << myfilename.GetFullPath() << std::endl;
+ MainTagArray.Empty();
+ bool result = LoadTAGS( myfilename.GetFullPath().Append(wxT(".tags")) ); //Load tags to wxHexEditorCtrl
+ if (!result)
+ wxMessageBox( wxString(_( "TAGS cannot be reloaded")),_("Error"), wxOK|wxICON_ERROR, this );
+
+ return result;
+}
+
bool HexEditor::InsertBytes( void ) {
#ifdef _DEBUG_
std::cout << "Insert Bytes!" << std::endl;
diff --git a/src/HexEditor.h b/src/HexEditor.h
index abcd283..41fc2bb 100644
--- a/src/HexEditor.h
+++ b/src/HexEditor.h
@@ -140,6 +140,7 @@ class HexEditor: public HexEditorCtrl
void ReplaceDialog( void );
void CopyAsDialog( void );
void GotoDialog( void );
+ bool DoLoadTAGS( void );
void UpdateCursorLocation( bool force=false );
void ConnectScroll(HexEditor* connection);
diff --git a/src/HexEditorFrame.cpp b/src/HexEditorFrame.cpp
index 6370b76..6ec7e15 100644
--- a/src/HexEditorFrame.cpp
+++ b/src/HexEditorFrame.cpp
@@ -421,6 +421,7 @@ void HexEditorFrame::ActionEnabler( void ){
mbar->Enable(idExportTAGs, true );
mbar->Enable(idImportTAGs, true );
+ mbar->Enable(idReloadTAGs, true );
MyInterpreter->Enable();
Toolbar->Refresh();
}
@@ -433,6 +434,7 @@ void HexEditorFrame::ActionDisabler( void ){
}
mbar->Enable(idExportTAGs, false );
mbar->Enable(idImportTAGs, false );
+ mbar->Enable(idReloadTAGs, false );
MyInterpreter->Clear();
MyInterpreter->Disable();
MyDisassemblerPanel->Clear();
@@ -603,6 +605,10 @@ void HexEditorFrame::OnMenuEvent( wxCommandEvent& event ){
}
break;
}
+ case idReloadTAGs:
+ MyHexEditor->DoLoadTAGS();
+ MyTagPanel->Set( MyHexEditor->MainTagArray );
+ break;
case idImportTAGs: {
wxFileDialog filediag(this,_("Choose a file for import TAGs"),
wxEmptyString,
diff --git a/src/HexEditorGui.cpp b/src/HexEditorGui.cpp
index 112c4e0..988e70e 100644
--- a/src/HexEditorGui.cpp
+++ b/src/HexEditorGui.cpp
@@ -58,7 +58,11 @@ HexEditorGui::HexEditorGui( wxWindow* parent, wxWindowID id, const wxString& tit
menuFileClose->Enable( false );
fileMenu->AppendSeparator();
-
+
+ wxMenuItem* menuFileReloadTAG;
+ menuFileReloadTAG = new wxMenuItem( fileMenu, idReloadTAGs, wxString( _("Reload &TAGs") + wxT('\t') + _("CTRL+R")) , _("Reload TAGs"), wxITEM_NORMAL );
+ fileMenu->Append( menuFileReloadTAG );
+
wxMenuItem* menuFileImportTAG;
menuFileImportTAG = new wxMenuItem( fileMenu, idImportTAGs, wxString( _("Import TAGs") ) , wxEmptyString, wxITEM_NORMAL );
fileMenu->Append( menuFileImportTAG );
@@ -327,6 +331,7 @@ HexEditorGui::HexEditorGui( wxWindow* parent, wxWindowID id, const wxString& tit
this->Connect( menuFileSave->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Connect( menuFileSaveAs->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Connect( menuFileClose->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
+ this->Connect( menuFileReloadTAG->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Connect( menuFileImportTAG->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Connect( menuFileExportTAG->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Connect( menuFileQuit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
@@ -393,6 +398,7 @@ HexEditorGui::~HexEditorGui()
this->Disconnect( wxID_SAVE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Disconnect( wxID_SAVEAS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Disconnect( idClose, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
+ this->Disconnect( idReloadTAGs, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Disconnect( idImportTAGs, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Disconnect( idExportTAGs, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
this->Disconnect( wxID_QUIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( HexEditorGui::OnMenuEvent ) );
diff --git a/src/HexEditorGui.h b/src/HexEditorGui.h
index e0073fe..61d4d12 100644
--- a/src/HexEditorGui.h
+++ b/src/HexEditorGui.h
@@ -81,6 +81,7 @@
#define idBugReport 1033
#define ID_CHK_UNSIGNED 1034
#define ID_CHK_BIGENDIAN 1035
+#define idReloadTAGs 1036
///////////////////////////////////////////////////////////////////////////////
/// Class HexEditorGui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment