mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Add search options for string encoding and endianness (#1490)
Added search options for string encoding (UTF-8, UTF-16, UTF-32) and endianness (Little, Big) in the hex editor. This enhancement allows users to customize the search process based on different string encodings and byte orders. Affected files: - `plugins/builtin/romfs/lang/de_DE.json` - `plugins/builtin/romfs/lang/en_US.json` - `plugins/builtin/romfs/lang/es_ES.json` - `plugins/builtin/romfs/lang/it_IT.json` - `plugins/builtin/romfs/lang/ja_JP.json` - `plugins/builtin/romfs/lang/ko_KR.json` - `plugins/builtin/romfs/lang/pt_BR.json` - `plugins/builtin/romfs/lang/zh_CN.json` - `plugins/builtin/romfs/lang/zh_TW.json` - `plugins/builtin/source/content/views/view_hex_editor.cpp` Resolves: #1325 --------- Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "content/views/view_hex_editor.hpp"
|
||||
#include "hex/api/task_manager.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
class PopupFind : public ViewHexEditor::Popup {
|
||||
public:
|
||||
explicit PopupFind(ViewHexEditor *editor) noexcept;
|
||||
~PopupFind() override;
|
||||
void draw(ViewHexEditor *editor) override;
|
||||
|
||||
private:
|
||||
void drawSearchDirectionButtons();
|
||||
void drawTabContents();
|
||||
|
||||
std::optional<Region> findByteSequence(const std::vector<u8> &sequence);
|
||||
|
||||
std::string m_inputString;
|
||||
std::vector<u8> m_searchByteSequence;
|
||||
std::optional<Region> m_foundRegion = std::nullopt;
|
||||
|
||||
bool m_requestFocus = true;
|
||||
std::atomic<bool> m_requestSearch = false;
|
||||
std::atomic<bool> m_searchBackwards = false;
|
||||
std::atomic<bool> m_reachedEnd = false;
|
||||
|
||||
enum class Encoding {
|
||||
UTF8,
|
||||
UTF16,
|
||||
UTF32
|
||||
};
|
||||
|
||||
enum class Endianness {
|
||||
Little,
|
||||
Big
|
||||
};
|
||||
|
||||
enum class SearchMode : bool {
|
||||
ByteSequence,
|
||||
String
|
||||
};
|
||||
|
||||
std::atomic<Encoding> m_stringEncoding = Encoding::UTF8;
|
||||
std::atomic<Endianness> m_stringEndianness = Endianness::Little;
|
||||
std::atomic<SearchMode> m_searchMode = SearchMode::ByteSequence;
|
||||
|
||||
TaskHolder m_searchTask;
|
||||
|
||||
void processInputString();
|
||||
};
|
||||
|
||||
} // namespace hex::plugin::builtin
|
||||
Reference in New Issue
Block a user