Don't show pattern editor when no file is loaded
This commit is contained in:
parent
295b32b890
commit
8aa4402f88
@ -3,12 +3,15 @@
|
|||||||
#include "parser/ast_node.hpp"
|
#include "parser/ast_node.hpp"
|
||||||
#include "parser/parser.hpp"
|
#include "parser/parser.hpp"
|
||||||
#include "parser/lexer.hpp"
|
#include "parser/lexer.hpp"
|
||||||
|
|
||||||
#include "views/view.hpp"
|
#include "views/view.hpp"
|
||||||
|
#include "views/highlight.hpp"
|
||||||
|
|
||||||
|
#include "providers/provider.hpp"
|
||||||
|
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "views/highlight.hpp"
|
|
||||||
|
|
||||||
#include "imfilebrowser.h"
|
#include "imfilebrowser.h"
|
||||||
|
|
||||||
@ -16,7 +19,7 @@ namespace hex {
|
|||||||
|
|
||||||
class ViewPattern : public View {
|
class ViewPattern : public View {
|
||||||
public:
|
public:
|
||||||
explicit ViewPattern(std::vector<Highlight> &highlights);
|
explicit ViewPattern(prv::Provider* &dataProvider, std::vector<Highlight> &highlights);
|
||||||
~ViewPattern() override;
|
~ViewPattern() override;
|
||||||
|
|
||||||
void createMenu() override;
|
void createMenu() override;
|
||||||
@ -26,6 +29,7 @@ namespace hex {
|
|||||||
char *m_buffer;
|
char *m_buffer;
|
||||||
|
|
||||||
std::vector<Highlight> &m_highlights;
|
std::vector<Highlight> &m_highlights;
|
||||||
|
prv::Provider* &m_dataProvider;
|
||||||
bool m_windowOpen = true;
|
bool m_windowOpen = true;
|
||||||
|
|
||||||
ImGui::FileBrowser m_fileBrowser;
|
ImGui::FileBrowser m_fileBrowser;
|
||||||
|
@ -20,7 +20,7 @@ int main() {
|
|||||||
|
|
||||||
// Create views
|
// Create views
|
||||||
window.addView<hex::ViewHexEditor>(dataProvider, highlights);
|
window.addView<hex::ViewHexEditor>(dataProvider, highlights);
|
||||||
window.addView<hex::ViewPattern>(highlights);
|
window.addView<hex::ViewPattern>(dataProvider, highlights);
|
||||||
window.addView<hex::ViewPatternData>(dataProvider, highlights);
|
window.addView<hex::ViewPatternData>(dataProvider, highlights);
|
||||||
window.addView<hex::ViewHashes>(dataProvider);
|
window.addView<hex::ViewHashes>(dataProvider);
|
||||||
window.addView<hex::ViewInformation>(dataProvider);
|
window.addView<hex::ViewInformation>(dataProvider);
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
ViewPattern::ViewPattern(std::vector<Highlight> &highlights) : View(), m_highlights(highlights) {
|
ViewPattern::ViewPattern(prv::Provider* &dataProvider, std::vector<Highlight> &highlights)
|
||||||
|
: View(), m_dataProvider(dataProvider), m_highlights(highlights) {
|
||||||
this->m_buffer = new char[0xFFFFFF];
|
this->m_buffer = new char[0xFFFFFF];
|
||||||
std::memset(this->m_buffer, 0x00, 0xFFFFFF);
|
std::memset(this->m_buffer, 0x00, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
@ -34,22 +35,25 @@ namespace hex {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (ImGui::Begin("Pattern", &this->m_windowOpen, ImGuiWindowFlags_None)) {
|
if (ImGui::Begin("Pattern", &this->m_windowOpen, ImGuiWindowFlags_None)) {
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
if (this->m_dataProvider != nullptr && this->m_dataProvider->isReadable()) {
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||||
|
|
||||||
auto size = ImGui::GetWindowSize();
|
auto size = ImGui::GetWindowSize();
|
||||||
size.y -= 50;
|
size.y -= 50;
|
||||||
ImGui::InputTextMultiline("Pattern", this->m_buffer, 0xFFFF, size, ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_CallbackEdit,
|
ImGui::InputTextMultiline("Pattern", this->m_buffer, 0xFFFF, size,
|
||||||
[](ImGuiInputTextCallbackData* data) -> int {
|
ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_CallbackEdit,
|
||||||
auto _this = static_cast<ViewPattern*>(data->UserData);
|
[](ImGuiInputTextCallbackData *data) -> int {
|
||||||
|
auto _this = static_cast<ViewPattern *>(data->UserData);
|
||||||
|
|
||||||
_this->parsePattern(data->Buf);
|
_this->parsePattern(data->Buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}, this
|
}, this
|
||||||
);
|
);
|
||||||
|
|
||||||
ImGui::PopStyleVar(2);
|
ImGui::PopStyleVar(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user