Added tools window
This commit is contained in:
parent
5b2dc51c07
commit
2526eda0db
@ -27,6 +27,7 @@ add_executable(ImHex
|
||||
source/views/view_hashes.cpp
|
||||
source/views/view_information.cpp
|
||||
source/views/view_help.cpp
|
||||
source/views/view_tools.cpp
|
||||
|
||||
libs/glad/source/glad.c
|
||||
|
||||
|
@ -6,7 +6,8 @@
|
||||
namespace hex {
|
||||
|
||||
enum class Events {
|
||||
DataChanged
|
||||
DataChanged,
|
||||
PatternChanged
|
||||
};
|
||||
|
||||
struct EventHandler {
|
||||
|
32
include/views/view_tools.hpp
Normal file
32
include/views/view_tools.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex.hpp>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "views/view.hpp"
|
||||
#include "views/pattern_data.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
#include <cstdio>
|
||||
|
||||
namespace hex {
|
||||
|
||||
namespace prv { class Provider; }
|
||||
|
||||
class ViewTools : public View {
|
||||
public:
|
||||
ViewTools();
|
||||
~ViewTools() override;
|
||||
|
||||
void createView() override;
|
||||
void createMenu() override;
|
||||
|
||||
private:
|
||||
bool m_windowOpen = true;
|
||||
|
||||
char *m_mangledBuffer = nullptr;
|
||||
char *m_demangledName = nullptr;
|
||||
};
|
||||
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
#include "views/view_hashes.hpp"
|
||||
#include "views/view_information.hpp"
|
||||
#include "views/view_help.hpp"
|
||||
#include "views/view_tools.hpp"
|
||||
|
||||
#include "providers/provider.hpp"
|
||||
|
||||
@ -26,6 +27,7 @@ int main() {
|
||||
window.addView<hex::ViewHashes>(dataProvider);
|
||||
window.addView<hex::ViewInformation>(dataProvider);
|
||||
window.addView<hex::ViewHelp>();
|
||||
window.addView<hex::ViewTools>();
|
||||
|
||||
window.loop();
|
||||
|
||||
|
@ -156,7 +156,7 @@ namespace hex {
|
||||
if (ImGui::MenuItem("About", ""))
|
||||
this->m_aboutWindowOpen = true;
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Pattern Language Cheat Sheet", ""))
|
||||
if (ImGui::MenuItem("Cheat Sheet", ""))
|
||||
this->m_patternHelpWindowOpen = true;
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
61
source/views/view_tools.cpp
Normal file
61
source/views/view_tools.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "views/view_tools.hpp"
|
||||
|
||||
#include <cxxabi.h>
|
||||
#include <cstring>
|
||||
|
||||
namespace hex {
|
||||
|
||||
ViewTools::ViewTools() {
|
||||
this->m_mangledBuffer = new char[0xFF'FFFF];
|
||||
this->m_demangledName = static_cast<char*>(malloc(8));
|
||||
|
||||
std::memset(this->m_mangledBuffer, 0xFF'FFFF, 0x00);
|
||||
strcpy(this->m_demangledName, "< ??? >");
|
||||
}
|
||||
|
||||
ViewTools::~ViewTools() {
|
||||
delete[] this->m_mangledBuffer;
|
||||
free(this->m_demangledName);
|
||||
}
|
||||
|
||||
void ViewTools::createView() {
|
||||
if (!this->m_windowOpen)
|
||||
return;
|
||||
|
||||
if (ImGui::Begin("Tools", &this->m_windowOpen)) {
|
||||
|
||||
ImGui::Text("Itanium demangler");
|
||||
ImGui::Separator();
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::InputText("Mangled name", this->m_mangledBuffer, 0xFF'FFFF)) {
|
||||
size_t length = 0;
|
||||
int status = 0;
|
||||
|
||||
if (this->m_demangledName != nullptr)
|
||||
free(this->m_demangledName);
|
||||
|
||||
this->m_demangledName = abi::__cxa_demangle(this->m_mangledBuffer, nullptr, &length, &status);
|
||||
|
||||
if (status != 0) {
|
||||
this->m_demangledName = static_cast<char*>(malloc(8));
|
||||
strcpy(this->m_demangledName, "< ??? >");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::InputText("Demangled name", this->m_demangledName, strlen(this->m_demangledName), ImGuiInputTextFlags_ReadOnly);
|
||||
|
||||
|
||||
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewTools::createMenu() {
|
||||
if (ImGui::BeginMenu("View")) {
|
||||
ImGui::MenuItem("Tools View", "", &this->m_windowOpen);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user