Skip to content

Ghidra is a software reverse engineering (SRE) framework

Fixed options registration guffaw

dragonmacher1e17aa7d5e3a
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.java b/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.java
index 4e3e7eed89..4c3ca57cc3 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/GhidraOptions.java
@@ -87,6 +87,11 @@ public interface GhidraOptions {
*/
final String OPTION_SEARCH_LIMIT = "Search Limit";
+ /**
+ * Options title the search category
+ */
+ final String OPTION_SEARCH_TITLE = "Search";
+
/**
* Category name for the "Auto Analysis" options.
*/
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.java
index d7b0d4b90e..50e0090637 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
@@ -37,9 +37,11 @@ class LocationReferencesHighlighter {
private static final String MARKER_SET_DESCRIPTION = "Shows the location of references " +
"currently displayed in the Location References window.";
- private static final String OPTIONS_TITLE = GhidraOptions.CATEGORY_BROWSER_FIELDS;
- private static final String HIGHLIGHT_COLOR =
- "References Highlight" + GhidraOptions.DELIMITER + "Color";
+ private static final String OPTIONS_TITLE = GhidraOptions.OPTION_SEARCH_TITLE;
+ private static final String HIGHLIGHT_COLOR_KEY =
+ "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 = new Color(168, 202, 242);
private boolean isHighlighting = false;
@@ -54,12 +56,21 @@ class LocationReferencesHighlighter {
@Override
public void optionsChanged(ToolOptions options, String name, Object oldValue,
Object newValue) {
- if (name.equals(HIGHLIGHT_COLOR)) {
+ 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,
+ plugin.getHelpLocation(), HIGHLIGHT_COLOR_DESCRIPTION);
+ }
+
LocationReferencesHighlighter(LocationReferencesPlugin locationReferencesPlugin,
LocationReferencesProvider provider, Navigatable navigatable) {
this.locationReferencesPlugin = locationReferencesPlugin;
@@ -71,8 +82,7 @@ class LocationReferencesHighlighter {
this.provider = provider;
ToolOptions options = locationReferencesPlugin.getTool().getOptions(OPTIONS_TITLE);
- options.registerOption(HIGHLIGHT_COLOR, DEFAULT_HIGHLIGHT_COLOR, null, null);
- highlightColor = options.getColor(HIGHLIGHT_COLOR, DEFAULT_HIGHLIGHT_COLOR);
+ highlightColor = options.getColor(HIGHLIGHT_COLOR_KEY, DEFAULT_HIGHLIGHT_COLOR);
options.addOptionsChangeListener(optionsListener);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesPlugin.java
index 970b697836..f79cba063a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesPlugin.java
@@ -74,6 +74,7 @@ public class LocationReferencesPlugin extends Plugin
@Override
protected void init() {
initOptions();
+ LocationReferencesHighlighter.registerHighlighterOptions(this);
}
private void initOptions() {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesProvider.java
index d2a13de27b..25e2c74eea 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesProvider.java
@@ -25,7 +25,6 @@ import javax.swing.event.ChangeListener;
import docking.ActionContext;
import docking.action.*;
import docking.widgets.table.GTable;
-import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.nav.Navigatable;
import ghidra.app.nav.NavigatableRemovalListener;
import ghidra.app.services.GoToService;
@@ -153,11 +152,6 @@ public class LocationReferencesProvider extends ComponentProviderAdapter
referencesPanel.reloadModel();
}
- private void doMakeSelection() {
- locationReferencesPlugin.firePluginEvent(new ProgramSelectionPluginEvent(
- locationReferencesPlugin.getName(), referencesPanel.getSelection(), program));
- }
-
private void setLocationDescriptor(LocationDescriptor locationDescriptor,
Navigatable navigatable) {
// turn off highlighting, as we have a new descriptor, which may change the data