1
0
mirror of synced 2024-11-24 15:50:16 +01:00

impr: Display encoding types in header of hex editor

Closes #1186
This commit is contained in:
WerWolv 2023-07-11 00:04:26 +02:00
parent 511ef3ef2b
commit 8524e93445
3 changed files with 24 additions and 2 deletions

View File

@ -37,11 +37,14 @@ namespace hex {
[[nodiscard]] const std::string& getTableContent() const { return this->m_tableContent; }
[[nodiscard]] const std::string& getName() const { return this->m_name; }
private:
void parse(const std::string &content);
bool m_valid = false;
std::string m_name;
std::string m_tableContent;
std::unique_ptr<std::map<size_t, std::map<std::vector<u8>, std::string>>> m_mapping;
size_t m_longestSequence = 0;

View File

@ -16,6 +16,7 @@ namespace hex {
this->m_tableContent = other.m_tableContent;
this->m_longestSequence = other.m_longestSequence;
this->m_valid = other.m_valid;
this->m_name = other.m_name;
}
EncodingFile::EncodingFile(EncodingFile &&other) {
@ -23,6 +24,7 @@ namespace hex {
this->m_tableContent = std::move(other.m_tableContent);
this->m_longestSequence = other.m_longestSequence;
this->m_valid = other.m_valid;
this->m_name = std::move(other.m_name);
}
EncodingFile::EncodingFile(Type type, const std::fs::path &path) : EncodingFile() {
@ -35,6 +37,14 @@ namespace hex {
return;
}
{
this->m_name = path.stem().string();
this->m_name = wolv::util::replaceStrings(this->m_name, "_", " ");
if (!this->m_name.empty())
this->m_name[0] = std::toupper(this->m_name[0]);
}
this->m_valid = true;
}
@ -47,6 +57,7 @@ namespace hex {
return;
}
this->m_name = "Unknown";
this->m_valid = true;
}
@ -56,6 +67,7 @@ namespace hex {
this->m_tableContent = other.m_tableContent;
this->m_longestSequence = other.m_longestSequence;
this->m_valid = other.m_valid;
this->m_name = other.m_name;
return *this;
}
@ -65,6 +77,7 @@ namespace hex {
this->m_tableContent = std::move(other.m_tableContent);
this->m_longestSequence = other.m_longestSequence;
this->m_valid = other.m_valid;
this->m_name = std::move(other.m_name);
return *this;
}

View File

@ -285,11 +285,17 @@ namespace hex::plugin::builtin::ui {
// ASCII column
ImGui::TableSetupColumn("");
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, this->m_showAscii ? (CharacterSize.x + this->m_characterCellPadding * 1_scaled) * this->m_bytesPerRow : 0);
ImGui::TableSetupColumn("hex.builtin.common.encoding.ascii"_lang, ImGuiTableColumnFlags_WidthFixed, this->m_showAscii ? (CharacterSize.x + this->m_characterCellPadding * 1_scaled) * this->m_bytesPerRow : 0);
// Custom encoding column
ImGui::TableSetupColumn("");
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch);
{
if (this->m_currCustomEncoding.has_value()) {
ImGui::TableSetupColumn(this->m_currCustomEncoding->getName().c_str(), ImGuiTableColumnFlags_WidthStretch);
} else {
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch);
}
}
ImGui::TableNextRow();
for (i32 i = 0; i < ImGui::TableGetColumnCount(); i++) {