Ghidra is a software reverse engineering (SRE) framework
GP-1981 registering Theme options for colors and fonts
ghidragon5c84d3e14346
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.java b/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.javaindex e564ed5235..f55db72821 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.java@@ -15,7 +15,6 @@*/package ghidra;-import java.awt.Color;import java.awt.event.MouseEvent;import generic.theme.GColor;@@ -157,7 +156,7 @@ public interface GhidraOptions {final String HIGHLIGHT_CURSOR_LINE_COLOR = "Cursor." + HIGHLIGHT_CURSOR_LINE_COLOR_OPTION_NAME;- final Color DEFAULT_CURSOR_LINE_COLOR = new GColor("color.bg.currentline.listing");+ final GColor DEFAULT_CURSOR_LINE_COLOR = new GColor("color.bg.currentline.listing");final String HIGHLIGHT_CURSOR_LINE_OPTION_NAME = "Highlight Cursor Line";@@ -192,9 +191,9 @@ public interface GhidraOptions {// end cursor highlightfinal String OPTION_SELECTION_COLOR = "Selection Colors.Selection Color";- final Color DEFAULT_SELECTION_COLOR = new GColor("color.bg.selection.listing");+ final GColor DEFAULT_SELECTION_COLOR = new GColor("color.bg.selection.listing");final String OPTION_HIGHLIGHT_COLOR = "Selection Colors.Highlight Color";- final Color DEFAULT_HIGHLIGHT_COLOR = new GColor("color.bg.highlight.listing");+ final GColor DEFAULT_HIGHLIGHT_COLOR = new GColor("color.bg.highlight.listing");final String APPLY_ENABLED = "apply.enabled";}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.javaindex 92df240190..5b476a5488 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java@@ -68,9 +68,9 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> exprivate static final String MOUSE_WHEEL_HORIZONTAL_SCROLLING = "Mouse.Horizontal Scrolling";//@formatter:off- public static final Color IFOCUSED_CURSOR_COLOR = new GColor("color.cursor.focused.listing");- public static final Color IUNFOCUSED_CURSOR_COLOR = new GColor("color.cursor.unfocused.listing");- public static final Color ICURRENT_LINE_HIGHLIGHT_COLOR = new GColor("color.bg.currentline.listing");+ public static final GColor IFOCUSED_CURSOR_COLOR = new GColor("color.cursor.focused.listing");+ public static final GColor IUNFOCUSED_CURSOR_COLOR = new GColor("color.cursor.unfocused.listing");+ public static final GColor ICURRENT_LINE_HIGHLIGHT_COLOR = new GColor("color.bg.currentline.listing");//@formatter:on// - Icon -@@ -553,21 +553,24 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> exHelpLocation helpLocation = new HelpLocation(getName(), "Selection Colors");fieldOptions.getOptions("Selection Colors").setOptionsHelpLocation(helpLocation);- fieldOptions.registerOption(GhidraOptions.OPTION_SELECTION_COLOR,- GhidraOptions.DEFAULT_SELECTION_COLOR, helpLocation,+ fieldOptions.registerThemeColorBinding(GhidraOptions.OPTION_SELECTION_COLOR,+ GhidraOptions.DEFAULT_SELECTION_COLOR.getId(), helpLocation,"The selection color in the browser.");- fieldOptions.registerOption(GhidraOptions.OPTION_HIGHLIGHT_COLOR,- GhidraOptions.DEFAULT_HIGHLIGHT_COLOR, helpLocation,+ fieldOptions.registerThemeColorBinding(GhidraOptions.OPTION_HIGHLIGHT_COLOR,+ GhidraOptions.DEFAULT_HIGHLIGHT_COLOR.getId(), helpLocation,"The highlight color in the browser.");- fieldOptions.registerOption(CURSOR_COLOR, IFOCUSED_CURSOR_COLOR, helpLocation,+ fieldOptions.registerThemeColorBinding(CURSOR_COLOR, IFOCUSED_CURSOR_COLOR.getId(),+ helpLocation,"The color of the cursor in the browser.");- fieldOptions.registerOption(UNFOCUSED_CURSOR_COLOR, IUNFOCUSED_CURSOR_COLOR, helpLocation,+ fieldOptions.registerThemeColorBinding(UNFOCUSED_CURSOR_COLOR,+ IUNFOCUSED_CURSOR_COLOR.getId(),+ helpLocation,"The color of the cursor in the browser when the browser does not have focus.");fieldOptions.registerOption(BLINK_CURSOR, true, helpLocation,"When selected, the cursor will blink when the containing window is focused.");- fieldOptions.registerOption(GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR,- ICURRENT_LINE_HIGHLIGHT_COLOR, helpLocation,+ fieldOptions.registerThemeColorBinding(GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR,+ ICURRENT_LINE_HIGHLIGHT_COLOR.getId(), helpLocation,"The background color of the line where the cursor is located");fieldOptions.registerOption(GhidraOptions.HIGHLIGHT_CURSOR_LINE, true, helpLocation,"Toggles highlighting background color of line containing the cursor");diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.javaindex 14c97610ea..c1f758a93e 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java@@ -53,9 +53,9 @@ import ghidra.util.datastruct.Stack;public class ListingHighlightProviderimplements ButtonPressedListener, OptionsChangeListener, HighlightProvider {//@formatter:off- private static final Color DEFAULT_HIGHLIGHT_COLOR = new GColor("color.fg.listing.highlighter.default");- private static final Color DEFAULT_SCOPED_READ_COLOR = new GColor("color.fg.listing.highlighter.scoped.read");- private static final Color DEFAULT_SCOPED_WRITE_COLOR = new GColor("color.fg.listing.highlighter.scoped.write");+ private static final GColor DEFAULT_HIGHLIGHT_COLOR = new GColor("color.fg.listing.highlighter.default");+ private static final GColor DEFAULT_SCOPED_READ_COLOR = new GColor("color.fg.listing.highlighter.scoped.read");+ private static final GColor DEFAULT_SCOPED_WRITE_COLOR = new GColor("color.fg.listing.highlighter.scoped.write");private static final String DISPLAY_HIGHLIGHT_NAME = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Enabled";private static final String SCOPED_WRITE_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Write Highlight Color";private static final String SCOPED_READ_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Read Highlight Color";@@ -869,11 +869,14 @@ public class ListingHighlightProviderToolOptions opt = tool.getOptions(CATEGORY_BROWSER_FIELDS);HelpLocation hl = new HelpLocation("CodeBrowserPlugin", "Cursor_Text_Highlight");- opt.registerOption(HIGHLIGHT_COLOR_NAME, DEFAULT_HIGHLIGHT_COLOR, hl,+ opt.registerThemeColorBinding(HIGHLIGHT_COLOR_NAME,+ DEFAULT_HIGHLIGHT_COLOR.getId(), hl,"The color to use to highlight text.");- opt.registerOption(SCOPED_WRITE_HIGHLIGHT_COLOR, DEFAULT_SCOPED_WRITE_COLOR, hl,+ opt.registerThemeColorBinding(SCOPED_WRITE_HIGHLIGHT_COLOR,+ DEFAULT_SCOPED_WRITE_COLOR.getId(), hl,"The color to use for showing a register being written.");- opt.registerOption(SCOPED_READ_HIGHLIGHT_COLOR, DEFAULT_SCOPED_READ_COLOR, hl,+ opt.registerThemeColorBinding(SCOPED_READ_HIGHLIGHT_COLOR,+ DEFAULT_SCOPED_READ_COLOR.getId(), hl,"The color to use for showing a register being read.");opt.registerOption(SCOPE_REGISTER_OPERAND, true, hl,diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.javaindex 16edd2b078..3be30d4367 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java@@ -29,7 +29,6 @@ import generic.theme.GIcon;import generic.theme.Gui;import ghidra.app.services.*;import ghidra.framework.main.ConsoleTextPane;-import ghidra.framework.options.OptionType;import ghidra.framework.options.ToolOptions;import ghidra.framework.plugintool.ComponentProviderAdapter;import ghidra.framework.plugintool.PluginTool;@@ -104,7 +103,7 @@ public class ConsoleComponentProvider extends ComponentProviderAdapterprivate void createOptions() {ToolOptions options = tool.getOptions("Console");HelpLocation help = new HelpLocation(getOwner(), getOwner());- options.registerOption(FONT_OPTION_LABEL, OptionType.FONT_TYPE, DEFAULT_FONT_ID, help,+ options.registerThemeFontBinding(FONT_OPTION_LABEL, DEFAULT_FONT_ID, help,FONT_DESCRIPTION);options.setOptionsHelpLocation(help);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/flowarrow/FlowArrowPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/flowarrow/FlowArrowPlugin.javaindex 4a87ad48e8..e99c3ddf73 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/flowarrow/FlowArrowPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/flowarrow/FlowArrowPlugin.java@@ -642,14 +642,14 @@ public class FlowArrowPlugin extends Plugin implements MarginProvider, OptionsChprivate void getOptions() {ToolOptions opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_DISPLAY);- opt.registerOption(OptionsGui.FLOW_ARROW_NON_ACTIVE.getColorOptionName(),- OptionsGui.FLOW_ARROW_NON_ACTIVE.getDefaultColor(), null,+ opt.registerThemeColorBinding(OptionsGui.FLOW_ARROW_NON_ACTIVE.getColorOptionName(),+ OptionsGui.FLOW_ARROW_NON_ACTIVE.getThemeColorId(), null,"The color for an arrow with no endpoint at the current address");- opt.registerOption(OptionsGui.FLOW_ARROW_ACTIVE.getColorOptionName(),- OptionsGui.FLOW_ARROW_ACTIVE.getDefaultColor(), null,+ opt.registerThemeColorBinding(OptionsGui.FLOW_ARROW_ACTIVE.getColorOptionName(),+ OptionsGui.FLOW_ARROW_ACTIVE.getThemeColorId(), null,"The color for an arrow with an endpoint at the current address");- opt.registerOption(OptionsGui.FLOW_ARROW_SELECTED.getColorOptionName(),- OptionsGui.FLOW_ARROW_SELECTED.getDefaultColor(), null,+ opt.registerThemeColorBinding(OptionsGui.FLOW_ARROW_SELECTED.getColorOptionName(),+ OptionsGui.FLOW_ARROW_SELECTED.getThemeColorId(), null,"The color for an arrow that has been selected by the user");Color c = opt.getColor(OptionsGui.BACKGROUND.getColorOptionName(),diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.javaindex 99172e061e..6a9b7be33f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.java@@ -32,7 +32,8 @@ import generic.theme.GColor;import generic.theme.Gui;import generic.util.WindowUtilities;import ghidra.app.plugin.core.console.CodeCompletion;-import ghidra.framework.options.*;+import ghidra.framework.options.OptionsChangeListener;+import ghidra.framework.options.ToolOptions;import ghidra.framework.plugintool.PluginTool;import ghidra.util.HelpLocation;import ghidra.util.Msg;@@ -379,7 +380,7 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {HelpLocation help = new HelpLocation(getName(), "ConsolePlugin");options.setOptionsHelpLocation(help);- options.registerOption(FONT_OPTION_LABEL, OptionType.FONT_TYPE, FONT_ID, help,+ options.registerThemeFontBinding(FONT_OPTION_LABEL, FONT_ID, help,FONT_DESCRIPTION);options.registerOption(COMPLETION_WINDOW_TRIGGER_LABEL, CompletionWindowTrigger.TAB, help,COMPLETION_WINDOW_TRIGGER_DESCRIPTION);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.javaindex d482152893..db1fd6dd2c 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java@@ -43,7 +43,7 @@ class LocationReferencesHighlighter {"Reference Search" + GhidraOptions.DELIMITER + "Highlight Match Color";private static final String HIGHLIGHT_COLOR_DESCRIPTION ="The highlight color of matches for the 'Show References' searcher";- private static Color DEFAULT_HIGHLIGHT_COLOR =+ private static GColor DEFAULT_HIGHLIGHT_COLOR =new GColor("color.bg.plugin.locationreferences.highlight");private boolean isHighlighting = false;@@ -55,17 +55,17 @@ class LocationReferencesHighlighter {private MarkerRemover markerRemover;private Color highlightColor;private OptionsChangeListener optionsListener = (options, name, oldValue, newValue) -> {-if (name.equals(HIGHLIGHT_COLOR_KEY)) {- highlightColor = (Color) newValue;-}-};+ if (name.equals(HIGHLIGHT_COLOR_KEY)) {+ highlightColor = (Color) newValue;+ }+ };// This is a bit unusual, but we do this here, since this highlighter will come and// go with each search. If we do not register a priori, then the option will not appear in the// tool until a search has happened, which is odd.static void registerHighlighterOptions(LocationReferencesPlugin plugin) {ToolOptions options = plugin.getTool().getOptions(OPTIONS_TITLE);- options.registerOption(HIGHLIGHT_COLOR_KEY, DEFAULT_HIGHLIGHT_COLOR,+ options.registerThemeColorBinding(HIGHLIGHT_COLOR_KEY, DEFAULT_HIGHLIGHT_COLOR.getId(),plugin.getHelpLocation(), HIGHLIGHT_COLOR_DESCRIPTION);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/addresstype/AddressTypeOverviewColorService.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/addresstype/AddressTypeOverviewColorService.javaindex 460a7571a8..26b590edeb 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/addresstype/AddressTypeOverviewColorService.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/addresstype/AddressTypeOverviewColorService.java@@ -45,17 +45,17 @@ import ghidra.util.HelpLocation;public class AddressTypeOverviewColorServiceimplements OverviewColorService, OptionsChangeListener, DomainObjectListener {private static final String OPTIONS_NAME = "Overview";- private static final Color DEFAULT_INSTRUCTION_COLOR =+ private static final GColor DEFAULT_INSTRUCTION_COLOR =new GColor("color.bg.plugin.overview.address.instruction");- private static final Color DEFAULT_DATA_COLOR =+ private static final GColor DEFAULT_DATA_COLOR =new GColor("color.bg.plugin.overview.address.data");- private static final Color DEFAULT_FUNCTION_COLOR =+ private static final GColor DEFAULT_FUNCTION_COLOR =new GColor("color.bg.plugin.overview.address.function");- private static final Color DEFAULT_UNDEFINED_COLOR =+ private static final GColor DEFAULT_UNDEFINED_COLOR =new GColor("color.bg.plugin.overview.address.undefined");- private static final Color DEFAULT_UNINITIALIZED_COLOR =+ private static final GColor DEFAULT_UNINITIALIZED_COLOR =new GColor("color.bg.plugin.overview.address.uninitialized");- private static final Color DEFAULT_EXTERNAL_REF_COLOR =+ private static final GColor DEFAULT_EXTERNAL_REF_COLOR =new GColor("color.bg.plugin.overview.address.external.ref");Color instructionColor = DEFAULT_INSTRUCTION_COLOR;@@ -280,16 +280,20 @@ public class AddressTypeOverviewColorServiceToolOptions options = tool.getOptions(OPTIONS_NAME);HelpLocation help = new HelpLocation(OverviewColorPlugin.HELP_TOPIC, "OverviewOptions");- options.registerOption("Instruction Color", DEFAULT_INSTRUCTION_COLOR, help,+ options.registerThemeColorBinding("Instruction Color", DEFAULT_INSTRUCTION_COLOR.getId(),+ help,"Color for instructions");- options.registerOption("Data Color", DEFAULT_DATA_COLOR, help, "Color for data");- options.registerOption("Function Color", DEFAULT_FUNCTION_COLOR, help,+ options.registerThemeColorBinding("Data Color", DEFAULT_DATA_COLOR.getId(), help,+ "Color for data");+ options.registerThemeColorBinding("Function Color", DEFAULT_FUNCTION_COLOR.getId(), help,"Color for functions");- options.registerOption("Undefined Color", DEFAULT_UNDEFINED_COLOR, help,+ options.registerThemeColorBinding("Undefined Color", DEFAULT_UNDEFINED_COLOR.getId(), help,"Color for undefined bytes");- options.registerOption("Uninitialized Color", DEFAULT_UNINITIALIZED_COLOR, help,+ options.registerThemeColorBinding("Uninitialized Color",+ DEFAULT_UNINITIALIZED_COLOR.getId(), help,"Color for uninitialize memory");- options.registerOption("External Reference Color", DEFAULT_EXTERNAL_REF_COLOR, help,+ options.registerThemeColorBinding("External Reference Color",+ DEFAULT_EXTERNAL_REF_COLOR.getId(), help,"Color for external references");}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.javaindex 8bf93f2d48..7ee5058bcc 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.java@@ -41,32 +41,32 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {private static final String KNOT1_COLOR_OPTION_NAME = "Range 1 color";private static final String KNOT1_TYPE_OPTION_NAME = "Entropy Range 1";- private static final Color KNOT1_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.1");+ private static final GColor KNOT1_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.1");private static final EntropyKnot KNOT1_DEF_TYPE = EntropyKnot.COMPRESSED;private static final String KNOT2_COLOR_OPTION_NAME = "Range 2 color";private static final String KNOT2_TYPE_OPTION_NAME = "Entropy Range 2";- private static final Color KNOT2_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.2");+ private static final GColor KNOT2_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.2");private static final EntropyKnot KNOT2_DEF_TYPE = EntropyKnot.X86;private static final String KNOT3_COLOR_OPTION_NAME = "Range 3 color";private static final String KNOT3_TYPE_OPTION_NAME = "Entropy Range 3";- private static final Color KNOT3_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.3");+ private static final GColor KNOT3_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.3");private static final EntropyKnot KNOT3_DEF_TYPE = EntropyKnot.ASCII;private static final String KNOT4_COLOR_OPTION_NAME = "Range 4 color";private static final String KNOT4_TYPE_OPTION_NAME = "Entropy Range 4";- private static final Color KNOT4_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.4");+ private static final GColor KNOT4_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.4");private static final EntropyKnot KNOT4_DEF_TYPE = EntropyKnot.UTF16;private static final String KNOT5_COLOR_OPTION_NAME = "Range 5 color";private static final String KNOT5_TYPE_OPTION_NAME = "Entropy Range 5";- private static final Color KNOT5_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.5");+ private static final GColor KNOT5_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.5");private static final EntropyKnot KNOT5_DEF_TYPE = EntropyKnot.NONE;- private static final Color PALETTE_COLOR_HIGH =+ private static final GColor PALETTE_COLOR_HIGH =new GColor("color.bg.plugin.overview.entropy.palette.base.high");- private static final Color PALETTE_COLOR_LOW =+ private static final GColor PALETTE_COLOR_LOW =new GColor("color.bg.plugin.overview.entropy.palette.base.low");private EntropyChunkSize chunksize;@@ -87,15 +87,15 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {options.setOptionsHelpLocation(help);options.registerOption(CHUNKSIZE_STRING, CHUNKSIZE_DEF, help, CHUNKSIZE_DESC_STRING);- options.registerOption(KNOT1_COLOR_OPTION_NAME, KNOT1_COLOR, help,+ options.registerThemeColorBinding(KNOT1_COLOR_OPTION_NAME, KNOT1_COLOR.getId(), help,KNOT_COLOR_STRING);- options.registerOption(KNOT2_COLOR_OPTION_NAME, KNOT2_COLOR, help,+ options.registerThemeColorBinding(KNOT2_COLOR_OPTION_NAME, KNOT2_COLOR.getId(), help,KNOT_COLOR_STRING);- options.registerOption(KNOT3_COLOR_OPTION_NAME, KNOT3_COLOR, help,+ options.registerThemeColorBinding(KNOT3_COLOR_OPTION_NAME, KNOT3_COLOR.getId(), help,KNOT_COLOR_STRING);- options.registerOption(KNOT4_COLOR_OPTION_NAME, KNOT4_COLOR, help,+ options.registerThemeColorBinding(KNOT4_COLOR_OPTION_NAME, KNOT4_COLOR.getId(), help,KNOT_COLOR_STRING);- options.registerOption(KNOT5_COLOR_OPTION_NAME, KNOT5_COLOR, help,+ options.registerThemeColorBinding(KNOT5_COLOR_OPTION_NAME, KNOT5_COLOR.getId(), help,KNOT_COLOR_STRING);options.registerOption(KNOT1_TYPE_OPTION_NAME, KNOT1_DEF_TYPE, help, KNOT_TYPE_STRING);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.javaindex 04b7ed27bd..257c23cb7f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java@@ -387,10 +387,11 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_NAME, true, null,"Toggles highlight search results");- opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,- PluginConstants.SEARCH_HIGHLIGHT_COLOR, null, "The search result highlight color");- opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,- PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR, null,+ opt.registerThemeColorBinding(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,+ PluginConstants.SEARCH_HIGHLIGHT_COLOR.getId(), null,+ "The search result highlight color");+ opt.registerThemeColorBinding(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,+ PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR.getId(), null,"The search result highlight color for the currently selected match");opt.addOptionsChangeListener(this);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.javaindex 55ba8c4a4c..0981bab88b 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java@@ -435,10 +435,11 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeListopt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_NAME, true, loc,"Determines whether to highlight the matched string for a search in the listing.");- opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,- PluginConstants.SEARCH_HIGHLIGHT_COLOR, null, "The search result highlight color");- opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,- PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR, null,+ opt.registerThemeColorBinding(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,+ PluginConstants.SEARCH_HIGHLIGHT_COLOR.getId(), null,+ "The search result highlight color");+ opt.registerThemeColorBinding(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,+ PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR.getId(), null,"The search result highlight color for the currently selected match");searchLimit =diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.javaindex 654a37c021..21d3edbe99 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.java@@ -15,8 +15,6 @@*/package ghidra.app.util;-import java.awt.Color;-import generic.theme.GColor;/**@@ -90,7 +88,7 @@ public interface PluginConstants {* Color for highlighting for searches.*/public static final String SEARCH_HIGHLIGHT_COLOR_OPTION_NAME = " Highlight Color";- public static final Color SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.search.highlight");+ public static final GColor SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.search.highlight");/*** Default highlight color used when something to highlight is at the current@@ -98,7 +96,7 @@ public interface PluginConstants {*/public static final String SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME ="Highlight Color for Current Match";- public static final Color SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR =+ public static final GColor SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR =new GColor("color.bg.search.current.line.highlight");}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.javaindex fb495845dc..003ff793f5 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java@@ -91,7 +91,7 @@ public abstract class FieldFactory implements ExtensionPoint {// For most fields (defined in optionsGui) these will be set. But "ad hoc" fields won't,// so register something. A second registration won't change the original- displayOptions.registerOption(colorOptionName, Colors.FOREGROUND, null,+ displayOptions.registerThemeColorBinding(colorOptionName, Colors.FOREGROUND.getId(), null,"Sets the " + colorOptionName);displayOptions.registerOption(styleOptionName, -1, null, "Sets the " + style);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.javaindex 7e3dd4ebdd..a2389af420 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.java@@ -54,11 +54,11 @@ public class ListingDisplayOptionsEditor implements OptionsEditor {private void registerOptions() {String prefix = "Sets the ";- options.registerOption(GhidraOptions.OPTION_BASE_FONT, OptionType.FONT_TYPE,+ options.registerThemeFontBinding(GhidraOptions.OPTION_BASE_FONT,DEFAULT_FONT_ID, null, prefix + GhidraOptions.OPTION_BASE_FONT);for (ScreenElement element : OptionsGui.elements) {String colorOptionName = element.getColorOptionName();- options.registerOption(colorOptionName, element.getDefaultColor(), null,+ options.registerThemeColorBinding(colorOptionName, element.getThemeColorId(), null,prefix + colorOptionName);String styleOptionName = element.getStyleOptionName();options.registerOption(styleOptionName, -1, null, prefix + styleOptionName);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ScreenElement.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ScreenElement.javaindex e701f15721..7068c80096 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ScreenElement.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ScreenElement.java@@ -1,6 +1,5 @@/* ###* IP: GHIDRA- * REVIEWED: YES** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.@@ -18,52 +17,65 @@ package ghidra.app.util.viewer.options;import java.awt.Color;+import generic.theme.GColor;public class ScreenElement {private String name;private String optionsName;private Color color;- private Color defaultColor;+ private GColor defaultColor;private int style;-- ScreenElement(String name, Color defaultColor) {++ ScreenElement(String name, GColor defaultColor) {this(name, name, defaultColor);}-- ScreenElement(String name, String optionsName, Color defaultColor) {++ ScreenElement(String name, String optionsName, GColor defaultColor) {this.name = name;this.optionsName = optionsName;this.defaultColor = defaultColor;this.color = defaultColor;this.style = -1;}-++ public String getThemeColorId() {+ return defaultColor.getId();+ }+public String getName() {return name;}+public Color getColor() {return color;}+public int getStyle() {return style;}+public Color getDefaultColor() {return defaultColor;}+public void setColor(Color color) {this.color = color;}+public void setStyle(int style) {this.style = style;}+public String getColorOptionName() {return optionsName + " Color";}+public String getStyleOptionName() {- return optionsName+ " Style";+ return optionsName + " Style";}+@Override- public String toString() {+ public String toString() {return name;}}diff --git a/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.java b/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.javaindex b39cc21177..650b63b499 100644--- a/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.java+++ b/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.java@@ -286,27 +286,26 @@ public class OptionsDBTest extends AbstractDockingTest {@Testpublic void testGetDefaultValue() {- options.registerOption("Foo", Color.RED, null, "description");- options.setColor("Foo", Color.BLUE);- assertColorsEqual(Color.BLUE, options.getColor("Foo", null));- assertColorsEqual(Color.RED, (Color) options.getDefaultValue("Foo"));+ options.registerOption("Foo", 5, null, "description");+ options.setInt("Foo", 10);+ assertEquals(10, options.getInt("Foo", 0));+ assertEquals(Integer.valueOf(5), options.getDefaultValue("Foo"));}@Testpublic void testGetDefaultValueWithThemeValues() {- options.registerOption("Foo", testColor, null, "description");+ options.registerThemeColorBinding("Foo", "color.test", null, "description");options.setColor("Foo", Color.BLUE);assertColorsEqual(Color.BLUE, options.getColor("Foo", null));- // registered options using theme values, don't have defaultsassertColorsEqual(Color.BLUE, (Color) options.getDefaultValue("Foo"));}@Testpublic void testRegisterPropertyEditor() {MyPropertyEditor editor = new MyPropertyEditor();- options.registerOption("color", OptionType.COLOR_TYPE, testColor, null, "description",+ options.registerOption("foo", OptionType.INT_TYPE, 5, null, "description",editor);- assertEquals(editor, options.getRegisteredPropertyEditor("color"));+ assertEquals(editor, options.getRegisteredPropertyEditor("foo"));}@@ -328,7 +327,7 @@ public class OptionsDBTest extends AbstractDockingTest {@Testpublic void testRestoreThemeOptionValue() {- options.registerOption("Foo", testColor, null, "description");+ options.registerThemeColorBinding("Foo", "color.test", null, "description");options.setColor("Foo", Palette.BLUE);assertColorsEqual(Palette.BLUE, options.getColor("Foo", null));options.restoreDefaultValue("Foo");@@ -576,7 +575,6 @@ public class OptionsDBTest extends AbstractDockingTest {// this will cause the palette color LAVENDER to be null - make sure to not use it in other//testsoptions.registerOption("Bar", "HEY", null, "description");- options.setString("Bar", "THERE");options.setString("Bar", null);assertEquals(null, options.getString("Bar", null));}@@ -585,10 +583,14 @@ public class OptionsDBTest extends AbstractDockingTest {public void testSettingThemeValueToNull() {// this will cause the palette color LAVENDER to be null - make sure to not use it in other//tests- options.registerOption("Bar", testColor, null, "description");- options.setColor("Bar", Palette.RED);- options.setColor("Bar", null);- assertEquals(null, options.getColor("Bar", null));+ options.registerThemeColorBinding("Bar", "color.test", null, "description");+ try {+ options.setColor("Bar", null);+ fail("Expected exception setting theme value to null");+ }+ catch (IllegalArgumentException e) {+ // expected+ }}@Testdiff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.javaindex 91588f4909..4202146c82 100644--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.java+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.java@@ -60,13 +60,13 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdaptstatic final String FG = "byteviewer.color.fg";static final String CURSOR = "byteviewer.color.cursor";- static final Color SEPARATOR_COLOR = new GColor("color.fg.byteviewer.separator");- static final Color CHANGED_VALUE_COLOR = new GColor("color.fg.byteviewer.changed");- static final Color CURSOR_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.active");- static final Color CURSOR_NON_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.not.active");- static final Color CURSOR_NOT_FOCUSED_COLOR = new GColor("color.cursor.byteviewer.unfocused");+ static final GColor SEPARATOR_COLOR = new GColor("color.fg.byteviewer.separator");+ static final GColor CHANGED_VALUE_COLOR = new GColor("color.fg.byteviewer.changed");+ static final GColor CURSOR_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.active");+ static final GColor CURSOR_NON_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.not.active");+ static final GColor CURSOR_NOT_FOCUSED_COLOR = new GColor("color.cursor.byteviewer.unfocused");- static final Color CURRENT_LINE_COLOR = GhidraOptions.DEFAULT_CURSOR_LINE_COLOR;+ static final GColor CURRENT_LINE_COLOR = GhidraOptions.DEFAULT_CURSOR_LINE_COLOR;//@formatter:onstatic final String DEFAULT_INDEX_NAME = "Addresses";@@ -199,29 +199,29 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdaptHelpLocation help = new HelpLocation("ByteViewerPlugin", "Option");opt.setOptionsHelpLocation(help);- opt.registerOption(SEPARATOR_COLOR_OPTION_NAME, SEPARATOR_COLOR, help,+ opt.registerThemeColorBinding(SEPARATOR_COLOR_OPTION_NAME, SEPARATOR_COLOR.getId(), help,"Color used for separator shown between memory blocks.");- opt.registerOption(CHANGED_VALUE_COLOR_OPTION_NAME, CHANGED_VALUE_COLOR,+ opt.registerThemeColorBinding(CHANGED_VALUE_COLOR_OPTION_NAME, CHANGED_VALUE_COLOR.getId(),new HelpLocation("ByteViewerPlugin", "EditColor"),"Color of changed bytes when editing.");- opt.registerOption(CURSOR_ACTIVE_COLOR_OPTION_NAME, CURSOR_ACTIVE_COLOR,+ opt.registerThemeColorBinding(CURSOR_ACTIVE_COLOR_OPTION_NAME, CURSOR_ACTIVE_COLOR.getId(),help, "Color of cursor in the active view.");- opt.registerOption(CURSOR_NON_ACTIVE_COLOR_OPTION_NAME,- CURSOR_NON_ACTIVE_COLOR,+ opt.registerThemeColorBinding(CURSOR_NON_ACTIVE_COLOR_OPTION_NAME,+ CURSOR_NON_ACTIVE_COLOR.getId(),help, "Color of cursor in the non-active views.");- opt.registerOption(CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME,- CURSOR_NOT_FOCUSED_COLOR,+ opt.registerThemeColorBinding(CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME,+ CURSOR_NOT_FOCUSED_COLOR.getId(),help, "Color of cursor when the byteview does not have focus.");- opt.registerOption(CURRENT_LINE_COLOR_OPTION_NAME,- GhidraOptions.DEFAULT_CURSOR_LINE_COLOR, help,+ opt.registerThemeColorBinding(CURRENT_LINE_COLOR_OPTION_NAME,+ GhidraOptions.DEFAULT_CURSOR_LINE_COLOR.getId(), help,"Color of the line containing the cursor");- opt.registerOption(OPTION_FONT, OptionType.FONT_TYPE, DEFAULT_FONT_ID, help,+ opt.registerThemeFontBinding(OPTION_FONT, DEFAULT_FONT_ID, help,"Font used in the views.");opt.registerOption(OPTION_HIGHLIGHT_CURSOR_LINE, true, help,"Toggles highlighting background color of line containing the cursor");diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.javaindex fff6884190..1ec6590391 100644--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java@@ -29,7 +29,8 @@ import generic.theme.Gui;import ghidra.GhidraOptions;import ghidra.GhidraOptions.CURSOR_MOUSE_BUTTON_NAMES;import ghidra.app.util.HelpTopics;-import ghidra.framework.options.*;+import ghidra.framework.options.Options;+import ghidra.framework.options.ToolOptions;import ghidra.framework.plugintool.Plugin;import ghidra.framework.plugintool.PluginTool;import ghidra.program.database.ProgramCompilerSpec;@@ -306,47 +307,47 @@ public class DecompileOptions {private int middleMouseHighlightButton = MouseEvent.BUTTON2;private final static String HIGHLIGHT_CURRENT_VARIABLE_MSG ="Display.Color for Current Variable Highlight";- private final static Color HIGHLIGHT_CURRENT_VARIABLE_COLOR = new GColor("color.bg.decompiler.current.variable");+ private final static GColor HIGHLIGHT_CURRENT_VARIABLE_COLOR = new GColor("color.bg.decompiler.current.variable");private final static String HIGHLIGHT_KEYWORD_MSG = "Display.Color for Keywords";- private final static Color HIGHLIGHT_KEYWORD_COLOR = new GColor("color.fg.decompiler.keyword");+ private final static GColor HIGHLIGHT_KEYWORD_COLOR = new GColor("color.fg.decompiler.keyword");private final static String HIGHLIGHT_FUNCTION_MSG = "Display.Color for Function names";- private final static Color HIGHLIGHT_FUNCTION_COLOR = new GColor("color.fg.decompiler.function.name");+ private final static GColor HIGHLIGHT_FUNCTION_COLOR = new GColor("color.fg.decompiler.function.name");private final static String HIGHLIGHT_COMMENT_MSG = "Display.Color for Comments";- private final static Color HIGHLIGHT_COMMENT_COLOR = new GColor( "color.fg.decompiler.comment");+ private final static GColor HIGHLIGHT_COMMENT_COLOR = new GColor( "color.fg.decompiler.comment");private final static String HIGHLIGHT_VARIABLE_MSG = "Display.Color for Variables";- private final static Color HIGHLIGHT_VARIABLE_COLOR = new GColor("color.fg.decompiler.variable");+ private final static GColor HIGHLIGHT_VARIABLE_COLOR = new GColor("color.fg.decompiler.variable");private final static String HIGHLIGHT_CONST_MSG = "Display.Color for Constants";- private final static Color HIGHLIGHT_CONST_COLOR = new GColor("color.fg.decompiler.constant");+ private final static GColor HIGHLIGHT_CONST_COLOR = new GColor("color.fg.decompiler.constant");private final static String HIGHLIGHT_TYPE_MSG = "Display.Color for Types";- private final static Color HIGHLIGHT_TYPE_COLOR = new GColor("color.fg.decompiler.type");+ private final static GColor HIGHLIGHT_TYPE_COLOR = new GColor("color.fg.decompiler.type");private final static String HIGHLIGHT_PARAMETER_MSG = "Display.Color for Parameters";- private final static Color HIGHLIGHT_PARAMETER_COLOR = new GColor("color.fg.decompiler.parameter");+ private final static GColor HIGHLIGHT_PARAMETER_COLOR = new GColor("color.fg.decompiler.parameter");private final static String HIGHLIGHT_GLOBAL_MSG = "Display.Color for Globals";- private final static Color HIGHLIGHT_GLOBAL_COLOR = new GColor("color.fg.decompiler.global");+ private final static GColor HIGHLIGHT_GLOBAL_COLOR = new GColor("color.fg.decompiler.global");private final static String HIGHLIGHT_SPECIAL_MSG = "Display.Color for Special";- private final static Color HIGHLIGHT_SPECIAL_COLOR = new GColor("color.fg.decompiler.special");+ private final static GColor HIGHLIGHT_SPECIAL_COLOR = new GColor("color.fg.decompiler.special");private final static String HIGHLIGHT_DEFAULT_MSG = "Display.Color Default";- private final static Color HIGHLIGHT_DEFAULT_COLOR = new GColor("color.fg.decompiler");+ private final static GColor HIGHLIGHT_DEFAULT_COLOR = new GColor("color.fg.decompiler");private static final String SEARCH_HIGHLIGHT_MSG = "Display.Color for Highlighting Find Matches";- private static final Color SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.decompiler.highlights.search");+ private static final GColor SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.decompiler.highlights.search");//@formatter:onprivate static final String BACKGROUND_COLOR_MSG = "Display.Background Color";private static final String BACKGROUND_COLOR_ID = "color.bg.decompiler";- private static final Color BACKGROUND_COLOR = new GColor(BACKGROUND_COLOR_ID);+ private static final GColor BACKGROUND_COLOR = new GColor(BACKGROUND_COLOR_ID);// Color applied to a token to indicate warning/errorprivate final static Color ERROR_COLOR = new GColor("color.fg.decompiler.comment");@@ -585,43 +586,43 @@ public class DecompileOptions {opt.registerOption(INTEGERFORMAT_OPTIONSTRING, INTEGERFORMAT_OPTIONDEFAULT,new HelpLocation(HelpTopics.DECOMPILER, "DisplayIntegerFormat"),INTEGERFORMAT_OPTIONDESCRIPTION);- opt.registerOption(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting keywords.");- opt.registerOption(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting types.");- opt.registerOption(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting function names.");- opt.registerOption(HIGHLIGHT_COMMENT_MSG, HIGHLIGHT_COMMENT_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_COMMENT_MSG, HIGHLIGHT_COMMENT_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting comments.");- opt.registerOption(HIGHLIGHT_VARIABLE_MSG, HIGHLIGHT_VARIABLE_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_VARIABLE_MSG, HIGHLIGHT_VARIABLE_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting variables.");- opt.registerOption(HIGHLIGHT_CONST_MSG, HIGHLIGHT_CONST_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_CONST_MSG, HIGHLIGHT_CONST_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting constants.");- opt.registerOption(HIGHLIGHT_PARAMETER_MSG, HIGHLIGHT_PARAMETER_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_PARAMETER_MSG, HIGHLIGHT_PARAMETER_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting parameters.");- opt.registerOption(HIGHLIGHT_GLOBAL_MSG, HIGHLIGHT_GLOBAL_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_GLOBAL_MSG, HIGHLIGHT_GLOBAL_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for highlighting global variables.");- opt.registerOption(HIGHLIGHT_SPECIAL_MSG, HIGHLIGHT_SPECIAL_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_SPECIAL_MSG, HIGHLIGHT_SPECIAL_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),"Color used for volatile or other exceptional variables.");- opt.registerOption(HIGHLIGHT_DEFAULT_MSG, HIGHLIGHT_DEFAULT_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_DEFAULT_MSG, HIGHLIGHT_DEFAULT_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayColorDefault"),"The color used when a specific color is not specified.");- opt.registerOption(BACKGROUND_COLOR_MSG, BACKGROUND_COLOR,+ opt.registerThemeColorBinding(BACKGROUND_COLOR_MSG, BACKGROUND_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayBackgroundColor"),"The background color of the decompiler window.");- opt.registerOption(FONT_MSG, OptionType.FONT_TYPE, DEFAULT_FONT_ID,+ opt.registerThemeFontBinding(FONT_MSG, DEFAULT_FONT_ID,new HelpLocation(HelpTopics.DECOMPILER, "DisplayFont"),"The font used to render text in the decompiler.");- opt.registerOption(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_COLOR,+ opt.registerThemeColorBinding(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayFindHighlight"),"The color used to highlight matches using the Find Dialog.");opt.registerOption(LINE_NUMBER_MSG, LINE_NUMBER_DEF,@@ -638,8 +639,8 @@ public class DecompileOptions {opt.registerOption(MAX_INSTRUCTIONS, SUGGESTED_MAX_INSTRUCTIONS,new HelpLocation(HelpTopics.DECOMPILER, "GeneralMaxInstruction"),"The maximum number of instructions decompiled in a single function");- opt.registerOption(HIGHLIGHT_CURRENT_VARIABLE_MSG,- HIGHLIGHT_CURRENT_VARIABLE_COLOR,+ opt.registerThemeColorBinding(HIGHLIGHT_CURRENT_VARIABLE_MSG,+ HIGHLIGHT_CURRENT_VARIABLE_COLOR.getId(),new HelpLocation(HelpTopics.DECOMPILER, "DisplayCurrentHighlight"),"Current variable highlight");opt.registerOption(CACHED_RESULTS_SIZE_MSG, SUGGESTED_CACHED_RESULTS_SIZE,diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FunctionGraphOptions.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FunctionGraphOptions.javaindex 58cdec4307..d2de8a371a 100644--- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FunctionGraphOptions.java+++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FunctionGraphOptions.java@@ -91,16 +91,16 @@ public class FunctionGraphOptions extends VisualGraphOptions {//@formatter:offpublic static final Color DEFAULT_GROUP_BACKGROUND_COLOR = new GColor("color.bg.functiongraph.vertex.group");- private Color defaultVertexBackgroundColor = new GColor("color.bg.functiongraph");- private Color defaultGroupBackgroundColor = new GColor("color.bg.functiongraph.vertex.group");+ private GColor defaultVertexBackgroundColor = new GColor("color.bg.functiongraph");+ private GColor defaultGroupBackgroundColor = new GColor("color.bg.functiongraph.vertex.group");- private Color fallthroughEdgeColor = new GColor("color.bg.functiongraph.edge.fall.through");- private Color conditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.conditional");- private Color unconditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.unconditional");+ private GColor fallthroughEdgeColor = new GColor("color.bg.functiongraph.edge.fall.through");+ private GColor conditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.conditional");+ private GColor unconditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.unconditional");- private Color fallthroughEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.fall.through.highlight");- private Color conditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.conditional.highlight");- private Color unconditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.unconditional.highlight");+ private GColor fallthroughEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.fall.through.highlight");+ private GColor conditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.conditional.highlight");+ private GColor unconditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.unconditional.highlight");//@formatter:onprivate boolean useFullSizeTooltip = false;@@ -173,10 +173,12 @@ public class FunctionGraphOptions extends VisualGraphOptions {options.registerOption(USE_CONDENSED_LAYOUT_KEY, useCondensedLayout(),new HelpLocation(OWNER, "Layout_Compressing"), USE_CONDENSED_LAYOUT_DESCRIPTION);- options.registerOption(DEFAULT_VERTEX_BACKGROUND_COLOR_KEY, defaultVertexBackgroundColor,+ options.registerThemeColorBinding(DEFAULT_VERTEX_BACKGROUND_COLOR_KEY,+ defaultVertexBackgroundColor.getId(),help, DEFAULT_VERTEX_BACKGROUND_COLOR_DESCRPTION);- options.registerOption(DEFAULT_GROUP_BACKGROUND_COLOR_KEY, defaultGroupBackgroundColor,+ options.registerThemeColorBinding(DEFAULT_GROUP_BACKGROUND_COLOR_KEY,+ defaultGroupBackgroundColor.getId(),help, DEFAULT_GROUP_BACKGROUND_COLOR_DESCRPTION);options.registerOption(UPDATE_GROUP_AND_UNGROUP_COLORS, updateGroupColorsAutomatically,@@ -185,24 +187,27 @@ public class FunctionGraphOptions extends VisualGraphOptions {options.registerOption(USE_FULL_SIZE_TOOLTIP_KEY, useFullSizeTooltip, help,USE_FULL_SIZE_TOOLTIP_DESCRIPTION);- options.registerOption(EDGE_COLOR_CONDITIONAL_JUMP_KEY, conditionalJumpEdgeColor, help,- "Conditional jump edge color");+ options.registerThemeColorBinding(EDGE_COLOR_CONDITIONAL_JUMP_KEY,+ conditionalJumpEdgeColor.getId(), help, "Conditional jump edge color");- options.registerOption(EDGE_UNCONDITIONAL_JUMP_COLOR_KEY, unconditionalJumpEdgeColor, help,+ options.registerThemeColorBinding(EDGE_UNCONDITIONAL_JUMP_COLOR_KEY,+ unconditionalJumpEdgeColor.getId(), help,"Unconditional jump edge color");- options.registerOption(EDGE_FALLTHROUGH_COLOR_KEY, fallthroughEdgeColor, help,+ options.registerThemeColorBinding(EDGE_FALLTHROUGH_COLOR_KEY, fallthroughEdgeColor.getId(),+ help,"Fallthrough edge color");- options.registerOption(EDGE_CONDITIONAL_JUMP_HIGHLIGHT_COLOR_KEY,- conditionalJumpEdgeHighlightColor, help,+ options.registerThemeColorBinding(EDGE_CONDITIONAL_JUMP_HIGHLIGHT_COLOR_KEY,+ conditionalJumpEdgeHighlightColor.getId(), help,"Conditional jump edge color when highlighting the reachablity of a vertex");- options.registerOption(EDGE_UNCONDITIONAL_JUMP_HIGHLIGHT_COLOR_KEY,- unconditionalJumpEdgeHighlightColor, help,+ options.registerThemeColorBinding(EDGE_UNCONDITIONAL_JUMP_HIGHLIGHT_COLOR_KEY,+ unconditionalJumpEdgeHighlightColor.getId(), help,"Unconditional jump edge color when highlighting the reachablity of a vertex");- options.registerOption(EDGE_FALLTHROUGH_HIGHLIGHT_COLOR_KEY, fallthroughEdgeHighlightColor,+ options.registerThemeColorBinding(EDGE_FALLTHROUGH_HIGHLIGHT_COLOR_KEY,+ fallthroughEdgeHighlightColor.getId(),help, "Fallthrough edge color when highlighting the reachablity of a vertex");}@@ -212,23 +217,6 @@ public class FunctionGraphOptions extends VisualGraphOptions {super.loadOptions(options);- conditionalJumpEdgeColor =- options.getColor(EDGE_COLOR_CONDITIONAL_JUMP_KEY, conditionalJumpEdgeColor);-- unconditionalJumpEdgeColor =- options.getColor(EDGE_UNCONDITIONAL_JUMP_COLOR_KEY, unconditionalJumpEdgeColor);-- fallthroughEdgeColor = options.getColor(EDGE_FALLTHROUGH_COLOR_KEY, fallthroughEdgeColor);-- conditionalJumpEdgeHighlightColor = options.getColor(- EDGE_CONDITIONAL_JUMP_HIGHLIGHT_COLOR_KEY, conditionalJumpEdgeHighlightColor);-- unconditionalJumpEdgeHighlightColor = options.getColor(- EDGE_UNCONDITIONAL_JUMP_HIGHLIGHT_COLOR_KEY, unconditionalJumpEdgeHighlightColor);-- fallthroughEdgeHighlightColor =- options.getColor(EDGE_FALLTHROUGH_HIGHLIGHT_COLOR_KEY, fallthroughEdgeHighlightColor);-relayoutOption = options.getEnum(RELAYOUT_OPTIONS_KEY, relayoutOption);navigationHistoryChoice =@@ -236,12 +224,6 @@ public class FunctionGraphOptions extends VisualGraphOptions {useFullSizeTooltip = options.getBoolean(USE_FULL_SIZE_TOOLTIP_KEY, useFullSizeTooltip);- defaultVertexBackgroundColor =- options.getColor(DEFAULT_VERTEX_BACKGROUND_COLOR_KEY, defaultVertexBackgroundColor);-- defaultGroupBackgroundColor =- options.getColor(DEFAULT_GROUP_BACKGROUND_COLOR_KEY, defaultGroupBackgroundColor);-updateGroupColorsAutomatically =options.getBoolean(UPDATE_GROUP_AND_UNGROUP_COLORS, updateGroupColorsAutomatically);diff --git a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.java b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.javaindex 65739e4419..770f47d818 100644--- a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.java+++ b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.java@@ -97,8 +97,8 @@ public class ProgramDiffPlugin extends ProgramPluginprivate static final String SELECTION_GROUP = "Selection Colors";private static final String DIFF_HIGHLIGHT_COLOR_NAME =SELECTION_GROUP + Options.DELIMITER + "Difference Color";- private Color diffHighlightColor = new GColor("color.bg.programdiff.highlight");- private Color cursorHighlightColor;+ private GColor diffHighlightColor = new GColor("color.bg.programdiff.highlight");+ private Color cursorHighlightColor = GhidraOptions.DEFAULT_CURSOR_LINE_COLOR;protected static final HelpService help = Help.getHelpService();private GoToService goToService;@@ -376,11 +376,9 @@ public class ProgramDiffPlugin extends ProgramPluginboolean diffHighlightChanged = false;if (options.getName().equals(GhidraOptions.CATEGORY_BROWSER_FIELDS)) {if (optionsName.equals(DIFF_HIGHLIGHT_COLOR_NAME)) {- diffHighlightColor = ((Color) newValue);diffHighlightChanged = true;}else if (optionsName.equals(GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR)) {- cursorHighlightColor = (Color) newValue;if (p2CursorMarkers != null) {p2CursorMarkers.setMarkerColor(cursorHighlightColor);}@@ -397,7 +395,6 @@ public class ProgramDiffPlugin extends ProgramPlugin}if (diffHighlightChanged) {- diffHighlightColor = ((Color) newValue);MarkerSet diffMarkers = getDiffMarkers();diffMarkers.setMarkerColor(diffHighlightColor);@@ -1398,14 +1395,11 @@ public class ProgramDiffPlugin extends ProgramPluginprivate void setupOptions() {String OPTIONS_TITLE = GhidraOptions.CATEGORY_BROWSER_FIELDS;ToolOptions opt = tool.getOptions(OPTIONS_TITLE);- opt.registerOption(DIFF_HIGHLIGHT_COLOR_NAME, diffHighlightColor,+ opt.registerThemeColorBinding(DIFF_HIGHLIGHT_COLOR_NAME, diffHighlightColor.getId(),new HelpLocation("CodeBrowserPlugin", "Browser_Fields"),"Color used to highlight differences between two programs.");- Color c = opt.getColor(DIFF_HIGHLIGHT_COLOR_NAME, diffHighlightColor);- diffHighlightColor = c;opt.addOptionsChangeListener(this);- cursorHighlightColor = opt.getColor(GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR, null);isHighlightCursorLine = opt.getBoolean(GhidraOptions.HIGHLIGHT_CURSOR_LINE, false);}diff --git a/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.java b/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.javaindex 9bf7dc04da..56d56235f0 100644--- a/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.java+++ b/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.java@@ -395,7 +395,7 @@ public class Gui {*/public static void setColor(String id, Color color) {if (color == null) {-+ throw new IllegalArgumentException("Can't set theme value to null!");}if (color instanceof GColor gColor) {if (id.equals(gColor.getId())) {diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.javaindex 7ffd84aeba..a1fe2c2673 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.java@@ -26,7 +26,8 @@ import javax.swing.KeyStroke;import javax.swing.SwingUtilities;import generic.theme.*;-import ghidra.util.*;+import ghidra.util.HelpLocation;+import ghidra.util.Msg;import ghidra.util.datastruct.WeakDataStructureFactory;import ghidra.util.datastruct.WeakSet;import ghidra.util.exception.AssertException;@@ -140,24 +141,10 @@ public abstract class AbstractOptions implements Options {}if (type == OptionType.COLOR_TYPE) {- if (defaultValue instanceof GColor gColor) {- registerThemeColor(optionName, gColor.getId(), help, description, editor);- return;- }- warnNonThemeValue("Registering non theme color: " + optionName);+ warnShouldUseTheme("Color");}if (type == OptionType.FONT_TYPE) {- if (defaultValue instanceof String fontId) {- registerThemeFont(optionName, fontId, help, description);- return;- }- String message = "Registering non theme font: " + optionName;- if (SystemUtilities.isInDevelopmentMode()) {- Msg.warn(this, message, ReflectionUtilities.createJavaFilteredThrowable());- }- else {- Msg.warn(this, message);- }+ warnShouldUseTheme("font");}if (!type.isCompatible(defaultValue)) {@@ -187,28 +174,30 @@ public abstract class AbstractOptions implements Options {valueMap.put(optionName, option);}- protected void warnNonThemeValue(String message) {- if (SystemUtilities.isInDevelopmentMode()) {- Msg.warn(this, message, ReflectionUtilities.createJavaFilteredThrowable());- }- else {- Msg.warn(this, message);- }+ private void warnShouldUseTheme(String optionType) {+ Throwable throwable =+ ReflectionUtilities.createThrowableWithStackOlderThan(AbstractOptions.class,+ SubOptions.class);+ String call = throwable.getStackTrace()[0].toString();+ Msg.warn(this, "Registering a direct " + optionType + " in the options is deprecated." ++ " Use registerTheme" + optionType + "Binding() instead!\n Called from " + call + "\n");}- private void registerThemeColor(String optionName, String colorId, HelpLocation help,- String description, PropertyEditor editor) {+ @Override+ public void registerThemeColorBinding(String optionName, String colorId, HelpLocation help,+ String description) {Option currentOption = getExistingComptibleOption(optionName, OptionType.COLOR_TYPE);if (currentOption != null && currentOption instanceof ThemeColorOption) {- currentOption.updateRegistration(description, help, null, editor);+ currentOption.updateRegistration(description, help, null, null);return;}description += " (Theme Color: " + colorId + ")";- Option option = new ThemeColorOption(optionName, colorId, description, help, editor);+ Option option = new ThemeColorOption(optionName, colorId, description, help);valueMap.put(optionName, option);}- private void registerThemeFont(String optionName, String fontId, HelpLocation help,+ @Override+ public void registerThemeFontBinding(String optionName, String fontId, HelpLocation help,String description) {if (Gui.getFont(fontId) == null) {throw new IllegalArgumentException("Invalid theme font id: \"" + fontId + "\"");diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.javaindex 256d38df63..e9e666698e 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.java@@ -149,6 +149,29 @@ public interface Options {public void registerOption(String optionName, OptionType type, Object defaultValue,HelpLocation help, String description, PropertyEditor editor);+ /**+ * Register/binds the option to a theme color id. Changing the option's color via the options+ * Gui will result in directly changing the theme color of the given color id.+ * @param optionName the name of the color option+ * @param colorId the theme color id whose color value is changed when the option's color is changed+ * @param help the HelpLocation for this option+ * @param description a description of the option+ */+ public void registerThemeColorBinding(String optionName, String colorId, HelpLocation help,+ String description);++ /**+ * Register/binds the option to a theme font id. Changing the option's font via the options+ * Gui will result in directly changing the theme color of the given font id.+ * @param optionName the name of the font option+ * @param fontId the theme color id whose color value is changed when the option's color+ * is changed+ * @param help the HelpLocation for this option+ * @param description a description of the option+ */+ public void registerThemeFontBinding(String optionName, String fontId, HelpLocation help,+ String description);+/*** Register the options editor that will handle the editing for all the options or a sub group of options.* @param editor the custom editor panel to be used to edit the options or sub group of options.diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.javaindex 734bbccf2f..53b72c9fdb 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.java@@ -92,6 +92,18 @@ public class SubOptions implements Options {options.registerOption(prefix + optionName, type, defaultValue, help, description, editor);}+ @Override+ public void registerThemeColorBinding(String optionName, String colorId, HelpLocation help,+ String description) {+ options.registerThemeColorBinding(prefix + optionName, colorId, help, description);+ }++ @Override+ public void registerThemeFontBinding(String optionName, String fontId, HelpLocation help,+ String description) {+ options.registerThemeFontBinding(prefix + optionName, fontId, help, description);+ }+@Overridepublic void putObject(String optionName, Object obj) {options.putObject(prefix + optionName, obj);diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeColorOption.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeColorOption.javaindex 22cb07fb48..0b8e698279 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeColorOption.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeColorOption.java@@ -16,11 +16,11 @@package ghidra.framework.options;import java.awt.Color;-import java.beans.PropertyEditor;import generic.theme.GColor;import generic.theme.Gui;import ghidra.util.HelpLocation;+import ghidra.util.Msg;/*** Options implementation for theme color options. A ThemeColorOption is an option that, when@@ -32,18 +32,20 @@ public class ThemeColorOption extends Option {private String colorId;public ThemeColorOption(String optionName, String colorId, String description,- HelpLocation help, PropertyEditor editor) {- super(optionName, OptionType.COLOR_TYPE, description, help, null, true, editor);+ HelpLocation help) {+ super(optionName, OptionType.COLOR_TYPE, description, help, null, true, null);this.colorId = colorId;+ if (!Gui.hasColor(colorId)) {+ Msg.warn(this,+ "Registered a theme color option with a non-defined theme color id of \"" ++ colorId + "\"");+ }+}@Overridepublic Color getCurrentValue() {- GColor gColor = new GColor(colorId);- if (gColor.isUnresolved()) {- return null;- }- return gColor;+ return new GColor(colorId);}@Overridediff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeFontOption.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeFontOption.javaindex 5a0aa9ef04..428662bc66 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeFontOption.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/ThemeFontOption.java@@ -19,6 +19,7 @@ import java.awt.Font;import generic.theme.Gui;import ghidra.util.HelpLocation;+import ghidra.util.Msg;/*** Options implementation for theme font options. A ThemeFontOption is an option that, when@@ -33,6 +34,12 @@ public class ThemeFontOption extends Option {HelpLocation help) {super(optionName, OptionType.FONT_TYPE, description, help, null, true, null);this.fontId = fontId;+ if (!Gui.hasFont(fontId)) {+ Msg.warn(this,+ "Registered a theme font option with a non-defined theme font id of \"" ++ fontId + "\"");+ }+}@Overridediff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/options/VisualGraphOptions.java b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/options/VisualGraphOptions.javaindex 8569b09bf8..8272f256cc 100644--- a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/options/VisualGraphOptions.java+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/options/VisualGraphOptions.java@@ -57,7 +57,7 @@ public class VisualGraphOptions {"new graphs and already rendered graphs are zoomed and positioned. See the help for " +"more details.";- public static final Color DEFAULT_GRAPH_BACKGROUND_COLOR = new GColor("color.bg.visualgraph");+ public static final GColor DEFAULT_GRAPH_BACKGROUND_COLOR = new GColor("color.bg.visualgraph");protected Color graphBackgroundColor = DEFAULT_GRAPH_BACKGROUND_COLOR;protected boolean useAnimation = true;@@ -122,7 +122,8 @@ public class VisualGraphOptions {options.registerOption(SCROLL_WHEEL_PANS_KEY, getScrollWheelPans(), help,SCROLL_WHEEL_PANS_DESCRIPTION);- options.registerOption(GRAPH_BACKGROUND_COLOR_KEY, DEFAULT_GRAPH_BACKGROUND_COLOR, help,+ options.registerThemeColorBinding(GRAPH_BACKGROUND_COLOR_KEY,+ DEFAULT_GRAPH_BACKGROUND_COLOR.getId(), help,GRAPH_BACKGROUND_COLOR_DESCRPTION);}diff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.java b/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.javaindex 044592d846..f02cfa4250 100644--- a/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.java+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.java@@ -87,9 +87,9 @@ public class GraphDisplayOptions implements OptionsChangeListener {private int maxNodeCount = 500; // graph display struggles with too many nodes- private Set<String> vertexRegistrations = new HashSet<>();- private Set<String> edgeRegistrations = new HashSet<>();- private Set<String> defaultRegistrations = new HashSet<>();+ private Map<String, String> vertexRegistrations = new HashMap<>();+ private Map<String, String> edgeRegistrations = new HashMap<>();+ private Map<String, String> defaultRegistrations = new HashMap<>();/*** Constructs a new GraphTypeDisplayOptions for the given {@link GraphType}@@ -168,7 +168,7 @@ public class GraphDisplayOptions implements OptionsChangeListener {*/public void setDefaultVertexColor(String themeColorId) {this.defaultVertexColor = new GColor(themeColorId);- defaultRegistrations.add(DEFAULT_VERTEX_COLOR);+ defaultRegistrations.put(DEFAULT_VERTEX_COLOR, themeColorId);}/**@@ -186,7 +186,7 @@ public class GraphDisplayOptions implements OptionsChangeListener {*/public void setDefaultEdgeColor(String themeColorId) {this.defaultEdgeColor = new GColor(themeColorId);- defaultRegistrations.add(DEFAULT_EDGE_COLOR);+ defaultRegistrations.put(DEFAULT_EDGE_COLOR, themeColorId);}/**@@ -399,7 +399,7 @@ public class GraphDisplayOptions implements OptionsChangeListener {public void setVertexColor(String vertexType, String themeColorId) {checkVertexType(vertexType);vertexColorMap.put(vertexType, new GColor(Objects.requireNonNull(themeColorId)));- vertexRegistrations.add(vertexType);+ vertexRegistrations.put(vertexType, themeColorId);}private String getVertexShapeName(String vertexType) {@@ -435,7 +435,7 @@ public class GraphDisplayOptions implements OptionsChangeListener {public void setEdgeColor(String edgeType, String themeColorId) {checkEdgeType(edgeType);edgeColorMap.put(edgeType, new GColor(Objects.requireNonNull(themeColorId)));- edgeRegistrations.add(edgeType);+ edgeRegistrations.put(edgeType, themeColorId);}/**@@ -526,7 +526,7 @@ public class GraphDisplayOptions implements OptionsChangeListener {*/public void setVertexSelectionColor(String themeColorId) {this.vertexSelectionColor = new GColor(themeColorId);- defaultRegistrations.add(VERTEX_SELECTION_COLOR);+ defaultRegistrations.put(VERTEX_SELECTION_COLOR, themeColorId);}/**@@ -553,7 +553,7 @@ public class GraphDisplayOptions implements OptionsChangeListener {*/public void setEdgeSelectionColor(String themeColorId) {this.edgeSelectionColor = new GColor(themeColorId);- defaultRegistrations.add(EDGE_SELECTION_COLOR);+ defaultRegistrations.put(EDGE_SELECTION_COLOR, themeColorId);}/**@@ -829,9 +829,10 @@ public class GraphDisplayOptions implements OptionsChangeListener {Options options = rootOptions.getOptions(VERTEX_COLORS);for (String vertexType : graphType.getVertexTypes()) {- if (vertexRegistrations.contains(vertexType)) {- options.registerOption(vertexType, OptionType.COLOR_TYPE,- getVertexColor(vertexType), help, "Choose the color for this vertex type");+ if (vertexRegistrations.containsKey(vertexType)) {+ options.registerThemeColorBinding(vertexType,+ vertexRegistrations.get(vertexType), help,+ "Choose the color for this vertex type");}}List<String> list = new ArrayList<>(graphType.getVertexTypes());@@ -859,8 +860,9 @@ public class GraphDisplayOptions implements OptionsChangeListener {Options options = rootOptions.getOptions(EDGE_COLORS);for (String edgeType : graphType.getEdgeTypes()) {- if (edgeRegistrations.contains(edgeType)) {- options.registerOption(edgeType, OptionType.COLOR_TYPE, getEdgeColor(edgeType),+ if (edgeRegistrations.containsKey(edgeType)) {+ options.registerThemeColorBinding(edgeType,+ edgeRegistrations.get(edgeType),help, "Choose the color for this edge type");}}@@ -879,27 +881,31 @@ public class GraphDisplayOptions implements OptionsChangeListener {"Graphs with more than this number of nodes will not be displayed. (Large graphs can cause Ghidra to become unstable/sluggish)");StringWithChoicesEditor editor = new StringWithChoicesEditor(VertexShape.getShapeNames());- if (defaultRegistrations.contains(VERTEX_SELECTION_COLOR)) {+ if (defaultRegistrations.containsKey(VERTEX_SELECTION_COLOR)) {optionNamesInDisplayOrder.add(VERTEX_SELECTION_COLOR);- options.registerOption(VERTEX_SELECTION_COLOR, OptionType.COLOR_TYPE,- vertexSelectionColor, help, "Color for highlighting selected vertices");+ options.registerThemeColorBinding(VERTEX_SELECTION_COLOR,+ defaultRegistrations.get(VERTEX_SELECTION_COLOR),+ help, "Color for highlighting selected vertices");}- if (defaultRegistrations.contains(EDGE_SELECTION_COLOR)) {+ if (defaultRegistrations.containsKey(EDGE_SELECTION_COLOR)) {optionNamesInDisplayOrder.add(EDGE_SELECTION_COLOR);- options.registerOption(EDGE_SELECTION_COLOR, OptionType.COLOR_TYPE, edgeSelectionColor,+ options.registerThemeColorBinding(EDGE_SELECTION_COLOR,+ defaultRegistrations.get(EDGE_SELECTION_COLOR),help, "Color for highlighting selected edge");}- if (defaultRegistrations.contains(DEFAULT_VERTEX_COLOR)) {+ if (defaultRegistrations.containsKey(DEFAULT_VERTEX_COLOR)) {optionNamesInDisplayOrder.add(DEFAULT_VERTEX_COLOR);- options.registerOption(DEFAULT_VERTEX_COLOR, OptionType.COLOR_TYPE, defaultVertexColor,+ options.registerThemeColorBinding(DEFAULT_VERTEX_COLOR,+ defaultRegistrations.get(DEFAULT_VERTEX_COLOR),help, "Color for vertices that have no vertex type defined");}- if (defaultRegistrations.contains(DEFAULT_EDGE_COLOR)) {+ if (defaultRegistrations.containsKey(DEFAULT_EDGE_COLOR)) {optionNamesInDisplayOrder.add(DEFAULT_EDGE_COLOR);- options.registerOption(DEFAULT_EDGE_COLOR, OptionType.COLOR_TYPE, defaultEdgeColor,+ options.registerThemeColorBinding(DEFAULT_EDGE_COLOR,+ defaultRegistrations.get(DEFAULT_EDGE_COLOR),help, "Color for edge that have no edge type defined");}@@ -927,7 +933,7 @@ public class GraphDisplayOptions implements OptionsChangeListener {if (themeFontId != null) {optionNamesInDisplayOrder.add(FONT);- options.registerOption(FONT, OptionType.FONT_TYPE, themeFontId, help,+ options.registerThemeFontBinding(FONT, themeFontId, help,"Font to use for vertex labels");}