feat: Replace useless constants view with a constant search option in the Find view

This commit is contained in:
WerWolv
2025-12-02 23:02:44 +01:00
parent da0c1674a6
commit d4df465633
27 changed files with 218 additions and 291 deletions

View File

@@ -1,38 +0,0 @@
#pragma once
#include <hex/ui/view.hpp>
#include <string>
namespace hex::plugin::builtin {
enum class ConstantType
{
Int10,
Int16BigEndian,
Int16LittleEndian
};
struct Constant {
std::string name, description;
std::string category;
ConstantType type;
std::string value;
};
class ViewConstants : public View::Window {
public:
explicit ViewConstants();
~ViewConstants() override = default;
void drawContent() override;
private:
void reloadConstants();
std::vector<Constant> m_constants;
std::vector<size_t> m_filterIndices;
std::string m_filter;
};
}

View File

@@ -46,7 +46,8 @@ namespace hex::plugin::builtin {
Sequence,
Regex,
BinaryPattern,
Value
Value,
Constants
} mode = Mode::Strings;
enum class StringType : int { ASCII = 0, UTF8 = 1, UTF16LE = 2, UTF16BE = 3, ASCII_UTF16LE = 4, ASCII_UTF16BE = 5 };
@@ -100,6 +101,10 @@ namespace hex::plugin::builtin {
} type = Type::U8;
} value;
struct Constants {
u32 alignment = 1;
} constants;
} m_searchSettings, m_decodeSettings;
using OccurrenceTree = wolv::container::IntervalTree<Occurrence>;
@@ -120,6 +125,7 @@ namespace hex::plugin::builtin {
static std::vector<Occurrence> searchRegex(Task &task, prv::Provider *provider, Region searchRegion, const SearchSettings::Regex &settings);
static std::vector<Occurrence> searchBinaryPattern(Task &task, prv::Provider *provider, Region searchRegion, const SearchSettings::BinaryPattern &settings);
static std::vector<Occurrence> searchValue(Task &task, prv::Provider *provider, Region searchRegion, const SearchSettings::Value &settings);
static std::vector<Occurrence> searchConstants(Task &task, prv::Provider *provider, Region searchRegion, const SearchSettings::Constants &settings);
void drawContextMenu(Occurrence &target, const std::string &value);