impr: Make inserting bytes at the start of the file with insert mode work better

This commit is contained in:
WerWolv
2024-12-23 01:33:52 +01:00
parent 1c3dfc9b2f
commit f931beb49a
3 changed files with 6 additions and 4 deletions

View File

@@ -95,7 +95,7 @@ namespace hex::ui {
private:
enum class CellType : u8 { None, Hex, ASCII };
void drawCell(u64 address, const u8 *data, size_t size, bool hovered, CellType cellType);
void drawCell(u64 address, u8 *data, size_t size, bool hovered, CellType cellType);
void drawSeparatorLine(u64 address, bool drawVerticalConnector);
void drawSelectionFrame(u32 x, u32 y, Region selection, u64 byteAddress, u16 bytesPerCell, const ImVec2 &cellPos, const ImVec2 &cellSize, const ImColor &backgroundColor) const;
void drawEditor(const ImVec2 &size);

View File

@@ -281,7 +281,7 @@ namespace hex::ui {
void HexEditor::drawCell(u64 address, const u8 *data, size_t size, bool hovered, CellType cellType) {
void HexEditor::drawCell(u64 address, u8 *data, size_t size, bool hovered, CellType cellType) {
static DataVisualizerAscii asciiVisualizer;
if (m_shouldUpdateEditingValue && address == m_editingAddress) {
@@ -320,6 +320,7 @@ namespace hex::ui {
std::memcpy(m_editingBytes.data(), data, size);
else if (m_mode == Mode::Insert) {
std::memset(m_editingBytes.data(), 0x00, size);
std::memset(data, 0x00, size);
m_provider->insert(address, size);
}