Ghidra is a software reverse engineering (SRE) framework
GP-2914 fixed issue with snapshot listing colors. Also, cleaned up color usage in FieldFactories
ghidragondb464c8bb2b0
diff --git a/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.java b/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.javaindex 275832cae7..4e44965edf 100644--- a/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.java+++ b/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.java@@ -20,6 +20,7 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.AttributedString;import docking.widgets.fieldpanel.field.TextFieldElement;import docking.widgets.fieldpanel.support.FieldLocation;+import generic.theme.GColor;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.field.*;import ghidra.app.util.viewer.format.FieldFormatModel;@@ -42,6 +43,7 @@ import ghidra.taint.model.TaintVec;*/public class TaintFieldFactory extends FieldFactory {public static final String PROPERTY_NAME = TaintTracePcodeExecutorStatePiece.NAME;+ public static final GColor COLOR = new GColor("color.fg.listing.taint");public static final String FIELD_NAME = "Taint";public TaintFieldFactory() {@@ -90,7 +92,7 @@ public class TaintFieldFactory extends FieldFactory {}return ListingTextField.createSingleLineTextField(this, proxy,- new TextFieldElement(new AttributedString(vec.toDisplay(), color, getMetrics()), 0, 0),+ new TextFieldElement(new AttributedString(vec.toDisplay(), COLOR, getMetrics()), 0, 0),startX + varWidth, width, hlProvider);}diff --git a/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.java b/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.javaindex 6231750e8c..ab78eb369d 100644--- a/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.java+++ b/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.java@@ -21,8 +21,8 @@ import java.util.List;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;+import generic.theme.GColor;import generic.theme.GThemeDefaults.Colors.Messages;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.field.*;import ghidra.app.util.viewer.format.FieldFormatModel;@@ -35,6 +35,7 @@ import ghidra.program.util.ProgramLocation;import ghidra.util.classfinder.ClassSearcher;public class ExternalDisassemblyFieldFactory extends FieldFactory {+ public static final GColor COLOR = new GColor("color.fg.listing.disassembly.external");private static List<ExternalDisassembler> availableDisassemblers;@@ -65,12 +66,6 @@ public class ExternalDisassemblyFieldFactory extends FieldFactory {super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);}- @Override- public void fieldOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- // have no options- }-@Overridepublic boolean acceptsType(int category, Class<?> proxyObjectClass) {return (category == FieldFormatModel.INSTRUCTION_OR_DATA);@@ -131,7 +126,7 @@ public class ExternalDisassemblyFieldFactory extends FieldFactory {if (disassembly == null) {return null;}- AttributedString text = new AttributedString(disassembly, Palette.BLACK, getMetrics());+ AttributedString text = new AttributedString(disassembly, COLOR, getMetrics());FieldElement fieldElement = new TextFieldElement(text, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, fieldElement,startX + varWidth, width, hlProvider);diff --git a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.java b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.javaindex 785835ba99..c5dfc43960 100644--- a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.java+++ b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.java@@ -20,6 +20,7 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;+import generic.theme.GColor;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.field.*;import ghidra.app.util.viewer.format.FieldFormatModel;@@ -34,6 +35,7 @@ import ghidra.program.util.ProgramLocation;public class EntropyFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Entropy";+ public static final GColor COLOR = new GColor("color.fg.listing.bytes.entropy");StringBuffer sb = new StringBuffer();/**@@ -80,19 +82,19 @@ public class EntropyFieldFactory extends FieldFactory {}entropy = calcEntropy(bytes, 0, bytes.length);float[] hsbvals = Color.RGBtoHSB(255, 0, 0, null);- color =+ Color color =Color.getHSBColor(hsbvals[0], hsbvals[1], (float) (hsbvals[1] * (entropy / 8.0)));+ String str = "" + (int) ((entropy / 8.0) * 100);+ AttributedString text = new AttributedString(str, color, getMetrics());++ FieldElement fieldElement = new TextFieldElement(text, 0, 0);+ return ListingTextField.createSingleLineTextField(this, proxy, fieldElement,+ startX + varWidth, width, hlProvider);}catch (MemoryAccessException e) {return null;}- String str = "" + (int) ((entropy / 8.0) * 100);- AttributedString text = new AttributedString(str, color, getMetrics());-- FieldElement fieldElement = new TextFieldElement(text, 0, 0);- return ListingTextField.createSingleLineTextField(this, proxy, fieldElement,- startX + varWidth, width, hlProvider);}private double calcEntropy(byte[] b, int start, int len) {@@ -153,8 +155,8 @@ public class EntropyFieldFactory extends FieldFactory {@Overridepublic FieldFactory newInstance(FieldFormatModel myModel, HighlightProvider myHlProvider,- ToolOptions displayOptions, ToolOptions fieldOptions) {- return new EntropyFieldFactory(myModel, myHlProvider, displayOptions, fieldOptions);+ ToolOptions displayOptions1, ToolOptions fieldOptions) {+ return new EntropyFieldFactory(myModel, myHlProvider, displayOptions1, fieldOptions);}}diff --git a/Ghidra/Features/Base/data/base.listing.theme.properties b/Ghidra/Features/Base/data/base.listing.theme.propertiesindex aa2a699135..5c98d9f3ae 100644--- a/Ghidra/Features/Base/data/base.listing.theme.properties+++ b/Ghidra/Features/Base/data/base.listing.theme.properties@@ -22,11 +22,10 @@ color.cursor.focused.listing = color.cursor.focusedcolor.cursor.unfocused.listing = color.cursor.unfocusedcolor.fg.listing.address = color.fg-color.fg.listing.ref.bad = redcolor.fg.listing.bytes = bluecolor.fg.listing.constant = greencolor.fg.listing.label.unreferenced = black-color.fg.listing.entrypoint = magenta+color.fg.listing.ext.entrypoint = magentacolor.fg.listing.comment.auto = lightGraycolor.fg.listing.comment.eol = bluecolor.fg.listing.comment.repeatable = darkOrange@@ -34,7 +33,9 @@ color.fg.listing.comment.ref.repeatable = cornflowerBluecolor.fg.listing.comment.plate = graycolor.fg.listing.comment.post = bluecolor.fg.listing.comment.pre = indigo-color.fg.listing.ref.ext.resolved = teal+color.fg.listing.ref.bad = red+color.fg.listing.ext.ref.unresolved = color.fg.listing.ref.bad+color.fg.listing.ext.ref.resolved = tealcolor.fg.listing.fieldname = color.fgcolor.fg.listing.function.callfixup = fuchsiacolor.fg.listing.function.name = blue@@ -44,20 +45,33 @@ color.fg.listing.function.param.auto = graycolor.fg.listing.function.return.type = blackcolor.fg.listing.function.param.custom = indigocolor.fg.listing.function.param.dynamic = #006666+color.fg.listing.function.variable = purple+color.fg.listing.function.variable.assigned = purple+color.fg.listing.function.name.thunk = color.fg.listing.function.name+color.fg.listing.label.local = greencolor.fg.listing.label.non.primary = olivecolor.fg.listing.label.primary = darkBluecolor.fg.listing.mnemonic.override = deepPinkcolor.fg.listing.mnemonic = navycolor.fg.listing.mnemonic.unimplemented = navy+color.fg.listing.array.values = color.fg+color.fg.listing.bytes.alignment = gray+color.fg.listing.bytes.entropy = color.fg+color.fg.listing.disassembly.external = color.fg+color.fg.listing.file.offset = color.fg+color.fg.listing.function.purge = blue+color.fg.listing.function.source = color.fg+color.fg.listing.mask.bits = navy+color.fg.listing.mask.value = green+color.fg.listing.mask.label = color.fg+color.fg.listing.block.start = indigo+color.fg.listing.instruction.parallel = blue-// TODOcolor.fg.listing.flow.arrow.inactive = lightGraycolor.fg.listing.flow.arrow.active = color.fgcolor.fg.listing.flow.arrow.selected = limeGreencolor.fg.listing.separator = color.fg-color.fg.listing.variable = purple-color.fg.listing.version.tracking = purplecolor.fg.listing.xref = darkGreencolor.fg.listing.xref.offcut = graycolor.fg.listing.xref.read = blue@@ -66,9 +80,12 @@ color.fg.listing.xref.other = color.fgcolor.fg.listing.register = olivecolor.fg.listing.underline = cornflowerBluecolor.fg.listing.pcode.label = blue-color.fg.listing.pcode.space = blue+color.fg.listing.pcode.address.space = bluecolor.fg.listing.pcode.varnode = bluecolor.fg.listing.pcode.userop = blue++color.fg.listing.stack.depth = blue+color.fg.listing.taint = color.fgcolor.bg.listing.comparison.bytes = chartreusecolor.bg.listing.comparison.mnemonic = chartreuse@@ -97,10 +114,8 @@ color.fg.listing.header.active.field = blackcolor.fg.listing.address = color.fg-color.fg.listing.ref.bad = color.palette.redcolor.fg.listing.bytes = color.palette.bluecolor.fg.listing.constant = color.palette.green-color.fg.listing.label.unreferenced = color.fgcolor.fg.listing.entrypoint = color.palette.magentacolor.fg.listing.comment.auto = color.fgcolor.fg.listing.comment.eol = color.palette.blue@@ -109,7 +124,7 @@ color.fg.listing.comment.ref.repeatable = color.palette.darkcyancolor.fg.listing.comment.plate = graycolor.fg.listing.comment.post = color.palette.bluecolor.fg.listing.comment.pre = color.palette.indigo-color.fg.listing.ref.ext.resolved = color.palette.teal+color.fg.listing.ref.resolved = color.palette.tealcolor.fg.listing.fieldname = color.fgcolor.fg.listing.function.callfixup = color.palette.magentacolor.fg.listing.function.name = color.palette.blue@@ -119,9 +134,12 @@ color.fg.listing.function.param.auto = graycolor.fg.listing.function.return.type = color.fgcolor.fg.listing.function.param.custom = color.palette.indigocolor.fg.listing.function.param.dynamic = color.palette.teal+color.fg.listing.function.variable = color.palette.purple+color.fg.listing.function.variable.assigned = color.palette.purplecolor.fg.listing.label.local = color.palette.greencolor.fg.listing.label.non.primary = color.palette.olivecolor.fg.listing.label.primary = color.palette.cyan+color.fg.listing.label.unreferenced = color.fgcolor.fg.listing.mnemonic.override = color.palette.pinkcolor.fg.listing.mnemonic = color.palette.cyancolor.fg.listing.mnemonic.unimplemented = color.palette.cyan@@ -131,7 +149,6 @@ color.fg.listing.flow.arrow.inactive = lightGraycolor.fg.listing.flow.arrow.active = color.fgcolor.fg.listing.flow.arrow.selected = limeGreencolor.fg.listing.separator = color.fg-color.fg.listing.variable = color.palette.purplecolor.fg.listing.version.tracking = color.palette.purplecolor.fg.listing.xref = color.palette.darkgreencolor.fg.listing.xref.offcut = gray@@ -141,6 +158,6 @@ color.fg.listing.xref.other = color.fgcolor.fg.listing.register = color.palette.olivecolor.fg.listing.underline = cornflowerBluecolor.fg.listing.pcode.label = color.palette.blue-color.fg.listing.pcode.space = color.palette.blue+color.fg.listing.pcode.address.space = color.palette.bluecolor.fg.listing.pcode.varnode = color.palette.bluecolor.fg.listing.pcode.userop = color.palette.bluediff --git a/Ghidra/Features/Base/data/base.theme.properties b/Ghidra/Features/Base/data/base.theme.propertiesindex 1cd006513a..4137cb6581 100644--- a/Ghidra/Features/Base/data/base.theme.properties+++ b/Ghidra/Features/Base/data/base.theme.properties@@ -5,11 +5,7 @@ color.bg.undefined = rgb(220, 220, 220) // bg for clients displaying undefined fcolor.flowtype.fall.through = redcolor.flowtype.jump.conditional = #007C00 // dark greencolor.flowtype.jump.unconditional = blue--color.function.thunk = color.palette.blue-color.fg.function.name = color.palette.blue-color.fg.function.params = color.palette.magenta-+color.bg.table.selection.bundle = [color]textHighlightcolor.fg.table.selection.bundle = [color]textHighlightTextcolor.fg.table.bundle.disabled = darkGray@@ -75,6 +71,8 @@ color.bg.plugin.datamgr.edge.composite = magentacolor.bg.plugin.datamgr.edge.reference = bluecolor.bg.plugin.datamgr.icon.highlight = rgb(204, 204, 255)+color.fg.plugin.disassembledview.address = color.fg+color.bg.plugin.editors.compositeeditor.text = color.fgcolor.bg.plugin.editors.compositeeditor.line = system.color.bordercolor.bg.plugin.editors.compositeeditor.line.interior = #D4D4D4@@ -87,11 +85,10 @@ color.bg.plugin.editors.compositeeditor.non.bit = #A0A0FFcolor.fg.plugin.equate.enum = lightskyblue-color.fg.plugin.function.editor.dialog.thunk = color.function.thunkcolor.fg.plugin.function.editor.dialog.textfield.default = color.fgcolor.fg.plugin.function.editor.dialog.textfield.error = color.fg.errorcolor.fg.plugin.function.editor.dialog.textfield.function.name = color.palette.blue-color.fg.plugin.function.editor.dialog.textfield.parameter = color.fg.function.params+color.fg.plugin.function.editor.dialog.textfield.parameter = color.fg.listing.function.paramcolor.bg.plugin.instructionsearch.table.masked.instruction = rgb(237, 243, 254) // faint bluecolor.bg.plugin.instructionsearch.table.masked.non.instruction = rgb(255, 242, 214) // tandiff --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 0f0ddb2889..81fc0e79d1 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@@ -40,12 +40,10 @@ import ghidra.app.plugin.core.codebrowser.hover.ListingHoverService;import ghidra.app.services.*;import ghidra.app.util.HighlightProvider;import ghidra.app.util.ProgramDropProvider;-import ghidra.app.util.viewer.field.ListingField;-import ghidra.app.util.viewer.field.ListingTextField;+import ghidra.app.util.viewer.field.*;import ghidra.app.util.viewer.format.*;import ghidra.app.util.viewer.listingpanel.*;import ghidra.app.util.viewer.options.ListingDisplayOptionsEditor;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.util.AddressIndexMap;import ghidra.framework.model.*;import ghidra.framework.options.*;@@ -112,7 +110,7 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> exconnectedProvider = createProvider(formatMgr, true);tool.showComponentProvider(connectedProvider, true);initOptions(fieldOptions);- initDisplayOptions(displayOptions);+ connectedProvider.getListingPanel().setTextBackgroundColor(ListingColors.BACKGROUND);initMiscellaneousOptions();displayOptions.addOptionsChangeListener(this);fieldOptions.addOptionsChangeListener(this);@@ -385,13 +383,7 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> exObject newValue) {ListingPanel listingPanel = connectedProvider.getListingPanel();- if (options.getName().equals(GhidraOptions.CATEGORY_BROWSER_DISPLAY)) {- if (optionName.equals(OptionsGui.BACKGROUND.getColorOptionName())) {- Color c = (Color) newValue;- listingPanel.setTextBackgroundColor(c);- }- }- else if (options.getName().equals(GhidraOptions.CATEGORY_BROWSER_FIELDS)) {+ if (options.getName().equals(GhidraOptions.CATEGORY_BROWSER_FIELDS)) {FieldPanel fieldPanel = listingPanel.getFieldPanel();if (optionName.equals(GhidraOptions.OPTION_SELECTION_COLOR)) {@@ -563,12 +555,9 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex"The highlight color in the browser.");fieldOptions.registerThemeColorBinding(CURSOR_COLOR_OPTIONS_NAME,- FOCUSED_CURSOR_COLOR.getId(),- helpLocation,- "The color of the cursor in the browser.");+ FOCUSED_CURSOR_COLOR.getId(), helpLocation, "The color of the cursor in the browser.");fieldOptions.registerThemeColorBinding(UNFOCUSED_CURSOR_COLOR_OPTIONS_NAME,- UNFOCUSED_CURSOR_COLOR.getId(),- helpLocation,+ UNFOCUSED_CURSOR_COLOR.getId(), helpLocation,"The color of the cursor in the browser when the browser does not have focus.");fieldOptions.registerOption(BLINK_CURSOR_OPTIONS_NAME, true, helpLocation,"When selected, the cursor will blink when the containing window is focused.");@@ -580,8 +569,7 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> exhelpLocation = new HelpLocation(getName(), "Keyboard_Controls_Shift");fieldOptions.registerOption(MOUSE_WHEEL_HORIZONTAL_SCROLLING_OPTIONS_NAME, true,- helpLocation,- "Enables horizontal scrolling by holding the Shift key while " ++ helpLocation, "Enables horizontal scrolling by holding the Shift key while " +"using the mouse scroll wheel");Color color = fieldOptions.getColor(GhidraOptions.OPTION_SELECTION_COLOR,@@ -594,9 +582,8 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> exselectionMarkers.setMarkerColor(color);}- color =- fieldOptions.getColor(GhidraOptions.OPTION_HIGHLIGHT_COLOR,- GhidraOptions.DEFAULT_HIGHLIGHT_COLOR);+ color = fieldOptions.getColor(GhidraOptions.OPTION_HIGHLIGHT_COLOR,+ GhidraOptions.DEFAULT_HIGHLIGHT_COLOR);MarkerSet highlightMarkers = getHighlightMarkers(currentProgram);fieldPanel.setHighlightColor(color);if (highlightMarkers != null) {@@ -622,12 +609,6 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> exisHighlightCursorLine = fieldOptions.getBoolean(GhidraOptions.HIGHLIGHT_CURSOR_LINE, true);}- private void initDisplayOptions(Options displayOptions) {- Color color = displayOptions.getColor(OptionsGui.BACKGROUND.getColorOptionName(),- OptionsGui.BACKGROUND.getDefaultColor());- connectedProvider.getListingPanel().setTextBackgroundColor(color);- }-private void initMiscellaneousOptions() {// make sure the following options are registeredHelpLocation helpLocation =diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.javaindex b8eaf1cd15..003142b2df 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java@@ -15,7 +15,8 @@*/package ghidra.app.plugin.core.disassembler;-import java.awt.*;+import java.awt.Color;+import java.awt.Component;import java.util.ArrayList;import java.util.List;@@ -24,15 +25,14 @@ import javax.swing.event.ChangeListener;import docking.WindowPosition;import docking.widgets.list.GListCellRenderer;+import generic.theme.GColor;import generic.theme.Gui;import ghidra.GhidraOptions;import ghidra.app.CorePluginPackage;import ghidra.app.plugin.PluginCategoryNames;import ghidra.app.plugin.ProgramPlugin;import ghidra.app.util.PseudoDisassembler;-import ghidra.app.util.viewer.field.BrowserCodeUnitFormat;-import ghidra.app.util.viewer.field.FieldFactory;-import ghidra.app.util.viewer.options.OptionsGui;+import ghidra.app.util.viewer.field.*;import ghidra.framework.model.DomainObjectChangedEvent;import ghidra.framework.model.DomainObjectListener;import ghidra.framework.options.OptionsChangeListener;@@ -78,6 +78,9 @@ import ghidra.util.exception.UsrException;)//@formatter:onpublic class DisassembledViewPlugin extends ProgramPlugin implements DomainObjectListener {+ private static final Color ADDRESS_COLOR =+ new GColor("color.fg.plugin.disassembledview.address");+/*** The number of addresses that should be disassembled, including the* address of the current {@link ProgramLocation}.@@ -324,24 +327,6 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec* The component provided for the DisassembledViewPlugin.*/private class DisassembledViewComponentProvider extends ComponentProviderAdapter {- /**- * Constant for the selection color setting.- */-- /**- * Constant for the address foreground color setting.- */- private static final String ADDRESS_COLOR_OPTION = "Address Color";-- /**- * Constant for the browser font setting.- */- private static final String ADDRESS_FONT_OPTION = "BASE FONT";- /**- * Constant for the browser's background setting.- */- private static final String BACKGROUND_COLOR_OPTION = "Background Color";-/*** The constant part of the tooltip text for the list cells. This* string is prepended to the currently selected address in the@@ -363,27 +348,6 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec*/private JList<DisassembledAddressInfo> contentList;- /**- * The color of the address in the list that represents the current- * selection in the code browser.- */- private Color selectedAddressColor;-- /**- * The color of the preview text.- */- private Color addressForegroundColor;-- /**- * The color for the list background.- */- private Color backgroundColor;-- /**- * The font for the list items.- */- private Font font;-/*** The preview style of the addresses being displayed.*/@@ -438,7 +402,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjecsuper.getListCellRendererComponent(list, value, index, isSelected,cellHasFocus);- setFont(font);+ setFont(Gui.getFont(FieldFactory.BASE_LISTING_FONT_ID));setToolTipText(TOOLTIP_TEXT_PREPEND +HTMLUtilities.escapeHTML(currentLocation.getAddress().toString()));@@ -446,8 +410,8 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec// make sure the first value is highlighted to indicate// that it is the selected program locationif (index == 0) {- Color foreground = addressForegroundColor;- Color background = selectedAddressColor;+ Color foreground = ADDRESS_COLOR;+ Color background = GhidraOptions.DEFAULT_SELECTION_COLOR;if (isSelected) {foreground = Gui.brighter(foreground);@@ -471,10 +435,6 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjecToolOptions opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);opt.addOptionsChangeListener(optionsChangeListener);- // current address background color- selectedAddressColor = opt.getColor(GhidraOptions.OPTION_SELECTION_COLOR,- GhidraOptions.DEFAULT_SELECTION_COLOR);-// the address preview styleaddressPreviewFormat = new BrowserCodeUnitFormat(tool);addressPreviewFormat.addChangeListener(addressFormatChangeListener);@@ -482,20 +442,9 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjecopt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_DISPLAY);opt.addOptionsChangeListener(optionsChangeListener);- // the preview text color- addressForegroundColor = opt.getColor(OptionsGui.SEPARATOR.getColorOptionName(),- OptionsGui.SEPARATOR.getDefaultColor());-- // background color- backgroundColor = opt.getColor(OptionsGui.BACKGROUND.getColorOptionName(),- OptionsGui.BACKGROUND.getDefaultColor());-- // font- font = Gui.getFont(FieldFactory.BASE_LISTING_FONT_ID);-- contentList.setForeground(addressForegroundColor);- contentList.setBackground(backgroundColor);- contentList.setFont(font);+ contentList.setForeground(ADDRESS_COLOR);+ contentList.setBackground(ListingColors.BACKGROUND);+ Gui.registerFont(contentList, "font.listing.base");}/**@@ -565,25 +514,6 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec@Overridepublic void optionsChanged(ToolOptions options, String optionName, Object oldValue,Object newValue) {- if (options.getName().equals(GhidraOptions.CATEGORY_BROWSER_FIELDS)) {- if (optionName.equals(GhidraOptions.OPTION_SELECTION_COLOR)) {- selectedAddressColor = (Color) newValue;- }- }- else if (options.getName().equals(GhidraOptions.CATEGORY_BROWSER_DISPLAY)) {- if (optionName.equals(ADDRESS_COLOR_OPTION)) {- addressForegroundColor = (Color) newValue;- contentList.setForeground(addressForegroundColor);- }- else if (optionName.equals(BACKGROUND_COLOR_OPTION)) {- backgroundColor = (Color) newValue;- contentList.setBackground(backgroundColor);- }- else if (optionName.equals(ADDRESS_FONT_OPTION)) {- font = Gui.getFont(FieldFactory.BASE_LISTING_FONT_ID);- }- }-// update the displaycontentList.repaint();}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 e99c3ddf73..26af74e77a 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@@ -28,6 +28,8 @@ import ghidra.app.CorePluginPackage;import ghidra.app.events.*;import ghidra.app.plugin.PluginCategoryNames;import ghidra.app.services.CodeViewerService;+import ghidra.app.util.viewer.field.ListingColors;+import ghidra.app.util.viewer.field.ListingColors.FlowArrowColors;import ghidra.app.util.viewer.listingpanel.*;import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.util.AddressIndexMap;@@ -434,8 +436,7 @@ public class FlowArrowPlugin extends Plugin implements MarginProvider, OptionsChList<FlowArrow> results = new ArrayList<>();ArrowCache arrowCache = new ArrowCache();CodeUnitIterator it = program.getListing()- .getCodeUnitIterator(- CodeUnit.INSTRUCTION_PROPERTY, screenAddresses, true);+ .getCodeUnitIterator(CodeUnit.INSTRUCTION_PROPERTY, screenAddresses, true);while (it.hasNext()) {CodeUnit cu = it.next();@@ -545,9 +546,8 @@ public class FlowArrowPlugin extends Plugin implements MarginProvider, OptionsChAddress bottomAddr = layoutToPixel.getLayoutAddress(n - 1);if (bottomAddr != null) {AddressSpace testSpace = bottomAddr.getAddressSpace();- validState = (program.getAddressFactory()- .getAddressSpace(- testSpace.getSpaceID()) == testSpace);+ validState =+ (program.getAddressFactory().getAddressSpace(testSpace.getSpaceID()) == testSpace);}}@@ -652,21 +652,10 @@ public class FlowArrowPlugin extends Plugin implements MarginProvider, OptionsChOptionsGui.FLOW_ARROW_SELECTED.getThemeColorId(), null,"The color for an arrow that has been selected by the user");- Color c = opt.getColor(OptionsGui.BACKGROUND.getColorOptionName(),- OptionsGui.BACKGROUND.getDefaultColor());- flowArrowPanel.setBackground(c);-- c = opt.getColor(OptionsGui.FLOW_ARROW_NON_ACTIVE.getColorOptionName(),- OptionsGui.FLOW_ARROW_NON_ACTIVE.getDefaultColor());- flowArrowPanel.setForeground(c);-- c = opt.getColor(OptionsGui.FLOW_ARROW_ACTIVE.getColorOptionName(),- OptionsGui.FLOW_ARROW_ACTIVE.getDefaultColor());- flowArrowPanel.setHighlightColor(c);-- c = opt.getColor(OptionsGui.FLOW_ARROW_SELECTED.getColorOptionName(),- OptionsGui.FLOW_ARROW_SELECTED.getDefaultColor());- flowArrowPanel.setSelectedColor(c);+ flowArrowPanel.setBackground(ListingColors.BACKGROUND);+ flowArrowPanel.setForeground(FlowArrowColors.INACTIVE);+ flowArrowPanel.setHighlightColor(FlowArrowColors.ACTIVE);+ flowArrowPanel.setSelectedColor(FlowArrowColors.SELECTED);opt.addOptionsChangeListener(this);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.javaindex 05d80a593b..0f1e8a5daa 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.java@@ -19,13 +19,12 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;+import generic.theme.GColor;import generic.theme.GThemeDefaults.Colors;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.cmd.function.CallDepthChangeInfo;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.field.*;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;import ghidra.framework.options.ToolOptions;@@ -36,6 +35,7 @@ import ghidra.program.util.StackDepthFieldLocation;public class StackDepthFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Stack Depth";+ public static final GColor COLOR = new GColor("color.fg.listing.stack.depth");private Address lastEntry = null;private CallDepthChangeInfo depth = null;private long lastModNumber = -1;@@ -47,9 +47,6 @@ public class StackDepthFieldFactory extends FieldFactory {private StackDepthFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,Options displayOptions, Options fieldOptions) {super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);- color = displayOptions.getColor(OptionsGui.BYTES.getColorOptionName(),- OptionsGui.BYTES.getDefaultColor());-}@Override@@ -88,7 +85,7 @@ public class StackDepthFieldFactory extends FieldFactory {// This can be used to display the value of any register symbolically flowing over the program.// depthString = depth.getRegValueRepresentation(cu.getMinAddress(), cu.getProgram().getRegister("ESP"));- AttributedString as = new AttributedString(depthString, Palette.BLUE, getMetrics());+ AttributedString as = new AttributedString(depthString, COLOR, getMetrics());Integer overrideDepth =CallDepthChangeInfo.getStackDepthChange(cu.getProgram(), cu.getMinAddress());@@ -166,5 +163,4 @@ public class StackDepthFieldFactory extends FieldFactory {}return (category == FieldFormatModel.INSTRUCTION_OR_DATA);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.javaindex 1f70f889e4..c58b54c84e 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.java@@ -35,7 +35,6 @@ import docking.widgets.checkbox.GCheckBox;import docking.widgets.combobox.GComboBox;import docking.widgets.label.GLabel;import docking.widgets.table.*;-import generic.theme.GColor;import generic.theme.GIcon;import generic.theme.GThemeDefaults.Colors;import generic.theme.GThemeDefaults.Colors.*;@@ -43,6 +42,7 @@ import generic.util.WindowUtilities;import ghidra.app.services.DataTypeManagerService;import ghidra.app.util.ToolTipUtils;import ghidra.app.util.cparser.C.CParserUtils;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.program.model.address.Address;import ghidra.program.model.data.DataType;import ghidra.program.model.listing.Function;@@ -54,8 +54,6 @@ import ghidra.util.layout.VerticalLayout;import resources.Icons;public class FunctionEditorDialog extends DialogComponentProvider implements ModelChangeListener {- private static final Color FG_COLOR_THUNK =- new GColor("color.fg.plugin.function.editor.dialog.thunk");private FunctionEditorModel model;private DocumentListener nameFieldDocumentListener;@@ -215,7 +213,7 @@ public class FunctionEditorDialog extends DialogComponentProvider implements ModBorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Java.BORDER),BorderFactory.createEmptyBorder(0, 5, 0, 5));thunkedText.setBorder(border);- thunkedText.setForeground(FG_COLOR_THUNK);+ thunkedText.setForeground(FunctionColors.THUNK);thunkedPanel.add(thunkedText);return thunkedPanel;}@@ -304,8 +302,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements ModsignatureTextField.setTabListener(tabListener);- signatureTextField.setChangeListener(- e -> model.setSignatureFieldText(signatureTextField.getText()));+ signatureTextField+ .setChangeListener(e -> model.setSignatureFieldText(signatureTextField.getText()));return panel;}@@ -334,9 +332,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Modmessage += "<BR><BR>";}- message = HTMLUtilities.wrapAsHTML(- message + "<CENTER><B>Do you want to continue editing or " +- "abort your changes?</B></CENTER>");+ message = HTMLUtilities.wrapAsHTML(message ++ "<CENTER><B>Do you want to continue editing or " + "abort your changes?</B></CENTER>");int result = OptionDialog.showOptionNoCancelDialog(rootPanel, "Invalid Function Signature",message, "Continue Editing", "Abort Changes", OptionDialog.ERROR_MESSAGE);return result == OptionDialog.OPTION_TWO; // Option 2 is to abort@@ -372,8 +369,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements ModnoReturnCheckBox = new GCheckBox("No Return");noReturnCheckBox.addItemListener(e -> model.setNoReturn(noReturnCheckBox.isSelected()));storageCheckBox = new GCheckBox("Use Custom Storage");- storageCheckBox.addItemListener(- e -> model.setUseCustomizeStorage(storageCheckBox.isSelected()));+ storageCheckBox+ .addItemListener(e -> model.setUseCustomizeStorage(storageCheckBox.isSelected()));panel.add(noReturnCheckBox);panel.add(storageCheckBox);panel.setBorder(BorderFactory.createTitledBorder("Function Attributes:"));@@ -386,8 +383,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements ModString[] names = new String[callingConventionNames.size()];callingConventionComboBox = new GComboBox<>(callingConventionNames.toArray(names));callingConventionComboBox.setSelectedItem(model.getCallingConventionName());- callingConventionComboBox.addItemListener(e -> model.setCallingConventionName(- (String) callingConventionComboBox.getSelectedItem()));+ callingConventionComboBox.addItemListener(e -> model+ .setCallingConventionName((String) callingConventionComboBox.getSelectedItem()));return callingConventionComboBox;}@@ -400,8 +397,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements ModcallFixupComboBox.addItem(FunctionEditorModel.NONE_CHOICE);if (callFixupNames.length != 0) {- callFixupComboBox.setToolTipText(- "Select call-fixup as defined by compiler specification");+ callFixupComboBox+ .setToolTipText("Select call-fixup as defined by compiler specification");for (String element : callFixupNames) {callFixupComboBox.addItem(element);}@@ -760,15 +757,13 @@ public class FunctionEditorDialog extends DialogComponentProvider implements ModsetToolTipText("Invalid Parameter Storage");}else {- setForeground(- isSelected ? table.getSelectionForeground() : Colors.FOREGROUND);+ setForeground(isSelected ? table.getSelectionForeground() : Colors.FOREGROUND);setToolTipText("");}setText(storage.toString());}else {- setForeground(- isSelected ? table.getSelectionForeground() : Colors.FOREGROUND);+ setForeground(isSelected ? table.getSelectionForeground() : Colors.FOREGROUND);setText("");setToolTipText(null);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.javaindex 6d995776bc..e018bfabde 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.java@@ -59,20 +59,16 @@ public class PcodeFieldFactory extends FieldFactory {super(name, model, highlightProvider, displayOptions, fieldOptions);setWidth(300);- color = displayOptions.getColor(OptionsGui.BYTES.getColorOptionName(),- OptionsGui.BYTES.getDefaultColor());style = displayOptions.getInt(OptionsGui.BYTES.getStyleOptionName(), -1);formatter = new AttributedStringPcodeFormatter();- setColors(displayOptions);setOptions(fieldOptions);}@Overridepublic FieldFactory newInstance(FieldFormatModel myModel, HighlightProvider highlightProvider,- ToolOptions displayOptions, ToolOptions fieldOptions) {- return new PcodeFieldFactory(FIELD_NAME, myModel, highlightProvider, displayOptions,- fieldOptions);+ ToolOptions options, ToolOptions fieldOptions) {+ return new PcodeFieldFactory(FIELD_NAME, myModel, highlightProvider, options, fieldOptions);}@Override@@ -150,7 +146,6 @@ public class PcodeFieldFactory extends FieldFactory {Object newValue) {super.displayOptionsChanged(options, optionName, oldValue, newValue);formatter.setFontMetrics(getMetrics());- setColors(options);}@Override@@ -166,37 +161,6 @@ public class PcodeFieldFactory extends FieldFactory {}}- /**- * Called when the fonts are first initialized or when one of the options changes. It looks up- * all the color settings and resets the its values.- */- private void setColors(Options options) {- formatter.setAddressColor(options.getColor(OptionsGui.ADDRESS.getColorOptionName(),- OptionsGui.ADDRESS.getDefaultColor()));- formatter.setRegisterColor(options.getColor(OptionsGui.REGISTERS.getColorOptionName(),- OptionsGui.REGISTERS.getDefaultColor()));- formatter.setScalarColor(options.getColor(OptionsGui.CONSTANT.getColorOptionName(),- OptionsGui.CONSTANT.getDefaultColor()));- formatter.setLocalColor(options.getColor(OptionsGui.LABELS_LOCAL.getColorOptionName(),- OptionsGui.LABELS_LOCAL.getDefaultColor()));- formatter.setMnemonicColor(options.getColor(OptionsGui.MNEMONIC.getColorOptionName(),- OptionsGui.MNEMONIC.getDefaultColor()));- formatter.setUnimplColor(options.getColor(OptionsGui.UNIMPL.getColorOptionName(),- OptionsGui.UNIMPL.getDefaultColor()));- formatter.setSeparatorColor(options.getColor(OptionsGui.SEPARATOR.getColorOptionName(),- OptionsGui.SEPARATOR.getDefaultColor()));- formatter.setLineLabelColor(- options.getColor(OptionsGui.PCODE_LINE_LABEL.getColorOptionName(),- OptionsGui.PCODE_LINE_LABEL.getDefaultColor()));- formatter.setSpaceColor(options.getColor(OptionsGui.PCODE_ADDR_SPACE.getColorOptionName(),- OptionsGui.PCODE_ADDR_SPACE.getDefaultColor()));- formatter.setRawColor(options.getColor(OptionsGui.PCODE_RAW_VARNODE.getColorOptionName(),- OptionsGui.PCODE_RAW_VARNODE.getDefaultColor()));- formatter.setUseropColor(options.getColor(OptionsGui.PCODE_USEROP.getColorOptionName(),- OptionsGui.PCODE_USEROP.getDefaultColor()));- formatter.setFontMetrics(getMetrics());- }-private void setOptions(Options fieldOptions) {fieldOptions.registerOption(MAX_DISPLAY_LINES_MSG, MAX_DISPLAY_LINES, null,"Max number line of pcode to display");@@ -206,5 +170,4 @@ public class PcodeFieldFactory extends FieldFactory {boolean displayRaw = fieldOptions.getBoolean(DISPLAY_RAW_PCODE, false);formatter.setOptions(maxDisplayLines, displayRaw);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/SymbolInspector.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/SymbolInspector.javaindex 233c7d4dff..35e46adcba 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/SymbolInspector.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/SymbolInspector.java@@ -434,13 +434,7 @@ public class SymbolInspector implements OptionsChangeListener {if (se == null) {return Colors.BACKGROUND;}- String optionName = se.getColorOptionName();- Color color = (Color) cache.get(optionName);- if (color == null) {- color = optionsObject.getColor(se.getColorOptionName(), se.getDefaultColor());- cache.put(optionName, color);- }- return color;+ return se.getDefaultColor();}private int getStyle(ScreenElement se) {@@ -450,7 +444,7 @@ public class SymbolInspector implements OptionsChangeListener {String optionName = se.getStyleOptionName();Integer style = (Integer) cache.get(optionName);if (style == null) {- style = Integer.valueOf(optionsObject.getInt(se.getStyleOptionName(), -1));+ style = optionsObject.getInt(optionName, -1);cache.put(optionName, style);}return style.intValue();diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/ToolTipUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/ToolTipUtils.javaindex 41b30272d3..efd670063a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/ToolTipUtils.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/ToolTipUtils.java@@ -23,10 +23,9 @@ import java.util.List;import org.apache.commons.lang3.StringUtils;-import generic.theme.GColor;import generic.theme.GThemeDefaults.Colors;import ghidra.app.util.html.*;-import ghidra.app.util.viewer.options.OptionsGui;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.program.model.address.Address;import ghidra.program.model.data.*;import ghidra.program.model.data.Enum;@@ -44,13 +43,6 @@ import ghidra.util.StringUtilities;*/public class ToolTipUtils {- private static final Color FG_FUNCTION_NAME = new GColor("color.fg.function.name");- private static final Color PARAM_NAME_COLOR = new GColor("color.fg.function.params");- private static final Color PARAM_CUSTOM_STORAGE_COLOR =- OptionsGui.PARAMETER_CUSTOM.getDefaultColor();- private static final Color PARAM_DYNAMIC_STORAGE_COLOR =- OptionsGui.PARAMETER_DYNAMIC.getDefaultColor();-private static final String ELLIPSES = "...";public static final int LINE_LENGTH = 80;private static final int PARAM_LENGTH_WRAP_THRESHOLD = LINE_LENGTH;@@ -269,11 +261,11 @@ public class ToolTipUtils {}Color paramColor =- usesCustomStorage ? PARAM_CUSTOM_STORAGE_COLOR : PARAM_DYNAMIC_STORAGE_COLOR;+ usesCustomStorage ? FunctionColors.PARAM_CUSTOM : FunctionColors.PARAM_DYNAMIC;buf.append(colorString(paramColor, friendlyEncodeHTML(param.getVariableStorage().toString())));buf.append("</td><td width=\"1%\">");- buf.append(colorString(PARAM_NAME_COLOR, friendlyEncodeHTML(name)));+ buf.append(colorString(FunctionColors.PARAM, friendlyEncodeHTML(name)));// consume remaining space and compact other columnsbuf.append("</td><td width=\"100%\"> </td></tr>");@@ -304,7 +296,7 @@ public class ToolTipUtils {}String functionName = StringUtilities.trimMiddle(function.getName(), LINE_LENGTH);- buffy.append(colorString(FG_FUNCTION_NAME, friendlyEncodeHTML(functionName)));+ buffy.append(colorString(FunctionColors.NAME, friendlyEncodeHTML(functionName)));buffy.append(HTML_SPACE).append("(");buildParameterPreview(function, buffy);@@ -405,7 +397,7 @@ public class ToolTipUtils {pb.append(colorString(Colors.FOREGROUND, friendlyEncodeHTML(type)));pb.append(HTML_SPACE);- pb.append(colorString(PARAM_NAME_COLOR, friendlyEncodeHTML(name)));+ pb.append(colorString(FunctionColors.NAME, friendlyEncodeHTML(name)));params.add(pb.toString());return rawTextLength;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/pcode/AttributedStringPcodeFormatter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/pcode/AttributedStringPcodeFormatter.javaindex dc80d10a90..02cf133236 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/pcode/AttributedStringPcodeFormatter.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/pcode/AttributedStringPcodeFormatter.java@@ -23,7 +23,8 @@ import java.util.List;import docking.widgets.fieldpanel.field.AttributedString;import docking.widgets.fieldpanel.field.CompositeAttributedString;import ghidra.app.plugin.processors.sleigh.template.OpTpl;-import ghidra.app.util.viewer.options.OptionsGui;+import ghidra.app.util.viewer.field.ListingColors;+import ghidra.app.util.viewer.field.ListingColors.*;import ghidra.program.model.address.AddressSpace;import ghidra.program.model.lang.Language;import ghidra.program.model.lang.Register;@@ -37,18 +38,6 @@ public class AttributedStringPcodeFormatter extendsprivate FontMetrics metrics;- private Color addressColor = OptionsGui.ADDRESS.getDefaultColor();- private Color registerColor = OptionsGui.REGISTERS.getDefaultColor();- private Color scalarColor = OptionsGui.CONSTANT.getDefaultColor();- private Color localColor = OptionsGui.LABELS_LOCAL.getDefaultColor();- private Color mnemonicColor = OptionsGui.MNEMONIC.getDefaultColor();- private Color unimplColor = OptionsGui.UNIMPL.getDefaultColor();- private Color separatorColor = OptionsGui.SEPARATOR.getDefaultColor();- private Color lineLabelColor = OptionsGui.PCODE_LINE_LABEL.getDefaultColor();- private Color spaceColor = OptionsGui.PCODE_ADDR_SPACE.getDefaultColor();- private Color rawColor = OptionsGui.PCODE_RAW_VARNODE.getDefaultColor();- private Color useropColor = OptionsGui.PCODE_USEROP.getDefaultColor();-private AttributedString aSpace;private AttributedString aEquals;private AttributedString aComma;@@ -67,110 +56,10 @@ public class AttributedStringPcodeFormatter extendsinitPunctuation();}- /**- * Set the color for addresses- *- * @param addressColor- */- public void setAddressColor(Color addressColor) {- this.addressColor = addressColor;- }-- /**- * Set the color for register names- *- * @param registerColor- */- public void setRegisterColor(Color registerColor) {- this.registerColor = registerColor;- }-- /**- * Set the color for scalars and non-address constants- *- * @param scalarColor- */- public void setScalarColor(Color scalarColor) {- this.scalarColor = scalarColor;- }-- /**- * Set the color for labels referring to addresses- *- * @param localColor- */- public void setLocalColor(Color localColor) {- this.localColor = localColor;- }-- /**- * Set the color for op mnemonics- *- * @param mnemonicColor- */- public void setMnemonicColor(Color mnemonicColor) {- this.mnemonicColor = mnemonicColor;- }-- /**- * Set the color for the {@code unimpl} op mnemonic- *- * @param unimplColor- */- public void setUnimplColor(Color unimplColor) {- this.unimplColor = unimplColor;- }-- /**- * Set the color for punctuation- *- * @param separatorColor- */- public void setSeparatorColor(Color separatorColor) {- this.separatorColor = separatorColor;- initPunctuation();- }-- /**- * Set the color for labels referring to p-code ops- *- * @param lineLabelColor- */- public void setLineLabelColor(Color lineLabelColor) {- this.lineLabelColor = lineLabelColor;- }-- /**- * Set the color for address space names- *- * @param spaceColor- */- public void setSpaceColor(Color spaceColor) {- this.spaceColor = spaceColor;- }-- /**- * Set the color for raw varnodes- *- * @param rawColor- */- public void setRawColor(Color rawColor) {- this.rawColor = rawColor;- }-- /**- * Set the color for userop ({@code CALLOTHER}) names- *- * @param useropColor- */- public void setUseropColor(Color useropColor) {- this.useropColor = useropColor;- }-/*** Set font metrics for AttributedString objects*- * @param metrics+ * @param metrics the font metrics*/public void setFontMetrics(FontMetrics metrics) {this.metrics = metrics;@@ -180,8 +69,8 @@ public class AttributedStringPcodeFormatter extends/*** Set general formatting options*- * @param maxDisplayLines- * @param displayRawPcode+ * @param maxDisplayLines the maximum number of lines to display+ * @param displayRawPcode show raw pcode*/public void setOptions(int maxDisplayLines, boolean displayRawPcode) {this.maxDisplayLines = maxDisplayLines;@@ -189,16 +78,16 @@ public class AttributedStringPcodeFormatter extends}private void initPunctuation() {- aSpace = new AttributedString(" ", separatorColor, metrics);- aEquals = new AttributedString(" = ", separatorColor, metrics);- aComma = new AttributedString(",", separatorColor, metrics);- aLeftParen = new AttributedString("(", separatorColor, metrics);- aRightParen = new AttributedString(")", separatorColor, metrics);- aLeftBracket = new AttributedString("[", separatorColor, metrics);- aRightBracket = new AttributedString("]", separatorColor, metrics);- aStar = new AttributedString("*", separatorColor, metrics);- aColon = new AttributedString(":", separatorColor, metrics);- aQuote = new AttributedString("\"", separatorColor, metrics);+ aSpace = new AttributedString(" ", ListingColors.SEPARATOR, metrics);+ aEquals = new AttributedString(" = ", ListingColors.SEPARATOR, metrics);+ aComma = new AttributedString(",", ListingColors.SEPARATOR, metrics);+ aLeftParen = new AttributedString("(", ListingColors.SEPARATOR, metrics);+ aRightParen = new AttributedString(")", ListingColors.SEPARATOR, metrics);+ aLeftBracket = new AttributedString("[", ListingColors.SEPARATOR, metrics);+ aRightBracket = new AttributedString("]", ListingColors.SEPARATOR, metrics);+ aStar = new AttributedString("*", ListingColors.SEPARATOR, metrics);+ aColon = new AttributedString(":", ListingColors.SEPARATOR, metrics);+ aQuote = new AttributedString("\"", ListingColors.SEPARATOR, metrics);}@Override@@ -244,24 +133,27 @@ public class AttributedStringPcodeFormatter extends@Overridepublic void appendLineLabelRef(long label) {- lineList.add(new AttributedString(stringifyLineLabel(label), lineLabelColor, metrics));+ lineList.add(+ new AttributedString(stringifyLineLabel(label), PcodeColors.LABEL, metrics));}@Overridepublic void appendMnemonic(int opcode) {- Color color = opcode == PcodeOp.UNIMPLEMENTED ? unimplColor : mnemonicColor;+ Color color = opcode == PcodeOp.UNIMPLEMENTED ? MnemonicColors.UNIMPLEMENTED+ : MnemonicColors.NORMAL;lineList.add(new AttributedString(stringifyOpMnemonic(opcode), color, metrics));}@Overridepublic void appendUserop(int id) {- lineList.add(new AttributedString(stringifyUserop(language, id), useropColor, metrics));+ lineList.add(+ new AttributedString(stringifyUserop(language, id), PcodeColors.USEROP, metrics));}@Overridepublic void appendRawVarnode(AddressSpace space, long offset, long size) {- lineList.add(new AttributedString(stringifyRawVarnode(space, offset, size), rawColor,- metrics));+ lineList.add(new AttributedString(stringifyRawVarnode(space, offset, size),+ PcodeColors.VARNODE, metrics));}private AttributedString getAttributedChar(char c) {@@ -298,33 +190,36 @@ public class AttributedStringPcodeFormatter extends@Overridepublic void appendAddressWordOffcut(long wordOffset, long offcut) {- lineList.add(new AttributedString(stringifyWordOffcut(wordOffset, offcut), addressColor,- metrics));+ lineList.add(new AttributedString(stringifyWordOffcut(wordOffset, offcut),+ ListingColors.ADDRESS, metrics));}@Overridepublic void appendLabel(String label) {- lineList.add(new AttributedString(label, localColor, metrics));+ lineList.add(new AttributedString(label, LabelColors.LOCAL, metrics));}@Overridepublic void appendRegister(Register register) {- lineList.add(new AttributedString(stringifyRegister(register), registerColor, metrics));+ lineList.add(+ new AttributedString(stringifyRegister(register), ListingColors.REGISTER, metrics));}@Overridepublic void appendScalar(long value) {- lineList.add(new AttributedString(stringifyScalarValue(value), scalarColor, metrics));+ lineList.add(+ new AttributedString(stringifyScalarValue(value), ListingColors.CONSTANT, metrics));}@Overridepublic void appendSpace(AddressSpace space) {- lineList.add(new AttributedString(stringifySpace(space), spaceColor, metrics));+ lineList.add(+ new AttributedString(stringifySpace(space), PcodeColors.ADDRESS_SPACE, metrics));}@Overridepublic void appendUnique(long offset) {- lineList.add(new AttributedString(stringifyUnique(offset), localColor, metrics));+ lineList.add(new AttributedString(stringifyUnique(offset), LabelColors.LOCAL, metrics));}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.javaindex 93b36675f9..d50a0b08b0 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java@@ -18,6 +18,7 @@ package ghidra.app.util.viewer.field;import java.awt.*;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.options.ScreenElement;@@ -29,27 +30,17 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {private static class ParameterFieldOptions {private final ScreenElement element;- Color color;FontMetrics defaultMetrics;FontMetrics[] fontMetrics = new FontMetrics[4];int style = -1;ParameterFieldOptions(ScreenElement element) {this.element = element;- color = element.getDefaultColor();- }-- String getColorOptionName() {- return element.getColorOptionName();}String getStyleOptionName() {return element.getStyleOptionName();}-- Color getDefaultColor() {- return element.getDefaultColor();- }}private static final int CUSTOM_PARAM_INDEX = 0;@@ -76,8 +67,6 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {protected AbstractVariableFieldFactory(String name, FieldFormatModel model,HighlightProvider highlightProvider, Options displayOptions, Options fieldOptions) {super(name, model, highlightProvider, displayOptions, fieldOptions);-- initDisplayOptions(displayOptions);}protected void initDisplayOptions(Options displayOptions) {@@ -86,7 +75,7 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {colorOptionName = "Variable Color";styleOptionName = "Variable Style";- super.initDisplayOptions();+ super.initDisplayOptions(displayOptions);parameterFieldOptions = new ParameterFieldOptions[2];parameterFieldOptions[CUSTOM_PARAM_INDEX] =@@ -95,9 +84,6 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {new ParameterFieldOptions(OptionsGui.PARAMETER_DYNAMIC);for (int i = 0; i < 2; i++) {- parameterFieldOptions[i].color =- displayOptions.getColor(parameterFieldOptions[i].getColorOptionName(),- parameterFieldOptions[i].getDefaultColor());parameterFieldOptions[i].style =displayOptions.getInt(parameterFieldOptions[i].getStyleOptionName(), -1);setMetrics(baseFont, parameterFieldOptions[i]);@@ -115,10 +101,7 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {}else {for (int i = 0; i < 2; i++) {- if (optionName.equals(parameterFieldOptions[i].getColorOptionName())) {- parameterFieldOptions[i].color = (Color) newValue;- }- else if (optionName.equals(styleOptionName)) {+ if (optionName.equals(styleOptionName)) {parameterFieldOptions[i].style = options.getInt(optionName, -1);setMetrics(baseFont, parameterFieldOptions[i]);}@@ -139,11 +122,10 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {protected Color getColor(Variable var) {if (var instanceof Parameter) {- int index = var.getFunction().hasCustomVariableStorage() ? CUSTOM_PARAM_INDEX- : DYNAMIC_PARAM_INDEX;- return parameterFieldOptions[index].color;+ return var.getFunction().hasCustomVariableStorage() ? FunctionColors.PARAM_CUSTOM+ : FunctionColors.PARAM_DYNAMIC;}- return color;+ return FunctionColors.PARAM;}protected FontMetrics getMetrics(Variable var) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.javaindex abca961115..db806c8b03 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java@@ -15,13 +15,11 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.beans.PropertyEditor;import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -40,7 +38,6 @@ import ghidra.util.exception.AssertException;*/public class AddressFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Address";- public static final Color DEFAULT_COLOR = Colors.FOREGROUND;private final static String GROUP_TITLE = "Address Field";public final static String DISPLAY_BLOCK_NAME =GROUP_TITLE + Options.DELIMITER + "Display Block Name";@@ -96,11 +93,6 @@ public class AddressFieldFactory extends FieldFactory {fieldOptions.getOptions(GROUP_TITLE).setOptionsHelpLocation(helpLoc);}- @Override- public Color getDefaultColor() {- return DEFAULT_COLOR;- }-@Overridepublic void fieldOptionsChanged(Options options, String optionsName, Object oldValue,Object newValue) {@@ -123,8 +115,8 @@ public class AddressFieldFactory extends FieldFactory {}CodeUnit cu = (CodeUnit) obj;String text = getAddressString(cu);- FieldElement as =- new TextFieldElement(new AttributedString(text, color, getMetrics()), 0, 0);+ FieldElement as = new TextFieldElement(+ new AttributedString(text, ListingColors.ADDRESS, getMetrics()), 0, 0);ListingTextField ltf;if (rightJustify) {ltf = ListingTextField.createSingleLineTextFieldWithReverseClipping(this, proxy, as,@@ -211,4 +203,5 @@ public class AddressFieldFactory extends FieldFactory {return new AddressFieldFactory(newModel, highlightStringProvider, toolOptions,fieldOptions);}+}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.javaindex 806c0a2dca..a03438a55a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.java@@ -18,23 +18,16 @@ package ghidra.app.util.viewer.field;import java.beans.PropertyEditor;import java.math.BigInteger;-import docking.widgets.fieldpanel.field.AttributedString;-import docking.widgets.fieldpanel.field.FieldElement;-import docking.widgets.fieldpanel.field.TextFieldElement;+import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import docking.widgets.fieldpanel.support.RowColLocation;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.format.FormatManager;import ghidra.app.util.viewer.proxy.ProxyObj;-import ghidra.framework.options.CustomOption;-import ghidra.framework.options.OptionType;-import ghidra.framework.options.Options;-import ghidra.framework.options.ToolOptions;+import ghidra.framework.options.*;import ghidra.program.model.data.DataType;-import ghidra.program.model.listing.CodeUnit;-import ghidra.program.model.listing.Data;-import ghidra.program.model.listing.Program;+import ghidra.program.model.listing.*;import ghidra.program.util.ProgramLocation;import ghidra.util.HelpLocation;import ghidra.util.exception.AssertException;@@ -110,7 +103,8 @@ public class ArrayValuesFieldFactory extends FieldFactory {Data child = parent.getComponent(index++);boolean isLastItem = isLastLine && (i == itemCount - 1);String value = getDisplayValue(child, !isLastItem);- AttributedString as = new AttributedString(value, color, getMetrics());+ AttributedString as =+ new AttributedString(value, ListingColors.ARRAY_VALUES, getMetrics());aStrings[i] = new TextFieldElement(as, i, 0);}return ListingTextField.createPackedTextField(this, proxy, aStrings, startX + varWidth,diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.javaindex fb28a24596..4dd04dce1b 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.java@@ -15,14 +15,13 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import java.util.ArrayList;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -36,7 +35,6 @@ import ghidra.program.util.ProgramLocation;*/public class AssignedVariableFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Var Assign";- public static final Color DEFAULT_COLOR = Palette.PURPLE;/*** Default constructor.@@ -57,12 +55,6 @@ public class AssignedVariableFieldFactory extends FieldFactory {super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);}- @Override- public void fieldOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- // stub- }-/*** Returns the FactoryField for the given object at index index.* @param varWidth the amount of variable width spacing for any fields@@ -95,7 +87,8 @@ public class AssignedVariableFieldFactory extends FieldFactory {buf.append(var.getVariableStorage().toString());buf.append(" = ");buf.append(var.getName());- AttributedString as = new AttributedString(buf.toString(), color, getMetrics());+ AttributedString as = new AttributedString(buf.toString(),+ FunctionColors.VARIABLE_ASSIGNED, getMetrics());elemenetList.add(new TextFieldElement(as, 0, 0));}}@@ -146,9 +139,4 @@ public class AssignedVariableFieldFactory extends FieldFactory {return new AssignedVariableFieldFactory(formatModel, hsProvider, displayOptions,fieldOptions);}-- @Override- public Color getDefaultColor() {- return DEFAULT_COLOR;- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.javaindex 0bcab118fc..c2146192b3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.java@@ -27,7 +27,6 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import docking.widgets.fieldpanel.support.RowColLocation;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -47,8 +46,6 @@ import ghidra.util.HelpLocation;public class BytesFieldFactory extends FieldFactory {private static final int CHARS_IN_BYTE = 2;public static final String FIELD_NAME = "Bytes";- public static final Color DEFAULT_COLOR = Palette.BLUE;- public static final Color ALIGNMENT_BYTES_COLOR = Palette.GRAY;public final static String GROUP_TITLE = "Bytes Field";public final static String MAX_DISPLAY_LINES_MSG =GROUP_TITLE + Options.DELIMITER + "Maximum Lines To Display";@@ -211,10 +208,11 @@ public class BytesFieldFactory extends FieldFactory {FieldElement[] aStrings = new FieldElement[fieldElementLength + extraLen];- buildAttributedByteValues(aStrings, 0, bytes, length, 0, color, extraLen != 0);+ buildAttributedByteValues(aStrings, 0, bytes, length, 0, ListingColors.BYTES,+ extraLen != 0);if (extraLen != 0) {buildAttributedByteValues(aStrings, fieldElementLength, alignmentBytes,- alignmentBytes.length, residual, ALIGNMENT_BYTES_COLOR, false);+ alignmentBytes.length, residual, ListingColors.BYTES_ALIGNMENT, false);}return ListingTextField.createPackedTextField(this, proxy, aStrings, startX + varWidth,@@ -434,11 +432,6 @@ public class BytesFieldFactory extends FieldFactory {return null;}- @Override- public Color getDefaultColor() {- return DEFAULT_COLOR;- }-@Overridepublic boolean acceptsType(int category, Class<?> proxyObjectClass) {if (!CodeUnit.class.isAssignableFrom(proxyObjectClass)) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.javaindex 6a489e42b4..3ff530313d 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.java@@ -52,8 +52,8 @@ public class DummyFieldFactory extends FieldFactory {return null;}int x = startX + varWidth;- FieldElement text =- new TextFieldElement(new AttributedString("", color, getMetrics()), 0, 0);+ FieldElement text = new TextFieldElement(+ new AttributedString("", ListingColors.BACKGROUND, getMetrics()), 0, 0);return ListingTextField.createSingleLineTextField(this, obj, text, x, width, hlProvider);}@@ -80,7 +80,7 @@ public class DummyFieldFactory extends FieldFactory {@Overridepublic FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hlProvdier,- ToolOptions displayOptions, ToolOptions fieldOptions) {+ ToolOptions options, ToolOptions fieldOptions) {return this;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.javaindex 65113d6208..f9c68055dd 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java@@ -26,6 +26,7 @@ import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.*;import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.*;+import ghidra.app.util.viewer.field.ListingColors.CommentColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -43,25 +44,25 @@ import ghidra.util.bean.field.AnnotatedTextFieldElement;*/public class EolCommentFieldFactory extends FieldFactory {public static final String FIELD_NAME = "EOL Comment";- private final static String GROUP_TITLE = "EOL Comments Field";+ private static final String GROUP_TITLE = "EOL Comments Field";private static final String SEMICOLON_PREFIX = "; ";- public final static String ENABLE_WORD_WRAP_MSG =+ public static final String ENABLE_WORD_WRAP_MSG =GROUP_TITLE + Options.DELIMITER + "Enable Word Wrapping";- public final static String MAX_DISPLAY_LINES_MSG =+ public static final String MAX_DISPLAY_LINES_MSG =GROUP_TITLE + Options.DELIMITER + "Maximum Lines To Display";- public final static String ENABLE_SHOW_SEMICOLON_MSG =+ public static final String ENABLE_SHOW_SEMICOLON_MSG =GROUP_TITLE + Options.DELIMITER + "Show Semicolon at Start of Each Line";- public final static String ENABLE_ALWAYS_SHOW_REPEATABLE_MSG =+ public static final String ENABLE_ALWAYS_SHOW_REPEATABLE_MSG =GROUP_TITLE + Options.DELIMITER + "Always Show the Repeatable Comment";- public final static String ENABLE_ALWAYS_SHOW_REF_REPEATABLE_MSG =+ public static final String ENABLE_ALWAYS_SHOW_REF_REPEATABLE_MSG =GROUP_TITLE + Options.DELIMITER + "Always Show the Referenced Repeatable Comments";- public final static String ENABLE_ALWAYS_SHOW_AUTOMATIC_MSG =+ public static final String ENABLE_ALWAYS_SHOW_AUTOMATIC_MSG =GROUP_TITLE + Options.DELIMITER + "Always Show the Automatic Comment";public static final String USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG =GROUP_TITLE + Options.DELIMITER + "Use Abbreviated Automatic Comments";public static final String SHOW_FUNCTION_AUTOMITIC_COMMENT_MSG =GROUP_TITLE + Options.DELIMITER + "Show Function Reference Automatic Comments";- public final static String ENABLE_PREPEND_REF_ADDRESS_MSG =+ public static final String ENABLE_PREPEND_REF_ADDRESS_MSG =GROUP_TITLE + Options.DELIMITER + "Prepend the Address to Each Referenced Comment";public static final Color DEFAULT_COLOR = Palette.BLUE;@@ -74,9 +75,6 @@ public class EolCommentFieldFactory extends FieldFactory {private boolean useAbbreviatedAutomatic;private boolean showAutomaticFunctions;private boolean prependRefAddress;- private Color repeatableCommentColor;- private Color automaticCommentColor;- private Color refRepeatableCommentColor;private int repeatableCommentStyle;private int automaticCommentStyle;private int refRepeatableCommentStyle;@@ -138,19 +136,10 @@ public class EolCommentFieldFactory extends FieldFactory {maxDisplayLines = fieldOptions.getInt(MAX_DISPLAY_LINES_MSG, 6);isWordWrap = fieldOptions.getBoolean(ENABLE_WORD_WRAP_MSG, false);- repeatableCommentColor =- displayOptions.getColor(OptionsGui.COMMENT_REPEATABLE.getColorOptionName(),- OptionsGui.COMMENT_REPEATABLE.getDefaultColor());repeatableCommentStyle =displayOptions.getInt(OptionsGui.COMMENT_REPEATABLE.getStyleOptionName(), -1);- automaticCommentColor =- displayOptions.getColor(OptionsGui.COMMENT_AUTO.getColorOptionName(),- OptionsGui.COMMENT_AUTO.getDefaultColor());automaticCommentStyle =displayOptions.getInt(OptionsGui.COMMENT_AUTO.getStyleOptionName(), -1);- refRepeatableCommentColor =- displayOptions.getColor(OptionsGui.COMMENT_REF_REPEAT.getColorOptionName(),- OptionsGui.COMMENT_REF_REPEAT.getDefaultColor());refRepeatableCommentStyle =displayOptions.getInt(OptionsGui.COMMENT_REF_REPEAT.getStyleOptionName(), -1);showSemicolon = fieldOptions.getBoolean(ENABLE_SHOW_SEMICOLON_MSG, false);@@ -160,8 +149,7 @@ public class EolCommentFieldFactory extends FieldFactory {alwaysShowAutomatic = fieldOptions.getBoolean(ENABLE_ALWAYS_SHOW_AUTOMATIC_MSG, false);useAbbreviatedAutomatic =fieldOptions.getBoolean(USE_ABBREVIATED_AUTOMITIC_COMMENT_MSG, true);- showAutomaticFunctions =- fieldOptions.getBoolean(SHOW_FUNCTION_AUTOMITIC_COMMENT_MSG, true);+ showAutomaticFunctions = fieldOptions.getBoolean(SHOW_FUNCTION_AUTOMITIC_COMMENT_MSG, true);prependRefAddress = fieldOptions.getBoolean(ENABLE_PREPEND_REF_ADDRESS_MSG, false);@@ -225,9 +213,6 @@ public class EolCommentFieldFactory extends FieldFactory {*/private void adjustRepeatableDisplayOptions(Options options, String optionName, Object oldValue,Object newValue) {- if (optionName.equals(OptionsGui.COMMENT_REPEATABLE.getColorOptionName())) {- repeatableCommentColor = (Color) newValue;- }String repeatableStyleName = OptionsGui.COMMENT_REPEATABLE.getStyleOptionName();if (optionName.equals(repeatableStyleName)) {repeatableCommentStyle = options.getInt(repeatableStyleName, -1);@@ -244,9 +229,6 @@ public class EolCommentFieldFactory extends FieldFactory {*/private void adjustRefRepeatDisplayOptions(Options options, String optionName, Object oldValue,Object newValue) {- if (optionName.equals(OptionsGui.COMMENT_REF_REPEAT.getColorOptionName())) {- refRepeatableCommentColor = (Color) newValue;- }String refRepeatStyleName = OptionsGui.COMMENT_REF_REPEAT.getStyleOptionName();if (optionName.equals(refRepeatStyleName)) {refRepeatableCommentStyle = options.getInt(refRepeatStyleName, -1);@@ -262,9 +244,6 @@ public class EolCommentFieldFactory extends FieldFactory {*/private void adjustAutomaticCommentDisplayOptions(Options options, String optionName,Object oldValue, Object newValue) {- if (optionName.equals(OptionsGui.COMMENT_AUTO.getColorOptionName())) {- automaticCommentColor = (Color) newValue;- }String automaticCommentStyleName = OptionsGui.COMMENT_AUTO.getStyleOptionName();if (optionName.equals(automaticCommentStyleName)) {automaticCommentStyle = options.getInt(automaticCommentStyleName, -1);@@ -315,8 +294,8 @@ public class EolCommentFieldFactory extends FieldFactory {List<FieldElement> elementList = new ArrayList<>();// This Code Unit's End of Line Comment- AttributedString myEolPrefixString =- new AttributedString(SEMICOLON_PREFIX, color, getMetrics(style), false, null);+ AttributedString myEolPrefixString = new AttributedString(SEMICOLON_PREFIX,+ CommentColors.EOL, getMetrics(style), false, null);String[] eolComments = displayableEol.getEOLComments();List<FieldElement> eolFieldElements = convertToFieldElements(program, eolComments,myEolPrefixString, showSemicolon, isWordWrap, getNextRow(elementList));@@ -325,7 +304,7 @@ public class EolCommentFieldFactory extends FieldFactory {// This Code Unit's Repeatable Commentif (alwaysShowRepeatable || elementList.isEmpty()) {AttributedString myRepeatablePrefixString = new AttributedString(SEMICOLON_PREFIX,- repeatableCommentColor, getMetrics(repeatableCommentStyle), false, null);+ CommentColors.REPEATABLE, getMetrics(repeatableCommentStyle), false, null);String[] repeatableComments = displayableEol.getRepeatableComments();List<FieldElement> repeatableFieldElements =convertToFieldElements(program, repeatableComments, myRepeatablePrefixString,@@ -336,7 +315,7 @@ public class EolCommentFieldFactory extends FieldFactory {// Referenced Repeatable Commentsif (alwaysShowRefRepeatables || elementList.isEmpty()) {AttributedString refRepeatPrefixString = new AttributedString(SEMICOLON_PREFIX,- refRepeatableCommentColor, getMetrics(refRepeatableCommentStyle), false, null);+ CommentColors.REF_REPEATABLE, getMetrics(refRepeatableCommentStyle), false, null);int refRepeatCount = displayableEol.getReferencedRepeatableCommentsCount();for (int subTypeIndex = 0; subTypeIndex < refRepeatCount; subTypeIndex++) {RefRepeatComment refRepeatComment =@@ -352,7 +331,7 @@ public class EolCommentFieldFactory extends FieldFactory {// Automatic Commentif (alwaysShowAutomatic || elementList.isEmpty()) {AttributedString autoCommentPrefixString = new AttributedString(SEMICOLON_PREFIX,- automaticCommentColor, getMetrics(automaticCommentStyle), false, null);+ CommentColors.AUTO, getMetrics(automaticCommentStyle), false, null);String[] autoComment = displayableEol.getAutomaticComment();List<FieldElement> autoCommentFieldElements =convertToFieldElements(program, autoComment, autoCommentPrefixString, showSemicolon,@@ -575,11 +554,6 @@ public class EolCommentFieldFactory extends FieldFactory {newFieldOptions);}- @Override- public Color getDefaultColor() {- return OptionsGui.COMMENT_EOL.getDefaultColor();- }-/*** Convert the array of comments to a single string and use the given* separatorChar as the delimiter.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 003ff793f5..4785a87c67 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@@ -19,12 +19,9 @@ import java.awt.*;import java.math.BigInteger;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors;-import generic.theme.GThemeDefaults.Colors.Palette;import generic.theme.Gui;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;import ghidra.framework.options.ToolOptions;@@ -48,8 +45,6 @@ public abstract class FieldFactory implements ExtensionPoint {protected String name;protected int startX;protected int width;- protected Color color;- protected Color underlineColor = Palette.BLUE;private FontMetrics defaultMetrics;private FontMetrics[] fontMetrics = new FontMetrics[4];protected Font baseFont;@@ -59,7 +54,6 @@ public abstract class FieldFactory implements ExtensionPoint {protected String colorOptionName;protected String styleOptionName;- protected Options displayOptions;/*** Base constructor@@ -79,26 +73,23 @@ public abstract class FieldFactory implements ExtensionPoint {width = 100;- this.displayOptions = displayOptions;- initDisplayOptions();+ initDisplayOptions(displayOptions);+ initFieldOptions(fieldOptions);+ }+ protected void initFieldOptions(Options fieldOptions) {fieldOptions.getOptions(name).setOptionsHelpLocation(new HelpLocation("CodeBrowserPlugin", name));}- protected void initDisplayOptions() {+ protected void initDisplayOptions(Options displayOptions) {baseFont = Gui.getFont(BASE_LISTING_FONT_ID);// 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.registerThemeColorBinding(colorOptionName, Colors.FOREGROUND.getId(), null,- "Sets the " + colorOptionName);displayOptions.registerOption(styleOptionName, -1, null, "Sets the " + style);- color = displayOptions.getColor(colorOptionName, getDefaultColor());style = displayOptions.getInt(styleOptionName, -1);- underlineColor = displayOptions.getColor(OptionsGui.UNDERLINE.getColorOptionName(),- OptionsGui.UNDERLINE.getDefaultColor());setMetrics(baseFont);}@@ -110,24 +101,6 @@ public abstract class FieldFactory implements ExtensionPoint {this.name = name;}- /**- * Notification that the Options have changed.- * @param options the Options object that changed. Will be either the display- * options or the field options.- * @param optionName the name of the property that changed.- * @param oldValue the old value of the property.- * @param newValue the new value of the property.- */- public void optionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- if (options == displayOptions) {- displayOptionsChanged(options, optionName, oldValue, newValue);- }- else {- fieldOptionsChanged(options, optionName, oldValue, newValue);- }- }-/*** Notification the services changed. Subclasses should override this method* if they care about service changes.@@ -161,16 +134,10 @@ public abstract class FieldFactory implements ExtensionPoint {baseFont = SystemUtilities.adjustForFontSizeOverride((Font) newValue);setMetrics(baseFont);}- else if (optionName.equals(colorOptionName)) {- color = (Color) newValue;- }else if (optionName.equals(styleOptionName)) {style = options.getInt(optionName, -1);setMetrics(baseFont);}- else if (optionName.equals(OptionsGui.UNDERLINE.getColorOptionName())) {- underlineColor = (Color) newValue;- }model.update();}@@ -194,14 +161,6 @@ public abstract class FieldFactory implements ExtensionPoint {return name;}- /**- * Returns the default field color.- * @return the color.- */- public Color getDefaultColor() {- return Colors.FOREGROUND;- }-/*** Returns the starting x position for the fields generated by this factory.* @return the start x.diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.javaindex eb1bc69114..e5f2053006 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.java@@ -15,7 +15,6 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;@@ -24,7 +23,6 @@ import ghidra.GhidraOptions;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.format.FormatManager;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;import ghidra.framework.options.ToolOptions;@@ -115,7 +113,8 @@ public class FieldNameFieldFactory extends FieldFactory {if ((fieldName == null) || (fieldName.length() == 0)) {return null;}- AttributedString as = new AttributedString(fieldName, color, getMetrics());+ AttributedString as =+ new AttributedString(fieldName, ListingColors.FIELD_NAME, getMetrics());FieldElement text = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, text, startX + varWidth,@@ -160,9 +159,4 @@ public class FieldNameFieldFactory extends FieldFactory {ToolOptions toolOptions, ToolOptions fieldOptions) {return new FieldNameFieldFactory(formatModel, provider, toolOptions, fieldOptions);}-- @Override- public Color getDefaultColor() {- return OptionsGui.FIELD_NAME.getDefaultColor();- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.javaindex 2a4c0f1336..c4feb95930 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.java@@ -20,6 +20,7 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;+import generic.theme.GColor;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -41,6 +42,7 @@ import ghidra.util.exception.AssertException;public class FileOffsetFieldFactory extends FieldFactory {public static final String FIELD_NAME = "File Offset";+ public static final GColor COLOR = new GColor("color.fg.listing.file.offset");public static final String GROUP_TITLE = "File Offset Field";public final static String FILE_OFFSET_DISPLAY_OPTIONS_NAME =GROUP_TITLE + Options.DELIMITER + "File Offset Display Options";@@ -141,7 +143,7 @@ public class FileOffsetFieldFactory extends FieldFactory {}}FieldElement fieldElement =- new TextFieldElement(new AttributedString(text, color, getMetrics()), 0, 0);+ new TextFieldElement(new AttributedString(text, COLOR, getMetrics()), 0, 0);ListingTextField listingTextField = ListingTextField.createSingleLineTextField(this, proxy,fieldElement, startX + varWidth, width, hlProvider);listingTextField.setPrimary(true);@@ -191,5 +193,4 @@ public class FileOffsetFieldFactory extends FieldFactory {return (category == FieldFormatModel.INSTRUCTION_OR_DATA ||category == FieldFormatModel.OPEN_DATA || category == FieldFormatModel.ARRAY);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.javaindex c79fb0b1a6..1eb1b3fc51 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.java@@ -15,15 +15,14 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import java.util.ArrayList;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.FunctionProxy;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -38,8 +37,6 @@ import ghidra.program.util.ProgramLocation;public class FunctionCallFixupFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Function Call-Fixup";- private Color fixupColor;- private Color literalColor;/*** Default Constructor@@ -59,20 +56,6 @@ public class FunctionCallFixupFieldFactory extends FieldFactory {Options displayOptions, Options fieldOptions) {super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);- literalColor = displayOptions.getColor(OptionsGui.SEPARATOR.getColorOptionName(),- OptionsGui.SEPARATOR.getDefaultColor());- fixupColor = displayOptions.getColor(OptionsGui.FUN_CALL_FIXUP.getColorOptionName(),- OptionsGui.FUN_CALL_FIXUP.getDefaultColor());- }-- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- super.displayOptionsChanged(options, optionName, oldValue, newValue);- literalColor = options.getColor(OptionsGui.FUN_CALL_FIXUP.getColorOptionName(),- OptionsGui.FUN_CALL_FIXUP.getDefaultColor());- fixupColor = options.getColor(OptionsGui.FUN_CALL_FIXUP.getColorOptionName(),- OptionsGui.FUN_CALL_FIXUP.getDefaultColor());}@Override@@ -91,10 +74,10 @@ public class FunctionCallFixupFieldFactory extends FieldFactory {AttributedString as;int elementIndex = 0;- as = new AttributedString("Call-Fixup: ", literalColor, getMetrics());+ as = new AttributedString("Call-Fixup: ", ListingColors.SEPARATOR, getMetrics());textElements.add(new TextFieldElement(as, elementIndex++, 0));- as = new AttributedString(callFixupStr, fixupColor, getMetrics());+ as = new AttributedString(callFixupStr, FunctionColors.CALL_FIXUP, getMetrics());textElements.add(new TextFieldElement(as, elementIndex++, 0));return ListingTextField.createSingleLineTextField(this, proxy,@@ -141,14 +124,4 @@ public class FunctionCallFixupFieldFactory extends FieldFactory {fieldOptions);}- @Override- public Color getDefaultColor() {- return OptionsGui.FUN_CALL_FIXUP.getDefaultColor();- }-- @Override- public void fieldOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- // don't care- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.javaindex 18c8e77051..63db9fab68 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.java@@ -19,10 +19,9 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors.Palette;+import generic.theme.GColor;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;import ghidra.framework.options.ToolOptions;@@ -32,6 +31,7 @@ import ghidra.program.util.ProgramLocation;public class FunctionPurgeFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Function Purge";+ public static final GColor COLOR = new GColor("color.fg.listing.function.purge");public FunctionPurgeFieldFactory() {super(FIELD_NAME);@@ -40,8 +40,6 @@ public class FunctionPurgeFieldFactory extends FieldFactory {private FunctionPurgeFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,Options displayOptions, Options fieldOptions) {super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);- color = displayOptions.getColor(OptionsGui.BYTES.getColorOptionName(),- OptionsGui.BYTES.getDefaultColor());}@@ -79,7 +77,7 @@ public class FunctionPurgeFieldFactory extends FieldFactory {stringDepth = Integer.toHexString(depth);}}- AttributedString as = new AttributedString(stringDepth, Palette.BLUE, getMetrics());+ AttributedString as = new AttributedString(stringDepth, COLOR, getMetrics());FieldElement text = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, text, startX + varWidth,width, hlProvider);@@ -123,5 +121,4 @@ public class FunctionPurgeFieldFactory extends FieldFactory {}return (category == FieldFormatModel.FUNCTION);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.javaindex a409d14a6f..0c1b90f3ca 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.java@@ -15,15 +15,15 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import docking.widgets.fieldpanel.field.AttributedString;import docking.widgets.fieldpanel.field.FieldElement;import docking.widgets.fieldpanel.support.FieldLocation;+import generic.theme.GColor;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.CommentColors;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.FunctionProxy;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -38,6 +38,7 @@ import ghidra.program.util.ProgramLocation;*/public class FunctionRepeatableCommentFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Function Repeatable Comment";+ public static final GColor COLOR = new GColor("color.fg.listing.comment.repeatable");/*** Default constructor@@ -70,7 +71,8 @@ public class FunctionRepeatableCommentFieldFactory extends FieldFactory {Program program = f.getProgram();String[] commentArr = f.getRepeatableCommentAsArray();FieldElement[] fields = new FieldElement[commentArr.length];- AttributedString prototype = new AttributedString("prototype", color, getMetrics());+ AttributedString prototype =+ new AttributedString("prototype", CommentColors.REPEATABLE, getMetrics());for (int i = 0; i < commentArr.length; i++) {fields[i] = CommentUtils.parseTextForAnnotations(commentArr[i], program, prototype, i);}@@ -125,12 +127,4 @@ public class FunctionRepeatableCommentFieldFactory extends FieldFactory {return new FunctionRepeatableCommentFieldFactory(formatModel, provider, options,fieldOptions);}-- /**- * @see ghidra.app.util.viewer.field.FieldFactory#getDefaultColor()- */- @Override- public Color getDefaultColor() {- return OptionsGui.COMMENT_EOL.getDefaultColor();- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.javaindex 68673018de..5925bb905a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.java@@ -23,12 +23,10 @@ import java.util.List;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import docking.widgets.fieldpanel.support.RowColLocation;-import generic.theme.GThemeDefaults.Colors;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.GhidraOptions;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.FunctionProxy;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -48,17 +46,7 @@ public class FunctionSignatureFieldFactory extends FieldFactory {GROUP_TITLE + Options.DELIMITER + GhidraOptions.DISPLAY_NAMESPACE;private boolean displayFunctionScope;- private Color funNameColor;- private Color unresolvedThunkRefColor;- private Color resolvedThunkRefColor;- private Color funRetColor;- private Color literalColor;- private Color funParamsColor;- private Color autoParamColor;- /**- * Default Constructor- */public FunctionSignatureFieldFactory() {super(FIELD_NAME);}@@ -78,45 +66,6 @@ public class FunctionSignatureFieldFactory extends FieldFactory {"Prepends namespaces to labels that are not in the global namespace.");displayFunctionScope = fieldOptions.getBoolean(DISPLAY_NAMESPACE, false);-- funRetColor = displayOptions.getColor(OptionsGui.FUN_RET_TYPE.getColorOptionName(),- OptionsGui.FUN_RET_TYPE.getDefaultColor());- funNameColor = displayOptions.getColor(OptionsGui.FUN_NAME.getColorOptionName(),- OptionsGui.FUN_NAME.getDefaultColor());- unresolvedThunkRefColor =- displayOptions.getColor(OptionsGui.BAD_REF_ADDR.getColorOptionName(),- OptionsGui.BAD_REF_ADDR.getDefaultColor());- resolvedThunkRefColor =- displayOptions.getColor(OptionsGui.EXT_REF_RESOLVED.getColorOptionName(),- OptionsGui.EXT_REF_RESOLVED.getDefaultColor());- funParamsColor = displayOptions.getColor(OptionsGui.FUN_PARAMS.getColorOptionName(),- OptionsGui.FUN_PARAMS.getDefaultColor());- autoParamColor = displayOptions.getColor(OptionsGui.FUN_AUTO_PARAMS.getColorOptionName(),- OptionsGui.FUN_PARAMS.getDefaultColor());- literalColor = displayOptions.getColor(OptionsGui.SEPARATOR.getColorOptionName(),- OptionsGui.SEPARATOR.getDefaultColor());- }-- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- super.displayOptionsChanged(options, optionName, oldValue, newValue);- funRetColor =- options.getColor(OptionsGui.FUN_RET_TYPE.getColorOptionName(), Colors.FOREGROUND);- funNameColor =- options.getColor(OptionsGui.FUN_NAME.getColorOptionName(), Colors.FOREGROUND);- unresolvedThunkRefColor =- displayOptions.getColor(OptionsGui.BAD_REF_ADDR.getColorOptionName(),- OptionsGui.BAD_REF_ADDR.getDefaultColor());- resolvedThunkRefColor =- displayOptions.getColor(OptionsGui.EXT_REF_RESOLVED.getColorOptionName(),- OptionsGui.EXT_REF_RESOLVED.getDefaultColor());- funParamsColor =- options.getColor(OptionsGui.FUN_PARAMS.getColorOptionName(), Colors.FOREGROUND);- autoParamColor =- options.getColor(OptionsGui.FUN_AUTO_PARAMS.getColorOptionName(), Palette.GRAY);- literalColor =- options.getColor(OptionsGui.SEPARATOR.getColorOptionName(), Colors.FOREGROUND);}@Override@@ -135,7 +84,8 @@ public class FunctionSignatureFieldFactory extends FieldFactory {// inlineif (function.isInline()) {- as = new AttributedString(Function.INLINE + " ", funRetColor, getMetrics());+ as = new AttributedString(Function.INLINE + " ", FunctionColors.RETURN_TYPE,+ getMetrics());textElements.add(new FunctionInlineFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;@@ -143,7 +93,8 @@ public class FunctionSignatureFieldFactory extends FieldFactory {// thunkif (function.isThunk()) {- as = new AttributedString(Function.THUNK + " ", funRetColor, getMetrics());+ as = new AttributedString(Function.THUNK + " ", FunctionColors.RETURN_TYPE,+ getMetrics());textElements.add(new FunctionThunkFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;@@ -151,7 +102,8 @@ public class FunctionSignatureFieldFactory extends FieldFactory {// noreturnif (function.hasNoReturn()) {- as = new AttributedString(Function.NORETURN + " ", funRetColor, getMetrics());+ as = new AttributedString(Function.NORETURN + " ", FunctionColors.RETURN_TYPE,+ getMetrics());textElements.add(new FunctionNoReturnFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;@@ -159,7 +111,7 @@ public class FunctionSignatureFieldFactory extends FieldFactory {// return typeas = new AttributedString(function.getReturn().getFormalDataType().getDisplayName() + " ",- funRetColor, getMetrics());+ FunctionColors.RETURN_TYPE, getMetrics());textElements.add(new FunctionReturnTypeFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;@@ -171,9 +123,10 @@ public class FunctionSignatureFieldFactory extends FieldFactory {}if (callingConvention != null &&!callingConvention.equals(Function.UNKNOWN_CALLING_CONVENTION_STRING)) {- as = new AttributedString(callingConvention + " ", funRetColor, getMetrics());- textElements.add(- new FunctionCallingConventionFieldElement(as, elementIndex, 0, startCol));+ as = new AttributedString(callingConvention + " ", FunctionColors.RETURN_TYPE,+ getMetrics());+ textElements+ .add(new FunctionCallingConventionFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;}@@ -186,14 +139,15 @@ public class FunctionSignatureFieldFactory extends FieldFactory {elementIndex++;// opening parenthesis- as = new AttributedString("(", literalColor, getMetrics());+ as = new AttributedString("(", ListingColors.SEPARATOR, getMetrics());textElements.add(new FunctionStartParametersFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;// parametersint paramOffset = 0;- AttributedString commaSeparator = new AttributedString(", ", literalColor, getMetrics());+ AttributedString commaSeparator =+ new AttributedString(", ", ListingColors.SEPARATOR, getMetrics());int lastParam = params.length - 1;for (int i = 0; i < params.length; i++) {@@ -202,7 +156,8 @@ public class FunctionSignatureFieldFactory extends FieldFactory {// continue;// }- Color pcolor = params[i].isAutoParameter() ? autoParamColor : funParamsColor;+ Color pcolor =+ params[i].isAutoParameter() ? FunctionColors.PARAM_AUTO : FunctionColors.PARAM;String text = params[i].getFormalDataType().getDisplayName() + " ";as = new AttributedString(text, pcolor, getMetrics());@@ -238,23 +193,23 @@ public class FunctionSignatureFieldFactory extends FieldFactory {paramOffset += commaSeparator.length();elementIndex++;}- as = new AttributedString(FunctionSignature.VAR_ARGS_DISPLAY_STRING, funParamsColor,- getMetrics());+ as = new AttributedString(FunctionSignature.VAR_ARGS_DISPLAY_STRING,+ FunctionColors.PARAM, getMetrics());textElements.add(new FunctionSignatureFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;}else if (lastParam < 0 && function.getSignatureSource() != SourceType.DEFAULT) {// void parameter list- as = new AttributedString(FunctionSignature.VOID_PARAM_DISPLAY_STRING, funParamsColor,- getMetrics());+ as = new AttributedString(FunctionSignature.VOID_PARAM_DISPLAY_STRING,+ FunctionColors.PARAM, getMetrics());textElements.add(new FunctionSignatureFieldElement(as, elementIndex, 0, startCol));startCol += as.length();elementIndex++;}// closing parenthesis- as = new AttributedString(")", literalColor, getMetrics());+ as = new AttributedString(")", ListingColors.SEPARATOR, getMetrics());textElements.add(new FunctionEndParametersFieldElement(as, elementIndex, 0, startCol));return ListingTextField.createSingleLineTextField(this, proxy,@@ -266,23 +221,23 @@ public class FunctionSignatureFieldFactory extends FieldFactory {if (function.isThunk()) {Function thunkedFunction = function.getThunkedFunction(true);if (thunkedFunction == null) {- return unresolvedThunkRefColor;+ return ListingColors.EXT_REF_UNRESOLVED;}else if (thunkedFunction.isExternal()) {ExternalLocation externalLocation = thunkedFunction.getExternalLocation();String libName = externalLocation.getLibraryName();if (Library.UNKNOWN.equals(libName)) {- return unresolvedThunkRefColor;+ return ListingColors.EXT_REF_UNRESOLVED;}ExternalManager externalManager = function.getProgram().getExternalManager();String path = externalManager.getExternalLibraryPath(libName);if (path == null || path.length() == 0) {- return unresolvedThunkRefColor;+ return ListingColors.EXT_REF_UNRESOLVED;}- return resolvedThunkRefColor;+ return ListingColors.EXT_REF_RESOLVED;}}- return funNameColor;+ return FunctionColors.NAME;}@Override@@ -420,13 +375,7 @@ public class FunctionSignatureFieldFactory extends FieldFactory {@Overridepublic FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,ToolOptions toolOptions, ToolOptions fieldOptions) {- return new FunctionSignatureFieldFactory(formatModel, provider, toolOptions,- fieldOptions);- }-- @Override- public Color getDefaultColor() {- return OptionsGui.FUN_NAME.getDefaultColor();+ return new FunctionSignatureFieldFactory(formatModel, provider, toolOptions, fieldOptions);}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.javaindex 333b65eb3a..57d7b26b10 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.java@@ -15,16 +15,14 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import docking.widgets.fieldpanel.field.AttributedString;import docking.widgets.fieldpanel.field.TextFieldElement;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.FunctionProxy;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -40,8 +38,6 @@ import ghidra.program.util.ProgramLocation;public class FunctionSignatureSourceFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Signature Source";-// private Color funRetColor;- private Color literalColor;//private int displayWidth;@@ -62,17 +58,6 @@ public class FunctionSignatureSourceFieldFactory extends FieldFactory {public FunctionSignatureSourceFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,Options displayOptions, Options fieldOptions) {super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);-- literalColor = displayOptions.getColor(OptionsGui.SEPARATOR.getColorOptionName(),- OptionsGui.SEPARATOR.getDefaultColor());- }-- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- super.displayOptionsChanged(options, optionName, oldValue, newValue);- literalColor =- options.getColor(OptionsGui.SEPARATOR.getColorOptionName(), Colors.FOREGROUND);}@Override@@ -85,7 +70,8 @@ public class FunctionSignatureSourceFieldFactory extends FieldFactory {Function function = functionProxy.getObject();SourceType source = function.getSignatureSource();String sourceStr = "<" + source.toString() + ">";- AttributedString as = new AttributedString(sourceStr, literalColor, getMetrics());+ AttributedString as =+ new AttributedString(sourceStr, FunctionColors.SOURCE, getMetrics());return ListingTextField.createSingleLineTextField(this, proxy,new TextFieldElement(as, 0, 0), startX + varWidth, width, hlProvider);}@@ -131,15 +117,4 @@ public class FunctionSignatureSourceFieldFactory extends FieldFactory {return new FunctionSignatureSourceFieldFactory(formatModel, provider, toolOptions,fieldOptions);}-- @Override- public Color getDefaultColor() {- return OptionsGui.SEPARATOR.getDefaultColor();- }-- @Override- public void fieldOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- // don't care- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.javaindex 90e7f64912..e44c1be15a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.java@@ -15,7 +15,6 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import java.util.*;import java.util.stream.Collectors;@@ -24,10 +23,9 @@ import org.apache.commons.lang3.StringUtils;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.FunctionProxy;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -45,9 +43,6 @@ import ghidra.program.util.ProgramLocation;public class FunctionTagFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Function Tags";- public static final Color DEFAULT_COLOR = Palette.MAROON;-- private Color literalColor;/*** Default Constructor@@ -67,10 +62,6 @@ public class FunctionTagFieldFactory extends FieldFactory {private FunctionTagFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,Options displayOptions, Options fieldOptions) {super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);- color = displayOptions.getColor(OptionsGui.FUN_TAG.getColorOptionName(),- OptionsGui.FUN_TAG.getDefaultColor());- literalColor = displayOptions.getColor(OptionsGui.SEPARATOR.getColorOptionName(),- OptionsGui.SEPARATOR.getDefaultColor());}@Override@@ -139,18 +130,6 @@ public class FunctionTagFieldFactory extends FieldFactory {return new FunctionTagFieldFactory(formatModel, provider, toolOptions, fieldOptions);}- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- if (optionName.equals(OptionsGui.FUN_TAG.getColorOptionName())) {- color = (Color) newValue;- }- else if (optionName.equals(OptionsGui.SEPARATOR.getColorOptionName())) {- literalColor = (Color) newValue;- }- super.displayOptionsChanged(options, optionName, oldValue, newValue);- }-/*** Creates a tags list field to be show at the beginning of each function that shows the tags* assigned to that function.@@ -169,11 +148,11 @@ public class FunctionTagFieldFactory extends FieldFactory {AttributedString as;int elementIndex = 0;- as = new AttributedString("Tags: ", literalColor, getMetrics());+ as = new AttributedString("Tags: ", ListingColors.SEPARATOR, getMetrics());textElements.add(new TextFieldElement(as, elementIndex++, 0));String tagNamesStr = StringUtils.join(tagNames, ", ");- as = new AttributedString(tagNamesStr, color, getMetrics());+ as = new AttributedString(tagNamesStr, FunctionColors.TAG, getMetrics());textElements.add(new TextFieldElement(as, elementIndex++, 0));return textElements;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.javaindex a520453ae1..a9827594ef 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.java@@ -20,9 +20,8 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.MaskColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -38,9 +37,6 @@ import ghidra.util.StringUtilities;public class InstructionMaskValueFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Instr Mask/Value";- public static final Color MASK_COLOR = Palette.getColor("navy");- public static final Color VALUE_COLOR = Palette.GREEN;- public static final Color LABEL_COLOR = Colors.FOREGROUND;/*** Default constructor.@@ -61,12 +57,6 @@ public class InstructionMaskValueFieldFactory extends FieldFactory {super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);}- @Override- public void fieldOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- // stub- }-/*** Returns the FactoryField for the given object at index index.* @param varWidth the amount of variable width spacing for any fields@@ -100,14 +90,15 @@ public class InstructionMaskValueFieldFactory extends FieldFactory {try {FieldElement[] fieldElements = new FieldElement[2 * (operandCount + 1)];fieldElements[0] =- getLine("M[m]: ", instructionMask.getBytes(), MASK_COLOR, proxy, varWidth);+ getLine("M[m]: ", instructionMask.getBytes(), MaskColors.BITS, proxy, varWidth);fieldElements[1] =- getLine("V[m]: ", instructionMask.applyMask(instr), VALUE_COLOR, proxy, varWidth);+ getLine("V[m]: ", instructionMask.applyMask(instr), MaskColors.VALUE, proxy,+ varWidth);for (int i = 0; i < operandCount; i++) {fieldElements[2 * (i + 1)] = getLine("M[" + i + "]: ", operandMasks[i].getBytes(),- MASK_COLOR, proxy, varWidth);+ MaskColors.BITS, proxy, varWidth);fieldElements[2 * (i + 1) + 1] = getLine("V[" + i + "]: ",- operandMasks[i].applyMask(instr), VALUE_COLOR, proxy, varWidth);+ operandMasks[i].applyMask(instr), MaskColors.VALUE, proxy, varWidth);}return ListingTextField.createMultilineTextField(this, proxy, fieldElements,@@ -123,10 +114,11 @@ public class InstructionMaskValueFieldFactory extends FieldFactory {FieldElement[] fieldElements = new FieldElement[2];AttributedString as =- new AttributedString(label, LABEL_COLOR, getMetrics(), false, underlineColor);+ new AttributedString(label, MaskColors.LABEL, getMetrics(), false,+ ListingColors.UNDERLINE);fieldElements[0] = new TextFieldElement(as, 0, 0);as = new AttributedString(getFormattedBytes(value), valueColor, getMetrics(), false,- underlineColor);+ ListingColors.UNDERLINE);fieldElements[1] = new TextFieldElement(as, 0, 0);return new CompositeFieldElement(fieldElements);}@@ -178,9 +170,4 @@ public class InstructionMaskValueFieldFactory extends FieldFactory {return new InstructionMaskValueFieldFactory(formatModel, hsProvider, toolOptions,fieldOptions);}-- @Override- public Color getDefaultColor() {- return Colors.FOREGROUND;- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.javaindex e225df955b..1d9e1bf669 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.java@@ -454,5 +454,4 @@ public class LabelFieldFactory extends FieldFactory {ToolOptions pDisplayOptions, ToolOptions fieldOptions) {return new LabelFieldFactory(formatModel, provider, pDisplayOptions, fieldOptions);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingColors.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingColors.javanew file mode 100644index 0000000000..0941c7ac64--- /dev/null+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingColors.java@@ -0,0 +1,110 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.viewer.field;++import generic.theme.GColor;++public class ListingColors {+ // @formatter:off++ public static final GColor BACKGROUND = new GColor("color.bg.listing");++ public static final GColor ADDRESS = new GColor("color.fg.listing.address");+ public static final GColor BYTES = new GColor("color.fg.listing.bytes");+ public static final GColor EXT_ENTRY_POINT = new GColor("color.fg.listing.ext.entrypoint");+ public static final GColor FIELD_NAME = new GColor("color.fg.listing.fieldname");+ public static final GColor SEPARATOR = new GColor("color.fg.listing.separator");+ public static final GColor UNDERLINE = new GColor("color.fg.listing.underline");+ public static final GColor ARRAY_VALUES = new GColor("color.fg.listing.array.values");+ public static final GColor BYTES_ALIGNMENT = new GColor("color.fg.listing.bytes.alignment");+ public static final GColor BLOCK_START = new GColor("color.fg.listing.block.start");++ public static final GColor CONSTANT = new GColor("color.fg.listing.constant");+ public static final GColor REF_BAD = new GColor("color.fg.listing.ref.bad");+ public static final GColor EXT_REF_UNRESOLVED = new GColor("color.fg.listing.ext.ref.unresolved");+ public static final GColor EXT_REF_RESOLVED = new GColor("color.fg.listing.ext.ref.resolved");+ public static final GColor REGISTER = new GColor("color.fg.listing.register");+ public static final GColor PARALLEL_INSTRUCTION = new GColor("color.fg.listing.instruction.parallel");+++ public static class XrefColors {+ public static final GColor DEFAULT = new GColor("color.fg.listing.xref");+ public static final GColor OFFCUT = new GColor("color.fg.listing.xref.offcut");+ public static final GColor READ = new GColor("color.fg.listing.xref.read");+ public static final GColor WRITE = new GColor("color.fg.listing.xref.write");+ public static final GColor OTHER = new GColor("color.fg.listing.xref.other");+ }++ public static class PcodeColors {+ public static final GColor LABEL = new GColor("color.fg.listing.pcode.label");+ public static final GColor ADDRESS_SPACE = new GColor("color.fg.listing.pcode.address.space");+ public static final GColor VARNODE = new GColor("color.fg.listing.pcode.varnode");+ public static final GColor USEROP = new GColor("color.fg.listing.pcode.userop");+ }++ public static class MnemonicColors {+ public static final GColor NORMAL = new GColor("color.fg.listing.mnemonic");+ public static final GColor OVERRIDE = new GColor("color.fg.listing.mnemonic.override");+ public static final GColor UNIMPLEMENTED = new GColor("color.fg.listing.mnemonic.unimplemented");+ }++ public static class CommentColors {+ public static final GColor AUTO = new GColor("color.fg.listing.comment.auto");+ public static final GColor EOL = new GColor("color.fg.listing.comment.eol");+ public static final GColor PLATE= new GColor("color.fg.listing.comment.plate");+ public static final GColor POST= new GColor("color.fg.listing.comment.post");+ public static final GColor PRE= new GColor("color.fg.listing.comment.pre");+ public static final GColor REPEATABLE = new GColor("color.fg.listing.comment.repeatable");+ public static final GColor REF_REPEATABLE = new GColor("color.fg.listing.comment.ref.repeatable");+ }++ public static class LabelColors {+ public static final GColor LOCAL = new GColor("color.fg.listing.label.local");+ public static final GColor NON_PRIMARY = new GColor("color.fg.listing.label.non.primary");+ public static final GColor PRIMARY = new GColor("color.fg.listing.label.primary");+ public static final GColor UNREFERENCED = new GColor("color.fg.listing.label.unreferenced");+ }++ public static class FunctionColors {+ public static final GColor CALL_FIXUP = new GColor("color.fg.listing.function.callfixup");+ public static final GColor NAME = new GColor("color.fg.listing.function.name");+ public static final GColor PARAM = new GColor("color.fg.listing.function.param");+ public static final GColor PARAM_AUTO = new GColor("color.fg.listing.function.param.auto");+ public static final GColor PARAM_CUSTOM = new GColor("color.fg.listing.function.param.custom");+ public static final GColor PARAM_DYNAMIC = new GColor("color.fg.listing.function.param.dynamic");+ public static final GColor RETURN_TYPE = new GColor("color.fg.listing.function.return.type");+ public static final GColor SOURCE = new GColor("color.fg.listing.function.source");+ public static final GColor TAG = new GColor("color.fg.listing.function.tag");+ public static final GColor VARIABLE = new GColor("color.fg.listing.function.variable");+ public static final GColor VARIABLE_ASSIGNED = new GColor("color.fg.listing.function.variable.assigned");+ public static final GColor THUNK = new GColor("color.fg.listing.function.name.thunk");+ }++ public static class FlowArrowColors {+ public static final GColor ACTIVE = new GColor("color.fg.listing.flow.arrow.active");+ public static final GColor INACTIVE = new GColor("color.fg.listing.flow.arrow.inactive");+ public static final GColor SELECTED = new GColor("color.fg.listing.flow.arrow.selected");+ }++ public static class MaskColors {+ public static final GColor BITS = new GColor("color.fg.listing.mask.bits");+ public static final GColor LABEL = new GColor("color.fg.listing.mask.label");+ public static final GColor VALUE = new GColor("color.fg.listing.mask.value");++ }+ // @formatter:on++}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.javaindex 235eb487fc..da1b90aabb 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.java@@ -23,7 +23,6 @@ import java.util.List;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import docking.widgets.fieldpanel.support.RowColLocation;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -42,14 +41,12 @@ import ghidra.program.util.ProgramLocation;public class MemoryBlockStartFieldFactory extends FieldFactory {private static final String FIELD_NAME = "Memory Block Start";- private static final Color BLOCK_COLOR = Palette.getColor("indigo");/*** Constructor*/public MemoryBlockStartFieldFactory() {super(FIELD_NAME);- color = BLOCK_COLOR;}/**@@ -62,7 +59,6 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {private MemoryBlockStartFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,Options displayOptions, Options fieldOptions) {super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);- color = BLOCK_COLOR;}/**@@ -187,15 +183,6 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {fieldOptions);}- /**- * Creates a comment to be show at the beginning of each block that shows the following:- * - block name- * - block type- * - block start/end address (size)- * - block comment- *- * @param cu- */protected List<AttributedString> createBlockStartText(CodeUnit cu) {List<AttributedString> lines = new ArrayList<>();@@ -227,7 +214,7 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {String line1 = block.getName() + " " + type;String line2 = block.getComment();String line3 = block.getStart().toString(true) + "-" + block.getEnd().toString(true);-+ Color color = ListingColors.BLOCK_START;AttributedString borderAS = new AttributedString("//", color, getMetrics());lines.add(borderAS);lines.add(new AttributedString("// " + line1, color, getMetrics()));@@ -240,12 +227,6 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {return lines;}- /**- * Creates {@link FieldElement} instances for each given {@link AttributedString}.- *- * @param attributedStrings- * @return- */private FieldElement[] createFieldElements(List<AttributedString> attributedStrings) {List<FieldElement> elements = new ArrayList<>();int lineNum = 0;@@ -261,23 +242,4 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {return elementsArray;}-- /**- * Returns the length of the longest string in the given list.- *- * @param lines- * @return- */- private int getLongestLineSize(String... lines) {-- int longest = 0;- for (String line : lines) {- if (line.length() > longest) {- longest = line.length();- }- }- return longest;-- }-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.javaindex a7850ca733..b3af3ab501 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.java@@ -23,11 +23,10 @@ import javax.swing.event.ChangeListener;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import generic.theme.GThemeDefaults.Colors.Messages;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.GhidraOptions;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.MnemonicColors;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;import ghidra.framework.options.ToolOptions;@@ -45,14 +44,11 @@ import ghidra.util.HelpLocation;*/public class MnemonicFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Mnemonic";- public static final Color OVERRIDE_COLOR = Palette.PURPLE;private final static Color BAD_PROTOTYPE_COLOR = Messages.ERROR;private final static String SHOW_UNDERLINE_FOR_REFERENCES =GhidraOptions.MNEMONIC_GROUP_TITLE + Options.DELIMITER + "Underline Fields With References";- private static final String OVERRIDE_COLOR_OPTION = "Mnemonic, Override Color";- private Color overrideColor;private boolean underliningEnabled = true;protected BrowserCodeUnitFormat codeUnitFormat;@@ -76,8 +72,6 @@ public class MnemonicFieldFactory extends FieldFactory {Options displayOptions, ToolOptions fieldOptions) {super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);- overrideColor = displayOptions.getColor(OVERRIDE_COLOR_OPTION, OVERRIDE_COLOR);-HelpLocation hl = new HelpLocation("CodeBrowserPlugin", "Mnemonic_Field");fieldOptions.getOptions("Mnemonic Fields").setOptionsHelpLocation(hl);@@ -90,15 +84,6 @@ public class MnemonicFieldFactory extends FieldFactory {codeUnitFormat.addChangeListener(codeUnitFormatListener);}- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- if (optionName.equals(OVERRIDE_COLOR_OPTION)) {- overrideColor = (Color) newValue;- }- super.displayOptionsChanged(options, optionName, oldValue, newValue);- }-@Overridepublic void fieldOptionsChanged(Options options, String optionName, Object oldValue,Object newValue) {@@ -129,14 +114,14 @@ public class MnemonicFieldFactory extends FieldFactory {boolean underline = underliningEnabled && (cu.getMnemonicReferences().length > 0);String mnemonic = codeUnitFormat.getMnemonicRepresentation(cu);- Color c = color;+ Color c = MnemonicColors.NORMAL;if (invalidInstrProto) {c = BAD_PROTOTYPE_COLOR;}else if (cu instanceof Instruction) {Instruction instr = (Instruction) cu;if (instr.getFlowOverride() != FlowOverride.NONE || instr.isFallThroughOverridden()) {- c = overrideColor;+ c = MnemonicColors.OVERRIDE;}}else {@@ -146,7 +131,7 @@ public class MnemonicFieldFactory extends FieldFactory {}}AttributedString as =- new AttributedString(mnemonic, c, getMetrics(), underline, underlineColor);+ new AttributedString(mnemonic, c, getMetrics(), underline, ListingColors.UNDERLINE);FieldElement text = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, text, startX + varWidth,width, hlProvider);@@ -222,8 +207,4 @@ public class MnemonicFieldFactory extends FieldFactory {return new MnemonicFieldFactory(formatModel, hsProvider, displayOptions, fieldOptions);}- @Override- public Color getDefaultColor() {- return OptionsGui.MNEMONIC.getDefaultColor();- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.javaindex ee539773cc..f8d80eb218 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.java@@ -42,7 +42,7 @@ public class OpenCloseFieldFactory extends FieldFactory {/*** Constructor* @param model the model that the field belongs to.- * @param hsProvider the HightLightStringProvider.+ * @param hlProvider the HightLightStringProvider.* @param displayOptions the Options for display properties.* @param fieldOptions the Options for field specific properties.*/@@ -86,13 +86,6 @@ public class OpenCloseFieldFactory extends FieldFactory {return null;}- /**- * @see ghidra.app.util.viewer.field.FieldFactory#servicesChanged()- */- @Override- public void servicesChanged() {- }-/*** Computes if the given data is the last component at its level.*/@@ -165,5 +158,4 @@ public class OpenCloseFieldFactory extends FieldFactory {ToolOptions displayOptions, ToolOptions fieldOptions) {return new OpenCloseFieldFactory(fieldModel, provider, displayOptions, fieldOptions);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.javaindex 1c1c215955..b3803a1919 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.java@@ -27,6 +27,7 @@ import docking.widgets.fieldpanel.support.FieldLocation;import docking.widgets.fieldpanel.support.RowColLocation;import ghidra.GhidraOptions;import ghidra.app.util.*;+import ghidra.app.util.viewer.field.ListingColors.FunctionColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -366,7 +367,7 @@ abstract class OperandFieldHelper extends FieldFactory {: getAttributesForData(data, value);AttributedString as =new AttributedString(dataValueRepresentation.toString(), attributes.colorAttribute,- getMetrics(attributes.styleAttribute), underline, underlineColor);+ getMetrics(attributes.styleAttribute), underline, ListingColors.UNDERLINE);FieldElement field = new OperandFieldElement(as, 0, 0, 0);if (shouldWordWrap(data, dataValueRepresentation)) {@@ -450,7 +451,7 @@ abstract class OperandFieldHelper extends FieldFactory {AttributedString as =new AttributedString(opRepList != null ? opRepList.toString() : "<UNSUPPORTED>",badRefAttributes.colorAttribute, getMetrics(badRefAttributes.styleAttribute),- false, underlineColor);+ false, ListingColors.UNDERLINE);elements.add(new OperandFieldElement(as, opIndex, subOpIndex, characterOffset));characterOffset += as.length();}@@ -491,7 +492,7 @@ abstract class OperandFieldHelper extends FieldFactory {ColorStyleAttributes attributes = getOpAttributes(opElem, inst, opIndex);AttributedString as = new AttributedString(opElem.toString(), attributes.colorAttribute,- getMetrics(attributes.styleAttribute), underline, underlineColor);+ getMetrics(attributes.styleAttribute), underline, ListingColors.UNDERLINE);elements.add(new OperandFieldElement(as, opIndex, subOpIndex, characterOffset));return characterOffset + as.length();}@@ -670,34 +671,27 @@ abstract class OperandFieldHelper extends FieldFactory {* changes. It looks up all the color settings and resets the its values.*/private void setOptions(Options options) {- separatorAttributes.colorAttribute = options.getColor(- OptionsGui.SEPARATOR.getColorOptionName(), OptionsGui.SEPARATOR.getDefaultColor());++ separatorAttributes.colorAttribute = ListingColors.SEPARATOR;+ scalarAttributes.colorAttribute = ListingColors.CONSTANT;+ variableRefAttributes.colorAttribute = FunctionColors.VARIABLE;+ addressAttributes.colorAttribute = ListingColors.ADDRESS;+ externalRefAttributes.colorAttribute = ListingColors.EXT_REF_RESOLVED;+ badRefAttributes.colorAttribute = ListingColors.REF_BAD;+ registerAttributes.colorAttribute = ListingColors.REGISTER;+separatorAttributes.styleAttribute =options.getInt(OptionsGui.SEPARATOR.getStyleOptionName(), -1);- scalarAttributes.colorAttribute = options.getColor(OptionsGui.CONSTANT.getColorOptionName(),- OptionsGui.CONSTANT.getDefaultColor());scalarAttributes.styleAttribute =options.getInt(OptionsGui.CONSTANT.getStyleOptionName(), -1);- variableRefAttributes.colorAttribute = options.getColor(- OptionsGui.VARIABLE.getColorOptionName(), OptionsGui.VARIABLE.getDefaultColor());variableRefAttributes.styleAttribute =options.getInt(OptionsGui.VARIABLE.getStyleOptionName(), -1);- addressAttributes.colorAttribute = options.getColor(OptionsGui.ADDRESS.getColorOptionName(),- OptionsGui.ADDRESS.getDefaultColor());addressAttributes.styleAttribute =options.getInt(OptionsGui.ADDRESS.getStyleOptionName(), -1);- externalRefAttributes.colorAttribute =- options.getColor(OptionsGui.EXT_REF_RESOLVED.getColorOptionName(),- OptionsGui.EXT_REF_RESOLVED.getDefaultColor());externalRefAttributes.styleAttribute =options.getInt(OptionsGui.EXT_REF_RESOLVED.getStyleOptionName(), -1);- badRefAttributes.colorAttribute =- options.getColor(OptionsGui.BAD_REF_ADDR.getColorOptionName(),- OptionsGui.BAD_REF_ADDR.getDefaultColor());badRefAttributes.styleAttribute =options.getInt(OptionsGui.BAD_REF_ADDR.getStyleOptionName(), -1);- registerAttributes.colorAttribute = options.getColor(- OptionsGui.REGISTERS.getColorOptionName(), OptionsGui.REGISTERS.getDefaultColor());registerAttributes.styleAttribute =options.getInt(OptionsGui.REGISTERS.getStyleOptionName(), -1);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.javaindex 1a7d7b69e3..f5814473e6 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.java@@ -15,13 +15,10 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;-import generic.theme.GThemeDefaults.Colors;-import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -40,7 +37,6 @@ import ghidra.program.util.ProgramLocation;public class ParallelInstructionFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Parallel ||";- public static final Color DEFAULT_COLOR = Palette.BLUE;/*** Default constructor.@@ -61,12 +57,6 @@ public class ParallelInstructionFieldFactory extends FieldFactory {super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);}- @Override- public void fieldOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- // don't care- }-/*** Returns the FactoryField for the given object at index index.* @param proxy the object whose properties should be displayed.@@ -92,8 +82,8 @@ public class ParallelInstructionFieldFactory extends FieldFactory {return null;}- AttributedString as =- new AttributedString(fieldText, color, getMetrics(), false, underlineColor);+ AttributedString as = new AttributedString(fieldText, ListingColors.PARALLEL_INSTRUCTION,+ getMetrics(), false, ListingColors.UNDERLINE);FieldElement text = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, text, startX + varWidth,width, hlProvider);@@ -132,9 +122,4 @@ public class ParallelInstructionFieldFactory extends FieldFactory {return new ParallelInstructionFieldFactory(formatModel, hsProvider, toolOptinos,fieldOptions);}-- @Override- public Color getDefaultColor() {- return Colors.FOREGROUND;- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.javaindex 0c0c4c3a06..5c5e1c68f1 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java@@ -27,9 +27,9 @@ import docking.widgets.fieldpanel.support.*;import generic.theme.GThemeDefaults.Colors.Palette;import ghidra.app.util.HelpTopics;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.CommentColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.listingpanel.ListingModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.DataProxy;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -227,7 +227,8 @@ public class PlateFieldFactory extends FieldFactory {return false;}- AttributedString prototype = new AttributedString(EMPTY_STRING, color, getMetrics());+ AttributedString prototype =+ new AttributedString(EMPTY_STRING, CommentColors.PLATE, getMetrics());AttributedString asteriscs = getStarsString();int row = elements.size();@@ -288,19 +289,19 @@ public class PlateFieldFactory extends FieldFactory {addPadding(buffy, prePadding);FieldElement prefix = new TextFieldElement(- new AttributedString(buffy.toString(), color, getMetrics()), row, 0);+ new AttributedString(buffy.toString(), CommentColors.PLATE, getMetrics()), row, 0);- FieldElement ellipsis =- new TextFieldElement(new AttributedString(ellipsisText, color, getMetrics()), row,- prefix.length() + element.length());+ FieldElement ellipsis = new TextFieldElement(+ new AttributedString(ellipsisText, CommentColors.PLATE, getMetrics()), row,+ prefix.length() + element.length());buffy.setLength(0);addPadding(buffy, postPadding);buffy.append(' ').append('*');- FieldElement suffix =- new TextFieldElement(new AttributedString(buffy.toString(), color, getMetrics()), row,- prefix.length() + element.length() + ellipsis.length());+ FieldElement suffix = new TextFieldElement(+ new AttributedString(buffy.toString(), CommentColors.PLATE, getMetrics()), row,+ prefix.length() + element.length() + ellipsis.length());return new FieldElementResult(new CompositeFieldElement(new FieldElement[] { prefix, element, ellipsis, suffix }),@@ -314,7 +315,8 @@ public class PlateFieldFactory extends FieldFactory {}private void addBlankLines(List<FieldElement> elements, int numberBlankLines, CodeUnit cu) {- AttributedString prototype = new AttributedString(EMPTY_STRING, color, getMetrics());+ AttributedString prototype =+ new AttributedString(EMPTY_STRING, CommentColors.PLATE, getMetrics());for (int row = 0; row < numberBlankLines; row++) {elements.add(0, new TextFieldElement(prototype, row, 0));}@@ -350,7 +352,8 @@ public class PlateFieldFactory extends FieldFactory {elements.add(new TextFieldElement(asteriscs, row++, 0));int commentRow = row++;- AttributedString as = new AttributedString(defaultComment, color, getMetrics());+ AttributedString as =+ new AttributedString(defaultComment, CommentColors.PLATE, getMetrics());TextFieldElement commentElement = new TextFieldElement(as, commentRow, 0);FieldElementResult result = addSideBorder(commentElement, commentRow, true);elements.add(result.getFieldElement());@@ -424,7 +427,7 @@ public class PlateFieldFactory extends FieldFactory {private AttributedString getStarsString() {String asteriscs = getStars();- return new AttributedString(asteriscs, color, getMetrics());+ return new AttributedString(asteriscs, CommentColors.PLATE, getMetrics());}/**@@ -547,8 +550,8 @@ public class PlateFieldFactory extends FieldFactory {int dataRow = commentRow + numberBlankLines + headerCount;ListingTextField listingTextField = (ListingTextField) listingField;- RowColLocation location = listingTextField.dataToScreenLocation(dataRow,- commentLocation.getCharOffset());+ RowColLocation location =+ listingTextField.dataToScreenLocation(dataRow, commentLocation.getCharOffset());return new FieldLocation(index, fieldNum, location.row(), location.col());}@@ -569,11 +572,6 @@ public class PlateFieldFactory extends FieldFactory {return new PlateFieldFactory(formatModel, hsProvider, toolOptions, fieldOptions);}- @Override- public Color getDefaultColor() {- return OptionsGui.COMMENT_PLATE.getDefaultColor();- }-@Overridepublic void fieldOptionsChanged(Options options, String optionName, Object oldValue,Object newValue) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.javaindex 22eb944650..672b99efc3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.java@@ -25,6 +25,7 @@ import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import docking.widgets.fieldpanel.support.FieldUtils;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.CommentColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -72,7 +73,6 @@ public class PostCommentFieldFactory extends FieldFactory {private int nLinesAfterBlocks;private boolean isWordWrap;private boolean alwaysShowAutomatic;- private Color automaticCommentColor;private int automaticCommentStyle;/**@@ -104,9 +104,6 @@ public class PostCommentFieldFactory extends FieldFactory {flagJMPsRETs = fieldOptions.getBoolean(FLAG_TERMINATOR_OPTION, false);nLinesAfterBlocks = fieldOptions.getInt(LINES_AFTER_BLOCKS_OPTION, 0);- automaticCommentColor =- displayOptions.getColor(OptionsGui.COMMENT_AUTO.getColorOptionName(),- OptionsGui.COMMENT_AUTO.getDefaultColor());automaticCommentStyle =displayOptions.getInt(OptionsGui.COMMENT_AUTO.getStyleOptionName(), -1);@@ -331,11 +328,6 @@ public class PostCommentFieldFactory extends FieldFactory {return new PostCommentFieldFactory(formatModel, provider, toolOptions, fieldOptions);}- @Override- public Color getDefaultColor() {- return OptionsGui.COMMENT_POST.getDefaultColor();- }-@Overridepublic void fieldOptionsChanged(Options options, String optionName, Object oldValue,Object newValue) {@@ -379,9 +371,6 @@ public class PostCommentFieldFactory extends FieldFactory {*/private void adjustAutomaticCommentDisplayOptions(Options options, String optionName,Object oldValue, Object newValue) {- if (optionName.equals(OptionsGui.COMMENT_AUTO.getColorOptionName())) {- automaticCommentColor = (Color) newValue;- }String automaticCommentStyleName = OptionsGui.COMMENT_AUTO.getStyleOptionName();if (optionName.equals(automaticCommentStyleName)) {automaticCommentStyle = options.getInt(automaticCommentStyleName, -1);@@ -393,6 +382,7 @@ public class PostCommentFieldFactory extends FieldFactory {Listing listing = instr.getProgram().getListing();Address addr = instr.getMinAddress();FlowType flowType = instr.getFlowType();+ Color color = CommentColors.POST;// Options that affect Post Comments:// Flag Function Exits (only if post comment does not exist)@@ -456,7 +446,7 @@ public class PostCommentFieldFactory extends FieldFactory {if (fields.length > 0) {for (int i = 0; i < nLinesAutoComment; i++) {AttributedString as = new AttributedString(autoComment[i],- automaticCommentColor, getMetrics(automaticCommentStyle), false, null);+ CommentColors.AUTO, getMetrics(automaticCommentStyle), false, null);fields[i] = new TextFieldElement(as, i, 0);}for (int i = 0; i < comments.length; i++) {@@ -497,10 +487,11 @@ public class PostCommentFieldFactory extends FieldFactory {CodeUnit cu = (CodeUnit) proxy.getObject();Program program = cu.getProgram();- AttributedString prototypeString = new AttributedString("prototype", color, getMetrics());+ AttributedString prototypeString =+ new AttributedString("prototype", CommentColors.POST, getMetrics());List<FieldElement> fields = new ArrayList<>();for (int i = 0; i < nLinesAutoComment; i++) {- AttributedString as = new AttributedString(autoComment[i], automaticCommentColor,+ AttributedString as = new AttributedString(autoComment[i], CommentColors.AUTO,getMetrics(automaticCommentStyle), false, null);fields.add(new TextFieldElement(as, i, 0));}@@ -513,7 +504,7 @@ public class PostCommentFieldFactory extends FieldFactory {}if (useLinesAfterBlock) {for (int i = 0; i < nLinesAfterBlocks; i++) {- AttributedString as = new AttributedString("", color, getMetrics());+ AttributedString as = new AttributedString("", CommentColors.POST, getMetrics());fields.add(new TextFieldElement(as, fields.size(), 0));}}@@ -618,12 +609,12 @@ public class PostCommentFieldFactory extends FieldFactory {hasAppropriatePcodeOp = true;if (op.getOpcode() == PcodeOp.CALLOTHER) {if (callOtherName == null) {- callOtherName = inst.getProgram().getLanguage().getUserDefinedOpName(- (int) op.getInput(0).getOffset());+ callOtherName = inst.getProgram()+ .getLanguage()+ .getUserDefinedOpName((int) op.getInput(0).getOffset());if (op.getOutput() != null) {outputWarningString =- "WARNING: Output of " + callOtherName +- " destroyed by override!";+ "WARNING: Output of " + callOtherName + " destroyed by override!";}}else {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.javaindex bc58280672..e0bde83c4c 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.java@@ -15,7 +15,6 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import java.util.ArrayList;import java.util.List;@@ -26,6 +25,7 @@ import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import docking.widgets.fieldpanel.support.FieldUtils;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.CommentColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;@@ -66,7 +66,6 @@ public class PreCommentFieldFactory extends FieldFactory {private boolean flagSubroutineEntry;private boolean isWordWrap;private boolean alwaysShowAutomatic;- private Color automaticCommentColor;private int automaticCommentStyle;/**@@ -95,9 +94,6 @@ public class PreCommentFieldFactory extends FieldFactory {flagFunctionEntry = fieldOptions.getBoolean(FLAG_FUNCTION_ENTRY_OPTION, false);flagSubroutineEntry = fieldOptions.getBoolean(FLAG_SUBROUTINE_ENTRY_OPTION, false);- automaticCommentColor =- displayOptions.getColor(OptionsGui.COMMENT_AUTO.getColorOptionName(),- OptionsGui.COMMENT_AUTO.getDefaultColor());automaticCommentStyle =displayOptions.getInt(OptionsGui.COMMENT_AUTO.getStyleOptionName(), -1);@@ -188,11 +184,6 @@ public class PreCommentFieldFactory extends FieldFactory {return new PreCommentFieldFactory(formatModel, provider, toolOptions, fieldOptions);}- @Override- public Color getDefaultColor() {- return OptionsGui.COMMENT_PRE.getDefaultColor();- }-@Overridepublic void fieldOptionsChanged(Options options, String optionName, Object oldValue,Object newValue) {@@ -266,7 +257,7 @@ public class PreCommentFieldFactory extends FieldFactory {// NOTE: A zero-length composite has a length of 1 which may cause it to improperly consume// the address location which actually corresponds to a trailing zero-length// component.-+int levelsToIgnore = 0;String label = null;Address prevDataAddr = data.getMinAddress().previous();@@ -314,11 +305,11 @@ public class PreCommentFieldFactory extends FieldFactory {lastDtc = ddt.getComponent(lastDtcOrdinal, data);}}-+if (lastDtc == null || lastDtc.getLength() == 0) {break;}-+Data component = data.getComponent(lastDtc.getOrdinal());if (component == null) {return null;@@ -329,11 +320,12 @@ public class PreCommentFieldFactory extends FieldFactory {if (lastDtc == null || lastDtc.isBitFieldComponent()) {return null;}-+return buildZeroLengthComponentAutoComment(lastDtc, data, levelsToIgnore, label);}- private String[] buildZeroLengthComponentAutoComment(DataTypeComponent lastZeroLengthComponent, Data data, int levelsToIgnore, String label) {+ private String[] buildZeroLengthComponentAutoComment(DataTypeComponent lastZeroLengthComponent,+ Data data, int levelsToIgnore, String label) {String fieldName = lastZeroLengthComponent.getFieldName();if (StringUtils.isEmpty(fieldName)) {@@ -356,8 +348,8 @@ public class PreCommentFieldFactory extends FieldFactory {flexName.insert(0, label + ".");}- return new String[] { "Zero-length Component: " + lastZeroLengthComponent.getDataType().getName() + " " +- flexName.toString() };+ return new String[] { "Zero-length Component: " ++ lastZeroLengthComponent.getDataType().getName() + " " + flexName.toString() };}private ListingTextField getTextField(String[] comments, String[] autoComment,@@ -378,10 +370,11 @@ public class PreCommentFieldFactory extends FieldFactory {CodeUnit cu = (CodeUnit) proxy.getObject();Program program = cu.getProgram();- AttributedString prototypeString = new AttributedString("prototype", color, getMetrics());+ AttributedString prototypeString =+ new AttributedString("prototype", CommentColors.PRE, getMetrics());List<FieldElement> fields = new ArrayList<>();for (int i = 0; i < nLinesAutoComment; i++) {- AttributedString as = new AttributedString(autoComment[i], automaticCommentColor,+ AttributedString as = new AttributedString(autoComment[i], CommentColors.AUTO,getMetrics(automaticCommentStyle), false, null);fields.add(new TextFieldElement(as, i, 0));}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.javaindex 6ae3f2f80c..0a1c3e7bd8 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.java@@ -15,7 +15,6 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import java.util.*;@@ -23,7 +22,6 @@ import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;import ghidra.framework.options.ToolOptions;@@ -47,7 +45,6 @@ public class RegisterFieldFactory extends FieldFactory {RegisterFieldFactory.REGISTER_GROUP_NAME + Options.DELIMITER +"Display Default Register Values";private RegComparator regComp;- private Color regColor;private boolean showHiddenRegisters;private boolean showDefaultValues;@@ -59,15 +56,16 @@ public class RegisterFieldFactory extends FieldFactory {Options displayOptions, Options fieldOptions) {super(FIELD_NAME, model, highlightProvider, displayOptions, fieldOptions);regComp = new RegComparator();- initDisplayOptions();+ }++ @Override+ protected void initFieldOptions(Options fieldOptions) {+ super.initFieldOptions(fieldOptions);fieldOptions.registerOption(DISPLAY_HIDDEN_REGISTERS_OPTION_NAME, false, null,"Shows/hides context registers");fieldOptions.registerOption(DISPLAY_DEFAULT_REGISTER_VALUES_OPTION_NAME, false, null,"Shows/hides default register values");- regColor =- displayOptions.getColor(OptionsGui.REGISTERS.getColorOptionName(), getDefaultColor());-showHiddenRegisters = fieldOptions.getBoolean(DISPLAY_HIDDEN_REGISTERS_OPTION_NAME, false);showDefaultValues =fieldOptions.getBoolean(DISPLAY_DEFAULT_REGISTER_VALUES_OPTION_NAME, false);@@ -152,11 +150,6 @@ public class RegisterFieldFactory extends FieldFactory {return (category == FieldFormatModel.FUNCTION);}- @Override- public Color getDefaultColor() {- return OptionsGui.REGISTERS.getDefaultColor();- }-@Overridepublic void fieldOptionsChanged(Options options, String optionName, Object oldValue,Object newValue) {@@ -173,16 +166,6 @@ public class RegisterFieldFactory extends FieldFactory {}}- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- super.displayOptionsChanged(options, optionName, oldValue, newValue);- if (optionName.equals(OptionsGui.REGISTERS.getColorOptionName())) {- regColor = (Color) newValue;- model.update();- }- }-private List<Register> getSetRegisters(Function function) {Program program = function.getProgram();ProgramContext programContext = program.getProgramContext();@@ -219,7 +202,8 @@ public class RegisterFieldFactory extends FieldFactory {private FieldElement[] getFieldElements(String[] registerStrings) {FieldElement[] fieldElements = new FieldElement[registerStrings.length];for (int i = 0; i < registerStrings.length; i++) {- AttributedString str = new AttributedString(registerStrings[i], regColor, getMetrics());+ AttributedString str =+ new AttributedString(registerStrings[i], ListingColors.REGISTER, getMetrics());fieldElements[i] = new TextFieldElement(str, i, 0);}return fieldElements;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.javaindex dcbbd95a44..663c87346c 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.java@@ -15,7 +15,6 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import java.util.ArrayList;import java.util.List;@@ -25,7 +24,6 @@ import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.cmd.function.CallDepthChangeInfo;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;import ghidra.framework.options.ToolOptions;@@ -36,15 +34,11 @@ import ghidra.program.model.listing.*;import ghidra.program.util.ProgramLocation;import ghidra.program.util.RegisterTransitionFieldLocation;-/**- * Generates Mnemonic Fields.- */public class RegisterTransitionFieldFactory extends FieldFactory {private static final String FIELD_NAME = "Register Transition";private static final String DISPLAY_HIDDEN_REGISTERS_OPTION_NAME =RegisterFieldFactory.DISPLAY_HIDDEN_REGISTERS_OPTION_NAME;- private Color regColor;private boolean showContextRegisters;/**@@ -68,9 +62,6 @@ public class RegisterTransitionFieldFactory extends FieldFactory {}private void initOptions(Options displayOptions, Options fieldOptions) {- regColor =- displayOptions.getColor(OptionsGui.REGISTERS.getColorOptionName(), getDefaultColor());-showContextRegisters = fieldOptions.getBoolean(DISPLAY_HIDDEN_REGISTERS_OPTION_NAME, false);}@@ -85,17 +76,6 @@ public class RegisterTransitionFieldFactory extends FieldFactory {}}- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- super.displayOptionsChanged(options, optionName, oldValue, newValue);-- if (optionName.equals(OptionsGui.REGISTERS.getColorOptionName())) {- regColor = (Color) newValue;- model.update();- }- }-/*** Returns the FactoryField for the given object at index index.* @param varWidth the amount of variable width spacing for any fields@@ -141,12 +121,15 @@ public class RegisterTransitionFieldFactory extends FieldFactory {FieldElement[] fieldElements = new FieldElement[numElements];for (int i = 0; i < numRegisters; i++) {Register register = transitionRegisters.get(i);- AttributedString str = new AttributedString("assume " + register.getName() + " = " +- getValueString(register, context, curAddress), regColor, getMetrics());+ AttributedString str = new AttributedString(+ "assume " + register.getName() + " = " ++ getValueString(register, context, curAddress),+ ListingColors.REGISTER, getMetrics());fieldElements[i] = new TextFieldElement(str, i, 0);}if (stackDepthStr != null) {- AttributedString str = new AttributedString(stackDepthStr, regColor, getMetrics());+ AttributedString str =+ new AttributedString(stackDepthStr, ListingColors.REGISTER, getMetrics());fieldElements[numRegisters] = new TextFieldElement(str, numRegisters, 0);}return ListingTextField.createMultilineTextField(this, proxy, fieldElements,@@ -264,9 +247,4 @@ public class RegisterTransitionFieldFactory extends FieldFactory {return new RegisterTransitionFieldFactory(fieldFormatModel, hsProvider, displayOptions,fieldOptions);}-- @Override- public Color getDefaultColor() {- return OptionsGui.MNEMONIC.getDefaultColor();- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.javaindex 8662d9f951..1823c5e1cd 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.java@@ -48,7 +48,7 @@ public class SeparatorFieldFactory extends FieldFactory {/*** Constructor* @param model the model that the field belongs to.- * @param hsProvider the HightLightStringProvider.+ * @param hlProvider the HightLightStringProvider.* @param displayOptions the Options for display properties.* @param fieldOptions the Options for field specific properties.*/@@ -71,7 +71,8 @@ public class SeparatorFieldFactory extends FieldFactory {sb.append(sepChar);}- AttributedString as = new AttributedString(sb.toString(), color, getMetrics());+ AttributedString as =+ new AttributedString(sb.toString(), ListingColors.SEPARATOR, getMetrics());FieldElement text = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, text, startX + varWidth,width, hlProvider);@@ -118,5 +119,4 @@ public class SeparatorFieldFactory extends FieldFactory {ToolOptions displayOptions, ToolOptions fieldOptions) {return new SeparatorFieldFactory(formatModel, provider, displayOptions, fieldOptions);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.javaindex 2d3a5de21e..76cffda75f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.java@@ -47,7 +47,7 @@ public class SpaceFieldFactory extends FieldFactory {/*** Constructor* @param model the model that the field belongs to.- * @param hsProvider the HightLightStringProvider.+ * @param hlProvider the HightLightStringProvider.* @param displayOptions the Options for display properties.* @param fieldOptions the Options for field specific properties.*/@@ -84,8 +84,8 @@ public class SpaceFieldFactory extends FieldFactory {fes[i] = new TextFieldElement(as, 0, 0);}- return ListingTextField.createMultilineTextField(this, proxy, fes,- startX + varWidth, width, n + 1, hlProvider);+ return ListingTextField.createMultilineTextField(this, proxy, fes, startX + varWidth,+ width, n + 1, hlProvider);}return null;@@ -153,5 +153,4 @@ public class SpaceFieldFactory extends FieldFactory {ToolOptions displayOptions, ToolOptions fieldOptions) {return new SpaceFieldFactory(formatModel, provider, displayOptions, fieldOptions);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.javaindex 9d0e77fb0d..1d2d149542 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.java@@ -30,12 +30,9 @@ import ghidra.program.model.listing.Data;import ghidra.program.util.ProgramLocation;import ghidra.program.util.SpacerFieldLocation;import ghidra.util.StringUtilities;-import ghidra.util.classfinder.ClassSearcher;/*** Generates Spacer Fields.- * <P>- * This field is not meant to be loaded by the {@link ClassSearcher}, hence the X in the name.*/public class SpacerFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Spacer";@@ -114,7 +111,7 @@ public class SpacerFieldFactory extends FieldFactory {@Overridepublic ListingField getField(ProxyObj<?> proxy, int varWidth) {if (enabled && (text != null)) {- AttributedString as = new AttributedString(text, color, getMetrics());+ AttributedString as = new AttributedString(text, ListingColors.SEPARATOR, getMetrics());FieldElement field = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, field, startX + varWidth,width, hlProvider);@@ -186,5 +183,4 @@ public class SpacerFieldFactory extends FieldFactory {ToolOptions options, ToolOptions fieldOptions) {return new SpacerFieldFactory(formatModel, provider, options, fieldOptions);}-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.javaindex 023832b368..9757eacf84 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.java@@ -23,7 +23,6 @@ import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.FunctionProxy;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -41,9 +40,6 @@ import ghidra.program.util.ThunkedFunctionFieldLocation;public class ThunkedFunctionFieldFactory extends FieldFactory {public static final String FIELD_NAME = "Thunked-Function";- private Color literalColor;- private Color unresolvedThunkRefColor;- private Color resolvedThunkRefColor;/*** Default Constructor@@ -62,46 +58,23 @@ public class ThunkedFunctionFieldFactory extends FieldFactory {public ThunkedFunctionFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,ToolOptions displayOptions, Options fieldOptions) {super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);-- literalColor = displayOptions.getColor(OptionsGui.SEPARATOR.getColorOptionName(),- OptionsGui.SEPARATOR.getDefaultColor());- unresolvedThunkRefColor =- displayOptions.getColor(OptionsGui.BAD_REF_ADDR.getColorOptionName(),- OptionsGui.BAD_REF_ADDR.getDefaultColor());- resolvedThunkRefColor =- displayOptions.getColor(OptionsGui.EXT_REF_RESOLVED.getColorOptionName(),- OptionsGui.EXT_REF_RESOLVED.getDefaultColor());- }-- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- super.displayOptionsChanged(options, optionName, oldValue, newValue);- literalColor = options.getColor(OptionsGui.FUN_CALL_FIXUP.getColorOptionName(),- OptionsGui.FUN_CALL_FIXUP.getDefaultColor());- unresolvedThunkRefColor =- displayOptions.getColor(OptionsGui.BAD_REF_ADDR.getColorOptionName(),- OptionsGui.BAD_REF_ADDR.getDefaultColor());- resolvedThunkRefColor =- displayOptions.getColor(OptionsGui.EXT_REF_RESOLVED.getColorOptionName(),- OptionsGui.EXT_REF_RESOLVED.getDefaultColor());}private Color getThunkedFunctionNameColor(Function thunkedFunction) {if (!thunkedFunction.isExternal()) {- return literalColor;+ return ListingColors.SEPARATOR;}ExternalLocation externalLocation = thunkedFunction.getExternalLocation();String libName = externalLocation.getLibraryName();if (Library.UNKNOWN.equals(libName)) {- return unresolvedThunkRefColor;+ return ListingColors.EXT_REF_UNRESOLVED;}ExternalManager externalManager = thunkedFunction.getProgram().getExternalManager();String path = externalManager.getExternalLibraryPath(libName);if (path == null || path.length() == 0) {- return unresolvedThunkRefColor;+ return ListingColors.EXT_REF_UNRESOLVED;}- return resolvedThunkRefColor;+ return ListingColors.EXT_REF_RESOLVED;}@Override@@ -120,7 +93,7 @@ public class ThunkedFunctionFieldFactory extends FieldFactory {AttributedString as;int elementIndex = 0;- as = new AttributedString("Thunked-Function: ", literalColor, getMetrics());+ as = new AttributedString("Thunked-Function: ", ListingColors.SEPARATOR, getMetrics());textElements.add(new TextFieldElement(as, elementIndex++, 0));as = new AttributedString(thunkedFunction.getName(true),@@ -171,10 +144,4 @@ public class ThunkedFunctionFieldFactory extends FieldFactory {return new ThunkedFunctionFieldFactory(formatModel, provider, pDisplayOptions,fieldOptions);}-- @Override- public void fieldOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- // don't care- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.javaindex 53c00173b2..8b48c21920 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.java@@ -15,14 +15,12 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.app.util.viewer.proxy.VariableProxy;import ghidra.framework.options.Options;@@ -48,7 +46,7 @@ public class VariableCommentFieldFactory extends AbstractVariableFieldFactory {/*** Constructor* @param model the model that the field belongs to.- * @param hsProvider the HightLightStringProvider.+ * @param hlProvider the HightLightStringProvider.* @param displayOptions the Options for display properties.* @param fieldOptions the Options for field specific properties.*/@@ -181,12 +179,4 @@ public class VariableCommentFieldFactory extends AbstractVariableFieldFactory {ToolOptions displayOptions, ToolOptions fieldOptions) {return new VariableCommentFieldFactory(formatModel, provider, displayOptions, fieldOptions);}-- /**- * @see ghidra.app.util.viewer.field.FieldFactory#getDefaultColor()- */- @Override- public Color getDefaultColor() {- return OptionsGui.VARIABLE.getDefaultColor();- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.javaindex 8b8a9e73c9..41d054c1e7 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.java@@ -15,7 +15,6 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.awt.FontMetrics;import java.math.BigInteger;@@ -27,7 +26,6 @@ import generic.theme.GIcon;import generic.theme.GThemeDefaults.Colors.Messages;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.app.util.viewer.proxy.VariableProxy;import ghidra.framework.options.Options;@@ -151,9 +149,4 @@ public class VariableLocFieldFactory extends AbstractVariableFieldFactory {ToolOptions toolOptions, ToolOptions fieldOptions) {return new VariableLocFieldFactory(formatModel, provider, toolOptions, fieldOptions);}-- @Override- public Color getDefaultColor() {- return OptionsGui.VARIABLE.getDefaultColor();- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.javaindex 2bdbae8796..29fc07f729 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.java@@ -15,14 +15,12 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.app.util.viewer.proxy.VariableProxy;import ghidra.framework.options.Options;@@ -129,13 +127,4 @@ public class VariableNameFieldFactory extends AbstractVariableFieldFactory {ToolOptions displayOptions, ToolOptions fieldOptions) {return new VariableNameFieldFactory(formatModel, provider, displayOptions, fieldOptions);}-- /**- * @see ghidra.app.util.viewer.field.FieldFactory#getDefaultColor()- */- @Override- public Color getDefaultColor() {- return OptionsGui.VARIABLE.getDefaultColor();-- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.javaindex f9fb4a0e42..bc3ea8a29c 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.java@@ -15,14 +15,12 @@*/package ghidra.app.util.viewer.field;-import java.awt.Color;import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.app.util.viewer.proxy.VariableProxy;import ghidra.framework.options.Options;@@ -139,13 +137,4 @@ public class VariableTypeFieldFactory extends AbstractVariableFieldFactory {ToolOptions displayOptions, ToolOptions fieldOptions) {return new VariableTypeFieldFactory(formatModel, provider, displayOptions, fieldOptions);}-- /**- * @see ghidra.app.util.viewer.field.FieldFactory#getDefaultColor()- */- @Override- public Color getDefaultColor() {- return OptionsGui.VARIABLE.getDefaultColor();- }-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.javaindex bd98344f0c..d2e7827800 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.java@@ -24,6 +24,7 @@ import docking.widgets.fieldpanel.support.RowColLocation;import generic.theme.GThemeDefaults.Colors;import ghidra.app.util.HighlightProvider;import ghidra.app.util.XReferenceUtils;+import ghidra.app.util.viewer.field.ListingColors.XrefColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -69,9 +70,13 @@ public class VariableXRefFieldFactory extends XRefFieldFactory {protected VariableXRefFieldFactory(String name, FieldFormatModel model,HighlightProvider hlProvider, Options displayOptions, ToolOptions fieldOptions) {super(name, model, hlProvider, displayOptions, fieldOptions);+ }++ @Override+ protected void initDisplayOptions(Options displayOptions) {colorOptionName = "XRef Color";styleOptionName = "XRef Style";- initDisplayOptions();+ super.initDisplayOptions(displayOptions);}@Override@@ -110,7 +115,7 @@ public class VariableXRefFieldFactory extends XRefFieldFactory {Reference reference = xrefs.get(count);String prefix = getPrefix(program, reference, func);AttributedString as = new AttributedString(reference.getFromAddress().toString(prefix),- color, getMetrics());+ XrefColors.DEFAULT, getMetrics());if (displayRefType) {as = createRefTypeAttributedString(reference, as);}@@ -122,7 +127,7 @@ public class VariableXRefFieldFactory extends XRefFieldFactory {char[] charSpaces = new char[delimiter.length()];Arrays.fill(charSpaces, ' ');AttributedString spaces =- new AttributedString(new String(charSpaces), color, getMetrics());+ new AttributedString(new String(charSpaces), XrefColors.DEFAULT, getMetrics());as = new CompositeAttributedString(new AttributedString[] { as, spaces });}elements[count] = new TextFieldElement(as, count, 0);@@ -132,7 +137,7 @@ public class VariableXRefFieldFactory extends XRefFieldFactory {Reference ref = offcuts.get(i);String prefix = getPrefix(program, ref, func);AttributedString as = new AttributedString(ref.getFromAddress().toString(prefix),- offcutColor, getMetrics());+ XrefColors.OFFCUT, getMetrics());if (displayRefType) {as = createRefTypeAttributedString(ref, as);}@@ -144,14 +149,14 @@ public class VariableXRefFieldFactory extends XRefFieldFactory {char[] charSpaces = new char[delimiter.length()];Arrays.fill(charSpaces, ' ');AttributedString spaces =- new AttributedString(new String(charSpaces), offcutColor, getMetrics());+ new AttributedString(new String(charSpaces), XrefColors.OFFCUT, getMetrics());as = new CompositeAttributedString(new AttributedString[] { as, spaces });}elements[count] = new TextFieldElement(as, count, 0);}if (tooMany) {- AttributedString as = new AttributedString("[more]", color, getMetrics());+ AttributedString as = new AttributedString("[more]", XrefColors.DEFAULT, getMetrics());elements[count - 1] = new TextFieldElement(as, count - 1, 0);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.javaindex 32032e99eb..41593bd61d 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.java@@ -20,6 +20,7 @@ import java.math.BigInteger;import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;+import ghidra.app.util.viewer.field.ListingColors.XrefColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.app.util.viewer.proxy.VariableProxy;@@ -77,7 +78,7 @@ public class VariableXRefHeaderFieldFactory extends VariableXRefFieldFactory {return null;}- AttributedString as = new AttributedString(headString, color, getMetrics());+ AttributedString as = new AttributedString(headString, XrefColors.DEFAULT, getMetrics());FieldElement text = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, text, startX + varWidth,width, hlProvider);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.javaindex 306b6cb585..7d5164b752 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.java@@ -30,8 +30,8 @@ import docking.widgets.fieldpanel.support.*;import generic.theme.GThemeDefaults.Colors;import ghidra.app.util.HighlightProvider;import ghidra.app.util.XReferenceUtils;+import ghidra.app.util.viewer.field.ListingColors.XrefColors;import ghidra.app.util.viewer.format.FieldFormatModel;-import ghidra.app.util.viewer.options.OptionsGui;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.*;import ghidra.program.model.address.Address;@@ -77,10 +77,6 @@ public class XRefFieldFactory extends FieldFactory {private PropertyEditor namespaceOptionsEditor = new NamespacePropertyEditor();- protected Color offcutColor;- protected Color readColor;- protected Color writeColor;- protected Color otherColor;protected String delim = DELIMITER;protected boolean displayBlockName;protected boolean groupByFunction;@@ -143,15 +139,6 @@ public class XRefFieldFactory extends FieldFactory {fieldOptions.registerOption(GROUP_BY_FUNCTION_KEY, false, hl,"True signals to group all xrefs by the containing calling function.");- offcutColor = displayOptions.getColor(OptionsGui.XREF_OFFCUT.getColorOptionName(),- OptionsGui.XREF_OFFCUT.getDefaultColor());- readColor = displayOptions.getColor(OptionsGui.XREF_READ.getColorOptionName(),- OptionsGui.XREF_READ.getDefaultColor());- writeColor = displayOptions.getColor(OptionsGui.XREF_WRITE.getColorOptionName(),- OptionsGui.XREF_WRITE.getDefaultColor());- otherColor = displayOptions.getColor(OptionsGui.XREF_OTHER.getColorOptionName(),- OptionsGui.XREF_OTHER.getDefaultColor());-typeComparator = (r1, r2) -> {if (r1.getReferenceType().toString().equals(r2.getReferenceType().toString())) {return r1.compareTo(r2);@@ -183,13 +170,11 @@ public class XRefFieldFactory extends FieldFactory {namespaceOptionsEditor);CustomOption customOption = fieldOptions.getCustomOption(NAMESPACE_OPTIONS_KEY, null);fieldOptions.getOptions(NAMESPACE_OPTIONS_KEY)- .setOptionsHelpLocation(- new HelpLocation("CodeBrowserPlugin", "XREFs_Field"));+ .setOptionsHelpLocation(new HelpLocation("CodeBrowserPlugin", "XREFs_Field"));if (!(customOption instanceof NamespaceWrappedOption)) {- throw new AssertException(- "Someone set an option for " + NAMESPACE_OPTIONS_KEY +- " that is not the expected " +- "ghidra.app.util.viewer.field.NamespaceWrappedOption type.");+ throw new AssertException("Someone set an option for " + NAMESPACE_OPTIONS_KEY ++ " that is not the expected " ++ "ghidra.app.util.viewer.field.NamespaceWrappedOption type.");}NamespaceWrappedOption namespaceOption = (NamespaceWrappedOption) customOption;@@ -199,33 +184,6 @@ public class XRefFieldFactory extends FieldFactory {localPrefixText = namespaceOption.getLocalPrefixText();}- @Override- public void displayOptionsChanged(Options options, String optionName, Object oldValue,- Object newValue) {- super.displayOptionsChanged(options, optionName, oldValue, newValue);-- if (optionName.equals(OptionsGui.XREF_OFFCUT.getColorOptionName())) {- offcutColor = (Color) newValue;- model.update();- }- else if (optionName.equals(OptionsGui.XREF.getColorOptionName())) {- color = (Color) newValue;- model.update();- }- else if (optionName.equals(OptionsGui.XREF_READ.getColorOptionName())) {- readColor = (Color) newValue;- model.update();- }- else if (optionName.equals(OptionsGui.XREF_WRITE.getColorOptionName())) {- writeColor = (Color) newValue;- model.update();- }- else if (optionName.equals(OptionsGui.XREF_OTHER.getColorOptionName())) {- otherColor = (Color) newValue;- model.update();- }- }-@Overridepublic void fieldOptionsChanged(Options options, String optionName, Object oldValue,Object newValue) {@@ -268,11 +226,6 @@ public class XRefFieldFactory extends FieldFactory {maxXRefs = n;}- @Override- public Color getDefaultColor() {- return OptionsGui.XREF.getDefaultColor();- }-@Overridepublic ListingField getField(ProxyObj<?> proxy, int varWidth) {Object obj = proxy.getObject();@@ -330,8 +283,8 @@ public class XRefFieldFactory extends FieldFactory {*/- private ListingField getFieldByFunction(ProxyObj<?> proxy, int varWidth,- List<Reference> xrefs, List<Reference> offcuts) {+ private ListingField getFieldByFunction(ProxyObj<?> proxy, int varWidth, List<Reference> xrefs,+ List<Reference> offcuts) {int totalXrefs = xrefs.size() + offcuts.size();if (totalXrefs == 0) {@@ -372,9 +325,8 @@ public class XRefFieldFactory extends FieldFactory {HighlightFactory hlFactory =new FieldHighlightFactory(hlProvider, getClass(), proxy.getObject());Function currentFunction = functionManager.getFunctionContaining(cu.getMinAddress());- List<TextField> functionRows =- createXrefRowsByFunction(program, currentFunction, xrefsByFunction, isOffcut, varWidth,- hlFactory);+ List<TextField> functionRows = createXrefRowsByFunction(program, currentFunction,+ xrefsByFunction, isOffcut, varWidth, hlFactory);//// TODO maxXRefs makes sense when simply displaying xrefs. What does max mean when@@ -398,9 +350,8 @@ public class XRefFieldFactory extends FieldFactory {// Our screen rows are what we are building to display; a data row we are here// defining to be a single xref. This is a somewhat arbitrary decision.int dataRow = totalXrefs - noFunction.size();- TextField noFunctionXrefsField =- createWrappingXrefRow(program, dataRow, noFunction, currentFunction, isOffcut,- availableLines, hlFactory);+ TextField noFunctionXrefsField = createWrappingXrefRow(program, dataRow, noFunction,+ currentFunction, isOffcut, availableLines, hlFactory);List<TextField> allFields = new ArrayList<>();allFields.addAll(functionRows);@@ -412,7 +363,8 @@ public class XRefFieldFactory extends FieldFactory {if (tooMany) {// add the [more] elementint lastRow = allFields.size() - 1;- AttributedString as = new AttributedString(MORE_XREFS_STRING, color, metrics);+ AttributedString as =+ new AttributedString(MORE_XREFS_STRING, XrefColors.DEFAULT, metrics);TextFieldElement moreElement = new TextFieldElement(as, lastRow, 0);ClippingTextField ctf = new ClippingTextField(newStartX, width, moreElement, hlFactory);allFields.add(ctf);@@ -425,8 +377,7 @@ public class XRefFieldFactory extends FieldFactory {private List<TextField> createXrefRowsByFunction(Program program, Function currentFunction,TreeMap<Function, List<Reference>> xrefsByFunction, Predicate<Reference> isOffcut,- int varWidth,- HighlightFactory hlFactory) {+ int varWidth, HighlightFactory hlFactory) {FontMetrics metrics = getMetrics();AttributedString delimiter = new AttributedString(delim, Colors.FOREGROUND, metrics);@@ -449,12 +400,10 @@ public class XRefFieldFactory extends FieldFactory {sizeText = "[" + refs.size() + "]: ";}String text = functionName + sizeText;- AttributedString nameString =- new AttributedString(text, color, metrics);+ AttributedString nameString = new AttributedString(text, XrefColors.DEFAULT, metrics);List<XrefFieldElement> rowElements = new ArrayList<>();Reference firstRef = refs.get(0);- XrefAttributedString xrefString =- new XrefAttributedString(firstRef, nameString);+ XrefAttributedString xrefString = new XrefAttributedString(firstRef, nameString);rowElements.add(new XrefFieldElement(xrefString, row, 0));//@@ -466,9 +415,8 @@ public class XRefFieldFactory extends FieldFactory {boolean isLast = i == n - 1;Reference ref = refs.get(i);String prefix = getMergedPrefix(program, ref, currentFunction, fromFunction);- XrefFieldElement element =- createFunctionElement(program, prefix, ref, row, isLast ? null : delimiter,- isOffcut.test(ref));+ XrefFieldElement element = createFunctionElement(program, prefix, ref, row,+ isLast ? null : delimiter, isOffcut.test(ref));rowElements.add(element);}@@ -585,8 +533,7 @@ public class XRefFieldFactory extends FieldFactory {int n = list.size();HighlightFactory hlFactory =new FieldHighlightFactory(hlProvider, getClass(), proxy.getObject());- TextField field =- new FlowLayoutTextField(list, startX + varWidth, width, n, hlFactory);+ TextField field = new FlowLayoutTextField(list, startX + varWidth, width, n, hlFactory);return new XrefListingField(this, proxy, field);}@@ -596,7 +543,8 @@ public class XRefFieldFactory extends FieldFactory {if (showEllipses) {// add the 'more' stringint lastRow = list.size() - 1;- AttributedString as = new AttributedString(MORE_XREFS_STRING, color, getMetrics());+ AttributedString as =+ new AttributedString(MORE_XREFS_STRING, XrefColors.DEFAULT, getMetrics());fieldElements.add(new TextFieldElement(as, lastRow, 0));}return fieldElements;@@ -607,14 +555,13 @@ public class XRefFieldFactory extends FieldFactory {FontMetrics metrics = getMetrics();String addressString = ref.getFromAddress().toString(prefix);- Color refColor = isOffcut ? offcutColor : color;+ Color refColor = isOffcut ? XrefColors.OFFCUT : XrefColors.DEFAULT;AttributedString addressPart = new AttributedString(addressString, refColor, metrics);if (displayRefType) {addressPart = createRefTypeAttributedString(ref, addressPart);}- XrefAttributedString xrefString =- new XrefAttributedString(ref, addressPart, delimiter);+ XrefAttributedString xrefString = new XrefAttributedString(ref, addressPart, delimiter);if (delimiter == null) {xrefString.hideDelimiter();}@@ -627,14 +574,13 @@ public class XRefFieldFactory extends FieldFactory {FontMetrics metrics = getMetrics();String addressString = ref.getFromAddress().toString(prefix);- Color refColor = isOffcut ? offcutColor : color;+ Color refColor = isOffcut ? XrefColors.OFFCUT : XrefColors.DEFAULT;AttributedString as = new AttributedString(addressString, refColor, metrics);if (displayRefType) {as = createRefTypeAttributedString(ref, as);}- XrefAttributedString xrefString =- new XrefAttributedString(ref, as, delimiter);+ XrefAttributedString xrefString = new XrefAttributedString(ref, as, delimiter);return new XrefFieldElement(xrefString, row, 0);}@@ -642,23 +588,23 @@ public class XRefFieldFactory extends FieldFactory {AttributedString referenceString) {AttributedString fullReferenceString = referenceString;if (reference.getReferenceType().isRead() && reference.getReferenceType().isWrite()) {- AttributedString typeString = new AttributedString("(R", readColor, getMetrics());+ AttributedString typeString = new AttributedString("(R", XrefColors.READ, getMetrics());fullReferenceString = new CompositeAttributedString(new AttributedString[] { fullReferenceString, typeString });- typeString = new AttributedString("W)", writeColor, getMetrics());+ typeString = new AttributedString("W)", XrefColors.WRITE, getMetrics());return new CompositeAttributedString(new AttributedString[] { fullReferenceString, typeString });}- Color displayColor = color;+ Color displayColor = XrefColors.DEFAULT;if (reference.getReferenceType().isRead() || reference.getReferenceType().isIndirect()) {- displayColor = readColor;+ displayColor = XrefColors.READ;}else if (reference.getReferenceType().isWrite()) {- displayColor = writeColor;+ displayColor = XrefColors.WRITE;}else if (reference.getReferenceType().isData()) {- displayColor = otherColor;+ displayColor = XrefColors.OTHER;}AttributedString typeString =@@ -823,8 +769,7 @@ public class XRefFieldFactory extends FieldFactory {}private XRefFieldLocation getXRefLocation(XrefFieldElement xrefElement, CodeUnit cu,- int[] cpath,- RowColLocation loc, int row) {+ int[] cpath, RowColLocation loc, int row) {Reference xref = xrefElement.getXref();Address refAddr = xref.getFromAddress();return new XRefFieldLocation(cu.getProgram(), cu.getMinAddress(), cpath, refAddr, row,@@ -912,9 +857,8 @@ public class XRefFieldFactory extends FieldFactory {// resizing field to a particular size, resulted in layout of references to be strangechar[] charSpaces = new char[length];Arrays.fill(charSpaces, ' ');- AttributedString spaces =- new AttributedString(new String(charSpaces), source.getColor(0),- source.getFontMetrics(0));+ AttributedString spaces = new AttributedString(new String(charSpaces),+ source.getColor(0), source.getFontMetrics(0));attributedStrings[attributedStrings.length - 1] = spaces;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.javaindex 1c2d6140b9..f52c673993 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.java@@ -22,6 +22,7 @@ import docking.widgets.fieldpanel.field.*;import docking.widgets.fieldpanel.support.FieldLocation;import ghidra.app.util.HighlightProvider;import ghidra.app.util.XReferenceUtils;+import ghidra.app.util.viewer.field.ListingColors.XrefColors;import ghidra.app.util.viewer.format.FieldFormatModel;import ghidra.app.util.viewer.proxy.ProxyObj;import ghidra.framework.options.Options;@@ -52,9 +53,13 @@ public class XRefHeaderFieldFactory extends XRefFieldFactory {public XRefHeaderFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,Options displayOptions, ToolOptions fieldOptions) {super(XREF_FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);+ }++ @Override+ protected void initDisplayOptions(Options displayOptions) {colorOptionName = "XRef Color";styleOptionName = "XRef Style";- initDisplayOptions();+ super.initDisplayOptions(displayOptions);}@Override@@ -68,7 +73,7 @@ public class XRefHeaderFieldFactory extends XRefFieldFactory {if (headString == null || headString.length() == 0) {return null;}- AttributedString as = new AttributedString(headString, color, getMetrics());+ AttributedString as = new AttributedString(headString, XrefColors.DEFAULT, getMetrics());FieldElement field = new TextFieldElement(as, 0, 0);return ListingTextField.createSingleLineTextField(this, proxy, field, startX + varWidth,width, hlProvider);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.javaindex 38388e21ce..f80f309a2a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.java@@ -430,19 +430,32 @@ public class FieldFormatModel {}/**- * Notifies that the options have changed.+ * Notifies that the field display options have changed.* @param options the Options object that changed.* @param optionName the name of the property that changed.* @param oldValue the old value of the property.* @param newValue the new value of the property.*/- public void optionsChanged(Options options, String optionName, Object oldValue,+ public void displayOptionsChanged(Options options, String optionName, Object oldValue,Object newValue) {for (Row row : rows) {- row.optionsChanged(options, optionName, oldValue, newValue);+ row.displayOptionsChanged(options, optionName, oldValue, newValue);}}+ /**+ * Notifies that the field options have changed.+ * @param options the Options object that changed.+ * @param optionName the name of the property that changed.+ * @param oldValue the old value of the property.+ * @param newValue the new value of the property.+ */+ public void fieldOptionsChanged(Options options, String optionName, Object oldValue,+ Object newValue) {+ for (Row row : rows) {+ row.fieldOptionsChanged(options, optionName, oldValue, newValue);+ }+ }//==================================================================================================//Inner Classes//==================================================================================================@@ -465,9 +478,17 @@ class Row {layoutFields();}- public void optionsChanged(Options options, String name, Object oldValue, Object newValue) {+ public void displayOptionsChanged(Options options, String name, Object oldValue,+ Object newValue) {+ for (FieldFactory factory : fields) {+ factory.displayOptionsChanged(options, name, oldValue, newValue);+ }+ }++ public void fieldOptionsChanged(Options options, String name, Object oldValue,+ Object newValue) {for (FieldFactory factory : fields) {- factory.optionsChanged(options, name, oldValue, newValue);+ factory.fieldOptionsChanged(options, name, oldValue, newValue);}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.javaindex 0342893934..d3f80efabb 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.java@@ -107,9 +107,7 @@ public class FormatManager implements OptionsChangeListener {}public FormatManager createClone() {- ToolOptions newDisplayOptions = displayOptions.copy();- ToolOptions newFieldOptions = fieldOptions.copy();- FormatManager newManager = new FormatManager(newDisplayOptions, newFieldOptions);+ FormatManager newManager = new FormatManager(displayOptions, fieldOptions);SaveState saveState = new SaveState();saveState(saveState);newManager.readState(saveState);@@ -848,10 +846,17 @@ public class FormatManager implements OptionsChangeListener {@Overridepublic void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) {- for (int i = 0; i < NUM_MODELS; i++) {- models[i].optionsChanged(options, name, oldValue, newValue);+ if (options == displayOptions) {+ for (int i = 0; i < NUM_MODELS; i++) {+ models[i].displayOptionsChanged(options, name, oldValue, newValue);+ }+ }+ else if (options == fieldOptions) {+ for (int i = 0; i < NUM_MODELS; i++) {+ models[i].fieldOptionsChanged(options, name, oldValue, newValue);+ }+ getArrayDisplayOptions(options);}- getArrayDisplayOptions(options);modelChanged(null);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.javaindex e5d808ddb4..e1d87b52db 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.java@@ -35,172 +35,81 @@ import docking.widgets.fieldpanel.listener.LayoutModelListener;import docking.widgets.fieldpanel.support.*;import docking.widgets.indexedscrollpane.IndexedScrollPane;import docking.widgets.label.GDLabel;-import generic.theme.GColor;import generic.theme.GThemeDefaults.Colors;import generic.theme.GThemeDefaults.Colors.Palette;import generic.theme.GThemeDefaults.Colors.Tables;import ghidra.GhidraOptions;+import ghidra.app.util.viewer.field.ListingColors;+import ghidra.app.util.viewer.field.ListingColors.*;import ghidra.util.SystemUtilities;/*** Class for displaying and manipulating field colors and fonts.*/public class OptionsGui extends JPanel {- private static final long serialVersionUID = 1L;private static final Highlight[] NO_HIGHLIGHTS = new Highlight[0];private static final HighlightFactory hlFactory =(field, text, cursorTextOffset) -> NO_HIGHLIGHTS;- public static final ScreenElement BACKGROUND =- new ScreenElement("Background", new GColor("color.bg.listing"));- public static final ScreenElement COMMENT_AUTO =- new ScreenElement("Comment, Automatic", new GColor("color.fg.listing.comment.auto"));- public static final ScreenElement ADDRESS =- new ScreenElement("Address", new GColor("color.fg.listing.address"));-- public static final ScreenElement BAD_REF_ADDR =- new ScreenElement("Bad Reference Address", new GColor("color.fg.listing.ref.bad"));-- public static final ScreenElement BYTES =- new ScreenElement("Bytes", new GColor("color.fg.listing.bytes"));-- public static final ScreenElement CONSTANT =- new ScreenElement("Constant", new GColor("color.fg.listing.constant"));-- public static final ScreenElement LABELS_UNREFD = new ScreenElement("Labels, Unreferenced",- new GColor("color.fg.listing.label.unreferenced"));-- public static final ScreenElement ENTRY_POINT =- new ScreenElement("Entry Point", new GColor("color.fg.listing.entrypoint"));-- public static final ScreenElement COMMENT_EOL = new ScreenElement("Comment, EOL", "EOL Comment",- new GColor("color.fg.listing.comment.auto"));-- public static final ScreenElement EXT_REF_RESOLVED = new ScreenElement(- "External Reference, Resolved", new GColor("color.fg.listing.ref.ext.resolved"));-- public static final ScreenElement FIELD_NAME =- new ScreenElement("Field Name", new GColor("color.fg.listing.fieldname"));-- public static final ScreenElement FUN_CALL_FIXUP =- new ScreenElement("Function Call-Fixup", new GColor("color.fg.listing.function.callfixup"));-- public static final ScreenElement FUN_NAME =- new ScreenElement("Function Name", new GColor("color.fg.listing.function.name"));-- public static final ScreenElement FUN_PARAMS =- new ScreenElement("Function Parameters", new GColor("color.fg.listing.function.param"));-- public static final ScreenElement FUN_TAG =- new ScreenElement("Function Tag", new GColor("color.fg.listing.function.tag"));-- public static final ScreenElement FUN_AUTO_PARAMS = new ScreenElement(- "Function Auto-Parameters", new GColor("color.fg.listing.function.param.auto"));-- public static final ScreenElement FUN_RET_TYPE = new ScreenElement("Function Return Type",- new GColor("color.fg.listing.function.return.type"));-- public static final ScreenElement COMMENT_REPEATABLE =- new ScreenElement("Comment, Repeatable", new GColor("color.fg.listing.comment.repeatable"));-- public static final ScreenElement COMMENT_REF_REPEAT = new ScreenElement(- "Comment, Referenced Repeatable", new GColor("color.fg.listing.comment.ref.repeatable"));-- public static final ScreenElement LABELS_LOCAL =- new ScreenElement("Labels, Local", new GColor("color.fg.listing.label.local"));-- public static final ScreenElement MNEMONIC_OVERRIDE =- new ScreenElement("Mnemonic, Override", new GColor("color.fg.listing.mnemonic.override"));-- public static final ScreenElement MNEMONIC =- new ScreenElement("Mnemonic", new GColor("color.fg.listing.mnemonic"));-- public static final ScreenElement UNIMPL = new ScreenElement("Unimplemented Mnemonic",- new GColor("color.fg.listing.mnemonic.unimplemented"));-- public static final ScreenElement FLOW_ARROW_NON_ACTIVE = new ScreenElement(- "Flow Arrow, Not Active", new GColor("color.fg.listing.flow.arrow.inactive"));-- public static final ScreenElement FLOW_ARROW_ACTIVE =- new ScreenElement("Flow Arrow, Active", new GColor("color.fg.listing.flow.arrow.active"));-- public static final ScreenElement FLOW_ARROW_SELECTED = new ScreenElement(- "Flow Arrow, Selected", new GColor("color.fg.listing.flow.arrow.selected"));-- public static final ScreenElement LABELS_NON_PRIMARY =- new ScreenElement("Labels, Non-primary", new GColor("color.fg.listing.label.non.primary"));-- public static final ScreenElement COMMENT_PLATE = new ScreenElement("Comment, Plate",- "Plate Comment", new GColor("color.fg.listing.comment.plate"));-- public static final ScreenElement COMMENT_POST = new ScreenElement("Comment, Post",- "Post-Comment", new GColor("color.fg.listing.comment.post"));-- public static final ScreenElement COMMENT_PRE = new ScreenElement("Comment, Pre", "Pre-Comment",- new GColor("color.fg.listing.comment.pre"));-- public static final ScreenElement LABELS_PRIMARY =- new ScreenElement("Labels, Primary", new GColor("color.fg.listing.label.primary"));-- public static final ScreenElement SEPARATOR =- new ScreenElement("Separator", new GColor("color.fg.listing.separator"));-- public static final ScreenElement VARIABLE =- new ScreenElement("Variable", new GColor("color.fg.listing.variable"));-- public static final ScreenElement PARAMETER_CUSTOM = new ScreenElement(- "Parameter, Custom Storage", new GColor("color.fg.listing.function.param.custom"));-- public static final ScreenElement PARAMETER_DYNAMIC = new ScreenElement(- "Parameter, Dynamic Storage", new GColor("color.fg.listing.function.param.dynamic"));-- public static final ScreenElement VERSION_TRAK =- new ScreenElement("Version Track", new GColor("color.fg.listing.version.tracking"));-- public static final ScreenElement XREF =- new ScreenElement("XRef", new GColor("color.fg.listing.xref"));-- public static final ScreenElement XREF_OFFCUT =- new ScreenElement("XRef, Offcut", new GColor("color.fg.listing.xref.offcut"));-- public static final ScreenElement XREF_READ =- new ScreenElement("XRef Read", new GColor("color.fg.listing.xref.read"));-- public static final ScreenElement XREF_WRITE =- new ScreenElement("XRef Write", new GColor("color.fg.listing.xref.write"));-- public static final ScreenElement XREF_OTHER =- new ScreenElement("XRef Other", new GColor("color.fg.listing.xref.other"));-- public static final ScreenElement REGISTERS =- new ScreenElement("Registers", new GColor("color.fg.listing.register"));-- public static final ScreenElement UNDERLINE =- new ScreenElement("Underline", new GColor("color.fg.listing.underline"));-- public static final ScreenElement PCODE_LINE_LABEL =- new ScreenElement("P-code Line Label", new GColor("color.fg.listing.pcode.label"));-- public static final ScreenElement PCODE_ADDR_SPACE =- new ScreenElement("P-code Address Space", new GColor("color.fg.listing.pcode.space"));-- public static final ScreenElement PCODE_RAW_VARNODE =- new ScreenElement("P-code Raw Varnode", new GColor("color.fg.listing.pcode.varnode"));-- public static final ScreenElement PCODE_USEROP =- new ScreenElement("P-code Userop", new GColor("color.fg.listing.pcode.userop"));+ // @formatter:off+ public static final ScreenElement BACKGROUND = new ScreenElement("Background", ListingColors.BACKGROUND);+ public static final ScreenElement COMMENT_AUTO = new ScreenElement("Comment, Automatic", CommentColors.AUTO);+ public static final ScreenElement ADDRESS = new ScreenElement("Address", ListingColors.ADDRESS);+ public static final ScreenElement BAD_REF_ADDR = new ScreenElement("Bad Reference Address", ListingColors.REF_BAD);+ public static final ScreenElement BYTES = new ScreenElement("Bytes", ListingColors.BYTES);+ public static final ScreenElement CONSTANT = new ScreenElement("Constant", ListingColors.CONSTANT);+ public static final ScreenElement LABELS_UNREFD = new ScreenElement("Labels, Unreferenced", LabelColors.UNREFERENCED);+ public static final ScreenElement ENTRY_POINT = new ScreenElement("Entry Point", ListingColors.EXT_ENTRY_POINT);+ public static final ScreenElement COMMENT_EOL = new ScreenElement("Comment, EOL", "EOL Comment", CommentColors.EOL);+ public static final ScreenElement EXT_REF_RESOLVED = new ScreenElement("External Reference, Resolved", ListingColors.EXT_REF_RESOLVED);+ public static final ScreenElement FIELD_NAME = new ScreenElement("Field Name", ListingColors.FIELD_NAME);+ public static final ScreenElement FUN_CALL_FIXUP = new ScreenElement("Function Call-Fixup", FunctionColors.CALL_FIXUP);+ public static final ScreenElement FUN_NAME = new ScreenElement("Function Name", FunctionColors.NAME);+ public static final ScreenElement FUN_PARAMS = new ScreenElement("Function Parameters", FunctionColors.PARAM);+ public static final ScreenElement FUN_TAG = new ScreenElement("Function Tag", FunctionColors.TAG);+ public static final ScreenElement FUN_AUTO_PARAMS = new ScreenElement("Function Auto-Parameters", FunctionColors.PARAM_AUTO);+ public static final ScreenElement FUN_RET_TYPE = new ScreenElement("Function Return Type", FunctionColors.RETURN_TYPE);+ public static final ScreenElement COMMENT_REPEATABLE = new ScreenElement("Comment, Repeatable", CommentColors.REPEATABLE);+ public static final ScreenElement COMMENT_REF_REPEAT = new ScreenElement("Comment, Referenced Repeatable", CommentColors.REF_REPEATABLE);+ public static final ScreenElement LABELS_LOCAL = new ScreenElement("Labels, Local", LabelColors.LOCAL);+ public static final ScreenElement MNEMONIC = new ScreenElement("Mnemonic", MnemonicColors.NORMAL);+ public static final ScreenElement MNEMONIC_OVERRIDE = new ScreenElement("Mnemonic, Override", MnemonicColors.OVERRIDE);+ public static final ScreenElement MNEMONIC_UNIMPL = new ScreenElement("Unimplemented Mnemonic", MnemonicColors.UNIMPLEMENTED);+ public static final ScreenElement FLOW_ARROW_ACTIVE = new ScreenElement("Flow Arrow, Active", FlowArrowColors.ACTIVE);+ public static final ScreenElement FLOW_ARROW_NON_ACTIVE = new ScreenElement("Flow Arrow, Not Active", FlowArrowColors.INACTIVE);+ public static final ScreenElement FLOW_ARROW_SELECTED = new ScreenElement("Flow Arrow, Selected", FlowArrowColors.SELECTED);+ public static final ScreenElement LABELS_PRIMARY = new ScreenElement("Labels, Primary", LabelColors.PRIMARY);+ public static final ScreenElement LABELS_NON_PRIMARY = new ScreenElement("Labels, Non-primary", LabelColors.NON_PRIMARY);+ public static final ScreenElement COMMENT_PLATE = new ScreenElement("Comment, Plate", "Plate Comment", CommentColors.PLATE);+ public static final ScreenElement COMMENT_POST = new ScreenElement("Comment, Post", "Post-Comment", CommentColors.POST);+ public static final ScreenElement COMMENT_PRE = new ScreenElement("Comment, Pre", "Pre-Comment", CommentColors.PRE);+ public static final ScreenElement SEPARATOR = new ScreenElement("Separator", ListingColors.SEPARATOR);+ public static final ScreenElement VARIABLE = new ScreenElement("Variable", FunctionColors.VARIABLE);+ public static final ScreenElement PARAMETER_CUSTOM = new ScreenElement("Parameter, Custom Storage", FunctionColors.PARAM_CUSTOM);+ public static final ScreenElement PARAMETER_DYNAMIC = new ScreenElement("Parameter, Dynamic Storage", FunctionColors.PARAM_DYNAMIC);+ public static final ScreenElement XREF = new ScreenElement("XRef", XrefColors.DEFAULT);+ public static final ScreenElement XREF_OFFCUT = new ScreenElement("XRef, Offcut", XrefColors.OFFCUT);+ public static final ScreenElement XREF_READ = new ScreenElement("XRef Read", XrefColors.READ);+ public static final ScreenElement XREF_WRITE = new ScreenElement("XRef Write", XrefColors.WRITE);+ public static final ScreenElement XREF_OTHER = new ScreenElement("XRef Other", XrefColors.OTHER);+ public static final ScreenElement REGISTERS = new ScreenElement("Registers", ListingColors.REGISTER);+ public static final ScreenElement UNDERLINE = new ScreenElement("Underline", ListingColors.UNDERLINE);+ public static final ScreenElement PCODE_LINE_LABEL = new ScreenElement("P-code Line Label", PcodeColors.LABEL);+ public static final ScreenElement PCODE_ADDR_SPACE = new ScreenElement("P-code Address Space", PcodeColors.ADDRESS_SPACE);+ public static final ScreenElement PCODE_RAW_VARNODE = new ScreenElement("P-code Raw Varnode", PcodeColors.VARNODE);+ public static final ScreenElement PCODE_USEROP = new ScreenElement("P-code Userop", PcodeColors.USEROP);//@formatter:on- static ScreenElement[] elements = { ADDRESS, BACKGROUND, BAD_REF_ADDR, BYTES, COMMENT_AUTO,- COMMENT_EOL, COMMENT_PLATE, COMMENT_POST, COMMENT_PRE, COMMENT_REPEATABLE,- COMMENT_REF_REPEAT, CONSTANT, ENTRY_POINT, EXT_REF_RESOLVED, FIELD_NAME, FLOW_ARROW_ACTIVE,- FLOW_ARROW_NON_ACTIVE, FLOW_ARROW_SELECTED, FUN_CALL_FIXUP, FUN_NAME, FUN_PARAMS,- FUN_AUTO_PARAMS, FUN_RET_TYPE,- FUN_TAG, LABELS_LOCAL, LABELS_NON_PRIMARY, LABELS_PRIMARY, LABELS_UNREFD, MNEMONIC,- MNEMONIC_OVERRIDE, PARAMETER_CUSTOM, PARAMETER_DYNAMIC, PCODE_LINE_LABEL, PCODE_ADDR_SPACE,- PCODE_RAW_VARNODE, PCODE_USEROP, REGISTERS, SEPARATOR, UNDERLINE, UNIMPL, VARIABLE,- VERSION_TRAK, XREF, XREF_OFFCUT, XREF_READ, XREF_WRITE, XREF_OTHER };+ static ScreenElement[] elements =+ { ADDRESS, BACKGROUND, BAD_REF_ADDR, BYTES, COMMENT_AUTO, COMMENT_EOL, COMMENT_PLATE,+ COMMENT_POST, COMMENT_PRE, COMMENT_REPEATABLE, COMMENT_REF_REPEAT, CONSTANT,+ ENTRY_POINT, EXT_REF_RESOLVED, FIELD_NAME, FLOW_ARROW_ACTIVE, FLOW_ARROW_NON_ACTIVE,+ FLOW_ARROW_SELECTED, FUN_CALL_FIXUP, FUN_NAME, FUN_PARAMS, FUN_AUTO_PARAMS,+ FUN_RET_TYPE, FUN_TAG, LABELS_LOCAL, LABELS_NON_PRIMARY, LABELS_PRIMARY, LABELS_UNREFD,+ MNEMONIC, MNEMONIC_OVERRIDE, PARAMETER_CUSTOM, PARAMETER_DYNAMIC, PCODE_LINE_LABEL,+ PCODE_ADDR_SPACE, PCODE_RAW_VARNODE, PCODE_USEROP, REGISTERS, SEPARATOR, UNDERLINE,+ MNEMONIC_UNIMPL, VARIABLE, XREF, XREF_OFFCUT, XREF_READ, XREF_WRITE, XREF_OTHER };private Map<Integer, FontMetrics> metricsMap = new HashMap<>();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 7068c80096..80ccc844c3 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@@ -54,7 +54,7 @@ public class ScreenElement {return style;}- public Color getDefaultColor() {+ public GColor getDefaultColor() {return defaultColor;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/table/GhidraTableCellRenderer.java b/Ghidra/Features/Base/src/main/java/ghidra/util/table/GhidraTableCellRenderer.javaindex aa98413eda..f95c8a4d1e 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/util/table/GhidraTableCellRenderer.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/table/GhidraTableCellRenderer.java@@ -23,6 +23,7 @@ import javax.swing.table.TableModel;import docking.widgets.table.GTableCellRenderer;import generic.theme.GColor;+import ghidra.app.util.viewer.field.ListingColors;import ghidra.program.model.address.Address;import ghidra.program.model.listing.Program;import ghidra.program.model.mem.Memory;@@ -31,10 +32,6 @@ import ghidra.program.model.symbol.Symbol;public class GhidraTableCellRenderer extends GTableCellRenderer {- // Defaults as defined by OptionsGui class - would be nice to use the tool options- private static final Color BAD_REF_ADDR_COLOR = new GColor("color.fg.listing.ref.bad");- private static final Color EXT_REF_RESOLVED_COLOR =- new GColor("color.fg.listing.ref.ext.resolved");public Color SELECTED_CELL_COLOR = new GColor("color.bg.table.selected.ghidratable");public Color BAD_EQUATE_COLOR = new GColor("color.fg.table.ghidratable.equate.bad");public Color EQUATE_COLOR = new GColor("color.fg.table.ghidratable.equate");@@ -67,14 +64,14 @@ public class GhidraTableCellRenderer extends GTableCellRenderer {protected void setForegroundColor(JTable table, TableModel model, Object value) {if (isExternalAdress(value)) {if (isResolvedExternalAddress(model, (Address) value)) {- setForeground(EXT_REF_RESOLVED_COLOR);+ setForeground(ListingColors.EXT_REF_RESOLVED);}else {- setForeground(BAD_REF_ADDR_COLOR);+ setForeground(ListingColors.EXT_REF_UNRESOLVED);}}else if (isValueOutOfMemoryAddress(model, value)) {- setForeground(BAD_REF_ADDR_COLOR);+ setForeground(ListingColors.REF_BAD);}else {setForeground(table.getForeground());diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.javaindex 85ec74cdff..486570efed 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserOptionsTest.java@@ -351,27 +351,27 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTestassertEquals("01", btf.getText());assertEquals(3, btf.getNumCols(0));FieldElement fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001104"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("05 06 07 08", btf.getText());assertEquals(12, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 3);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 6);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 9);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001108"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("09", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));}@Test@@ -393,39 +393,39 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTestassertEquals("0102 0304", btf.getText());assertEquals(10, btf.getNumCols(0));FieldElement fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 2);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 5);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 7);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));cb.goToField(addr("0x1001104"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("0506 0708", btf.getText());assertEquals(10, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 2);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 5);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 7);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001108"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("090a 0b0c", btf.getText());assertEquals(10, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 2);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 5);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 7);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));}@Test@@ -445,39 +445,39 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTestassertEquals("01 02 03 04", btf.getText());assertEquals(12, btf.getNumCols(0));FieldElement fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 3);- assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertEquals(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 6);- assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertEquals(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 9);- assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertEquals(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));cb.goToField(addr("0x1001104"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("05 06 07 08", btf.getText());assertEquals(12, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 3);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 6);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 9);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001108"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("09 0a 0b 0c", btf.getText());assertEquals(12, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 3);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 6);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));fe = btf.getFieldElement(0, 9);- assertColorsEqual(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES_ALIGNMENT, fe.getColor(0));}@Test@@ -498,69 +498,69 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTestassertEquals("01", btf.getText());assertEquals(3, btf.getNumCols(0));FieldElement fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001201"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("02", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001202"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("03", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001203"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("04", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001204"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("05 06 07 08", btf.getText());assertEquals(12, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 3);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 6);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));fe = btf.getFieldElement(0, 9);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001208"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("09", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x1001209"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("0a", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x100120a"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("0b", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));cb.goToField(addr("0x100120b"), "Bytes", 0, 0);btf = (ListingTextField) cb.getCurrentField();assertEquals("0c", btf.getText());assertEquals(3, btf.getNumCols(0));fe = btf.getFieldElement(0, 1);- assertColorsEqual(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0));+ assertColorsEqual(ListingColors.BYTES, fe.getColor(0));}@SuppressWarnings("unchecked")diff --git a/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/ToolOptions.java b/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/ToolOptions.javaindex c21f855e5b..e2cfbf3501 100644--- a/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/ToolOptions.java+++ b/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/ToolOptions.java@@ -181,18 +181,20 @@ public class ToolOptions extends AbstractOptions {private void writeWrappedOptions(boolean includeDefaultBindings, Element root) {for (String optionName : valueMap.keySet()) {Option option = valueMap.get(optionName);- if (includeDefaultBindings || !option.isDefault()) {+ if (option instanceof ThemeColorOption || option instanceof ThemeFontOption) {+ // theme values are saved by the theme, no need to save them to the options+ continue;+ }+ if (includeDefaultBindings || !option.isDefault()) {Object value = option.getCurrentValue();if (isSupportedBySaveState(value)) {- // handled above- continue;+ continue; // handled above}WrappedOption wrappedOption = wrapOption(option);if (wrappedOption == null) {- // cannot write an option without a value to determine its type- continue;+ continue; // cannot write an option without a value to determine its type}SaveState ss = new SaveState(WRAPPED_OPTION_NAME);