mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
feat: Finish up work on new pl section system
This commit is contained in:
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
Submodule lib/external/pattern_language updated: 2fc96aedca...a74070f38e
@@ -106,7 +106,7 @@ namespace hex {
|
||||
EVENT_DEF(EventDataChanged);
|
||||
EVENT_DEF(EventHighlightingChanged);
|
||||
EVENT_DEF(EventWindowClosing, GLFWwindow *);
|
||||
EVENT_DEF(EventRegionSelected, Region);
|
||||
EVENT_DEF(EventRegionSelected, ImHexApi::HexEditor::ProviderRegion);
|
||||
EVENT_DEF(EventSettingsChanged);
|
||||
EVENT_DEF(EventAbnormalTermination, int);
|
||||
EVENT_DEF(EventOSThemeChanged);
|
||||
@@ -138,6 +138,4 @@ namespace hex {
|
||||
EVENT_DEF(RequestShowYesNoQuestionPopup, std::string, std::function<void()>, std::function<void()>);
|
||||
EVENT_DEF(RequestShowFileChooserPopup, std::vector<std::fs::path>, std::vector<nfdfilteritem_t>, std::function<void(std::fs::path)>);
|
||||
|
||||
EVENT_DEF(QuerySelection, std::optional<Region> &);
|
||||
|
||||
}
|
||||
@@ -64,6 +64,14 @@ namespace hex {
|
||||
color_t m_color = 0x00;
|
||||
};
|
||||
|
||||
struct ProviderRegion : public Region {
|
||||
prv::Provider *provider;
|
||||
|
||||
[[nodiscard]] prv::Provider *getProvider() const { return this->provider; }
|
||||
|
||||
[[nodiscard]] Region getRegion() const { return { this->address, this->size }; }
|
||||
};
|
||||
|
||||
namespace impl {
|
||||
|
||||
using HighlightingFunction = std::function<std::optional<color_t>(u64, const u8*, size_t, bool)>;
|
||||
@@ -75,6 +83,7 @@ namespace hex {
|
||||
std::map<u32, Tooltip> &getTooltips();
|
||||
std::map<u32, TooltipFunction> &getTooltipFunctions();
|
||||
|
||||
void setCurrentSelection(ProviderRegion region);
|
||||
}
|
||||
|
||||
u32 addBackgroundHighlight(const Region ®ion, color_t color);
|
||||
@@ -96,9 +105,10 @@ namespace hex {
|
||||
void removeForegroundHighlightingProvider(u32 id);
|
||||
|
||||
bool isSelectionValid();
|
||||
std::optional<Region> getSelection();
|
||||
void setSelection(const Region ®ion);
|
||||
void setSelection(u64 address, size_t size);
|
||||
std::optional<ProviderRegion> getSelection();
|
||||
void setSelection(const Region ®ion, prv::Provider *provider = nullptr);
|
||||
void setSelection(const ProviderRegion ®ion);
|
||||
void setSelection(u64 address, size_t size, prv::Provider *provider = nullptr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,11 @@ namespace hex {
|
||||
return s_tooltipFunctions;
|
||||
}
|
||||
|
||||
static std::optional<ProviderRegion> s_currentSelection;
|
||||
void setCurrentSelection(std::optional<ProviderRegion> region) {
|
||||
s_currentSelection = region;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
u32 addBackgroundHighlight(const Region ®ion, color_t color) {
|
||||
@@ -181,19 +186,20 @@ namespace hex {
|
||||
return getSelection().has_value();
|
||||
}
|
||||
|
||||
std::optional<Region> getSelection() {
|
||||
std::optional<Region> selection;
|
||||
EventManager::post<QuerySelection>(selection);
|
||||
|
||||
return selection;
|
||||
std::optional<ProviderRegion> getSelection() {
|
||||
return impl::s_currentSelection;
|
||||
}
|
||||
|
||||
void setSelection(const Region ®ion) {
|
||||
void setSelection(const Region ®ion, prv::Provider *provider) {
|
||||
setSelection(ProviderRegion { region, provider == nullptr ? Provider::get() : provider });
|
||||
}
|
||||
|
||||
void setSelection(const ProviderRegion ®ion) {
|
||||
EventManager::post<RequestSelectionChange>(region);
|
||||
}
|
||||
|
||||
void setSelection(u64 address, size_t size) {
|
||||
setSelection({ address, size });
|
||||
void setSelection(u64 address, size_t size, prv::Provider *provider) {
|
||||
setSelection({ { address, size }, provider == nullptr ? Provider::get() : provider });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user