feat: Greatly improved diff view

Fixes #631
This commit is contained in:
WerWolv
2023-02-15 17:01:36 +01:00
parent 07fd86fc9d
commit 3067ff08ec
6 changed files with 263 additions and 206 deletions

View File

@@ -4,11 +4,16 @@
#include <imgui.h>
#include <hex/ui/view.hpp>
#include <hex/api/task.hpp>
#include <array>
#include <string>
#include <vector>
#include "ui/hex_editor.hpp"
#include <IntervalTree.h>
namespace hex::plugin::builtin {
class ViewDiff : public View {
@@ -19,13 +24,33 @@ namespace hex::plugin::builtin {
void drawContent() override;
private:
void drawDiffLine(const std::array<int, 2> &providerIds, u64 row) const;
struct Column {
ui::HexEditor hexEditor;
int provider = -1;
i32 scrollLock = 0;
};
int m_providerA = -1, m_providerB = -1;
enum class DifferenceType : u8 {
Added,
Removed,
Modified
};
bool m_greyedOutZeros = true;
bool m_upperCaseHex = true;
u32 m_columnCount = 16;
struct Diff {
Region region;
DifferenceType type;
};
bool drawDiffColumn(Column &column, float height) const;
void drawProviderSelector(Column &column);
std::string getProviderName(Column &column) const;
private:
std::array<Column, 2> m_columns;
std::vector<Diff> m_diffs;
TaskHolder m_diffTask;
std::atomic<bool> m_analyzed = false;
};
}

View File

@@ -26,6 +26,7 @@ namespace hex::plugin::builtin::ui {
void draw(float height = ImGui::GetContentRegionAvail().y);
void setProvider(prv::Provider *provider) { this->m_provider = provider; }
void setUnknownDataCharacter(char character) { this->m_unknownDataCharacter = character; }
private:
enum class CellType { None, Hex, ASCII };
@@ -174,6 +175,7 @@ namespace hex::plugin::builtin::ui {
u16 m_bytesPerRow = 16;
ContentRegistry::HexEditor::DataVisualizer *m_currDataVisualizer;
u32 m_grayZeroHighlighter = 0;
char m_unknownDataCharacter = '?';
bool m_shouldJumpToSelection = false;
bool m_centerOnJump = false;