Skip to content

Commit

Permalink
[WIP] Configurable highlight colours
Browse files Browse the repository at this point in the history
  • Loading branch information
solemnwarning committed Apr 20, 2024
1 parent 0ac09d8 commit e9e4175
Show file tree
Hide file tree
Showing 16 changed files with 1,473 additions and 70 deletions.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -378,6 +378,7 @@ APP_OBJS := \
src/FileWriter.$(BUILD_TYPE).o \
src/FillRangeDialog.$(BUILD_TYPE).o \
src/FixedSizeValueRegion.$(BUILD_TYPE).o \
src/HighlightColourMap.$(BUILD_TYPE).o \
src/HSVColour.$(BUILD_TYPE).o \
src/IntelHexExport.$(BUILD_TYPE).o \
src/IntelHexImport.$(BUILD_TYPE).o \
Expand All @@ -395,6 +396,7 @@ APP_OBJS := \
src/RangeProcessor.$(BUILD_TYPE).o \
src/search.$(BUILD_TYPE).o \
src/SettingsDialog.$(BUILD_TYPE).o \
src/SettingsDialogHighlights.$(BUILD_TYPE).o \
src/StringPanel.$(BUILD_TYPE).o \
src/textentrydialog.$(BUILD_TYPE).o \
src/Tab.$(BUILD_TYPE).o \
Expand Down Expand Up @@ -471,6 +473,7 @@ TEST_OBJS := \
src/FileWriter.$(BUILD_TYPE).o \
src/FillRangeDialog.$(BUILD_TYPE).o \
src/FixedSizeValueRegion.$(BUILD_TYPE).o \
src/HighlightColourMap.$(BUILD_TYPE).o \
src/HSVColour.$(BUILD_TYPE).o \
src/IntelHexExport.$(BUILD_TYPE).o \
src/IntelHexImport.$(BUILD_TYPE).o \
Expand All @@ -485,6 +488,7 @@ TEST_OBJS := \
src/RangeProcessor.$(BUILD_TYPE).o \
src/search.$(BUILD_TYPE).o \
src/SettingsDialog.$(BUILD_TYPE).o \
src/SettingsDialogHighlights.$(BUILD_TYPE).o \
src/StringPanel.$(BUILD_TYPE).o \
src/Tab.$(BUILD_TYPE).o \
src/textentrydialog.$(BUILD_TYPE).o \
Expand Down Expand Up @@ -515,6 +519,7 @@ TEST_OBJS := \
tests/endian_conv.o \
tests/FastRectangleFiller.o \
tests/FileWriter.o \
tests/HighlightColourMap.o \
tests/HSVColour.o \
tests/IntelHexExport.o \
tests/IntelHexImport.o \
Expand Down
35 changes: 33 additions & 2 deletions src/AppSettings.cpp
@@ -1,5 +1,5 @@
/* Reverse Engineer's Hex Editor
* Copyright (C) 2022 Daniel Collins <solemnwarning@solemnwarning.net>
* Copyright (C) 2022-2024 Daniel Collins <solemnwarning@solemnwarning.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
Expand All @@ -17,13 +17,15 @@

#include "platform.hpp"

#include "App.hpp"
#include "AppSettings.hpp"

wxDEFINE_EVENT(REHex::PREFERRED_ASM_SYNTAX_CHANGED, wxCommandEvent);

REHex::AppSettings::AppSettings():
preferred_asm_syntax(AsmSyntax::INTEL),
goto_offset_base(GotoOffsetBase::AUTO) {}
goto_offset_base(GotoOffsetBase::AUTO),
highlight_colours(HighlightColourMap::defaults()) {}

REHex::AppSettings::AppSettings(wxConfig *config): AppSettings()
{
Expand Down Expand Up @@ -52,12 +54,31 @@ REHex::AppSettings::AppSettings(wxConfig *config): AppSettings()
default:
break;
}

if(config->HasGroup("highlight-colours"))
{
try {
wxConfigPathChanger scoped_path(config, "highlight-colours/");
highlight_colours = HighlightColourMap::from_config(config);
}
catch(const std::exception &e)
{
wxGetApp().printf_error("Error loading highlight colours: %s\n", e.what());
}
}
}

void REHex::AppSettings::write(wxConfig *config)
{
config->Write("preferred-asm-syntax", (long)(preferred_asm_syntax));
config->Write("goto-offset-base", (long)(goto_offset_base));

{
config->DeleteGroup("highlight-colours");

wxConfigPathChanger scoped_path(config, "highlight-colours/");
highlight_colours.to_config(config);
}
}

REHex::AsmSyntax REHex::AppSettings::get_preferred_asm_syntax() const
Expand Down Expand Up @@ -87,3 +108,13 @@ void REHex::AppSettings::set_goto_offset_base(GotoOffsetBase goto_offset_base)
{
this->goto_offset_base = goto_offset_base;
}

const REHex::HighlightColourMap &REHex::AppSettings::get_highlight_colours() const
{
return highlight_colours;
}

void REHex::AppSettings::set_highlight_colours(const HighlightColourMap &highlight_colours)
{
this->highlight_colours = highlight_colours;
}
8 changes: 7 additions & 1 deletion src/AppSettings.hpp
@@ -1,5 +1,5 @@
/* Reverse Engineer's Hex Editor
* Copyright (C) 2022 Daniel Collins <solemnwarning@solemnwarning.net>
* Copyright (C) 2022-2024 Daniel Collins <solemnwarning@solemnwarning.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
Expand All @@ -21,6 +21,8 @@
#include <wx/config.h>
#include <wx/wx.h>

#include "HighlightColourMap.hpp"

namespace REHex
{
enum class AsmSyntax
Expand Down Expand Up @@ -51,9 +53,13 @@ namespace REHex
GotoOffsetBase get_goto_offset_base() const;
void set_goto_offset_base(GotoOffsetBase goto_offset_base);

const HighlightColourMap &get_highlight_colours() const;
void set_highlight_colours(const HighlightColourMap &highlight_colours);

private:
AsmSyntax preferred_asm_syntax;
GotoOffsetBase goto_offset_base;
HighlightColourMap highlight_colours;
};

wxDECLARE_EVENT(PREFERRED_ASM_SYNTAX_CHANGED, wxCommandEvent);
Expand Down

0 comments on commit e9e4175

Please sign in to comment.