GP-1981 - Theming - Base module color conversion

This commit is contained in:
dragonmacher 2022-09-01 15:00:44 -04:00 committed by ghidragon
parent 7c7d98090f
commit 15e633c239
97 changed files with 1142 additions and 1777 deletions

View file

@ -18,7 +18,6 @@ data/MachOFunctionsThatDoNotReturn||GHIDRA||||END|
data/PEFunctionsThatDoNotReturn||GHIDRA||||END| data/PEFunctionsThatDoNotReturn||GHIDRA||||END|
data/base.listing.theme.properties||GHIDRA||||END| data/base.listing.theme.properties||GHIDRA||||END|
data/base.theme.properties||GHIDRA||||END| data/base.theme.properties||GHIDRA||||END|
data/decompiler.theme.properties||GHIDRA||||END|
data/file_extension_icons.xml||GHIDRA||||END| data/file_extension_icons.xml||GHIDRA||||END|
data/functionTags.xml||GHIDRA||||END| data/functionTags.xml||GHIDRA||||END|
data/ms_pe_rich_products.xml||GHIDRA||||END| data/ms_pe_rich_products.xml||GHIDRA||||END|

View file

@ -9,12 +9,12 @@ color.bg.listing.tabs.selected = #788CBD
color.bg.listing.tabs.unselected = [color]control color.bg.listing.tabs.unselected = [color]control
color.bg.listing.tabs.highlighted = #ABC8FF color.bg.listing.tabs.highlighted = #ABC8FF
color.bg.listing.tabs.list = rgb(255, 255, 230) color.bg.listing.tabs.list = rgb(255, 255, 230)
color.bg.listing.tabs.more.tabs.hover = rgb(255, 226, 213)
color.fg.listing.tabs.text.selected = black color.fg.listing.tabs.text.selected = black
color.fg.listing.tabs.text.unselected = color.fg color.fg.listing.tabs.text.unselected = color.fg
color.fg.listing.tabs.list = black color.fg.listing.tabs.list = black
color.bg.listing.header.active.field = rgb(244, 221, 183) color.bg.listing.header.active.field = rgb(244, 221, 183)
color.fg.listing.header.active.field = color.fg color.fg.listing.header.active.field = color.fg
@ -30,7 +30,7 @@ color.fg.listing.entrypoint = magenta
color.fg.listing.comment.auto = lightGray color.fg.listing.comment.auto = lightGray
color.fg.listing.comment.eol = blue color.fg.listing.comment.eol = blue
color.fg.listing.comment.repeatable = darkOrange color.fg.listing.comment.repeatable = darkOrange
color.fg.listing.comment.ref-repeatable = cornflowerBlue color.fg.listing.comment.ref.repeatable = cornflowerBlue
color.fg.listing.comment.plate = gray color.fg.listing.comment.plate = gray
color.fg.listing.comment.post = blue color.fg.listing.comment.post = blue
color.fg.listing.comment.pre = indigo color.fg.listing.comment.pre = indigo
@ -41,23 +41,23 @@ color.fg.listing.function.name = blue
color.fg.listing.function.param = black color.fg.listing.function.param = black
color.fg.listing.function.tag = mediumVioletRed color.fg.listing.function.tag = mediumVioletRed
color.fg.listing.function.param.auto = gray color.fg.listing.function.param.auto = gray
color.fg.listing.function.return-type = black color.fg.listing.function.return.type = black
color.fg.listing.function.param.custom = indigo color.fg.listing.function.param.custom = indigo
color.fg.listing.function.param.dynamic = #006666 color.fg.listing.function.param.dynamic = #006666
color.fg.listing.label.local = green color.fg.listing.label.local = green
color.fg.listing.label.non-primary = olive color.fg.listing.label.non.primary = olive
color.fg.listing.label.primary = darkBlue color.fg.listing.label.primary = darkBlue
color.fg.listing.mnemonic.override = deepPink color.fg.listing.mnemonic.override = deepPink
color.fg.listing.mnemonic = navy color.fg.listing.mnemonic = navy
color.fg.listing.mnemonic.unimplemented = navy color.fg.listing.mnemonic.unimplemented = navy
// TODO // TODO
color.fg.listing.flow-arrow.inactive = lightGray color.fg.listing.flow.arrow.inactive = lightGray
color.fg.listing.flow-arrow.active = color.fg color.fg.listing.flow.arrow.active = color.fg
color.fg.listing.flow-arrow.selected = limeGreen color.fg.listing.flow.arrow.selected = limeGreen
color.fg.listing.separator = color.fg color.fg.listing.separator = color.fg
color.fg.listing.variable = purple color.fg.listing.variable = purple
color.fg.listing.version-tracking = purple color.fg.listing.version.tracking = purple
color.fg.listing.xref = darkGreen color.fg.listing.xref = darkGreen
color.fg.listing.xref.offcut = gray color.fg.listing.xref.offcut = gray
color.fg.listing.xref.read = blue color.fg.listing.xref.read = blue
@ -86,50 +86,4 @@ color.fg.listing.tabs.list = black
color.bg.listing.header.active.field = rgb(244, 221, 183) color.bg.listing.header.active.field = rgb(244, 221, 183)
color.fg.listing.header.active.field = black color.fg.listing.header.active.field = black
#color.fg.listing.address = color.fg
#color.fg.listing.ref.bad = red
#color.fg.listing.bytes = blue
#color.fg.listing.constant = turquoise
#color.fg.listing.label.unreferenced = black
#color.fg.listing.entrypoint = magenta
#color.fg.listing.comment.auto = rgb(95,129,157)
#color.fg.listing.comment.eol = blue
#color.fg.listing.comment.repeatable = darkOrange
#color.fg.listing.comment.ref-repeatable = cornflowerBlue
#color.fg.listing.comment.plate = gray
#color.fg.listing.comment.post = blue
#color.fg.listing.comment.pre = indigo
#color.fg.listing.ref.ext.resolved = teal
#color.fg.listing.fieldname = color.fg
#color.fg.listing.function.callfixup = fuchsia
#color.fg.listing.function.name = blue
#color.fg.listing.function.param = black
#color.fg.listing.function.tag = mediumVioletRed
#color.fg.listing.function.param.auto = gray
#color.fg.listing.function.return-type = black
#color.fg.listing.function.param.custom = indigo
#color.fg.listing.function.param.dynamic = teal
#color.fg.listing.label.local = green
#color.fg.listing.label.non-primary = olive
#color.fg.listing.label.primary = darkBlue
#color.fg.listing.mnemonic.override = deepPink
#color.fg.listing.mnemonic = lightSlateGray
#color.fg.listing.mnemonic.unimplemented = navy
#color.fg.listing.flow-arrow.inactive = lightGray
#color.fg.listing.flow-arrow.active = color.fg
#color.fg.listing.flow-arrow.selected = limeGreen
#color.fg.listing.separator = color.fg
#color.fg.listing.variable = purple
#color.fg.listing.version-tracking = purple
#color.fg.listing.xref = darkGreen
#color.fg.listing.xref.offcut = gray
#color.fg.listing.xref.read = blue
#color.fg.listing.xref.write = darkOrange
#color.fg.listing.xref.other = color.fg
#color.fg.listing.register = olive
#color.fg.listing.underline = cornflowerBlue
#color.fg.listing.pcode.label = blue
#color.fg.listing.pcode.space = blue
#color.fg.listing.pcode.varnode = blue
#color.fg.listing.pcode.userop = blue

View file

@ -2,10 +2,12 @@
color.bg.undefined = rgb(220, 220, 220) // bg for clients displaying undefined functions color.bg.undefined = rgb(220, 220, 220) // bg for clients displaying undefined functions
color.flowtype.fall-through = red color.flowtype.fall.through = red
color.flowtype.jump.conditional = #007C00 // dark green color.flowtype.jump.conditional = #007C00 // dark green
color.flowtype.jump.unconditional = blue color.flowtype.jump.unconditional = blue
color.function.thunk = color.palette.blue
color.bg.table.selection.bundle = [color]textHighlight color.bg.table.selection.bundle = [color]textHighlight
color.fg.table.selection.bundle = [color]textHighlightText color.fg.table.selection.bundle = [color]textHighlightText
color.fg.table.bundle.disabled = darkGray color.fg.table.bundle.disabled = darkGray
@ -28,13 +30,13 @@ color.fg.infopanel.version = color.fg
color.fg.interpreterpanel = color.fg color.fg.interpreterpanel = color.fg
color.fg.interpreterpanel.error = color.fg.error color.fg.interpreterpanel.error = color.fg.error
color.fg.listing.highlighter.default = yellow color.fg.listing.highlighter.default = yellow
color.fg.listing.highlighter.scoped-read = rgb(204,204, 0) color.fg.listing.highlighter.scoped.read = rgb(204,204, 0)
color.fg.listing.highlighter.scoped-write = green color.fg.listing.highlighter.scoped.write = green
color.bg.markerservice = color.bg color.bg.markerservice = color.bg
color.bg.search.highlight = rgb(255,255,200) color.bg.search.highlight = rgb(255,255,200)
color.bg.search.current-line.highlight = yellow color.bg.search.current.line.highlight = yellow
color.bg.tree.renderer.icon.fill = #9F9FFF color.bg.tree.renderer.icon.fill = #9F9FFF
color.bg.tree.renderer.icon.line = #8282FF color.bg.tree.renderer.icon.line = #8282FF
@ -43,17 +45,120 @@ color.bg.analysis.options.not.default.enablement = rgb(255, 255, 200)
color.bg.analysis.options.not.default.enablement.selected = rgb(177, 212, 236) color.bg.analysis.options.not.default.enablement.selected = rgb(177, 212, 236)
color.fg.analysis.options.prototype = crimson color.fg.analysis.options.prototype = crimson
color.fg.plugin.assembler.completion.least = rgb(0, 128, 0)
color.fg.plugin.assembler.completion.middle = rgb(0, 0, 128)
color.fg.plugin.assembler.completion.most = blue
color.bg.plugin.bookmark.analysis = rgb(255, 128, 0) // orange
color.bg.plugin.bookmark.default = rgb(255, 0, 255) // magenta
color.bg.plugin.bookmark.error = rgb(204, 0, 51) // dark red
color.bg.plugin.bookmark.info = rgb(0, 255, 255) // cyan
color.bg.plugin.bookmark.note = rgb(128, 0, 255) // purple
color.bg.plugin.bookmark.warning = rgb(255, 196, 51) // dark yellow
color.bg.plugin.colorizer.default = #84AFD3
color.bg.plugin.colorizer.marker = pink
color.fg.plugin.comments.history.text = blue
color.fg.plugin.comments.history.user = color.fg
color.fg.plugin.comments.history.date = rgb(124, 37, 18)
color.bg.plugin.datamgr.edge.default = blue
color.bg.plugin.datamgr.edge.composite = magenta
color.bg.plugin.datamgr.edge.reference = blue
color.bg.plugin.datamgr.icon.highlight = rgb(204, 204, 255)
color.bg.plugin.editors.compositeeditor.text = color.fg
color.bg.plugin.editors.compositeeditor.line = [color]Component.borderColor
color.bg.plugin.editors.compositeeditor.line.interior = #D4D4D4
color.bg.plugin.editors.compositeeditor.byte.header = #DFDFDF
color.bg.plugin.editors.compositeeditor.bit.undefined = #F8F8F8
color.bg.plugin.editors.compositeeditor.bit.component = #BFBFFF
color.bg.plugin.editors.compositeeditor.bit.active = green
color.bg.plugin.editors.compositeeditor.bit.conflict = yellow
color.bg.plugin.editors.compositeeditor.non.bit = #A0A0FF
color.fg.plugin.equate.enum = lightskyblue
color.fg.plugin.function.editor.dialog.thunk = color.function.thunk
color.fg.plugin.function.editor.dialog.textfield.default = color.fg
color.fg.plugin.function.editor.dialog.textfield.error = color.fg.error
color.fg.plugin.function.editor.dialog.textfield.function.name = color.palette.blue
color.fg.plugin.function.editor.dialog.textfield.parameter = color.palette.magenta
color.bg.plugin.windowlocation = black
color.bg.plugin.windowlocation.bounds.virtual = red
color.bg.plugin.windowlocation.bounds.visible = green
color.bg.plugin.windowlocation.screens = orange
color.bg.plugin.windowlocation.window.selected = rgba(0, 255, 0, 200)
color.fg.plugin.windowlocation.window.text = gray
color.bg.plugin.instructionsearch.table.masked.instruction = rgb(237, 243, 254) // faint blue
color.bg.plugin.instructionsearch.table.masked.non.instruction = rgb(255, 242, 214) // tan
color.bg.plugin.instructionsearch.table.not.masked.instruction = rgb(188, 212, 254) // light blue
color.bg.plugin.instructionsearch.table.not.masked.non.instruction = rgb(203, 186, 150) // dark tan
color.bg.plugin.instructionsearch.table.default = rgb(214, 217, 223)
color.bg.plugin.instructionsearch.search.markers = lightgreen
color.fg.plugin.interpreter.renderer.color.standard.1 = rgb(0,0,0) // black
color.fg.plugin.interpreter.renderer.color.standard.2 = rgb(194, 54, 33) // red
color.fg.plugin.interpreter.renderer.color.standard.3 = rgb(37, 188, 36) // green
color.fg.plugin.interpreter.renderer.color.standard.4 = rgb(173, 173, 39) // yellow
color.fg.plugin.interpreter.renderer.color.standard.5 = rgb(73, 46, 225) // blue
color.fg.plugin.interpreter.renderer.color.standard.6 = rgb(211, 56, 211) // magenta
color.fg.plugin.interpreter.renderer.color.standard.7 = rgb(51, 187, 200) // cyan
color.fg.plugin.interpreter.renderer.color.standard.8 = rgb(203, 204, 205) // white
color.fg.plugin.interpreter.renderer.color.intense.1 = rgb(129, 131, 131) // intense black
color.fg.plugin.interpreter.renderer.color.intense.2 = rgb(252, 57, 31) // intense red
color.fg.plugin.interpreter.renderer.color.intense.3 = rgb(49, 231, 34) // intense green
color.fg.plugin.interpreter.renderer.color.intense.4 = rgb(234, 236, 35) // intense yellow
color.fg.plugin.interpreter.renderer.color.intense.5 = rgb(88, 51, 255) // intense blue
color.fg.plugin.interpreter.renderer.color.intense.6 = rgb(249, 53, 248) // intense magenta
color.fg.plugin.interpreter.renderer.color.intense.7 = rgb(20, 240, 240) // intense cyan
color.fg.plugin.interpreter.renderer.color.intense.8 = rgb(233, 235, 235) // intense white
color.bg.plugin.locationreferences.highlight = rgb(168, 202, 242)
color.bg.plugin.myprogramchangesdisplay.markers.changes.unsaved = darkgray
color.bg.plugin.myprogramchangesdisplay.markers.changes.conflicting = color.fg.error
color.bg.plugin.myprogramchangesdisplay.markers.changes.latest.version = blue
color.bg.plugin.myprogramchangesdisplay.markers.changes.not.checked.in = green
color.bg.plugin.overview.defalt = gray
color.bg.plugin.overview.address.data = rgb(128, 255, 128)
color.bg.plugin.overview.address.function = rgb(204, 150, 255)
color.bg.plugin.overview.address.external.ref = rgb(255, 150, 150)
color.bg.plugin.overview.address.instruction = rgb(192, 192, 255)
color.bg.plugin.overview.address.undefined = rgb(255, 51, 102)
color.bg.plugin.overview.address.uninitialized = black
color.bg.plugin.overview.entropy.knot.1 = red
color.bg.plugin.overview.entropy.knot.2 = blue
color.bg.plugin.overview.entropy.knot.3 = green
color.bg.plugin.overview.entropy.knot.4 = yellow
color.bg.plugin.overview.entropy.knot.5 = blue
color.bg.plugin.overview.entropy.uninitialized = blue
color.bg.plugin.overview.entropy.palette.base.low = black
color.bg.plugin.overview.entropy.palette.base.high = white
color.bg.plugin.overview.entropy.palette.text = color.fg
color.bg.plugin.references.table.active.operand = rgb(205, 205, 205)
color.bg.plugin.register.marker = rgb(0, 153, 153)
[Dark Defaults] [Dark Defaults]
color.bg = rgb(40, 42, 46) // TODO this should be in a more generic module color.bg = rgb(40, 42, 46) // TODO this should be in a more generic module
color.bg.undefined = #5C4D68 color.bg.undefined = #5C4D68
color.flowtype.fall-through = rgb(164, 66, 66) color.flowtype.fall.through = rgb(164, 66, 66)
color.flowtype.jump.conditional = rgb(95, 129, 157) color.flowtype.jump.conditional = rgb(95, 129, 157)
color.flowtype.jump.unconditional = rgb(140, 148, 64) color.flowtype.jump.unconditional = rgb(140, 148, 64)
color.bg.table.selection.bundle = [color]textHighlight color.bg.table.selection.bundle = [color]textHighlight
color.fg.table.selection.bundle = [color]textHighlightText color.fg.table.selection.bundle = [color]textHighlightText
color.fg.table.bundle.disabled = lightGray color.fg.table.bundle.disabled = lightGray
@ -67,11 +172,15 @@ color.fg.table.ghidratable.equate = royalBlue
color.fg.table.ghidratable.suggestion = darkGray color.fg.table.ghidratable.suggestion = darkGray
color.bg.search.highlight = rgb(189,183,107) color.bg.search.highlight = rgb(189,183,107)
color.bg.search.current-line.highlight = gold color.bg.search.current.line.highlight = gold
color.fg.listing.highlighter.scoped-read = rgb(100,100, 0) color.fg.listing.highlighter.scoped.read = rgb(100,100, 0)
color.fg.listing.highlighter.scoped-write = forestGreen color.fg.listing.highlighter.scoped.write = forestGreen
color.bg.analysis.options.not.default.enablement = #D1D19E color.bg.analysis.options.not.default.enablement = #D1D19E
color.bg.analysis.options.not.default.enablement.selected = rgb(177, 212, 236) color.bg.analysis.options.not.default.enablement.selected = rgb(177, 212, 236)
color.fg.analysis.options.prototype = lightcoral color.fg.analysis.options.prototype = lightcoral
color.bg.plugin.datamgr.edge.default = deepskyblue
color.bg.plugin.datamgr.edge.composite = plum
color.bg.plugin.datamgr.edge.reference = deepskyblue

View file

@ -1,31 +0,0 @@
[Defaults]
color.bg.decompiler = color.bg
color.fg.decompiler = color.fg
color.fg.decompiler.keyword = #0001e6
color.fg.decompiler.function.name = blue
color.fg.decompiler.comment = blueViolet
color.fg.decompiler.variable = #999900 // close to oliveDrab
color.fg.decompiler.constant = forestGreen
color.fg.decompiler.type = mediumBlue
color.fg.decompiler.parameter = darkMagenta
color.fg.decompiler.global = darkCyan
color.bg.decompiler.middle-mouse = rgba(255,255,0,.5)
color.bg.decompiler.current-variable = rgba(255,255,0,0.5)
[Dark Defaults]
color.fg.decompiler.keyword = peru
color.fg.decompiler.function.name = cadetBlue
color.fg.decompiler.comment = lightSlateGray
color.fg.decompiler.variable = #999900 // close to oliveDrab
color.fg.decompiler.constant = forestGreen
color.fg.decompiler.type = blue
color.fg.decompiler.parameter = darkMagenta
color.fg.decompiler.global = darkCyan
color.bg.decompiler.middle-mouse = rgb(55,59,65)
color.bg.decompiler.current-variable = rgb(55, 59, 65)

View file

@ -25,6 +25,7 @@ import javax.swing.text.html.HTMLEditorKit;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.GhidraOptions; import ghidra.GhidraOptions;
import ghidra.app.services.ProgramManager; import ghidra.app.services.ProgramManager;
import ghidra.framework.model.DomainObject; import ghidra.framework.model.DomainObject;
@ -270,7 +271,7 @@ class AnalyzeAllOpenProgramsTask extends Task {
appendTableHeader(buffy); appendTableHeader(buffy);
String specialFontOpen = "<B><font color=\"green\">"; String specialFontOpen = "<B><font color=\"" + Palette.GREEN.toHexString() + "\">";
String specialFontClose = "</font></B>"; String specialFontClose = "</font></B>";
for (Program program : validList) { for (Program program : validList) {

View file

@ -21,6 +21,7 @@ import java.beans.PropertyEditorSupport;
import javax.swing.*; import javax.swing.*;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors.Java;
import ghidra.framework.options.CustomOptionsEditor; import ghidra.framework.options.CustomOptionsEditor;
import ghidra.util.layout.PairLayout; import ghidra.util.layout.PairLayout;
@ -115,12 +116,10 @@ public class StoredAnalyzerTimesPropertyEditor extends PropertyEditorSupport
new JTextField(StoredAnalyzerTimes.formatTimeMS(times.getTotalTime())); new JTextField(StoredAnalyzerTimes.formatTimeMS(times.getTotalTime()));
valueField.setEditable(false); valueField.setEditable(false);
valueField.setHorizontalAlignment(SwingConstants.RIGHT); valueField.setHorizontalAlignment(SwingConstants.RIGHT);
valueField.setBorder(BorderFactory.createLineBorder(Color.black, 2)); valueField.setBorder(BorderFactory.createLineBorder(Java.BORDER, 2));
panel.add(valueField); panel.add(valueField);
return panel; return panel;
} }
} }

View file

@ -27,6 +27,8 @@ import docking.EmptyBorderToggleButton;
import docking.widgets.autocomplete.*; import docking.widgets.autocomplete.*;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import docking.widgets.textfield.TextFieldLinker; import docking.widgets.textfield.TextFieldLinker;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import ghidra.GhidraApplicationLayout; import ghidra.GhidraApplicationLayout;
import ghidra.GhidraLaunchable; import ghidra.GhidraLaunchable;
import ghidra.app.plugin.assembler.Assembler; import ghidra.app.plugin.assembler.Assembler;
@ -60,6 +62,14 @@ import resources.ResourceManager;
* Otherwise, the usual autocompletion behavior is applied automatically. * Otherwise, the usual autocompletion behavior is applied automatically.
*/ */
public class AssemblyDualTextField { public class AssemblyDualTextField {
private static Color FG_PREFERENCE_MOST =
new GColor("color.fg.plugin.assembler.completion.most");
private static Color FG_PREFERENCE_MIDDLE =
new GColor("color.fg.plugin.assembler.completion.middle");
private static Color FG_PREFERENCE_LEAST =
new GColor("color.fg.plugin.assembler.completion.least");
protected final TextFieldLinker linker = new TextFieldLinker(); protected final TextFieldLinker linker = new TextFieldLinker();
protected final JTextField mnemonic = new JTextField(); protected final JTextField mnemonic = new JTextField();
protected final JTextField operands = new JTextField(); protected final JTextField operands = new JTextField();
@ -179,8 +189,8 @@ public class AssemblyDualTextField {
public AssemblyInstruction(String text, byte[] data, int preference) { public AssemblyInstruction(String text, byte[] data, int preference) {
// TODO?: Description to display constructor tree information // TODO?: Description to display constructor tree information
super("", NumericUtilities.convertBytesToString(data, " "), super("", NumericUtilities.convertBytesToString(data, " "),
preference == 10000 ? Color.BLUE preference == 10000 ? FG_PREFERENCE_MOST
: preference == 5000 ? new Color(0, 0, 128) : new Color(0, 128, 0), : preference == 5000 ? FG_PREFERENCE_MIDDLE : FG_PREFERENCE_LEAST,
-preference); -preference);
this.data = data; this.data = data;
} }
@ -220,7 +230,7 @@ public class AssemblyDualTextField {
private String text; private String text;
public AssemblyError(String text, String desc) { public AssemblyError(String text, String desc) {
super(text, desc, Color.RED, 1); super(text, desc, Colors.ERROR, 1);
this.text = text; this.text = text;
} }
@ -442,7 +452,7 @@ public class AssemblyDualTextField {
* Set the "existing" instruction used for ordering proposed instructions by "most similar" * Set the "existing" instruction used for ordering proposed instructions by "most similar"
* *
* @see #computePreference(AssemblyResolvedPatterns) * @see #computePreference(AssemblyResolvedPatterns)
* @param existing * @param existing the existing instruction
*/ */
public void setExisting(Instruction existing) { public void setExisting(Instruction existing) {
this.existing = existing; this.existing = existing;
@ -468,6 +478,7 @@ public class AssemblyDualTextField {
/** /**
* For single mode: Get the text field containing the full assembly text * For single mode: Get the text field containing the full assembly text
* @return the text field
*/ */
public JTextField getAssemblyField() { public JTextField getAssemblyField() {
return assembly; return assembly;
@ -550,18 +561,13 @@ public class AssemblyDualTextField {
if (assembly.isVisible()) { if (assembly.isVisible()) {
throw new AssertionError(); throw new AssertionError();
} }
else { return VisibilityMode.DUAL_VISIBLE;
return VisibilityMode.DUAL_VISIBLE;
}
} }
else {
if (assembly.isVisible()) { if (assembly.isVisible()) {
return VisibilityMode.SINGLE_VISIBLE; return VisibilityMode.SINGLE_VISIBLE;
}
else {
return VisibilityMode.INVISIBLE;
}
} }
return VisibilityMode.INVISIBLE;
} }
/** /**
@ -695,7 +701,6 @@ public class AssemblyDualTextField {
* one are preferred. Last, the shortest instructions are preferred. * one are preferred. Last, the shortest instructions are preferred.
* *
* @param rc a resolved instruction * @param rc a resolved instruction
* @param existing the instruction, if any, currently under the user's cursor
* @return a preference * @return a preference
*/ */
protected int computePreference(AssemblyResolvedPatterns rc) { protected int computePreference(AssemblyResolvedPatterns rc) {

View file

@ -15,7 +15,6 @@
*/ */
package ghidra.app.plugin.core.assembler; package ghidra.app.plugin.core.assembler;
import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.event.FocusListener; import java.awt.event.FocusListener;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
@ -26,6 +25,7 @@ import docking.action.KeyBindingData;
import docking.action.MenuData; import docking.action.MenuData;
import docking.widgets.fieldpanel.FieldPanel; import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.fieldpanel.support.FieldLocation; import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GThemeDefaults.Colors;
import ghidra.framework.plugintool.Plugin; import ghidra.framework.plugintool.Plugin;
import ghidra.program.database.util.ProgramTransaction; import ghidra.program.database.util.ProgramTransaction;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
@ -56,7 +56,7 @@ public class PatchDataAction extends AbstractPatchAction {
setKeyBindingData(new KeyBindingData(KEYBIND_PATCH_DATA)); setKeyBindingData(new KeyBindingData(KEYBIND_PATCH_DATA));
setHelpLocation(new HelpLocation(owner.getName(), "patch_data")); setHelpLocation(new HelpLocation(owner.getName(), "patch_data"));
input.setBorder(BorderFactory.createLineBorder(Color.RED, 2)); input.setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
init(); init();
} }

View file

@ -15,7 +15,6 @@
*/ */
package ghidra.app.plugin.core.assembler; package ghidra.app.plugin.core.assembler;
import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.event.FocusListener; import java.awt.event.FocusListener;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
@ -33,6 +32,7 @@ import docking.action.MenuData;
import docking.widgets.autocomplete.*; import docking.widgets.autocomplete.*;
import docking.widgets.fieldpanel.*; import docking.widgets.fieldpanel.*;
import docking.widgets.fieldpanel.support.FieldLocation; import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.assembler.Assembler; import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers; import ghidra.app.plugin.assembler.Assemblers;
import ghidra.app.plugin.core.assembler.AssemblyDualTextField.*; import ghidra.app.plugin.core.assembler.AssemblyDualTextField.*;
@ -146,9 +146,9 @@ public class PatchInstructionAction extends AbstractPatchAction {
setKeyBindingData(new KeyBindingData(KEYBIND_PATCH_INSTRUCTION)); setKeyBindingData(new KeyBindingData(KEYBIND_PATCH_INSTRUCTION));
setHelpLocation(new HelpLocation(owner.getName(), "patch_instruction")); setHelpLocation(new HelpLocation(owner.getName(), "patch_instruction"));
input.getMnemonicField().setBorder(BorderFactory.createLineBorder(Color.RED, 2)); input.getMnemonicField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getOperandsField().setBorder(BorderFactory.createLineBorder(Color.RED, 2)); input.getOperandsField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getAssemblyField().setBorder(BorderFactory.createLineBorder(Color.RED, 2)); input.getAssemblyField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getAutocompleter().addAutocompletionListener(listenerForAccept); input.getAutocompleter().addAutocompletionListener(listenerForAccept);

View file

@ -21,6 +21,7 @@ import javax.swing.ImageIcon;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import generic.theme.GColor;
import ghidra.app.services.*; import ghidra.app.services.*;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSet; import ghidra.program.model.address.AddressSet;
@ -52,12 +53,12 @@ public class BookmarkNavigator {
final static int ANALYSIS_PRIORITY = MarkerService.BOOKMARK_PRIORITY + 6; final static int ANALYSIS_PRIORITY = MarkerService.BOOKMARK_PRIORITY + 6;
final static int DEFAULT_PRIORITY = MarkerService.BOOKMARK_PRIORITY + 8; final static int DEFAULT_PRIORITY = MarkerService.BOOKMARK_PRIORITY + 8;
final static Color NOTE_COLOR = new Color(128, 0, 255); // Purple final static Color NOTE_COLOR = new GColor("color.bg.plugin.bookmark.note");
final static Color INFO_COLOR = new Color(0, 255, 255); // Cyan final static Color INFO_COLOR = new GColor("color.bg.plugin.bookmark.info");
final static Color WARNING_COLOR = new Color(255, 196, 51); // Dark Yellow final static Color WARNING_COLOR = new GColor("color.bg.plugin.bookmark.warning");
final static Color ERROR_COLOR = new Color(204, 0, 51); // Dark Red final static Color ERROR_COLOR = new GColor("color.bg.plugin.bookmark.error");
final static Color ANALYSIS_COLOR = new Color(255, 128, 0); // Orange final static Color ANALYSIS_COLOR = new GColor("color.bg.plugin.bookmark.analysis");
final static Color DEFAULT_COLOR = new Color(255, 0, 255); // Magenta final static Color DEFAULT_COLOR = new GColor("color.bg.plugin.bookmark.default");
private String type; private String type;
private MarkerService markerService; private MarkerService markerService;

View file

@ -16,7 +16,6 @@
package ghidra.app.plugin.core.checksums; package ghidra.app.plugin.core.checksums;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -25,6 +24,7 @@ import javax.swing.*;
import docking.ActionContext; import docking.ActionContext;
import docking.action.*; import docking.action.*;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.context.ProgramContextAction; import ghidra.app.context.ProgramContextAction;
import ghidra.framework.plugintool.ComponentProviderAdapter; import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
@ -97,7 +97,7 @@ public class ComputeChecksumsProvider extends ComponentProviderAdapter {
errorStatus = new GDLabel(" "); errorStatus = new GDLabel(" ");
errorStatus.setName("message"); errorStatus.setName("message");
errorStatus.setHorizontalAlignment(SwingConstants.CENTER); errorStatus.setHorizontalAlignment(SwingConstants.CENTER);
errorStatus.setForeground(Color.RED); errorStatus.setForeground(Colors.ERROR);
errorStatus.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); errorStatus.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
main.add(errorStatus, BorderLayout.SOUTH); main.add(errorStatus, BorderLayout.SOUTH);

View file

@ -588,7 +588,8 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
} }
color = color =
fieldOptions.getColor(GhidraOptions.OPTION_HIGHLIGHT_COLOR, new Color(255, 255, 180)); fieldOptions.getColor(GhidraOptions.OPTION_HIGHLIGHT_COLOR,
GhidraOptions.DEFAULT_HIGHLIGHT_COLOR);
MarkerSet highlightMarkers = getHighlightMarkers(currentProgram); MarkerSet highlightMarkers = getHighlightMarkers(currentProgram);
fieldPanel.setHighlightColor(color); fieldPanel.setHighlightColor(color);
if (highlightMarkers != null) { if (highlightMarkers != null) {

View file

@ -18,6 +18,7 @@ package ghidra.app.plugin.core.codebrowser;
import java.awt.Color; import java.awt.Color;
import java.math.BigInteger; import java.math.BigInteger;
import generic.theme.TempColorUtils;
import ghidra.app.util.viewer.listingpanel.ListingBackgroundColorModel; import ghidra.app.util.viewer.listingpanel.ListingBackgroundColorModel;
import ghidra.app.util.viewer.listingpanel.ListingPanel; import ghidra.app.util.viewer.listingpanel.ListingPanel;
@ -52,10 +53,7 @@ public class LayeredColorModel implements ListingBackgroundColorModel {
} }
private Color blend(Color primary, Color secondary) { private Color blend(Color primary, Color secondary) {
int red = (primary.getRed() * 2 + secondary.getRed()) / 3; return TempColorUtils.blend1(primary, secondary);
int green = (primary.getGreen() * 2 + secondary.getGreen()) / 3;
int blue = (primary.getBlue() * 2 + secondary.getBlue()) / 3;
return new Color(red, green, blue);
} }
@Override @Override

View file

@ -54,8 +54,8 @@ public class ListingHighlightProvider
implements ButtonPressedListener, OptionsChangeListener, HighlightProvider { implements ButtonPressedListener, OptionsChangeListener, HighlightProvider {
//@formatter:off //@formatter:off
private static final Color DEFAULT_HIGHLIGHT_COLOR = new GColor("color.fg.listing.highlighter.default"); private static final Color DEFAULT_HIGHLIGHT_COLOR = new GColor("color.fg.listing.highlighter.default");
private static final Color DEFAULT_SCOPED_READ_COLOR = new GColor("color.fg.listing.highlighter.scoped-read"); private static final Color DEFAULT_SCOPED_READ_COLOR = new GColor("color.fg.listing.highlighter.scoped.read");
private static final Color DEFAULT_SCOPED_WRITE_COLOR = new GColor("color.fg.listing.highlighter.scoped-write"); private static final Color DEFAULT_SCOPED_WRITE_COLOR = new GColor("color.fg.listing.highlighter.scoped.write");
private static final String DISPLAY_HIGHLIGHT_NAME = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Enabled"; private static final String DISPLAY_HIGHLIGHT_NAME = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Enabled";
private static final String SCOPED_WRITE_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Write Highlight Color"; private static final String SCOPED_WRITE_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Write Highlight Color";
private static final String SCOPED_READ_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Read Highlight Color"; private static final String SCOPED_READ_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Read Highlight Color";
@ -144,7 +144,7 @@ public class ListingHighlightProvider
Pattern highlightPattern = currentHighlightPattern; Pattern highlightPattern = currentHighlightPattern;
Matcher matcher = highlightPattern.matcher(text); Matcher matcher = highlightPattern.matcher(text);
List<Highlight> highlightList = new ArrayList<Highlight>(); List<Highlight> highlightList = new ArrayList<>();
while (matcher.find()) { while (matcher.find()) {
int start = matcher.start(); int start = matcher.start();
int end = matcher.end() - 1; int end = matcher.end() - 1;
@ -479,7 +479,7 @@ public class ListingHighlightProvider
} }
private Set<Register> getRegisterSet(Register reg) { private Set<Register> getRegisterSet(Register reg) {
Set<Register> regSet = new HashSet<Register>(); Set<Register> regSet = new HashSet<>();
regSet.add(reg); regSet.add(reg);
Register r = reg.getParentRegister(); Register r = reg.getParentRegister();
while (r != null) { while (r != null) {
@ -558,7 +558,7 @@ public class ListingHighlightProvider
// and set writeScope, all other instructions upto that point will be // and set writeScope, all other instructions upto that point will be
// added to read scope // added to read scope
Program prog = instr.getProgram(); Program prog = instr.getProgram();
Stack<Address> backStack = new Stack<Address>(); Stack<Address> backStack = new Stack<>();
pushInstructionBackFlows(instr, backStack); pushInstructionBackFlows(instr, backStack);
while (!backStack.isEmpty()) { while (!backStack.isEmpty()) {
Address addr = backStack.pop(); Address addr = backStack.pop();
@ -587,7 +587,7 @@ public class ListingHighlightProvider
// follow flow downwards until register is changed // follow flow downwards until register is changed
// add in each line that has register anywhere // add in each line that has register anywhere
Program prog = instr.getProgram(); Program prog = instr.getProgram();
Stack<Address> stack = new Stack<Address>(); Stack<Address> stack = new Stack<>();
pushInstructionFlows(instr, stack); pushInstructionFlows(instr, stack);
while (!stack.isEmpty()) { while (!stack.isEmpty()) {
Address addr = stack.pop(); Address addr = stack.pop();
@ -847,7 +847,7 @@ public class ListingHighlightProvider
varnodeSize -= intOff; varnodeSize -= intOff;
varnodeOffset += intOff; varnodeOffset += intOff;
List<Varnode> varnodes = new ArrayList<Varnode>(); List<Varnode> varnodes = new ArrayList<>();
for (Varnode v : variableStorage.getVarnodes()) { for (Varnode v : variableStorage.getVarnodes()) {
if (varnodeOffset >= v.getSize()) { if (varnodeOffset >= v.getSize()) {
varnodeOffset -= v.getSize(); varnodeOffset -= v.getSize();

View file

@ -19,6 +19,7 @@ import javax.swing.JComponent;
import docking.widgets.fieldpanel.field.Field; import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation; import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GThemeDefaults.Colors;
import ghidra.GhidraOptions; import ghidra.GhidraOptions;
import ghidra.app.plugin.core.hover.AbstractConfigurableHover; import ghidra.app.plugin.core.hover.AbstractConfigurableHover;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
@ -111,7 +112,8 @@ public class DataTypeListingHover extends AbstractConfigurableHover implements L
} }
if (warningMsg.length() != 0) { if (warningMsg.length() != 0) {
String errorText = String errorText =
"<HTML><center><font color=\"red\">" + warningMsg + "!</font></center><BR>"; "<HTML><center><font color=\"" + Colors.ERROR.toHexString() + "\">" +
warningMsg + "!</font></center><BR>";
toolTipText = toolTipText.replace("<HTML>", errorText); toolTipText = toolTipText.replace("<HTML>", errorText);
} }
return createTooltipComponent(toolTipText); return createTooltipComponent(toolTipText);
@ -149,7 +151,9 @@ public class DataTypeListingHover extends AbstractConfigurableHover implements L
result += "<br>Missing NULL terminator."; result += "<br>Missing NULL terminator.";
} }
if (sdi.getStringLength() > dataInstance.getLength()) { if (sdi.getStringLength() > dataInstance.getLength()) {
result += "<br><font color=\"red\">String exceeds data field.</font>"; result +=
"<br><font color=\"" + Colors.ERROR.toHexString() +
"\">String exceeds data field.</font>";
} }
} }
return result; return result;

View file

@ -24,6 +24,8 @@ import org.jdom.Element;
import docking.ActionContext; import docking.ActionContext;
import docking.action.DockingAction; import docking.action.DockingAction;
import docking.action.MenuData; import docking.action.MenuData;
import generic.theme.GColor;
import generic.theme.TempColorUtils;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
@ -61,7 +63,7 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
private static final String MARKER_DESCRIPTION = "Shows the location of user-applied colors"; private static final String MARKER_DESCRIPTION = "Shows the location of user-applied colors";
private static final int PRIORITY = MarkerService.CHANGE_PRIORITY - 1; // lowest priority private static final int PRIORITY = MarkerService.CHANGE_PRIORITY - 1; // lowest priority
private static final Color MARKER_COLOR = Color.PINK; private static final Color MARKER_COLOR = new GColor("color.bg.plugin.colorizer.marker");
private static final String COLOR_HISTORY_XML_NAME = "COLOR_HISTORY"; private static final String COLOR_HISTORY_XML_NAME = "COLOR_HISTORY";
private static final String COLOR_HISTORY_LIST_XML_NAME = "COLOR_HISTORY"; private static final String COLOR_HISTORY_LIST_XML_NAME = "COLOR_HISTORY";
@ -80,12 +82,7 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
private NextColorRangeAction nextAction; private NextColorRangeAction nextAction;
private PreviousColorRangeAction previousAction; private PreviousColorRangeAction previousAction;
private SwingUpdateManager updateManager = new SwingUpdateManager(1000, new Runnable() { private SwingUpdateManager updateManager = new SwingUpdateManager(1000, () -> doUpdate());
@Override
public void run() {
doUpdate();
}
});
public ColorizingPlugin(PluginTool tool) { public ColorizingPlugin(PluginTool tool) {
super(tool); super(tool);
@ -108,12 +105,12 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
public void readConfigState(SaveState saveState) { public void readConfigState(SaveState saveState) {
Element xmlElement = saveState.getXmlElement(COLOR_HISTORY_XML_NAME); Element xmlElement = saveState.getXmlElement(COLOR_HISTORY_XML_NAME);
if (xmlElement != null) { if (xmlElement != null) {
List<Color> savedColorHistory = new ArrayList<Color>(); List<Color> savedColorHistory = new ArrayList<>();
List<Element> colorElements = xmlElement.getChildren("COLOR"); List<Element> colorElements = xmlElement.getChildren("COLOR");
for (Element element : colorElements) { for (Element element : colorElements) {
String rgbString = element.getAttributeValue("RGB"); String rgbString = element.getAttributeValue("RGB");
int rgb = Integer.parseInt(rgbString); int rgb = Integer.parseInt(rgbString);
savedColorHistory.add(new Color(rgb, true)); savedColorHistory.add(TempColorUtils.fromRgba(rgb));
} }
service.setColorHistory(savedColorHistory); service.setColorHistory(savedColorHistory);
@ -153,15 +150,15 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
} }
@Override @Override
public void serviceAdded(Class<?> interfaceClass, Object service) { public void serviceAdded(Class<?> interfaceClass, Object newService) {
if (interfaceClass.equals(MarkerService.class)) { if (interfaceClass.equals(MarkerService.class)) {
markerService = (MarkerService) service; markerService = (MarkerService) newService;
} }
} }
@Override @Override
public void serviceRemoved(Class<?> interfaceClass, Object service) { public void serviceRemoved(Class<?> interfaceClass, Object removedService) {
if (interfaceClass.equals(MarkerService.class)) { if (interfaceClass.equals(MarkerService.class)) {
markerService = null; markerService = null;
} }

View file

@ -20,6 +20,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import docking.options.editor.GhidraColorChooser; import docking.options.editor.GhidraColorChooser;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Palette;
import generic.theme.TempColorUtils;
import ghidra.app.util.viewer.listingpanel.PropertyBasedBackgroundColorModel; import ghidra.app.util.viewer.listingpanel.PropertyBasedBackgroundColorModel;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.program.database.IntRangeMap; import ghidra.program.database.IntRangeMap;
@ -29,7 +32,7 @@ import ghidra.util.exception.DuplicateNameException;
class ColorizingServiceProvider implements ColorizingService { class ColorizingServiceProvider implements ColorizingService {
private static final Color DEFAULT_COLOR = new Color(0x84AFD3); private static final Color DEFAULT_COLOR = new GColor("color.bg.plugin.colorizer.default");
static final String COLOR_CHOOSER_TITLE = "Please Select Background Color"; static final String COLOR_CHOOSER_TITLE = "Please Select Background Color";
private final PluginTool tool; private final PluginTool tool;
@ -86,7 +89,7 @@ class ColorizingServiceProvider implements ColorizingService {
public Color getColorFromUser(Color suggestedColor) { public Color getColorFromUser(Color suggestedColor) {
if (colorChooser == null) { if (colorChooser == null) {
colorChooser = colorChooser =
new GhidraColorChooser(suggestedColor == null ? Color.WHITE : suggestedColor); new GhidraColorChooser(suggestedColor == null ? Palette.WHITE : suggestedColor);
colorChooser.setTitle(COLOR_CHOOSER_TITLE); colorChooser.setTitle(COLOR_CHOOSER_TITLE);
if (savedColorHistory != null) { if (savedColorHistory != null) {
colorChooser.setColorHistory(savedColorHistory); colorChooser.setColorHistory(savedColorHistory);
@ -135,7 +138,7 @@ class ColorizingServiceProvider implements ColorizingService {
if (map != null) { if (map != null) {
Integer value = map.getValue(address); Integer value = map.getValue(address);
if (value != null) { if (value != null) {
return new Color(value, true); return TempColorUtils.fromRgba(value);
} }
} }
return null; return null;

View file

@ -16,12 +16,12 @@
package ghidra.app.plugin.core.comments; package ghidra.app.plugin.core.comments;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextPane; import javax.swing.JTextPane;
import javax.swing.text.*; import javax.swing.text.*;
import generic.theme.GColor;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CommentHistory; import ghidra.program.model.listing.CommentHistory;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
@ -115,18 +115,22 @@ class CommentHistoryPanel extends JPanel {
textAttrSet = new SimpleAttributeSet(); textAttrSet = new SimpleAttributeSet();
textAttrSet.addAttribute(StyleConstants.FontFamily, "Monospaced"); textAttrSet.addAttribute(StyleConstants.FontFamily, "Monospaced");
textAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(12)); textAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(12));
textAttrSet.addAttribute(StyleConstants.Foreground, Color.BLUE); textAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.plugin.comments.history.text"));
userAttrSet = new SimpleAttributeSet(); userAttrSet = new SimpleAttributeSet();
userAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); userAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
userAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(12)); userAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(12));
userAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); userAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
userAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.plugin.comments.history.user"));
dateAttrSet = new SimpleAttributeSet(); dateAttrSet = new SimpleAttributeSet();
dateAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); dateAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
dateAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11)); dateAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
dateAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); dateAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
dateAttrSet.addAttribute(StyleConstants.Foreground, new Color(124, 37, 18)); dateAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.plugin.comments.history.date"));
tabAttrSet = new SimpleAttributeSet(); tabAttrSet = new SimpleAttributeSet();
TabStop tabs = new TabStop(100, StyleConstants.ALIGN_LEFT, TabStop.LEAD_NONE); TabStop tabs = new TabStop(100, StyleConstants.ALIGN_LEFT, TabStop.LEAD_NONE);

View file

@ -28,6 +28,7 @@ import docking.ActionContext;
import docking.widgets.DropDownSelectionTextField; import docking.widgets.DropDownSelectionTextField;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes; import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes;
import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitFieldAllocation; import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitFieldAllocation;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
@ -73,7 +74,6 @@ public class BitFieldEditorPanel extends JPanel {
private BitSelectionHandler bitSelectionHandler; private BitSelectionHandler bitSelectionHandler;
private boolean updating = false; private boolean updating = false;
BitFieldEditorPanel(Composite composite, DataTypeManagerService dtmService, BitFieldEditorPanel(Composite composite, DataTypeManagerService dtmService,
@ -179,7 +179,7 @@ public class BitFieldEditorPanel extends JPanel {
statusTextField = new GDLabel(" "); statusTextField = new GDLabel(" ");
statusTextField.setHorizontalAlignment(SwingConstants.CENTER); statusTextField.setHorizontalAlignment(SwingConstants.CENTER);
statusTextField.setForeground(Color.red); statusTextField.setForeground(Colors.ERROR);
// use a strut panel so the size of the message area does not change if we make // use a strut panel so the size of the message area does not change if we make
// the message label not visible // the message label not visible

View file

@ -22,6 +22,7 @@ import java.util.*;
import javax.help.UnsupportedOperationException; import javax.help.UnsupportedOperationException;
import javax.swing.*; import javax.swing.*;
import generic.theme.GColor;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite; import ghidra.program.model.data.Composite;
import ghidra.util.HTMLUtilities; import ghidra.util.HTMLUtilities;
@ -42,15 +43,25 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {
private static final int LENEND_BOX_SIZE = 16; private static final int LENEND_BOX_SIZE = 16;
private static final Color TEXT_COLOR = Color.black; private static final Color TEXT_COLOR =
private static final Color LINE_COLOR = Color.black; new GColor("color.bg.plugin.editors.compositeeditor.text");
private static final Color BYTE_HEADER_COLOR = new Color(0xdfdfdf); private static final Color LINE_COLOR =
private static final Color UNDEFINED_BIT_COLOR = new Color(0xf8f8f8); new GColor("color.bg.plugin.editors.compositeeditor.line");
private static final Color ACTIVE_BITFIELD_BITS_COLOR = Color.green; private static final Color BYTE_HEADER_COLOR =
private static final Color CONFLICT_BITS_COLOR = Color.yellow; new GColor("color.bg.plugin.editors.compositeeditor.byte.header");
private static final Color BITFIELD_COMPONENT_COLOR = new Color(0xbfbfff);
private static final Color NON_BITFIELD_COMPONENT_COLOR = new Color(0xa0a0ff); private static final Color UNDEFINED_BIT_COLOR =
private static final Color INTERIOR_LINE_COLOR = new Color(0xd4d4d4); new GColor("color.bg.plugin.editors.compositeeditor.bit.undefined");
private static final Color BITFIELD_COMPONENT_COLOR =
new GColor("color.bg.plugin.editors.compositeeditor.bit.component");
private static final Color ACTIVE_BITFIELD_BITS_COLOR =
new GColor("color.bg.plugin.editors.compositeeditor.bit.active");
private static final Color CONFLICT_BITS_COLOR =
new GColor("color.bg.plugin.editors.compositeeditor.bit.conflict");
private static final Color NON_BITFIELD_COMPONENT_COLOR =
new GColor("color.bg.plugin.editors.compositeeditor.non.bit");
private static final Color INTERIOR_LINE_COLOR =
new GColor("color.bg.plugin.editors.compositeeditor.line.interior");
private int bitWidth = 10; private int bitWidth = 10;
private int byteWidth = getByteWidth(bitWidth); private int byteWidth = getByteWidth(bitWidth);
@ -211,7 +222,7 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {
return; return;
} }
if (e.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) { if (e.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) {
// TODO: should we handle other modes? // should we handle other modes?
return; return;
} }
e.consume(); e.consume();

View file

@ -30,6 +30,7 @@ import docking.widgets.OptionDialog;
import docking.widgets.button.GRadioButton; import docking.widgets.button.GRadioButton;
import docking.widgets.fieldpanel.support.FieldSelection; import docking.widgets.fieldpanel.support.FieldSelection;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes; import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite; import ghidra.program.model.data.Composite;
@ -394,7 +395,9 @@ public class CompEditorPanel extends CompositeEditorPanel {
String alignmentToolTip = String alignmentToolTip =
"<HTML>The <B>align</B> control allows the overall minimum alignment of this<BR>" + "<HTML>The <B>align</B> control allows the overall minimum alignment of this<BR>" +
"data type to be specified. The actual computed alignment<BR>" + "data type to be specified. The actual computed alignment<BR>" +
"may be any multiple of this value. <font color=blue size=\"-2\">(&lt;F1&gt; for help)</HTML>"; "may be any multiple of this value. " +
"<font color=\"" + Palette.BLUE.toHexString() +
"\" size=\"-2\">(&lt;F1&gt; for help)</HTML>";
alignPanel.setToolTipText(alignmentToolTip); alignPanel.setToolTipText(alignmentToolTip);
addMinimumAlignmentComponents(); addMinimumAlignmentComponents();
@ -570,7 +573,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
infoPanel.add(actualAlignmentPanel, gridBagConstraints); infoPanel.add(actualAlignmentPanel, gridBagConstraints);
actualAlignmentValueTextField = new JTextField(8); actualAlignmentValueTextField = new JTextField(8);
actualAlignmentValueTextField.setText("" + ((CompEditorModel) model).getActualAlignment()); actualAlignmentValueTextField
.setText(Integer.toString(((CompEditorModel) model).getActualAlignment()));
actualAlignmentValueTextField.setToolTipText(actualAlignmentToolTip); actualAlignmentValueTextField.setToolTipText(actualAlignmentToolTip);
actualAlignmentValueTextField.setEditable(false); actualAlignmentValueTextField.setEditable(false);
if (helpManager != null) { if (helpManager != null) {
@ -586,7 +590,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
gridBagConstraints.gridx = 3; gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 3; gridBagConstraints.gridy = 3;
infoPanel.add(actualAlignmentValueTextField, gridBagConstraints); infoPanel.add(actualAlignmentValueTextField, gridBagConstraints);
actualAlignmentValueTextField.setBackground(new Color(getBackground().getRGB())); actualAlignmentValueTextField.setBackground(getBackground());
} }
private void setupPacking() { private void setupPacking() {
@ -669,8 +673,11 @@ public class CompEditorPanel extends CompositeEditorPanel {
private void setupPackingEnablementButton() { private void setupPackingEnablementButton() {
packingEnablementButton.setName("Packing Enablement"); packingEnablementButton.setName("Packing Enablement");
String packingToolTipText = String packingToolTipText =
"<HTML>Enable packing when details of all components are known (including sizing and alignment).<BR>" + "<HTML>Enable packing when details of all components are known (including sizing and" +
"Disable packing when Reverse Engineering composite. <font color=blue size=\"-2\">(&lt;F1&gt; for help)</font></HTML>"; " alignment).<BR>" +
"Disable packing when Reverse Engineering composite. " +
"<font color=\"" + Palette.BLUE.toHexString() +
"\" size=\"-2\">(&lt;F1&gt; for help)</font></HTML>";
packingEnablementButton.addActionListener(e -> { packingEnablementButton.addActionListener(e -> {
((CompEditorModel) model).setPackingType( ((CompEditorModel) model).setPackingType(
packingEnablementButton.isSelected() ? PackingType.DEFAULT : PackingType.DISABLED, packingEnablementButton.isSelected() ? PackingType.DEFAULT : PackingType.DISABLED,
@ -708,8 +715,9 @@ public class CompEditorPanel extends CompositeEditorPanel {
explicitPackingButton.addActionListener(e -> chooseByValuePacking()); explicitPackingButton.addActionListener(e -> chooseByValuePacking());
explicitPackingButton.setToolTipText(packingToolTipText); explicitPackingButton.setToolTipText(packingToolTipText);
if (helpManager != null) { if (helpManager != null) {
helpManager.registerHelp(explicitPackingButton, new HelpLocation(provider.getHelpTopic(), helpManager.registerHelp(explicitPackingButton,
provider.getHelpName() + "_" + "Pack")); new HelpLocation(provider.getHelpTopic(),
provider.getHelpName() + "_" + "Pack"));
} }
explicitPackingTextField.setName("Packing Value"); explicitPackingTextField.setName("Packing Value");
@ -831,7 +839,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
} }
else { else {
// not editable - use same background as panel // not editable - use same background as panel
sizeTextField.setBackground(new Color(getBackground().getRGB())); sizeTextField.setBackground(getBackground());
} }
} }

View file

@ -43,6 +43,7 @@ import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import docking.widgets.table.*; import docking.widgets.table.*;
import docking.widgets.textfield.GValidatedTextField; import docking.widgets.textfield.GValidatedTextField;
import generic.theme.GColor;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.datatype.DataTypeSelectionEditor; import ghidra.app.util.datatype.DataTypeSelectionEditor;
import ghidra.app.util.datatype.NavigationDirection; import ghidra.app.util.datatype.NavigationDirection;
@ -70,8 +71,6 @@ public abstract class CompositeEditorPanel extends JPanel
implements CompositeEditorModelListener, ComponentCellEditorListener, Draggable, Droppable { implements CompositeEditorModelListener, ComponentCellEditorListener, Draggable, Droppable {
// Normal color for selecting components in the table. // Normal color for selecting components in the table.
// TODO: Why do we choose a different selection color?
//private static final Color SELECTION_COLOR = Color.YELLOW.brighter().brighter();
//protected static final Insets TEXTFIELD_INSETS = new JTextField().getInsets(); //protected static final Insets TEXTFIELD_INSETS = new JTextField().getInsets();
protected static final Border BEVELED_BORDER = BorderFactory.createLoweredBevelBorder(); protected static final Border BEVELED_BORDER = BorderFactory.createLoweredBevelBorder();
@ -605,8 +604,6 @@ public abstract class CompositeEditorPanel extends JPanel
JScrollPane sp = new JScrollPane(table); JScrollPane sp = new JScrollPane(table);
table.setPreferredScrollableViewportSize(new Dimension(model.getWidth(), 250)); table.setPreferredScrollableViewportSize(new Dimension(model.getWidth(), 250));
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
//table.setSelectionBackground(SELECTION_COLOR);
//table.setSelectionForeground(Color.black);
tablePanel.add(sp, BorderLayout.CENTER); tablePanel.add(sp, BorderLayout.CENTER);
SearchControlPanel searchPanel = new SearchControlPanel(this); SearchControlPanel searchPanel = new SearchControlPanel(this);
@ -636,7 +633,7 @@ public abstract class CompositeEditorPanel extends JPanel
// This can happen on the Mac and is usually white. This is a simple solution for // This can happen on the Mac and is usually white. This is a simple solution for
// that scenario. If this fails on other platforms, then do something more advanced // that scenario. If this fails on other platforms, then do something more advanced
// at that point. // at that point.
table.setGridColor(Color.GRAY); table.setGridColor(new GColor("color.bg.table.grid"));
} }
} }
@ -668,7 +665,7 @@ public abstract class CompositeEditorPanel extends JPanel
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
statusLabel = new GDLabel(" "); statusLabel = new GDLabel(" ");
statusLabel.setHorizontalAlignment(SwingConstants.CENTER); statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
statusLabel.setForeground(Color.blue); statusLabel.setForeground(new GColor("color.fg.dialog.status.normal"));
statusLabel.addComponentListener(new ComponentAdapter() { statusLabel.addComponentListener(new ComponentAdapter() {
@Override @Override
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {

View file

@ -15,13 +15,13 @@
*/ */
package ghidra.app.plugin.core.compositeeditor; package ghidra.app.plugin.core.compositeeditor;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import javax.swing.JLabel; import javax.swing.JLabel;
import docking.widgets.table.GTableCellRenderer; import docking.widgets.table.GTableCellRenderer;
import docking.widgets.table.GTableCellRenderingData; import docking.widgets.table.GTableCellRenderingData;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.HTMLUtilities; import ghidra.util.HTMLUtilities;
@ -43,7 +43,7 @@ public class DataTypeCellRenderer extends GTableCellRenderer {
String dtString = ""; String dtString = "";
String tooltipText = null; String tooltipText = null;
boolean useRed = false; boolean showError = false;
DataType dt = null; DataType dt = null;
if (value instanceof DataTypeInstance) { if (value instanceof DataTypeInstance) {
@ -51,7 +51,7 @@ public class DataTypeCellRenderer extends GTableCellRenderer {
tooltipText = getDataTypeToolTip(dt); tooltipText = getDataTypeToolTip(dt);
dtString = dt.getDisplayName(); dtString = dt.getDisplayName();
if (dt.isNotYetDefined()) { if (dt.isNotYetDefined()) {
useRed = true; showError = true;
} }
} }
@ -61,8 +61,8 @@ public class DataTypeCellRenderer extends GTableCellRenderer {
c.setToolTipText(tooltipText); c.setToolTipText(tooltipText);
if (useRed) { if (showError) {
c.setForeground(Color.RED); c.setForeground(Colors.ERROR);
} }
return c; return c;

View file

@ -15,10 +15,10 @@
*/ */
package ghidra.app.plugin.core.data; package ghidra.app.plugin.core.data;
import java.awt.*; import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
@ -31,6 +31,7 @@ import javax.swing.text.Document;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.widgets.button.GRadioButton; import docking.widgets.button.GRadioButton;
import docking.widgets.table.*; import docking.widgets.table.*;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
@ -272,18 +273,17 @@ public class CreateStructureDialog extends DialogComponentProvider {
return matchingStylePanel; return matchingStylePanel;
} }
// toggles whether the structure being created is new, based upon the // toggles whether the structure being created is new, based upon the name field, or a current
// name field, or a current structure, based upon a structure in the // structure, based upon a structure in the table. This method updates the GUI to reflect the
// table. This method updates the GUI to reflect the current creation // current creation state.
// state.
private void setCreateStructureByName(boolean createStructureByName) { private void setCreateStructureByName(boolean createStructureByName) {
if (createStructureByName) { if (createStructureByName) {
nameBorder.setTitleColor(Color.BLACK); nameBorder.setTitleColor(Colors.FOREGROUND);
structureBorder.setTitleColor(Color.GRAY); structureBorder.setTitleColor(Colors.FOREGROUND_DISABLED);
} }
else { else {
nameBorder.setTitleColor(Color.GRAY); nameBorder.setTitleColor(Colors.FOREGROUND_DISABLED);
structureBorder.setTitleColor(Color.BLACK); structureBorder.setTitleColor(Colors.FOREGROUND);
} }
nameTextField.setEnabled(createStructureByName); nameTextField.setEnabled(createStructureByName);
@ -299,7 +299,7 @@ public class CreateStructureDialog extends DialogComponentProvider {
// this class in terms of data contained // this class in terms of data contained
private void searchForMatchingStructures(final Program program, final Structure structure) { private void searchForMatchingStructures(final Program program, final Structure structure) {
SwingUtilities.invokeLater(() -> { Swing.runLater(() -> {
// Get the structures from the DataTypeManagers of the // Get the structures from the DataTypeManagers of the
// DataTypeManagerService // DataTypeManagerService
DataTypeManagerService service = pluginTool.getService(DataTypeManagerService.class); DataTypeManagerService service = pluginTool.getService(DataTypeManagerService.class);

View file

@ -18,10 +18,9 @@ package ghidra.app.plugin.core.datamgr;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import docking.widgets.label.GDHtmlLabel; import docking.widgets.label.GDHtmlLabel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
import ghidra.app.util.html.HTMLDataTypeRepresentation; import ghidra.app.util.html.HTMLDataTypeRepresentation;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
@ -41,13 +40,6 @@ class DataTypeComparePanel extends JPanel {
private String clientName; private String clientName;
private String sourceName; private String sourceName;
/**
* Creates a panel for viewing two data types side by side.
* @param dataType1 the first data type to display.
* @param dataType2 the second data type to display.
* @param one_to_two true if this panel should display an arrow from data type 1 to data type 2.
* false if the should be from 2 to 1.
*/
DataTypeComparePanel(String clientName, String sourceName) { DataTypeComparePanel(String clientName, String sourceName) {
super(new GridLayout(0, 2)); super(new GridLayout(0, 2));
this.clientName = clientName; this.clientName = clientName;
@ -72,12 +64,12 @@ class DataTypeComparePanel extends JPanel {
add(rightPanel); add(rightPanel);
dtLabel1 = new GDHtmlLabel(); dtLabel1 = new GDHtmlLabel();
dtLabel1.setOpaque(true); dtLabel1.setOpaque(true);
dtLabel1.setBackground(Color.WHITE); dtLabel1.setBackground(Colors.BACKGROUND);
dtLabel1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0)); dtLabel1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
dtLabel1.setVerticalAlignment(SwingConstants.TOP); dtLabel1.setVerticalAlignment(SwingConstants.TOP);
dtLabel2 = new GDHtmlLabel(); dtLabel2 = new GDHtmlLabel();
dtLabel2.setOpaque(true); dtLabel2.setOpaque(true);
dtLabel2.setBackground(Color.WHITE); dtLabel2.setBackground(Colors.BACKGROUND);
dtLabel2.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0)); dtLabel2.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 0));
dtLabel2.setVerticalAlignment(SwingConstants.TOP); dtLabel2.setVerticalAlignment(SwingConstants.TOP);
@ -96,19 +88,13 @@ class DataTypeComparePanel extends JPanel {
private void syncScrollers(JScrollPane leftScrollPane, JScrollPane rightScrollPane) { private void syncScrollers(JScrollPane leftScrollPane, JScrollPane rightScrollPane) {
final JViewport viewport1 = leftScrollPane.getViewport(); final JViewport viewport1 = leftScrollPane.getViewport();
final JViewport viewport2 = rightScrollPane.getViewport(); final JViewport viewport2 = rightScrollPane.getViewport();
viewport1.addChangeListener(new ChangeListener() { viewport1.addChangeListener(e -> {
@Override int y = viewport1.getViewPosition().y;
public void stateChanged(ChangeEvent e) { viewport2.setViewPosition(new Point(0, y));
int y = viewport1.getViewPosition().y;
viewport2.setViewPosition(new Point(0, y));
}
}); });
viewport2.addChangeListener(new ChangeListener() { viewport2.addChangeListener(e -> {
@Override int y = viewport2.getViewPosition().y;
public void stateChanged(ChangeEvent e) { viewport1.setViewPosition(new Point(0, y));
int y = viewport2.getViewPosition().y;
viewport1.setViewPosition(new Point(0, y));
}
}); });
} }

View file

@ -24,6 +24,7 @@ import docking.ActionContext;
import docking.action.*; import docking.action.*;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin; import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext; import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.FileArchive; import ghidra.app.plugin.core.datamgr.archive.FileArchive;
@ -95,7 +96,8 @@ public class DeleteArchiveAction extends DockingAction {
"Confirm Delete Operation", "Confirm Delete Operation",
"<html><b>Are you sure you want to delete archive: " + "<html><b>Are you sure you want to delete archive: " +
HTMLUtilities.escapeHTML(node.getName()) + "?<br><br>" + HTMLUtilities.escapeHTML(node.getName()) + "?<br><br>" +
"<font color=\"red\">(WARNING: This action will permanently " + "<font color=\"" + Colors.ERROR.toHexString() +
"\">(WARNING: This action will permanently " +
"delete the file from disk.)</font></b>", "delete the file from disk.)</font></b>",
"Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) { "Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return; return;

View file

@ -23,6 +23,7 @@ import docking.action.MenuData;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin; import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext; import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.archive.*; import ghidra.app.plugin.core.datamgr.archive.*;
@ -79,7 +80,8 @@ public class RemoveInvalidArchiveFromProgramAction extends DockingAction {
"<html><b>Are you sure you want to delete archive: " + "<html><b>Are you sure you want to delete archive: " +
HTMLUtilities.escapeHTML(invalidArchiveNode.getName()) + HTMLUtilities.escapeHTML(invalidArchiveNode.getName()) +
" from the program?<br><br>" + " from the program?<br><br>" +
"<font color=\"red\">(WARNING: This action will disassociate " + "<font color=\"" + Colors.ERROR.toHexString() +
"\">(WARNING: This action will disassociate " +
"all datatypes in the program from this archive.)</font></b>", "all datatypes in the program from this archive.)</font></b>",
"Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) { "Yes", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return; return;

View file

@ -17,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.actions;
import java.awt.Color; import java.awt.Color;
import generic.theme.GColor;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.service.graph.*; import ghidra.service.graph.*;
@ -33,6 +34,13 @@ import ghidra.util.task.TaskMonitor;
*/ */
public class TypeGraphTask extends Task { public class TypeGraphTask extends Task {
private static final Color BG_COLOR_DEFAULT =
new GColor("color.bg.plugin.datamgr.edge.default");
private static final Color BG_COLOR_COMPOSITE =
new GColor("color.bg.plugin.datamgr.edge.composite");
private static final Color BG_COLOR_REFERERNCE =
new GColor("color.bg.plugin.datamgr.edge.reference");
private DataType type; private DataType type;
private String graphTitle; private String graphTitle;
private GraphDisplayProvider graphService; private GraphDisplayProvider graphService;
@ -64,9 +72,9 @@ public class TypeGraphTask extends Task {
.build(); .build();
GraphDisplayOptions options = new GraphDisplayOptionsBuilder(graphType) GraphDisplayOptions options = new GraphDisplayOptionsBuilder(graphType)
.defaultVertexColor(Color.BLUE) .defaultVertexColor(BG_COLOR_DEFAULT)
.edge(COMPOSITE, Color.MAGENTA) .edge(COMPOSITE, BG_COLOR_COMPOSITE)
.edge(REFERENCE, Color.BLUE) .edge(REFERENCE, BG_COLOR_REFERERNCE)
.build(); .build();
AttributedGraph graph = new AttributedGraph(graphTitle, graphType); AttributedGraph graph = new AttributedGraph(graphTitle, graphType);

View file

@ -31,6 +31,7 @@ import docking.ActionContext;
import docking.ComponentProvider; import docking.ComponentProvider;
import docking.action.*; import docking.action.*;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.compositeeditor.EditorListener; import ghidra.app.plugin.core.compositeeditor.EditorListener;
import ghidra.app.plugin.core.compositeeditor.EditorProvider; import ghidra.app.plugin.core.compositeeditor.EditorProvider;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin; import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
@ -400,8 +401,9 @@ public class EnumEditorProvider extends ComponentProviderAdapter
private int showOptionDialog(Enum editedEnoom, Set<String> oldNameFields) { private int showOptionDialog(Enum editedEnoom, Set<String> oldNameFields) {
StringBuilder msg = new StringBuilder( StringBuilder msg = new StringBuilder(
"<html>If you save this Enum with the <font color=#ff0000>new value(s)</font>" + "<html>If you save this Enum with the <font color=\"" + Colors.ERROR.toHexString() +
" listed below,<br> it will invalidate equates created with the old value(s).<br>"); "\">new value(s)</font> listed below,<br>" +
" it will invalidate equates created with the old value(s).<br>");
msg.append("<ul>"); msg.append("<ul>");
for (String field : oldNameFields) { for (String field : oldNameFields) {
String newVal; String newVal;
@ -412,13 +414,16 @@ public class EnumEditorProvider extends ComponentProviderAdapter
// Happens if a field is deleted or there is a name AND value change. // Happens if a field is deleted or there is a name AND value change.
newVal = "Missing"; newVal = "Missing";
} }
msg.append(String.format("<li>%s: 0x%s \u2192 <font color=#ff0000>%s</font></li>", msg.append(String.format(
"<li>%s: 0x%s \u2192 <font color=\"" + Colors.ERROR.toHexString() +
"\">%s</font></li>",
HTMLUtilities.escapeHTML(field), Long.toHexString(originalEnum.getValue(field)), HTMLUtilities.escapeHTML(field), Long.toHexString(originalEnum.getValue(field)),
newVal)); newVal));
} }
msg.append("</ul>"); msg.append("</ul>");
msg.append( msg.append(
"Invalidated equates can be automatically removed now or<br>managed later from the <i><b>Equates Table</i></b> window."); "Invalidated equates can be automatically removed now or<br>managed later from the" +
" <i><b>Equates Table</i></b> window.");
msg.append("</html>"); msg.append("</html>");
int choice = OptionDialog.showOptionDialog(editorPanel, "Equate Conflicts", msg.toString(), int choice = OptionDialog.showOptionDialog(editorPanel, "Equate Conflicts", msg.toString(),
"Save and remove", "Save", OptionDialog.ERROR_MESSAGE); "Save and remove", "Save", OptionDialog.ERROR_MESSAGE);

View file

@ -22,6 +22,7 @@ import java.util.List;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import generic.theme.GColor;
import ghidra.app.services.DataTypeQueryService; import ghidra.app.services.DataTypeQueryService;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.data.Enum; import ghidra.program.model.data.Enum;
@ -37,6 +38,9 @@ public class DataTypeUtils {
private static final char END_CHAR = '\uffff'; private static final char END_CHAR = '\uffff';
private static final char BEGIN_CHAR = '\u0000'; private static final char BEGIN_CHAR = '\u0000';
private static final Color COLOR_ICON_HIGHLIGHT =
new GColor("color.bg.plugin.datamgr.icon.highlight");
private static Map<Icon, MultiIcon> highlightIconMap = new HashMap<>(); private static Map<Icon, MultiIcon> highlightIconMap = new HashMap<>();
private static String OPEN_FOLDER = "images/openFolder.png"; private static String OPEN_FOLDER = "images/openFolder.png";
@ -281,7 +285,7 @@ public class DataTypeUtils {
MultiIcon highlightIcon = highlightIconMap.get(baseIcon); MultiIcon highlightIcon = highlightIconMap.get(baseIcon);
if (highlightIcon == null) { if (highlightIcon == null) {
highlightIcon = new MultiIcon(new HighlightIcon(new Color(204, 204, 255))); highlightIcon = new MultiIcon(new HighlightIcon(COLOR_ICON_HIGHLIGHT));
highlightIcon.addIcon(baseIcon); highlightIcon.addIcon(baseIcon);
highlightIconMap.put(baseIcon, highlightIcon); highlightIconMap.put(baseIcon, highlightIcon);
} }
@ -461,7 +465,6 @@ public class DataTypeUtils {
} }
Msg.showInfo(DataTypeUtils.class, parent, title, msg); Msg.showInfo(DataTypeUtils.class, parent, title, msg);
} }
} }
//================================================================================================== //==================================================================================================
@ -533,45 +536,3 @@ class HighlightIcon implements Icon {
g.drawRect(x, y, WIDTH + 1, HEIGHT - 1); g.drawRect(x, y, WIDTH + 1, HEIGHT - 1);
} }
} }
class VersionIcon implements Icon {
private static Color VERSION_ICON_COLOR_DARK = new Color(0x82, 0x82, 0xff);
private static Color VERSION_ICON_COLOR_LIGHT = new Color(0x9f, 0x9f, 0xff);
private static final int WIDTH = 18;
private static final int HEIGHT = 17;
int width;
int height;
VersionIcon() {
this(WIDTH, HEIGHT);
}
VersionIcon(int width, int height) {
this.width = width;
this.height = height;
}
@Override
public int getIconHeight() {
return height;
}
@Override
public int getIconWidth() {
return width;
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(VERSION_ICON_COLOR_LIGHT);
g.fillRect(x + 1, y + 1, width - 2, height - 2);
g.setColor(VERSION_ICON_COLOR_DARK);
g.drawLine(x + 1, y, x + width - 2, y);
g.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 2);
g.drawLine(x + 1, y + height - 1, x + width - 2, y + height - 1);
g.drawLine(x, y + 1, x, y + height - 2);
}
}

View file

@ -34,6 +34,7 @@ import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.filter.FilterListener; import docking.widgets.filter.FilterListener;
import docking.widgets.filter.FilterTextField; import docking.widgets.filter.FilterTextField;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
import ghidra.util.task.SwingUpdateManager; import ghidra.util.task.SwingUpdateManager;
@ -133,8 +134,8 @@ class FilterAction extends ToggleDockingAction {
} }
synchronized void selectTypes(ArrayList<String> list) { synchronized void selectTypes(ArrayList<String> list) {
for (int i = 0; i < list.size(); i++) { for (String element : list) {
typeEnabledMap.put(list.get(i), Boolean.TRUE); typeEnabledMap.put(element, Boolean.TRUE);
} }
if (dialog != null) { if (dialog != null) {
dialog.selectTypes(list); dialog.selectTypes(list);
@ -222,15 +223,13 @@ class FilterAction extends ToggleDockingAction {
} }
void selectTypes(ArrayList<String> list) { void selectTypes(ArrayList<String> list) {
for (int i = 0; i < list.size(); i++) { for (String type : list) {
String type = list.get(i);
selectCheckBox(type); selectCheckBox(type);
} }
} }
private void selectCheckBox(String typeName) { private void selectCheckBox(String typeName) {
for (int i = 0; i < checkboxes.size(); i++) { for (JCheckBox cb : checkboxes) {
JCheckBox cb = checkboxes.get(i);
if (cb.getText().equals(typeName)) { if (cb.getText().equals(typeName)) {
cb.setSelected(true); cb.setSelected(true);
return; return;
@ -302,7 +301,7 @@ class FilterAction extends ToggleDockingAction {
typeButtonPanel.add(selectNoneButton); typeButtonPanel.add(selectNoneButton);
checkboxPanel = new JPanel(); checkboxPanel = new JPanel();
checkboxPanel.setBackground(Color.WHITE); checkboxPanel.setBackground(Colors.BACKGROUND);
checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS)); checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS));
buildCheckBoxList(); buildCheckBoxList();

View file

@ -24,6 +24,7 @@ import javax.swing.event.ChangeListener;
import docking.WindowPosition; import docking.WindowPosition;
import docking.widgets.list.GListCellRenderer; import docking.widgets.list.GListCellRenderer;
import generic.theme.Gui;
import ghidra.GhidraOptions; import ghidra.GhidraOptions;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
@ -449,8 +450,8 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
Color background = selectedAddressColor; Color background = selectedAddressColor;
if (isSelected) { if (isSelected) {
foreground = foreground.brighter(); foreground = Gui.brighter(foreground);
background = background.darker(); background = Gui.darker(background);
} }
setForeground(foreground); setForeground(foreground);
@ -509,22 +510,6 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
opt.removeOptionsChangeListener(optionsChangeListener); opt.removeOptionsChangeListener(optionsChangeListener);
} }
/**
* Adds the given listener to be notified when the user selects list
* items in the view.
*
* @param listener The listener to add.
*/
// void addListSelectionListener( ListSelectionListener listener )
// {
// contentList.addListSelectionListener( listener );
// }
/**
* Sets the contents to the provided value.
*
* @param displayContents The value that the view should display.
*/
void setContents(DisassembledAddressInfo[] addressInfos) { void setContents(DisassembledAddressInfo[] addressInfos) {
contentList.setListData(addressInfos); contentList.setListData(addressInfos);
} }
@ -606,9 +591,8 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
} }
/** /**
* An object that provides information about the address that it wraps. * An object that provides information about the address that it wraps. The info knows how to
* The info knows how to locate a {@link CodeInfo} object for the address * locate an info object for the address and can generate a string preview of the address.
* and can generate a string preview of the address.
*/ */
private class DisassembledAddressInfo { private class DisassembledAddressInfo {
/** /**
@ -683,8 +667,8 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
/** /**
* Get the code unit from the program location. * Get the code unit from the program location.
* *
* @param The address from which we want the CodeUnit. * @param address the address from which we want the CodeUnit.
* @return CodeUnit null if there is no location. * @return null if there is no location.
*/ */
private CodeUnit getCodeUnitForAddress(Address address) { private CodeUnit getCodeUnitForAddress(Address address) {
CodeUnit codeUnit = null; CodeUnit codeUnit = null;
@ -693,8 +677,8 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
Listing listing = currentProgram.getListing(); Listing listing = currentProgram.getListing();
codeUnit = listing.getCodeUnitAt(address); codeUnit = listing.getCodeUnitAt(address);
// if the CodeUnit is Data and is not defined, then we // if the CodeUnit is Data and is not defined, then we need to try to virtually
// need to try to virutally disassemble it // disassemble it
if (codeUnit instanceof Data) { if (codeUnit instanceof Data) {
if (!((Data) codeUnit).isDefined()) { if (!((Data) codeUnit).isDefined()) {
CodeUnit virtualCodeUnit = virtuallyDisassembleAddress(address); CodeUnit virtualCodeUnit = virtuallyDisassembleAddress(address);
@ -727,18 +711,15 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
codeUnit = disassembler.disassemble(address); codeUnit = disassembler.disassemble(address);
} }
catch (UsrException ue) { catch (UsrException ue) {
// these exceptions happen if there is insufficient data // these exceptions happen if there is insufficient data from the program:
// from the program: InsufficientBytesException, // InsufficientBytesException, UnknownInstructionException,
// UnknownInstructionException, UnknownContextException // UnknownContextException
} }
} }
return codeUnit; return codeUnit;
} }
/**
* Gets the preview String for the provided code unit.
*/
public String getAddressPreview(CodeUnitFormat format) { public String getAddressPreview(CodeUnitFormat format) {
return getAddress().toString() + " " + format.getRepresentationString(addressCodeUnit); return getAddress().toString() + " " + format.getRepresentationString(addressCodeUnit);
} }

View file

@ -21,8 +21,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JTable;
import docking.widgets.table.*; import docking.widgets.table.*;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Tables;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
import ghidra.docking.settings.FormatSettingsDefinition; import ghidra.docking.settings.FormatSettingsDefinition;
import ghidra.docking.settings.Settings; import ghidra.docking.settings.Settings;
@ -40,6 +43,8 @@ import util.CollectionUtils;
class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> { class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
private static final Color FG_ENUM_BASED = new GColor("color.fg.plugin.equate.enum");
private EquateTablePlugin plugin; private EquateTablePlugin plugin;
private List<Equate> equateList = new ArrayList<>(); private List<Equate> equateList = new ArrayList<>();
@ -149,10 +154,14 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
return label; return label;
} }
JTable table = data.getTable();
if (!eq.isValidUUID()) { // Error equate if (!eq.isValidUUID()) { // Error equate
label.setForeground((isSelected) ? Color.WHITE : Color.RED); label.setForeground(
} else if (!eq.isEnumBased()) { // User label (isSelected) ? table.getSelectionForeground() : Tables.FG_ERROR_UNSELECTED);
label.setForeground((isSelected) ? Color.WHITE : Color.BLUE.brighter()); }
else if (!eq.isEnumBased()) { // User label
label.setForeground(
(isSelected) ? table.getSelectionForeground() : FG_ENUM_BASED);
} }
String tooltip = getEquateToolTip(eq); String tooltip = getEquateToolTip(eq);
@ -192,7 +201,7 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
@Override @Override
public String getValue(Equate rowObject, Settings settings, Object data, public String getValue(Equate rowObject, Settings settings, Object data,
ServiceProvider serviceProvider) throws IllegalArgumentException { ServiceProvider sp) throws IllegalArgumentException {
return rowObject.getDisplayName(); return rowObject.getDisplayName();
} }
@ -243,7 +252,7 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
@Override @Override
public Long getValue(Equate rowObject, Settings settings, Object data, public Long getValue(Equate rowObject, Settings settings, Object data,
ServiceProvider serviceProvider) throws IllegalArgumentException { ServiceProvider sp) throws IllegalArgumentException {
FormatSettingsDefinition formatDef = FormatSettingsDefinition.DEF; FormatSettingsDefinition formatDef = FormatSettingsDefinition.DEF;
@ -263,7 +272,7 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
} }
private class EquateReferenceCountColumn private class EquateReferenceCountColumn
extends AbstractDynamicTableColumn<Equate, Integer, Object> { extends AbstractDynamicTableColumn<Equate, Integer, Object> {
public static final String NAME = "# Refs"; public static final String NAME = "# Refs";
@ -274,14 +283,14 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
@Override @Override
public Integer getValue(Equate rowObject, Settings settings, Object data, public Integer getValue(Equate rowObject, Settings settings, Object data,
ServiceProvider serviceProvider) throws IllegalArgumentException { ServiceProvider sp) throws IllegalArgumentException {
return rowObject.getReferenceCount(); return rowObject.getReferenceCount();
} }
} }
private class IsEnumBasedEquateColumn private class IsEnumBasedEquateColumn
extends AbstractDynamicTableColumn<Equate, Boolean, Object> { extends AbstractDynamicTableColumn<Equate, Boolean, Object> {
public static final String NAME = "Is Enum-Based"; public static final String NAME = "Is Enum-Based";
@ -292,7 +301,7 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
@Override @Override
public Boolean getValue(Equate rowObject, Settings settings, Object data, public Boolean getValue(Equate rowObject, Settings settings, Object data,
ServiceProvider serviceProvider) throws IllegalArgumentException { ServiceProvider sp) throws IllegalArgumentException {
return rowObject.isEnumBased(); return rowObject.isEnumBased();
} }
} }

View file

@ -15,11 +15,12 @@
*/ */
package ghidra.app.plugin.core.function; package ghidra.app.plugin.core.function;
import java.awt.Color;
import java.math.BigInteger; import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*; import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation; import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.app.cmd.function.CallDepthChangeInfo; import ghidra.app.cmd.function.CallDepthChangeInfo;
import ghidra.app.util.HighlightProvider; import ghidra.app.util.HighlightProvider;
import ghidra.app.util.viewer.field.*; import ghidra.app.util.viewer.field.*;
@ -39,12 +40,8 @@ public class StackDepthFieldFactory extends FieldFactory {
private CallDepthChangeInfo depth = null; private CallDepthChangeInfo depth = null;
private long lastModNumber = -1; private long lastModNumber = -1;
/**
*
*/
public StackDepthFieldFactory() { public StackDepthFieldFactory() {
super(FIELD_NAME); super(FIELD_NAME);
// TODO Auto-generated constructor stub
} }
private StackDepthFieldFactory(FieldFormatModel model, HighlightProvider hsProvider, private StackDepthFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
@ -57,14 +54,11 @@ public class StackDepthFieldFactory extends FieldFactory {
@Override @Override
public FieldFactory newInstance(FieldFormatModel newModel, HighlightProvider highlightProvider, public FieldFactory newInstance(FieldFormatModel newModel, HighlightProvider highlightProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) { ToolOptions toolDisplayOptions, ToolOptions fieldOptions) {
return new StackDepthFieldFactory(newModel, highlightProvider, displayOptions, return new StackDepthFieldFactory(newModel, highlightProvider, toolDisplayOptions,
fieldOptions); fieldOptions);
} }
/**
* @see ghidra.app.util.viewer.field.FieldFactory#getField(ProxyObj, int)
*/
@Override @Override
public ListingField getField(ProxyObj<?> proxy, int varWidth) { public ListingField getField(ProxyObj<?> proxy, int varWidth) {
Object obj = proxy.getObject(); Object obj = proxy.getObject();
@ -94,14 +88,14 @@ public class StackDepthFieldFactory extends FieldFactory {
// This can be used to display the value of any register symbolically flowing over the program. // 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")); // depthString = depth.getRegValueRepresentation(cu.getMinAddress(), cu.getProgram().getRegister("ESP"));
AttributedString as = new AttributedString(depthString, Color.BLUE, getMetrics()); AttributedString as = new AttributedString(depthString, Palette.BLUE, getMetrics());
Integer overrideDepth = Integer overrideDepth =
CallDepthChangeInfo.getStackDepthChange(cu.getProgram(), cu.getMinAddress()); CallDepthChangeInfo.getStackDepthChange(cu.getProgram(), cu.getMinAddress());
if (overrideDepth != null) { if (overrideDepth != null) {
String grows = (func.getStackFrame().growsNegative() ? " - " : " + "); String grows = (func.getStackFrame().growsNegative() ? " - " : " + ");
depthString = depthString + grows + Integer.toString(overrideDepth, 16); depthString = depthString + grows + Integer.toString(overrideDepth, 16);
as = new AttributedString(depthString, Color.RED, getMetrics()); as = new AttributedString(depthString, Colors.ERROR, getMetrics());
} }
FieldElement text = new TextFieldElement(as, 0, 0); FieldElement text = new TextFieldElement(as, 0, 0);
@ -109,13 +103,9 @@ public class StackDepthFieldFactory extends FieldFactory {
width, hlProvider); width, hlProvider);
} }
/**
* @param depthChange
* @return
*/
private String getDepthString(int depthChange, boolean isInDelaySlot) { private String getDepthString(int depthChange, boolean isInDelaySlot) {
if (isInDelaySlot) { if (isInDelaySlot) {
return ""; // if in delayslot, stack changes will be on main instruction return ""; // if in delay slot, stack changes will be on main instruction
} }
String stringDepth = "- ? -"; String stringDepth = "- ? -";

View file

@ -35,6 +35,9 @@ import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GComboBox; import docking.widgets.combobox.GComboBox;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import docking.widgets.table.*; import docking.widgets.table.*;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.*;
import generic.util.WindowUtilities; import generic.util.WindowUtilities;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.ToolTipUtils; import ghidra.app.util.ToolTipUtils;
@ -50,6 +53,9 @@ import ghidra.util.layout.VerticalLayout;
import resources.ResourceManager; import resources.ResourceManager;
public class FunctionEditorDialog extends DialogComponentProvider implements ModelChangeListener { public class FunctionEditorDialog extends DialogComponentProvider implements ModelChangeListener {
private static final Color FG_COLOR_THUNK =
new GColor("color.fg.plugin.function.editor.dialog.thunk");
private static Icon ADD_ICON = ResourceManager.loadImage("images/Plus.png"); private static Icon ADD_ICON = ResourceManager.loadImage("images/Plus.png");
private static Icon REMOVE_ICON = ResourceManager.loadImage("images/edit-delete.png"); private static Icon REMOVE_ICON = ResourceManager.loadImage("images/edit-delete.png");
private static Icon UP_ICON = ResourceManager.loadImage("images/up.png"); private static Icon UP_ICON = ResourceManager.loadImage("images/up.png");
@ -209,10 +215,10 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
thunkedText.setEditable(false); thunkedText.setEditable(false);
DockingUtils.setTransparent(thunkedText); DockingUtils.setTransparent(thunkedText);
CompoundBorder border = CompoundBorder border =
BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY), BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Java.BORDER),
BorderFactory.createEmptyBorder(0, 5, 0, 5)); BorderFactory.createEmptyBorder(0, 5, 0, 5));
thunkedText.setBorder(border); thunkedText.setBorder(border);
thunkedText.setForeground(Color.BLUE); thunkedText.setForeground(FG_COLOR_THUNK);
thunkedPanel.add(thunkedText); thunkedPanel.add(thunkedText);
return thunkedPanel; return thunkedPanel;
} }
@ -224,9 +230,9 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
scroll = new JScrollPane(verticalScrollPanel); scroll = new JScrollPane(verticalScrollPanel);
scroll.setBorder(null); scroll.setBorder(null);
scroll.setOpaque(true); scroll.setOpaque(true);
scroll.setBackground(Color.WHITE); scroll.setBackground(Colors.BACKGROUND);
scroll.getViewport().setBackground(new Color(0, 0, 0, 0)); // transparent scroll.getViewport().setBackground(Palette.NO_COLOR); // transparent
scroll.getViewport().setBackground(Color.WHITE); scroll.getViewport().setBackground(Colors.BACKGROUND);
previewPanel.add(scroll, BorderLayout.CENTER); previewPanel.add(scroll, BorderLayout.CENTER);
previewPanel.setBorder(BorderFactory.createLoweredBevelBorder()); previewPanel.setBorder(BorderFactory.createLoweredBevelBorder());
scroll.getViewport().addMouseListener(new MouseAdapter() { scroll.getViewport().addMouseListener(new MouseAdapter() {
@ -657,12 +663,13 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
DataType dataType = (DataType) value; DataType dataType = (DataType) value;
Color color = isSelected ? table.getSelectionForeground() : table.getForeground(); Color color = isSelected ? table.getSelectionForeground() : table.getForeground();
if (!tableModel.isCellEditable(row, column)) { if (!tableModel.isCellEditable(row, column)) {
color = isSelected ? Color.yellow : Color.gray; color =
isSelected ? Tables.FG_UNEDITABLE_SELECTED : Tables.FG_UNEDITABLE_UNSELECTED;
} }
if (dataType != null) { if (dataType != null) {
setText(dataType.getName()); setText(dataType.getName());
if (dataType.isNotYetDefined()) { if (dataType.isNotYetDefined()) {
color = Color.red; color = isSelected ? Tables.FG_ERROR_SELECTED : Tables.FG_ERROR_UNSELECTED;
} }
String toolTipText = ToolTipUtils.getToolTipText(dataType); String toolTipText = ToolTipUtils.getToolTipText(dataType);
String headerText = "<HTML><b>" + String headerText = "<HTML><b>" +
@ -751,17 +758,20 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
boolean isInvalidStorage = boolean isInvalidStorage =
!storage.isValid() || rowData.getFormalDataType().getLength() != storage.size(); !storage.isValid() || rowData.getFormalDataType().getLength() != storage.size();
if (isInvalidStorage) { if (isInvalidStorage) {
setForeground(Color.RED); setForeground(
isSelected ? Tables.FG_ERROR_SELECTED : Tables.FG_ERROR_UNSELECTED);
setToolTipText("Invalid Parameter Storage"); setToolTipText("Invalid Parameter Storage");
} }
else { else {
setForeground(isSelected ? Color.WHITE : Color.BLACK); setForeground(
isSelected ? table.getSelectionForeground() : Colors.FOREGROUND);
setToolTipText(""); setToolTipText("");
} }
setText(storage.toString()); setText(storage.toString());
} }
else { else {
setForeground(isSelected ? Color.WHITE : Color.BLACK); setForeground(
isSelected ? table.getSelectionForeground() : Colors.FOREGROUND);
setText(""); setText("");
setToolTipText(null); setToolTipText(null);
} }
@ -770,6 +780,7 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
} }
private class VariableStringCellRenderer extends GTableCellRenderer { private class VariableStringCellRenderer extends GTableCellRenderer {
@Override @Override
public Component getTableCellRendererComponent(GTableCellRenderingData data) { public Component getTableCellRendererComponent(GTableCellRenderingData data) {
@ -785,7 +796,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
ParameterTableModel tableModel = (ParameterTableModel) table.getModel(); ParameterTableModel tableModel = (ParameterTableModel) table.getModel();
if (!tableModel.isCellEditable(row, column)) { if (!tableModel.isCellEditable(row, column)) {
setForeground(isSelected ? Color.yellow : Color.gray); setForeground(
isSelected ? Tables.FG_UNEDITABLE_SELECTED : Tables.FG_UNEDITABLE_UNSELECTED);
} }
else { else {
if (isSelected) { if (isSelected) {
@ -853,7 +865,7 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
Composite originalComposite = g2d.getComposite(); Composite originalComposite = g2d.getComposite();
g2d.setComposite(alphaComposite); g2d.setComposite(alphaComposite);
g.setColor(Color.white); g.setColor(Colors.BACKGROUND);
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
g2d.setComposite(originalComposite); g2d.setComposite(originalComposite);

View file

@ -15,9 +15,6 @@
*/ */
package ghidra.app.plugin.core.function.editor; package ghidra.app.plugin.core.function.editor;
import static java.awt.Color.blue;
import static java.awt.Color.red;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -28,16 +25,21 @@ import javax.swing.event.*;
import javax.swing.text.*; import javax.swing.text.*;
import docking.actions.KeyBindingUtils; import docking.actions.KeyBindingUtils;
import generic.theme.GColor;
import ghidra.util.Swing; import ghidra.util.Swing;
class FunctionSignatureTextField extends JTextPane { class FunctionSignatureTextField extends JTextPane {
private static final String ENTER_ACTION_NAME = "ENTER"; private static final String ENTER_ACTION_NAME = "ENTER";
private static final String ESCAPE_ACTION_NAME = "ESCAPE"; private static final String ESCAPE_ACTION_NAME = "ESCAPE";
private static final String TAB_ACTION_NAME = "TAB"; private static final String TAB_ACTION_NAME = "TAB";
public static Color DEFAULT_COLOR = Color.black; public static Color DEFAULT_COLOR =
public static Color PARAMETER_NAME_COLOR = new Color(155, 50, 155); new GColor("color.fg.plugin.function.editor.dialog.textfield.default");
public static Color FUNCTION_NAME_COLOR = blue; public static Color PARAMETER_NAME_COLOR =
public static Color ERROR_NAME_COLOR = red; new GColor("color.fg.plugin.function.editor.dialog.textfield.parameter");
public static Color FUNCTION_NAME_COLOR =
new GColor("color.fg.plugin.function.editor.dialog.textfield.function.name");
public static Color ERROR_NAME_COLOR =
new GColor("color.fg.plugin.function.editor.dialog.textfield.error");
private StyledDocument doc; private StyledDocument doc;
private SimpleAttributeSet paramNameAttributes; private SimpleAttributeSet paramNameAttributes;

View file

@ -15,7 +15,6 @@
*/ */
package ghidra.app.plugin.core.function.editor; package ghidra.app.plugin.core.function.editor;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.EventObject; import java.util.EventObject;
@ -24,6 +23,7 @@ import javax.swing.*;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import generic.theme.GThemeDefaults.Colors.Tables;
import ghidra.program.model.listing.VariableStorage; import ghidra.program.model.listing.VariableStorage;
class StorageTableCellEditor extends AbstractCellEditor implements TableCellEditor { class StorageTableCellEditor extends AbstractCellEditor implements TableCellEditor {
@ -53,30 +53,27 @@ class StorageTableCellEditor extends AbstractCellEditor implements TableCellEdit
boolean isSelected, int row, int column) { boolean isSelected, int row, int column) {
String stringValue = value == null ? "" : value.toString(); String stringValue = value == null ? "" : value.toString();
JTextField field = new JTextField(stringValue); JTextField field = new JTextField(stringValue);
field.setBackground(Color.yellow); field.setBackground(
isSelected ? Tables.FG_UNEDITABLE_SELECTED : Tables.FG_UNEDITABLE_UNSELECTED);
field.setEditable(false); field.setEditable(false);
ParameterTableModel tableModel = (ParameterTableModel) table.getModel(); ParameterTableModel tableModel = (ParameterTableModel) table.getModel();
FunctionVariableData rowData = tableModel.getRowObject(row); FunctionVariableData rowData = tableModel.getRowObject(row);
final StorageAddressEditorDialog dialog = new StorageAddressEditorDialog(model.getProgram(), final StorageAddressEditorDialog dialog = new StorageAddressEditorDialog(model.getProgram(),
model.getDataTypeManagerService(), (VariableStorage) value, rowData); model.getDataTypeManagerService(), (VariableStorage) value, rowData);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(() -> {
DockingWindowManager.showDialog(table, dialog);
@Override if (!dialog.wasCancelled()) {
public void run() { storage = dialog.getStorage();
DockingWindowManager.showDialog(table, dialog); }
if (!dialog.wasCancelled()) { TableCellEditor cellEditor = table.getCellEditor();
storage = dialog.getStorage(); if (cellEditor == null) {
} return;
TableCellEditor cellEditor = table.getCellEditor(); }
if (cellEditor == null) { if (storage == null) {
return; cellEditor.cancelCellEditing();
} }
if (storage == null) { else {
cellEditor.cancelCellEditing(); cellEditor.stopCellEditing();
}
else {
cellEditor.stopCellEditing();
}
} }
}); });
return field; return field;

View file

@ -15,9 +15,9 @@
*/ */
package ghidra.app.plugin.core.function.tags; package ghidra.app.plugin.core.function.tags;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.*; import java.util.*;
import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.BevelBorder; import javax.swing.border.BevelBorder;
@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import docking.widgets.textfield.HintTextField; import docking.widgets.textfield.HintTextField;
import generic.theme.GThemeDefaults.Colors.Java;
import ghidra.app.cmd.function.CreateFunctionTagCmd; import ghidra.app.cmd.function.CreateFunctionTagCmd;
import ghidra.app.context.ProgramActionContext; import ghidra.app.context.ProgramActionContext;
import ghidra.framework.cmd.Command; import ghidra.framework.cmd.Command;
@ -58,8 +59,6 @@ import resources.ResourceManager;
public class FunctionTagProvider extends ComponentProviderAdapter public class FunctionTagProvider extends ComponentProviderAdapter
implements DomainObjectListener { implements DomainObjectListener {
private Color BORDER_COLOR = Color.GRAY;
private SourceTagsPanel sourcePanel; private SourceTagsPanel sourcePanel;
private TargetTagsPanel targetPanel; private TargetTagsPanel targetPanel;
private FunctionTagButtonPanel buttonPanel; private FunctionTagButtonPanel buttonPanel;
@ -240,9 +239,9 @@ public class FunctionTagProvider extends ComponentProviderAdapter
targetPanel = new TargetTagsPanel(this, tool, "Assigned To Function"); targetPanel = new TargetTagsPanel(this, tool, "Assigned To Function");
allFunctionsPanel = new AllFunctionsPanel(program, this, "Functions with Selected Tag"); allFunctionsPanel = new AllFunctionsPanel(program, this, "Functions with Selected Tag");
buttonPanel = new FunctionTagButtonPanel(sourcePanel, targetPanel); buttonPanel = new FunctionTagButtonPanel(sourcePanel, targetPanel);
sourcePanel.setBorder(BorderFactory.createLineBorder(BORDER_COLOR)); sourcePanel.setBorder(BorderFactory.createLineBorder(Java.BORDER));
targetPanel.setBorder(BorderFactory.createLineBorder(BORDER_COLOR)); targetPanel.setBorder(BorderFactory.createLineBorder(Java.BORDER));
allFunctionsPanel.setBorder(BorderFactory.createLineBorder(BORDER_COLOR)); allFunctionsPanel.setBorder(BorderFactory.createLineBorder(Java.BORDER));
// If we don't set this, then the splitter won't be able to shrink the // If we don't set this, then the splitter won't be able to shrink the
// target panels below the size required by its header, which can be large // target panels below the size required by its header, which can be large

View file

@ -24,6 +24,8 @@ import javax.swing.JToolTip;
import docking.widgets.fieldpanel.field.Field; import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation; import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.gotoquery.GoToHelper; import ghidra.app.plugin.core.gotoquery.GoToHelper;
import ghidra.app.services.CodeFormatService; import ghidra.app.services.CodeFormatService;
import ghidra.app.util.*; import ghidra.app.util.*;
@ -44,7 +46,8 @@ import ghidra.util.bean.opteditor.OptionsVetoException;
public abstract class AbstractReferenceHover extends AbstractConfigurableHover { public abstract class AbstractReferenceHover extends AbstractConfigurableHover {
private static final int WINDOW_OFFSET = 50; private static final int WINDOW_OFFSET = 50;
private static final Color BACKGROUND_COLOR = new Color(255, 255, 230); private static final Color BACKGROUND_COLOR = Colors.TOOLTIP_BACKGROUND;
private static final Color FG_COLOR_NOT_IN_MEMORY = new GColor("color.fg.disabled");
private CodeFormatService codeFormatService; private CodeFormatService codeFormatService;
private ListingPanel panel; private ListingPanel panel;
@ -283,7 +286,7 @@ public abstract class AbstractReferenceHover extends AbstractConfigurableHover {
String message = "Address not in memory"; String message = "Address not in memory";
message = HTMLUtilities.italic(message); message = HTMLUtilities.italic(message);
message = HTMLUtilities.colorString(Color.GRAY, message); message = HTMLUtilities.colorString(FG_COLOR_NOT_IN_MEMORY, message);
buffy.append(message); buffy.append(message);
toolTip.setTipText(buffy.toString()); toolTip.setTipText(buffy.toString());
return toolTip; return toolTip;

View file

@ -15,13 +15,13 @@
*/ */
package ghidra.app.plugin.core.instructionsearch; package ghidra.app.plugin.core.instructionsearch;
import java.awt.Color;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import docking.action.DockingAction; import docking.action.DockingAction;
import docking.action.MenuData; import docking.action.MenuData;
import docking.tool.ToolConstants; import docking.tool.ToolConstants;
import generic.theme.GThemeDefaults.Colors.Dialogs;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.context.NavigatableActionContext; import ghidra.app.context.NavigatableActionContext;
import ghidra.app.context.NavigatableContextAction; import ghidra.app.context.NavigatableContextAction;
@ -135,12 +135,12 @@ public class InstructionSearchPlugin extends ProgramPlugin {
if (selection.getNumAddresses() == 0) { if (selection.getNumAddresses() == 0) {
dialog.displayMessage( dialog.displayMessage(
"Select instructions from the listing (and hit reload) to populate the table.", "Select instructions from the listing (and hit reload) to populate the table.",
Color.BLUE); Dialogs.FG_MESSAGE_NORMAL);
return false; return false;
} }
if (!isSelectionSizeValid(selection)) { if (!isSelectionSizeValid(selection)) {
dialog.displayMessage("Invalid selection. Cannot select more than " + dialog.displayMessage("Invalid selection. Cannot select more than " +
MAX_SELECTION_SIZE + " instructions and/or data items.", Color.RED); MAX_SELECTION_SIZE + " instructions and/or data items.", Dialogs.FG_MESSAGE_ERROR);
return false; return false;
} }
@ -150,7 +150,7 @@ public class InstructionSearchPlugin extends ProgramPlugin {
} }
} }
catch (InvalidInputException e) { catch (InvalidInputException e) {
dialog.displayMessage(e.getMessage(), Color.RED); dialog.displayMessage(e.getMessage(), Dialogs.FG_MESSAGE_ERROR);
return false; return false;
} }

View file

@ -22,6 +22,8 @@ import java.util.Set;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.border.Border; import javax.swing.border.Border;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.instructionsearch.ui.AbstractInstructionTable.OperandState; import ghidra.app.plugin.core.instructionsearch.ui.AbstractInstructionTable.OperandState;
import ghidra.app.plugin.core.instructionsearch.ui.InstructionTable; import ghidra.app.plugin.core.instructionsearch.ui.InstructionTable;
@ -42,37 +44,41 @@ public class InstructionTableDataObject {
* This is static since all data objects will have the same list of * This is static since all data objects will have the same list of
* observers * observers
*/ */
private Set<InstructionTableObserver> observers = new HashSet<InstructionTableObserver>(); private Set<InstructionTableObserver> observers = new HashSet<>();
// The text displayed in the cell. // The text displayed in the cell.
private String data; private String data;
// Some cell attributes. // Some cell attributes.
private Color backgroundColor; private Color backgroundColor;
private Color foregroundColor; private Color foregroundColor = Colors.FOREGROUND;
private int fontStyle; private int fontStyle;
// The border style of the cell. This is used to facilitate the 3D look of the // The border style of the cell. This is used to facilitate the 3D look of the cells
// cells (bevel-styling). // (bevel-styling).
private Border border; private Border border;
// The state of the object; this describes whether the cell is in a masked or // The state of the object; this describes whether the cell is in a masked or unmasked state,
// unmasked state, or neither (NA). // or neither (NA).
private OperandState state; private OperandState state;
// True if this data object represents an instruction (and not an undefined data item or // True if this data object represents an instruction (and not an undefined data).
// string).
private boolean isInstruction; private boolean isInstruction;
// Stores information about the operand for this cell (if it's an operand); if the // Stores information about the operand for this cell (if it's an operand); if the
// cell represents a mnemonic then this does not apply. // cell represents a mnemonic then this does not apply.
private OperandMetadata operandCase; private OperandMetadata operandCase;
private static final Color BACKGROUND_COLOR = new Color(237, 243, 254); private static final Color BG_COLOR_MASKED_INSTRUCTION =
private static final Color BACKGROUND_COLOR_DARKER = new Color(188, 212, 254); new GColor("color.bg.plugin.instructionsearch.table.masked.instruction");
private static final Color BACKGROUND_COLOR_NON_INSTRUCTION = new Color(255, 242, 214); private static final Color BG_COLOR_NOT_MASKED_INSTRUCTION =
private static final Color BACKGROUND_COLOR_DARKER_NON_INSTRUCTION = new Color(203, 186, 150); new GColor("color.bg.plugin.instructionsearch.table.not.masked.instruction");
private static final Color PANEL_COLOR = new Color(214, 217, 223); private static final Color BG_COLOR_MASKED_NON_INSTRUCTION =
new GColor("color.bg.plugin.instructionsearch.table.masked.non.instruction");
private static final Color BG_COLOR_NOT_MASKED_NON_INSTRUCTION =
new GColor("color.bg.plugin.instructionsearch.table.not.masked.non.instruction");
private static final Color BG_COLOR_DEFAULT =
new GColor("color.bg.plugin.instructionsearch.table.default");
/** /**
* Constructor. * Constructor.
@ -124,22 +130,20 @@ public class InstructionTableDataObject {
switch (state) { switch (state) {
case MASKED: case MASKED:
backgroundColor = backgroundColor =
isInstruction ? BACKGROUND_COLOR : BACKGROUND_COLOR_NON_INSTRUCTION; isInstruction ? BG_COLOR_MASKED_INSTRUCTION : BG_COLOR_MASKED_NON_INSTRUCTION;
foregroundColor = Color.BLACK;
border = BorderFactory.createLoweredSoftBevelBorder(); border = BorderFactory.createLoweredSoftBevelBorder();
break; break;
case NOT_MASKED: case NOT_MASKED:
backgroundColor = isInstruction ? BACKGROUND_COLOR_DARKER backgroundColor = isInstruction ? BG_COLOR_NOT_MASKED_INSTRUCTION
: BACKGROUND_COLOR_DARKER_NON_INSTRUCTION; : BG_COLOR_NOT_MASKED_NON_INSTRUCTION;
foregroundColor = Color.BLACK;
border = BorderFactory.createRaisedSoftBevelBorder(); border = BorderFactory.createRaisedSoftBevelBorder();
break; break;
case NA: case NA:
backgroundColor = PANEL_COLOR; backgroundColor = BG_COLOR_DEFAULT;
break; break;
case PREVIEW: case PREVIEW:
backgroundColor = backgroundColor =
isInstruction ? BACKGROUND_COLOR : BACKGROUND_COLOR_NON_INSTRUCTION; isInstruction ? BG_COLOR_MASKED_INSTRUCTION : BG_COLOR_MASKED_NON_INSTRUCTION;
break; break;
} }
@ -148,9 +152,6 @@ public class InstructionTableDataObject {
} }
} }
/**
* Subscribes the given observer to be notified of changes to this object.
*/
public void register(InstructionTableObserver observer) { public void register(InstructionTableObserver observer) {
observers.add(observer); observers.add(observer);
} }

View file

@ -15,11 +15,13 @@
*/ */
package ghidra.app.plugin.core.instructionsearch.ui; package ghidra.app.plugin.core.instructionsearch.ui;
import java.awt.*; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import generic.theme.GThemeDefaults.Colors.Java;
import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin; import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin;
/** /**
@ -31,11 +33,6 @@ public class ControlPanel extends JPanel {
private SelectionScopeWidget rangeWidget; private SelectionScopeWidget rangeWidget;
private SearchDirectionWidget directionWidget; private SearchDirectionWidget directionWidget;
/**
*
* @param plugin
* @param dialog
*/
public ControlPanel(InstructionSearchPlugin plugin, InstructionSearchDialog dialog) { public ControlPanel(InstructionSearchPlugin plugin, InstructionSearchDialog dialog) {
setLayout(new GridBagLayout()); setLayout(new GridBagLayout());
@ -60,21 +57,13 @@ public class ControlPanel extends JPanel {
gbc.weightx = 1.0; gbc.weightx = 1.0;
this.add(directionWidget, gbc); this.add(directionWidget, gbc);
this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); this.setBorder(BorderFactory.createLineBorder(Java.BORDER));
} }
/**
*
* @return
*/
public SelectionScopeWidget getRangeWidget() { public SelectionScopeWidget getRangeWidget() {
return this.rangeWidget; return this.rangeWidget;
} }
/**
*
* @return
*/
public SearchDirectionWidget getDirectionWidget() { public SearchDirectionWidget getDirectionWidget() {
return this.directionWidget; return this.directionWidget;
} }

View file

@ -15,25 +15,23 @@
*/ */
package ghidra.app.plugin.core.instructionsearch.ui; package ghidra.app.plugin.core.instructionsearch.ui;
import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import docking.widgets.textarea.HintTextArea; import docking.widgets.textarea.HintTextArea;
import generic.theme.GThemeDefaults.Colors;
/** /**
* Allows users to provide a text hint in a text field, shown only when the text is empty. * Allows users to provide a text hint in a text field, shown only when the text is empty.
* * <p>
* Hint text will be shown in light grey, italicized, and in angle brackets. Normal text will * Hint text will be shown in light grey, italicized, and in angle brackets. Normal text will
* be plain black. * be plain black.
*/ */
public class HintTextAreaIS extends HintTextArea { public class HintTextAreaIS extends HintTextArea {
private String hint;
/** /**
* Constructs the class with the hint text to be shown. * Constructs the class with the hint text to be shown.
* *
* @param hint * @param hint the hint
*/ */
public HintTextAreaIS(final String hint) { public HintTextAreaIS(final String hint) {
super(hint); super(hint);
@ -53,16 +51,12 @@ public class HintTextAreaIS extends HintTextArea {
setAttributes(); setAttributes();
} }
/*********************************************************************************************
* PRIVATE METHODS
********************************************************************************************/
/** /**
* Sets the text attributes to be used when there is an error in the input. * Sets the text attributes to be used when there is an error in the input.
*/ */
private void setErrorAttributes() { private void setErrorAttributes() {
this.setFont(getFont().deriveFont(Font.PLAIN)); this.setFont(getFont().deriveFont(Font.PLAIN));
setForeground(Color.RED); setForeground(Colors.ERROR);
} }
} }

View file

@ -15,7 +15,8 @@
*/ */
package ghidra.app.plugin.core.instructionsearch.ui; package ghidra.app.plugin.core.instructionsearch.ui;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -25,6 +26,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import generic.theme.GThemeDefaults.Colors.Dialogs;
import ghidra.app.plugin.core.instructionsearch.model.*; import ghidra.app.plugin.core.instructionsearch.model.*;
import ghidra.app.plugin.core.instructionsearch.ui.SelectionModeWidget.InputMode; import ghidra.app.plugin.core.instructionsearch.ui.SelectionModeWidget.InputMode;
import ghidra.app.plugin.core.instructionsearch.util.InstructionSearchUtils; import ghidra.app.plugin.core.instructionsearch.util.InstructionSearchUtils;
@ -290,7 +292,8 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis
// there's a problem with the input. Just print a message to the user and // there's a problem with the input. Just print a message to the user and
// exit. // exit.
if (allBytes.size() < instruction.getLength()) { if (allBytes.size() < instruction.getLength()) {
msgPanel.setMessageText("Input invalid: unknown disassembly error.", Color.RED); msgPanel.setMessageText("Input invalid: unknown disassembly error.",
Dialogs.FG_MESSAGE_ERROR);
return; return;
} }
allBytes.subList(0, instruction.getLength()).clear(); allBytes.subList(0, instruction.getLength()).clear();
@ -300,7 +303,8 @@ public class InsertBytesWidget extends DialogComponentProvider implements KeyLis
// If there's an exception, just stop and let the user figure out what went // If there's an exception, just stop and let the user figure out what went
// wrong - no need to continue. // wrong - no need to continue.
msgPanel.setMessageText("Input invalid: unknown disassembly error.", Color.RED); msgPanel.setMessageText("Input invalid: unknown disassembly error.",
Dialogs.FG_MESSAGE_ERROR);
Msg.debug(this, "Error disassembling instruction", e); Msg.debug(this, "Error disassembling instruction", e);
return; return;

View file

@ -23,6 +23,8 @@ import javax.swing.*;
import docking.ComponentProvider; import docking.ComponentProvider;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Dialogs;
import ghidra.app.events.ProgramSelectionPluginEvent; import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin; import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin;
import ghidra.app.plugin.core.instructionsearch.model.InstructionMetadata; import ghidra.app.plugin.core.instructionsearch.model.InstructionMetadata;
@ -61,6 +63,9 @@ import ghidra.util.task.TaskMonitor;
public class InstructionSearchDialog extends DialogComponentProvider implements Observer { public class InstructionSearchDialog extends DialogComponentProvider implements Observer {
private static final Color BG_COLOR_MARKERS =
new GColor("color.bg.plugin.instructionsearch.search.markers");
// Panel containing the {@link InstructionTable} and {@link PreviewTable}. // Panel containing the {@link InstructionTable} and {@link PreviewTable}.
private InstructionSearchMainPanel tablePanel; private InstructionSearchMainPanel tablePanel;
@ -136,7 +141,7 @@ public class InstructionSearchDialog extends DialogComponentProvider implements
if (selection == null && getMessagePanel() != null) { if (selection == null && getMessagePanel() != null) {
getMessagePanel().setMessageText( getMessagePanel().setMessageText(
"Select instructions from the listing (and hit reload) to populate the table.", "Select instructions from the listing (and hit reload) to populate the table.",
Color.BLUE); Dialogs.FG_MESSAGE_NORMAL);
} }
if (selection != null && plugin.isSelectionValid(selection, this)) { if (selection != null && plugin.isSelectionValid(selection, this)) {
@ -498,7 +503,7 @@ public class InstructionSearchDialog extends DialogComponentProvider implements
model.setSelectionSize(matchSize); model.setSelectionSize(matchSize);
TableComponentProvider<Address> tableProvider = TableComponentProvider<Address> tableProvider =
table.showTableWithMarkers(title + " " + model.getName(), "InstructionSearch", table.showTableWithMarkers(title + " " + model.getName(), "InstructionSearch",
model, Color.GREEN, null, "Instruction Search Results", null); model, BG_COLOR_MARKERS, null, "Instruction Search Results", null);
tableProvider.installRemoveItemsAction(); tableProvider.installRemoveItemsAction();
}; };
SystemUtilities.runSwingLater(runnable); SystemUtilities.runSwingLater(runnable);

View file

@ -15,7 +15,6 @@
*/ */
package ghidra.app.plugin.core.instructionsearch.ui; package ghidra.app.plugin.core.instructionsearch.ui;
import java.awt.Color;
import java.awt.event.*; import java.awt.event.*;
import java.util.List; import java.util.List;
@ -23,6 +22,7 @@ import javax.swing.*;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.widgets.EmptyBorderButton; import docking.widgets.EmptyBorderButton;
import generic.theme.GThemeDefaults.Colors.Dialogs;
import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin; import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin;
import ghidra.app.plugin.core.instructionsearch.model.*; import ghidra.app.plugin.core.instructionsearch.model.*;
import ghidra.app.services.GoToService; import ghidra.app.services.GoToService;
@ -168,7 +168,9 @@ public class InstructionTable extends AbstractInstructionTable {
} }
InstructionTableDataObject[][] dataObjects = InstructionTableDataObject[][] dataObjects =
new InstructionTableDataObject[dialog.getSearchData().getInstructions().size()][numColumns]; new InstructionTableDataObject[dialog.getSearchData()
.getInstructions()
.size()][numColumns];
// Loop over all instructions, adding pertinent info to each data object. This could be a long-running // Loop over all instructions, adding pertinent info to each data object. This could be a long-running
// operation so put in a task that can be cancelled. // operation so put in a task that can be cancelled.
@ -516,9 +518,10 @@ public class InstructionTable extends AbstractInstructionTable {
} }
else { else {
if (dialog.getMessagePanel() != null) { if (dialog.getMessagePanel() != null) {
dialog.getMessagePanel().setMessageText( dialog.getMessagePanel()
"Instruction was loaded manually, no address in the listing to navigate to.", .setMessageText(
Color.BLUE); "Instruction was loaded manually, no address in the listing to navigate to.",
Dialogs.FG_MESSAGE_NORMAL);
} }
} }
} }

View file

@ -21,6 +21,7 @@ import javax.swing.*;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import docking.widgets.table.GTableCellRenderingData; import docking.widgets.table.GTableCellRenderingData;
import generic.theme.Gui;
import ghidra.app.plugin.core.instructionsearch.model.InstructionTableDataObject; import ghidra.app.plugin.core.instructionsearch.model.InstructionTableDataObject;
import ghidra.util.table.GhidraTableCellRenderer; import ghidra.util.table.GhidraTableCellRenderer;
@ -30,10 +31,6 @@ import ghidra.util.table.GhidraTableCellRenderer;
*/ */
public class InstructionTableCellRenderer extends GhidraTableCellRenderer { public class InstructionTableCellRenderer extends GhidraTableCellRenderer {
/**
*
* @param font
*/
public InstructionTableCellRenderer(Font font) { public InstructionTableCellRenderer(Font font) {
super(font); super(font);
} }
@ -76,24 +73,10 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer {
return this; return this;
} }
/*********************************************************************************************
* PRIVATE METHODS
********************************************************************************************/
/**
*
* @param dataObject
* @param theRenderer
*/
private void setBorderAttributes(InstructionTableDataObject dataObject, JLabel theRenderer) { private void setBorderAttributes(InstructionTableDataObject dataObject, JLabel theRenderer) {
theRenderer.setBorder(dataObject.getBorder()); theRenderer.setBorder(dataObject.getBorder());
} }
/**
*
* @param dataObject
* @param theRenderer
*/
private void setForegroundAttributes(InstructionTableDataObject dataObject, private void setForegroundAttributes(InstructionTableDataObject dataObject,
JLabel theRenderer) { JLabel theRenderer) {
// Change the foreground to use a font of our choosing. The main reason is that we // Change the foreground to use a font of our choosing. The main reason is that we
@ -103,12 +86,6 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer {
theRenderer.setFont(newFont); theRenderer.setFont(newFont);
} }
/**
*
* @param isSelected
* @param hasFocus
* @param dataObject
*/
private void setBackgroundAttributes(boolean isSelected, boolean hasFocus, private void setBackgroundAttributes(boolean isSelected, boolean hasFocus,
InstructionTableDataObject dataObject) { InstructionTableDataObject dataObject) {
// Set the background color based on what the cell says. If it's selected, make it a // Set the background color based on what the cell says. If it's selected, make it a
@ -116,7 +93,7 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer {
Color backgroundColor = dataObject.getBackgroundColor(); Color backgroundColor = dataObject.getBackgroundColor();
if (backgroundColor != null) { if (backgroundColor != null) {
if (isSelected || hasFocus) { if (isSelected || hasFocus) {
setBackground(backgroundColor.darker()); setBackground(Gui.darker(backgroundColor));
} }
else { else {
setBackground(backgroundColor); setBackground(backgroundColor);
@ -124,12 +101,6 @@ public class InstructionTableCellRenderer extends GhidraTableCellRenderer {
} }
} }
/**
*
* @param table
* @param value
* @param col
*/
private void setTextAttributes(JTable table, Object value, int col) { private void setTextAttributes(JTable table, Object value, int col) {
setHorizontalAlignment(SwingConstants.LEFT); setHorizontalAlignment(SwingConstants.LEFT);
TableModel model = table.getModel(); TableModel model = table.getModel();

View file

@ -15,19 +15,18 @@
*/ */
package ghidra.app.plugin.core.instructionsearch.ui; package ghidra.app.plugin.core.instructionsearch.ui;
import java.awt.Color;
import java.util.*; import java.util.*;
import javax.swing.SwingUtilities; import generic.theme.GThemeDefaults.Colors.Dialogs;
import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin; import ghidra.app.plugin.core.instructionsearch.InstructionSearchPlugin;
import ghidra.app.plugin.core.instructionsearch.model.InstructionMetadata; import ghidra.app.plugin.core.instructionsearch.model.InstructionMetadata;
import ghidra.app.plugin.core.instructionsearch.ui.SearchDirectionWidget.Direction; import ghidra.app.plugin.core.instructionsearch.ui.SearchDirectionWidget.Direction;
import ghidra.app.services.GoToService; import ghidra.app.services.GoToService;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRange; import ghidra.program.model.address.AddressRange;
import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.*;
import ghidra.program.util.BytesFieldLocation; import ghidra.program.util.BytesFieldLocation;
import ghidra.util.Swing;
import ghidra.util.task.Task; import ghidra.util.task.Task;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -73,8 +72,11 @@ class SearchInstructionsTask extends Task {
// See if we're searching forward or backwards. // See if we're searching forward or backwards.
boolean forward = boolean forward =
searchDialog.getControlPanel().getDirectionWidget().getSearchDirection().equals( searchDialog.getControlPanel()
Direction.FORWARD); .getDirectionWidget()
.getSearchDirection()
.equals(
Direction.FORWARD);
// If we're searching backwards we need to process address ranges in reverse so reverse // If we're searching backwards we need to process address ranges in reverse so reverse
// the list. // the list.
@ -121,7 +123,7 @@ class SearchInstructionsTask extends Task {
// //
// Note we put these on the swing thread or it will throw off the task monitor display. // Note we put these on the swing thread or it will throw off the task monitor display.
if (searchResults != null) { if (searchResults != null) {
SwingUtilities.invokeLater(() -> { Swing.runLater(() -> {
goToLocation(searchResults.getAddr()); goToLocation(searchResults.getAddr());
searchDialog.getMessagePanel().clear(); searchDialog.getMessagePanel().clear();
}); });
@ -134,7 +136,8 @@ class SearchInstructionsTask extends Task {
// If we've gone through all the ranges and there are still no results, show an // If we've gone through all the ranges and there are still no results, show an
// error message. // error message.
searchDialog.getMessagePanel().setMessageText("No results found", Color.BLUE); searchDialog.getMessagePanel()
.setMessageText("No results found", Dialogs.FG_MESSAGE_NORMAL);
return; return;
} }
@ -157,13 +160,13 @@ class SearchInstructionsTask extends Task {
// The reason for the getting the CodeUnit is that the instruction might be an off-cut, // The reason for the getting the CodeUnit is that the instruction might be an off-cut,
// and if that's the case, then we can't navigate directly to it. What we have to do // and if that's the case, then we can't navigate directly to it. What we have to do
// is find the CodeUnit containing the instruction and navigate to that. // is find the CodeUnit containing the instruction and navigate to that.
Program currentProgram = searchPlugin.getCurrentProgram();
Listing listing = currentProgram.getListing();
if (direction == Direction.FORWARD) { if (direction == Direction.FORWARD) {
for (InstructionMetadata instr : searchResults) { for (InstructionMetadata instr : searchResults) {
CodeUnit unit = searchPlugin.getCurrentProgram().getListing().getCodeUnitContaining( CodeUnit cu = listing.getCodeUnitContaining(instr.getAddr());
instr.getAddr()); if (cu.getMinAddress().compareTo(currentAddress) > 0) {
return cu.getMinAddress();
if (unit.getMinAddress().compareTo(currentAddress) > 0) {
return unit.getMinAddress();
} }
} }
} }
@ -173,14 +176,12 @@ class SearchInstructionsTask extends Task {
// //
// See above for an explanation for why we need to get the CodeUnit in this block. // See above for an explanation for why we need to get the CodeUnit in this block.
if (direction == Direction.BACKWARD) { if (direction == Direction.BACKWARD) {
ListIterator<InstructionMetadata> iter = ListIterator<InstructionMetadata> it = searchResults.listIterator(searchResults.size());
searchResults.listIterator(searchResults.size()); while (it.hasPrevious()) {
while (iter.hasPrevious()) { InstructionMetadata instr = it.previous();
InstructionMetadata instr = iter.previous(); CodeUnit cu = listing.getCodeUnitContaining(instr.getAddr());
CodeUnit unit = searchPlugin.getCurrentProgram().getListing().getCodeUnitContaining( if (cu.getMinAddress().compareTo(currentAddress) < 0) {
instr.getAddr()); return cu.getMinAddress();
if (unit.getMinAddress().compareTo(currentAddress) < 0) {
return unit.getMinAddress();
} }
} }
} }

View file

@ -19,6 +19,8 @@ import java.awt.Color;
import javax.swing.text.*; import javax.swing.text.*;
import generic.theme.GColor;
import generic.theme.TempColorUtils;
import ghidra.app.plugin.core.interpreter.AnsiParser.AnsiParserHandler; import ghidra.app.plugin.core.interpreter.AnsiParser.AnsiParserHandler;
/** /**
@ -32,22 +34,6 @@ import ghidra.app.plugin.core.interpreter.AnsiParser.AnsiParserHandler;
* renderers prevents the corruption of those escape sequences when interleaving the output streams. * renderers prevents the corruption of those escape sequences when interleaving the output streams.
*/ */
public class AnsiRenderer { public class AnsiRenderer {
public static final Color BLACK = new Color(0, 0, 0);
public static final Color RED = new Color(194, 54, 33);
public static final Color GREEN = new Color(37, 188, 36);
public static final Color YELLOW = new Color(173, 173, 39);
public static final Color BLUE = new Color(73, 46, 225);
public static final Color MAGENTA = new Color(211, 56, 211);
public static final Color CYAN = new Color(51, 187, 200);
public static final Color WHITE = new Color(203, 204, 205);
public static final Color HI_BLACK = new Color(129, 131, 131);
public static final Color HI_RED = new Color(252, 57, 31);
public static final Color HI_GREEN = new Color(49, 231, 34);
public static final Color HI_YELLOW = new Color(234, 236, 35);
public static final Color HI_BLUE = new Color(88, 51, 255);
public static final Color HI_MAGENTA = new Color(249, 53, 248);
public static final Color HI_CYAN = new Color(20, 240, 240);
public static final Color HI_WHITE = new Color(233, 235, 235);
/** /**
* These colors are taken from Terminal.app as documented on Wikipedia as of 26 April 2022. * These colors are taken from Terminal.app as documented on Wikipedia as of 26 April 2022.
@ -58,23 +44,23 @@ public class AnsiRenderer {
*/ */
private static final Color[] BASIC_COLORS = { private static final Color[] BASIC_COLORS = {
// standard colors // standard colors
BLACK, new GColor("color.fg.plugin.interpreter.renderer.color.standard.1"),
RED, new GColor("color.fg.plugin.interpreter.renderer.color.standard.2"),
GREEN, new GColor("color.fg.plugin.interpreter.renderer.color.standard.3"),
YELLOW, new GColor("color.fg.plugin.interpreter.renderer.color.standard.4"),
BLUE, new GColor("color.fg.plugin.interpreter.renderer.color.standard.5"),
MAGENTA, new GColor("color.fg.plugin.interpreter.renderer.color.standard.6"),
CYAN, new GColor("color.fg.plugin.interpreter.renderer.color.standard.7"),
WHITE, new GColor("color.fg.plugin.interpreter.renderer.color.standard.8"),
// high intensity colors // high intensity colors
HI_BLACK, new GColor("color.fg.plugin.interpreter.renderer.color.intense.1"),
HI_RED, new GColor("color.fg.plugin.interpreter.renderer.color.intense.2"),
HI_GREEN, new GColor("color.fg.plugin.interpreter.renderer.color.intense.3"),
HI_YELLOW, new GColor("color.fg.plugin.interpreter.renderer.color.intense.4"),
HI_BLUE, new GColor("color.fg.plugin.interpreter.renderer.color.intense.5"),
HI_MAGENTA, new GColor("color.fg.plugin.interpreter.renderer.color.intense.6"),
HI_CYAN, new GColor("color.fg.plugin.interpreter.renderer.color.intense.7"),
HI_WHITE, new GColor("color.fg.plugin.interpreter.renderer.color.intense.8"),
}; };
/** /**
* This aids the implementation of the 6x6x6 color cube. * This aids the implementation of the 6x6x6 color cube.
@ -98,12 +84,12 @@ public class AnsiRenderer {
} }
/** /**
* Get the 8-bit ansi color. * Get the 8-bit ANSI color.
* *
* <p> * <p>
* Colors 0-15 are the {@link AnsiRenderer#BASIC_COLORS: standard + high-intensity. Colors * Colors 0-15 are the {@link AnsiRenderer#AnsiRenderer}: standard + high-intensity. Colors
* 16-231 come from a 6x6x6 RGB cube; see {@link AnsiRenderer#CUBE_STEPS}. Finally, colors * 16-231 come from a 6x6x6 RGB cube; see {@link AnsiRenderer#CUBE_STEPS}. Finally, colors
* 232-255 are 24 steps of grayscale. * 232-255 are 24 steps of gray scale.
* *
* @param v an 8-bit number * @param v an 8-bit number
* @return the ANSI color * @return the ANSI color
@ -117,12 +103,12 @@ public class AnsiRenderer {
int b = v % 6; int b = v % 6;
int g = (v / 6) % 6; int g = (v / 6) % 6;
int r = (v / 36) % 6; int r = (v / 36) % 6;
return new Color(CUBE_STEPS[r], CUBE_STEPS[g], CUBE_STEPS[b]); return TempColorUtils.fromRgb(CUBE_STEPS[r], CUBE_STEPS[g], CUBE_STEPS[b]);
} }
else if (v < 256) { else if (v < 256) {
v -= 232; v -= 232;
int gray = v * 10 + 8; int gray = v * 10 + 8;
return new Color(gray, gray, gray); return TempColorUtils.fromRgb(gray, gray, gray);
} }
else { else {
/* invalid */ /* invalid */
@ -146,7 +132,7 @@ public class AnsiRenderer {
private int handleSGRAttribute(String[] bits, int pos) throws NumberFormatException { private int handleSGRAttribute(String[] bits, int pos) throws NumberFormatException {
int code = Integer.parseInt(bits[pos]); int code = Integer.parseInt(bits[pos]);
if (code >= 30 && code < 50) { if (code >= 30 && code < 50) {
/* Colour codes */ /* Color codes */
Object attributeName = Object attributeName =
(code < 40) ? StyleConstants.Foreground : StyleConstants.Background; (code < 40) ? StyleConstants.Foreground : StyleConstants.Background;
int colorCode = code % 10; int colorCode = code % 10;
@ -172,7 +158,7 @@ public class AnsiRenderer {
int r = Integer.parseInt(bits[pos + 2]); int r = Integer.parseInt(bits[pos + 2]);
int g = Integer.parseInt(bits[pos + 3]); int g = Integer.parseInt(bits[pos + 3]);
int b = Integer.parseInt(bits[pos + 4]); int b = Integer.parseInt(bits[pos + 4]);
attributes.addAttribute(attributeName, new Color(r, g, b)); attributes.addAttribute(attributeName, TempColorUtils.fromRgb(r, g, b));
return 5; return 5;
} }
return 1; return 1;
@ -314,6 +300,7 @@ public class AnsiRenderer {
* @param document Document to render the string to * @param document Document to render the string to
* @param text A text string which may contain 7-bit ANSI escape codes * @param text A text string which may contain 7-bit ANSI escape codes
* @param attributes Current text attributes; may be modified by this function * @param attributes Current text attributes; may be modified by this function
* @throws BadLocationException if there is an error parsing the text
*/ */
public void renderString(StyledDocument document, String text, MutableAttributeSet attributes) public void renderString(StyledDocument document, String text, MutableAttributeSet attributes)
throws BadLocationException { throws BadLocationException {

View file

@ -25,6 +25,7 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.ListDataListener; import javax.swing.event.ListDataListener;
import docking.widgets.list.GListCellRenderer; import docking.widgets.list.GListCellRenderer;
import generic.theme.GThemeDefaults.Colors;
import generic.util.WindowUtilities; import generic.util.WindowUtilities;
import ghidra.app.plugin.core.console.CodeCompletion; import ghidra.app.plugin.core.console.CodeCompletion;
@ -37,7 +38,7 @@ import ghidra.app.plugin.core.console.CodeCompletion;
public class CodeCompletionWindow extends JDialog { public class CodeCompletionWindow extends JDialog {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/* from ReferenceHoverPlugin */ /* from ReferenceHoverPlugin */
private static final Color BACKGROUND_COLOR = new Color(255, 255, 230); private static final Color BACKGROUND_COLOR = Colors.TOOLTIP_BACKGROUND;
protected final InterpreterPanel console; protected final InterpreterPanel console;
protected final JTextPane outputTextField; protected final JTextPane outputTextField;

View file

@ -27,6 +27,7 @@ import javax.swing.ImageIcon;
import docking.widgets.fieldpanel.support.FieldRange; import docking.widgets.fieldpanel.support.FieldRange;
import docking.widgets.fieldpanel.support.FieldSelection; import docking.widgets.fieldpanel.support.FieldSelection;
import generic.json.Json; import generic.json.Json;
import generic.theme.TempColorUtils;
import ghidra.app.services.MarkerDescriptor; import ghidra.app.services.MarkerDescriptor;
import ghidra.app.services.MarkerSet; import ghidra.app.services.MarkerSet;
import ghidra.app.util.viewer.listingpanel.VerticalPixelAddressMap; import ghidra.app.util.viewer.listingpanel.VerticalPixelAddressMap;
@ -259,10 +260,7 @@ abstract class MarkerSetImpl implements MarkerSet {
} }
protected static Color getFillColor(Color c) { protected static Color getFillColor(Color c) {
int red = (c.getRed() + 3 * COLOR_VALUE) / 4; return TempColorUtils.blend2(c, COLOR_VALUE);
int green = (c.getGreen() + 3 * COLOR_VALUE) / 4;
int blue = (c.getBlue() + 3 * COLOR_VALUE) / 4;
return new Color(red, green, blue);
} }
@Override @Override

View file

@ -29,6 +29,7 @@ import javax.swing.ImageIcon;
import docking.ActionContext; import docking.ActionContext;
import docking.action.DockingAction; import docking.action.DockingAction;
import docking.action.ToolBarData; import docking.action.ToolBarData;
import generic.theme.GColor;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin; import ghidra.app.plugin.ProgramPlugin;
@ -73,6 +74,15 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
private final static int OTHER_CHANGES_PRIORITY = MarkerService.CHANGE_PRIORITY + 2; private final static int OTHER_CHANGES_PRIORITY = MarkerService.CHANGE_PRIORITY + 2;
private final static int CONFLICT_PRIORITY = MarkerService.CHANGE_PRIORITY + 3; private final static int CONFLICT_PRIORITY = MarkerService.CHANGE_PRIORITY + 3;
private static final Color BG_COLOR_MARKER_UNSAVED =
new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.unsaved");
private static final Color BG_COLOR_MARKER_CONFLICTING =
new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.conflicting");
private static final Color BG_COLOR_MARKER_LATEST =
new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.latest.version");
private static final Color BG_COLOR_MARKER_NOT_CHECKED_IN =
new GColor("color.bg.plugin.myprogramchangesdisplay.markers.changes.not.checked.in");
private MarkerService markerService; private MarkerService markerService;
private MarkerSet currentMyChangeMarks; // my changes since last save private MarkerSet currentMyChangeMarks; // my changes since last save
@ -191,7 +201,7 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
private void createMarkerSets(Program program) { private void createMarkerSets(Program program) {
currentMyChangeMarks = currentMyChangeMarks =
markerService.createAreaMarker("Changes: Unsaved", "My changes not yet saved", program, markerService.createAreaMarker("Changes: Unsaved", "My changes not yet saved", program,
MY_CHANGE_PRIORITY, true, true, false, Color.darkGray); MY_CHANGE_PRIORITY, true, true, false, BG_COLOR_MARKER_UNSAVED);
if (program.getDomainFile().isCheckedOut()) { if (program.getDomainFile().isCheckedOut()) {
trackServerChanges(program); trackServerChanges(program);
@ -201,15 +211,15 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
private void trackServerChanges(Program program) { private void trackServerChanges(Program program) {
currentChangesSinceCheckoutMarks = markerService.createAreaMarker("Changes: Not Checked-In", currentChangesSinceCheckoutMarks = markerService.createAreaMarker("Changes: Not Checked-In",
"My saved changes made since I checked it out", program, CHANGES_SINCE_CO_PRIORITY, "My saved changes made since I checked it out", program, CHANGES_SINCE_CO_PRIORITY,
true, true, false, Color.GREEN); true, true, false, BG_COLOR_MARKER_NOT_CHECKED_IN);
currentOtherChangeMarks = markerService.createAreaMarker("Changes: Latest Version", currentOtherChangeMarks = markerService.createAreaMarker("Changes: Latest Version",
"Changes made by others to this program since I checked it out", program, "Changes made by others to this program since I checked it out", program,
OTHER_CHANGES_PRIORITY, true, true, false, Color.BLUE); OTHER_CHANGES_PRIORITY, true, true, false, BG_COLOR_MARKER_LATEST);
currentConflictChangeMarks = markerService.createAreaMarker("Changes: Conflicting", currentConflictChangeMarks = markerService.createAreaMarker("Changes: Conflicting",
"Changes made by others to this program that conflict with my changes", program, "Changes made by others to this program that conflict with my changes", program,
CONFLICT_PRIORITY, true, true, false, Color.RED); CONFLICT_PRIORITY, true, true, false, BG_COLOR_MARKER_CONFLICTING);
} }
private void disposeMarkerSets(Program program) { private void disposeMarkerSets(Program program) {

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,49 +23,49 @@ import javax.swing.*;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.text.*; import javax.swing.text.*;
/** import generic.theme.GThemeDefaults.Colors;
*
*/
public class RegisterField extends JTextField { public class RegisterField extends JTextField {
// private static Color UNSET_COLOR = new Color(204,0,204);
private int bitSize; private int bitSize;
private Long currentValue; private Long currentValue;
private long maxValue; private long maxValue;
private PlainDocument doc; private PlainDocument doc;
private boolean inFocus; private boolean inFocus;
private boolean skipFilter; private boolean skipFilter;
private ChangeListener listener; private ChangeListener listener;
private Color noValueColor = Color.LIGHT_GRAY; private Color noValueColor = Colors.FOREGROUND_DISABLED;
private Color valueColor = Color.BLACK; private Color valueColor = Colors.FOREGROUND;
private boolean useNoValue; private boolean useNoValue;
/**
* Constructor for RegisterField.
*/
public RegisterField(int bitSize, Long initialValue) {
this(bitSize, initialValue, true);
}
public RegisterField(int bitSize, Long initialValue, boolean useNoValue) { public RegisterField(int bitSize, Long initialValue) {
this.useNoValue = useNoValue; this(bitSize, initialValue, true);
setBitSize( bitSize ); }
doc = new PlainDocument(); public RegisterField(int bitSize, Long initialValue, boolean useNoValue) {
doc.setDocumentFilter(new MyDocFilter()); this.useNoValue = useNoValue;
this.setDocument(doc); setBitSize(bitSize);
doc = new PlainDocument();
doc.setDocumentFilter(new MyDocFilter());
this.setDocument(doc);
doSetValue(initialValue); doSetValue(initialValue);
this.addFocusListener(new FocusListener() { this.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent ev) { @Override
public void focusGained(FocusEvent ev) {
inFocus = true; inFocus = true;
doSetValue(currentValue); doSetValue(currentValue);
} }
public void focusLost(FocusEvent ev) { @Override
inFocus = false; public void focusLost(FocusEvent ev) {
inFocus = false;
doSetValue(currentValue); doSetValue(currentValue);
} }
}); });
} }
public Long getValue() { public Long getValue() {
return currentValue; return currentValue;
} }
@ -75,10 +74,12 @@ public class RegisterField extends JTextField {
noValueColor = c; noValueColor = c;
updateColor(); updateColor();
} }
public void setValueColor(Color c) { public void setValueColor(Color c) {
valueColor = c; valueColor = c;
updateColor(); updateColor();
} }
private void updateColor() { private void updateColor() {
if (inFocus || currentValue != null) { if (inFocus || currentValue != null) {
setForeground(valueColor); setForeground(valueColor);
@ -89,82 +90,91 @@ public class RegisterField extends JTextField {
setHorizontalAlignment(CENTER); setHorizontalAlignment(CENTER);
} }
} }
public void setBitSize( int bitSize ) {
this.bitSize = bitSize;
boolean isValid = bitSize >= 1 && bitSize < 64; public void setBitSize(int bitSize) {
this.bitSize = bitSize;
this.setEditable(isValid); boolean isValid = bitSize >= 1 && bitSize < 64;
this.setEnabled(isValid);
this.useNoValue = true; this.setEditable(isValid);
this.setEnabled(isValid);
if (isValid) { this.useNoValue = true;
this.maxValue = (1L << bitSize) - 1;
}
else {
skipFilter = true;
this.maxValue = 1;
}
/// if the value is no longer valid, then clear the value if (isValid) {
if ( !isValidValue( getValue() ) ) { this.maxValue = (1L << bitSize) - 1;
doSetValue( null ); }
} else {
} skipFilter = true;
public void setValue(Long value) { this.maxValue = 1;
}
/// if the value is no longer valid, then clear the value
if (!isValidValue(getValue())) {
doSetValue(null);
}
}
public void setValue(Long value) {
if (isEqual(value, currentValue)) { if (isEqual(value, currentValue)) {
return; return;
} }
doSetValue(value); doSetValue(value);
} }
private void doSetValue(Long value) {
if (value == null) { private void doSetValue(Long value) {
if (inFocus) { if (value == null) {
if (inFocus) {
setTextField(""); setTextField("");
} }
else { else {
if (useNoValue) { if (useNoValue) {
setTextField("-- No Value --"); setTextField("-- No Value --");
} }
else { else {
setTextField(""); setTextField("");
} }
} }
} }
else { else {
setTextField("0x"+Long.toHexString(value.longValue())); setTextField("0x" + Long.toHexString(value.longValue()));
} }
currentValue = value; currentValue = value;
updateColor(); updateColor();
} }
private boolean isEqual(Long l1, Long l2) {
if (l1 != null) { private boolean isEqual(Long l1, Long l2) {
return l1.equals(l2); if (l1 != null) {
} return l1.equals(l2);
else if (l2 != null) { }
return false; else if (l2 != null) {
} return false;
return true; }
} return true;
}
private void setTextField(String text) { private void setTextField(String text) {
if ( doc == null ) { if (doc == null) {
return; return;
} }
skipFilter = true; skipFilter = true;
try { try {
doc.replace(0, doc.getLength(), text, null); doc.replace(0, doc.getLength(), text, null);
} }
catch (BadLocationException e) {} catch (BadLocationException e) {
// ignore
}
skipFilter = false; skipFilter = false;
} }
public void setChangeListener(ChangeListener listener) { public void setChangeListener(ChangeListener listener) {
this.listener = listener; this.listener = listener;
} }
private boolean processText() { private boolean processText() {
String text = getText(); String text = getText();
if (text.length() == 0){ if (text.length() == 0) {
if (currentValue != null) { if (currentValue != null) {
currentValue = null; currentValue = null;
notifyListeners(); notifyListeners();
@ -173,20 +183,20 @@ public class RegisterField extends JTextField {
} }
if (text.equals("0x") || text.equals("0X")) { if (text.equals("0x") || text.equals("0X")) {
if ((currentValue == null) || (currentValue.longValue() != 0)) { if ((currentValue == null) || (currentValue.longValue() != 0)) {
currentValue = new Long(0); currentValue = 0L;
notifyListeners(); notifyListeners();
} }
return true; return true;
} }
try { try {
if (!text.startsWith("0x") && !text.startsWith("0X")) { if (!text.startsWith("0x") && !text.startsWith("0X")) {
while(text.length() > 1 && text.charAt(0)== '0') { while (text.length() > 1 && text.charAt(0) == '0') {
text = text.substring(1); text = text.substring(1);
} }
} }
Long newValue = Long.decode(text); Long newValue = Long.decode(text);
if ( isValidValue( newValue ) ) { if (isValidValue(newValue)) {
if (!newValue.equals(currentValue)) { if (!newValue.equals(currentValue)) {
currentValue = newValue; currentValue = newValue;
notifyListeners(); notifyListeners();
@ -194,28 +204,27 @@ public class RegisterField extends JTextField {
return true; return true;
} }
} }
catch(Exception e) { catch (Exception e) {
// handled by using beep below
} }
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
return false; return false;
} }
private boolean isValidValue(Long value) { private boolean isValidValue(Long value) {
if ( value == null ) { if (value == null) {
return false; return false;
} }
long l = value.longValue(); long l = value.longValue();
return (l >= 0) && (l <= maxValue); return (l >= 0) && (l <= maxValue);
} }
class MyDocFilter extends DocumentFilter { class MyDocFilter extends DocumentFilter {
/**
* @see javax.swing.text.DocumentFilter#insertString(FilterBypass, int, String, AttributeSet) @Override
*/ public void insertString(FilterBypass fb, int offset, String string,
@Override AttributeSet attr) throws BadLocationException {
public void insertString(FilterBypass fb, int offset, String string,
AttributeSet attr) throws BadLocationException {
if (skipFilter) { if (skipFilter) {
super.insertString(fb, offset, string, attr); super.insertString(fb, offset, string, attr);
return; return;
@ -226,14 +235,11 @@ public class RegisterField extends JTextField {
if (!processText()) { if (!processText()) {
fb.replace(0, doc.getLength(), oldText, attr); fb.replace(0, doc.getLength(), oldText, attr);
} }
} }
/** @Override
* @see javax.swing.text.DocumentFilter#remove(FilterBypass, int, int) public void remove(FilterBypass fb, int offset, int length)
*/ throws BadLocationException {
@Override
public void remove(FilterBypass fb, int offset, int length)
throws BadLocationException {
if (skipFilter) { if (skipFilter) {
super.remove(fb, offset, length); super.remove(fb, offset, length);
return; return;
@ -244,14 +250,11 @@ public class RegisterField extends JTextField {
if (!processText()) { if (!processText()) {
fb.replace(0, doc.getLength(), oldText, null); fb.replace(0, doc.getLength(), oldText, null);
} }
} }
/** @Override
* @see javax.swing.text.DocumentFilter#replace(FilterBypass, int, int, String, AttributeSet) public void replace(FilterBypass fb, int offset, int length,
*/ String text, AttributeSet attrs) throws BadLocationException {
@Override
public void replace(FilterBypass fb, int offset, int length,
String text, AttributeSet attrs) throws BadLocationException {
if (skipFilter) { if (skipFilter) {
super.replace(fb, offset, length, text, attrs); super.replace(fb, offset, length, text, attrs);
return; return;
@ -261,14 +264,14 @@ public class RegisterField extends JTextField {
if (!processText()) { if (!processText()) {
fb.replace(0, doc.getLength(), oldText, attrs); fb.replace(0, doc.getLength(), oldText, attrs);
} }
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
JFrame f = new JFrame("Test"); JFrame f = new JFrame("Test");
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.add(new JTextField("123"), BorderLayout.SOUTH); panel.add(new JTextField("123"), BorderLayout.SOUTH);
RegisterField rf = new RegisterField(1, new Long(1)); RegisterField rf = new RegisterField(1, 1L);
panel.add(rf, BorderLayout.CENTER); panel.add(rf, BorderLayout.CENTER);
f.getContentPane().add(panel); f.getContentPane().add(panel);
f.pack(); f.pack();
@ -277,15 +280,15 @@ public class RegisterField extends JTextField {
private void notifyListeners() { private void notifyListeners() {
if (listener != null) { if (listener != null) {
listener.stateChanged( null ); listener.stateChanged(null);
} }
} }
public int getBitSize() { public int getBitSize() {
return bitSize; return bitSize;
} }
public Color getValueColor() { public Color getValueColor() {
return valueColor; return valueColor;
} }
} }

View file

@ -18,6 +18,7 @@ package ghidra.app.plugin.core.navigation.locationreferences;
import java.awt.Color; import java.awt.Color;
import docking.widgets.fieldpanel.support.Highlight; import docking.widgets.fieldpanel.support.Highlight;
import generic.theme.GColor;
import ghidra.GhidraOptions; import ghidra.GhidraOptions;
import ghidra.app.nav.Navigatable; import ghidra.app.nav.Navigatable;
import ghidra.app.services.*; import ghidra.app.services.*;
@ -42,7 +43,8 @@ class LocationReferencesHighlighter {
"Reference Search" + GhidraOptions.DELIMITER + "Highlight Match Color"; "Reference Search" + GhidraOptions.DELIMITER + "Highlight Match Color";
private static final String HIGHLIGHT_COLOR_DESCRIPTION = private static final String HIGHLIGHT_COLOR_DESCRIPTION =
"The highlight color of matches for the 'Show References' searcher"; "The highlight color of matches for the 'Show References' searcher";
private static Color DEFAULT_HIGHLIGHT_COLOR = new Color(168, 202, 242); private static Color DEFAULT_HIGHLIGHT_COLOR =
new GColor("color.bg.plugin.locationreferences.highlight");
private boolean isHighlighting = false; private boolean isHighlighting = false;
private final Navigatable navigatable; private final Navigatable navigatable;
@ -52,15 +54,11 @@ class LocationReferencesHighlighter {
private HighlightProvider highlightProvider; private HighlightProvider highlightProvider;
private MarkerRemover markerRemover; private MarkerRemover markerRemover;
private Color highlightColor; private Color highlightColor;
private OptionsChangeListener optionsListener = new OptionsChangeListener() { private OptionsChangeListener optionsListener = (options, name, oldValue, newValue) -> {
@Override if (name.equals(HIGHLIGHT_COLOR_KEY)) {
public void optionsChanged(ToolOptions options, String name, Object oldValue, highlightColor = (Color) newValue;
Object newValue) { }
if (name.equals(HIGHLIGHT_COLOR_KEY)) { };
highlightColor = (Color) newValue;
}
}
};
// This is a bit unusual, but we do this here, since this highlighter will come and // This is a bit unusual, but we do this here, since this highlighter will come and
// go with each search. If we do not register a priori, then the option will not appear in the // go with each search. If we do not register a priori, then the option will not appear in the

View file

@ -15,13 +15,13 @@
*/ */
package ghidra.app.plugin.core.navigation.locationreferences; package ghidra.app.plugin.core.navigation.locationreferences;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.util.*; import java.util.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import docking.widgets.table.GTableCellRenderingData; import docking.widgets.table.GTableCellRenderingData;
import generic.theme.GThemeDefaults.Colors.Tables;
import ghidra.docking.settings.Settings; import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ServiceProvider; import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -171,7 +171,7 @@ class LocationReferencesTableModel extends AddressBasedTableModel<LocationRefere
super.getTableCellRendererComponent(data); super.getTableCellRendererComponent(data);
LocationReference rowObject = (LocationReference) data.getRowObject(); LocationReference rowObject = (LocationReference) data.getRowObject();
String refTypeString = getRefTypeString(rowObject); String refTypeString = getRefTypeString(rowObject, data.isSelected());
if (refTypeString != null) { if (refTypeString != null) {
setText(refTypeString); setText(refTypeString);
return this; return this;
@ -184,12 +184,13 @@ class LocationReferencesTableModel extends AddressBasedTableModel<LocationRefere
return this; return this;
} }
private String getRefTypeString(LocationReference rowObject) { private String getRefTypeString(LocationReference rowObject, boolean isSelected) {
String refType = rowObject.getRefTypeString(); String refType = rowObject.getRefTypeString();
if (!StringUtils.isBlank(refType)) { if (!StringUtils.isBlank(refType)) {
String trailingText = ""; String trailingText = "";
if (rowObject.isOffcutReference()) { if (rowObject.isOffcutReference()) {
setForeground(Color.RED); setForeground(
isSelected ? Tables.FG_ERROR_SELECTED : Tables.FG_ERROR_UNSELECTED);
trailingText = OFFCUT_STRING; trailingText = OFFCUT_STRING;
} }
return refType + trailingText; return refType + trailingText;
@ -199,7 +200,7 @@ class LocationReferencesTableModel extends AddressBasedTableModel<LocationRefere
@Override @Override
public String getFilterString(LocationReference rowObject, Settings settings) { public String getFilterString(LocationReference rowObject, Settings settings) {
String refTypeString = getRefTypeString(rowObject); String refTypeString = getRefTypeString(rowObject, false);
if (refTypeString != null) { if (refTypeString != null) {
return refTypeString; return refTypeString;
} }

View file

@ -25,6 +25,7 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import docking.action.DockingActionIf; import docking.action.DockingActionIf;
import generic.theme.GColor;
import ghidra.app.nav.Navigatable; import ghidra.app.nav.Navigatable;
import ghidra.app.services.GoToService; import ghidra.app.services.GoToService;
import ghidra.app.util.viewer.listingpanel.OverviewProvider; import ghidra.app.util.viewer.listingpanel.OverviewProvider;
@ -40,7 +41,7 @@ import help.Help;
* Uses an {@link OverviewColorService} to get the appropriate color for an address. * Uses an {@link OverviewColorService} to get the appropriate color for an address.
*/ */
public class OverviewColorComponent extends JPanel implements OverviewProvider { public class OverviewColorComponent extends JPanel implements OverviewProvider {
private static final Color DEFAULT_COLOR = Color.GRAY; private static final Color DEFAULT_COLOR = new GColor("color.bg.plugin.overview.defalt");
private OverviewColorService service; private OverviewColorService service;
private Color[] colors = new Color[0]; private Color[] colors = new Color[0];
private final SwingUpdateManager refreshUpdater = private final SwingUpdateManager refreshUpdater =
@ -158,7 +159,7 @@ public class OverviewColorComponent extends JPanel implements OverviewProvider {
} }
BigInteger indexCount = map.getIndexCount(); BigInteger indexCount = map.getIndexCount();
if (indexCount.equals(BigInteger.ZERO)) { if (indexCount.equals(BigInteger.ZERO)) {
Arrays.fill(colors, Color.GRAY); Arrays.fill(colors, DEFAULT_COLOR);
repaint(); repaint();
return; return;
} }

View file

@ -22,6 +22,7 @@ import java.util.List;
import docking.ActionContext; import docking.ActionContext;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.action.DockingActionIf; import docking.action.DockingActionIf;
import generic.theme.GColor;
import ghidra.app.plugin.core.overview.*; import ghidra.app.plugin.core.overview.*;
import ghidra.framework.model.*; import ghidra.framework.model.*;
import ghidra.framework.options.OptionsChangeListener; import ghidra.framework.options.OptionsChangeListener;
@ -44,13 +45,18 @@ import ghidra.util.HelpLocation;
public class AddressTypeOverviewColorService public class AddressTypeOverviewColorService
implements OverviewColorService, OptionsChangeListener, DomainObjectListener { implements OverviewColorService, OptionsChangeListener, DomainObjectListener {
private static final String OPTIONS_NAME = "Overview"; private static final String OPTIONS_NAME = "Overview";
private static final Color DEFAULT_INSTRUCTION_COLOR = new Color(192, 192, 255); private static final Color DEFAULT_INSTRUCTION_COLOR =
private static final Color DEFAULT_DATA_COLOR = new Color(128, 255, 128); new GColor("color.bg.plugin.overview.address.instruction");
private static final Color DEFAULT_FUNCTION_COLOR = new Color(204, 150, 255); private static final Color DEFAULT_DATA_COLOR =
private static final Color DEFAULT_UNDEFINED_COLOR = new Color(255, 51, 102); new GColor("color.bg.plugin.overview.address.data");
private static final Color DEFAULT_UNINITIALIZED_COLOR = Color.BLACK; private static final Color DEFAULT_FUNCTION_COLOR =
private static final Color DEFAULT_EXTERNAL_REF_COLOR = new Color(255, 150, 150); new GColor("color.bg.plugin.overview.address.function");
private static final Color DEFAULT_MARKER_COLOR = Color.WHITE; private static final Color DEFAULT_UNDEFINED_COLOR =
new GColor("color.bg.plugin.overview.address.undefined");
private static final Color DEFAULT_UNINITIALIZED_COLOR =
new GColor("color.bg.plugin.overview.address.uninitialized");
private static final Color DEFAULT_EXTERNAL_REF_COLOR =
new GColor("color.bg.plugin.overview.address.external.ref");
Color instructionColor = DEFAULT_INSTRUCTION_COLOR; Color instructionColor = DEFAULT_INSTRUCTION_COLOR;
Color dataColor = DEFAULT_DATA_COLOR; Color dataColor = DEFAULT_DATA_COLOR;

View file

@ -17,6 +17,7 @@ package ghidra.app.plugin.core.overview.entropy;
import java.awt.Color; import java.awt.Color;
import generic.theme.GColor;
import ghidra.app.plugin.core.overview.OverviewColorPlugin; import ghidra.app.plugin.core.overview.OverviewColorPlugin;
import ghidra.framework.options.OptionsChangeListener; import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions; import ghidra.framework.options.ToolOptions;
@ -28,34 +29,51 @@ import ghidra.util.HelpLocation;
* the color Palette for that service. * the color Palette for that service.
*/ */
public class EntropyOverviewOptionsManager implements OptionsChangeListener { public class EntropyOverviewOptionsManager implements OptionsChangeListener {
private static final Color uninitializedColor = Color.decode("0x0000ff"); private static final Color UNINITIALIZED_COLOR =
new GColor("color.bg.plugin.overview.entropy.uninitialized");
private static final String OPTIONS_NAME = "Entropy"; private static final String OPTIONS_NAME = "Entropy";
private final static String CHUNKSIZE_STRING = "Chunk size"; private static final String CHUNKSIZE_STRING = "Chunk size";
private final static String CHUNKSIZE_DESC_STRING = "Number of bytes per entropy score"; private static final String CHUNKSIZE_DESC_STRING = "Number of bytes per entropy score";
private final static EntropyChunkSize chunksize_def = EntropyChunkSize.LARGE; private static final EntropyChunkSize CHUNKSIZE_DEF = EntropyChunkSize.LARGE;
private final static String KNOT_COLOR_STRING = private static final String KNOT_COLOR_STRING =
"Color to use for highlighting a specific range of entropy values"; "Color to use for highlighting a specific range of entropy values";
private final static String KNOT_TYPE_STRING = "Type of range to highlight"; private static final String KNOT_TYPE_STRING = "Type of range to highlight";
private final static String KNOT1_COLOR_STRING = "Range 1 color";
private final static String KNOT1_TYPE_STRING = "Entropy Range 1"; private static final String KNOT1_COLOR_STRING = "Range 1 color";
private final static Color knot1_def_color = Color.decode("0xff0000"); private static final String KNOT1_TYPE_STRING = "Entropy Range 1";
private final static EntropyKnot knot1_def_type = EntropyKnot.COMPRESSED; private static final Color KNOT1_DEF_COLOR =
private final static String KNOT2_COLOR_STRING = "Range 2 color"; new GColor("color.bg.plugin.overview.entropy.knot.1");
private final static String KNOT2_TYPE_STRING = "Entropy Range 2"; private static final EntropyKnot KNOT1_DEF_TYPE = EntropyKnot.COMPRESSED;
private final static Color knot2_def_color = Color.decode("0x0000ff");
private final static EntropyKnot knot2_def_type = EntropyKnot.X86; private static final String KNOT2_COLOR_STRING = "Range 2 color";
private final static String KNOT3_COLOR_STRING = "Range 3 color"; private static final String KNOT2_TYPE_STRING = "Entropy Range 2";
private final static String KNOT3_TYPE_STRING = "Entropy Range 3"; private static final Color KNOT2_DEF_COLOR =
private final static Color knot3_def_color = Color.decode("0x00ff00"); new GColor("color.bg.plugin.overview.entropy.knot.2");
private final static EntropyKnot knot3_def_type = EntropyKnot.ASCII; private static final EntropyKnot KNOT2_DEF_TYPE = EntropyKnot.X86;
private final static String KNOT4_COLOR_STRING = "Range 4 color";
private final static String KNOT4_TYPE_STRING = "Entropy Range 4"; private static final String KNOT3_COLOR_STRING = "Range 3 color";
private final static Color knot4_def_color = Color.decode("0xffff00"); private static final String KNOT3_TYPE_STRING = "Entropy Range 3";
private final static EntropyKnot knot4_def_type = EntropyKnot.UTF16; private static final Color KNOT3_DEF_COLOR =
private final static String KNOT5_COLOR_STRING = "Range 5 color"; new GColor("color.bg.plugin.overview.entropy.knot.3");
private final static String KNOT5_TYPE_STRING = "Entropy Range 5"; private static final EntropyKnot KNOT3_DEF_TYPE = EntropyKnot.ASCII;
private final static Color knot5_def_color = Color.decode("0x0000ff");
private final static EntropyKnot knot5_def_type = EntropyKnot.NONE; private static final String KNOT4_COLOR_STRING = "Range 4 color";
private static final String KNOT4_TYPE_STRING = "Entropy Range 4";
private static final Color KNOT4_DEF_COLOR =
new GColor("color.bg.plugin.overview.entropy.knot.4");
private static final EntropyKnot KNOT4_DEF_TYPE = EntropyKnot.UTF16;
private static final String KNOT5_COLOR_STRING = "Range 5 color";
private static final String KNOT5_TYPE_STRING = "Entropy Range 5";
private static final Color KNOT5_DEF_COLOR =
new GColor("color.bg.plugin.overview.entropy.knot.5");
private static final EntropyKnot KNOT5_DEF_TYPE = EntropyKnot.NONE;
private static final Color PALETTE_COLOR_HIGH =
new GColor("color.bg.plugin.overview.entropy.palette.base.high");
private static final Color PALETTE_COLOR_LOW =
new GColor("color.bg.plugin.overview.entropy.palette.base.low");
private EntropyChunkSize chunksize; private EntropyChunkSize chunksize;
private Color knot1color; private Color knot1color;
private EntropyKnot knot1type; private EntropyKnot knot1type;
@ -67,7 +85,7 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
private EntropyKnot knot4type; private EntropyKnot knot4type;
private Color knot5color; private Color knot5color;
private EntropyKnot knot5type; private EntropyKnot knot5type;
private Palette palette = new Palette(256, uninitializedColor); private Palette palette = new Palette(256, UNINITIALIZED_COLOR);
private EntropyOverviewColorService service; private EntropyOverviewColorService service;
public EntropyOverviewOptionsManager(PluginTool tool, EntropyOverviewColorService service) { public EntropyOverviewOptionsManager(PluginTool tool, EntropyOverviewColorService service) {
@ -78,18 +96,18 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
options.addOptionsChangeListener(this); options.addOptionsChangeListener(this);
options.setOptionsHelpLocation(help); options.setOptionsHelpLocation(help);
options.registerOption(CHUNKSIZE_STRING, chunksize_def, help, CHUNKSIZE_DESC_STRING); options.registerOption(CHUNKSIZE_STRING, CHUNKSIZE_DEF, help, CHUNKSIZE_DESC_STRING);
options.registerOption(KNOT1_COLOR_STRING, knot1_def_color, help, KNOT_COLOR_STRING); options.registerOption(KNOT1_COLOR_STRING, KNOT1_DEF_COLOR, help, KNOT_COLOR_STRING);
options.registerOption(KNOT2_COLOR_STRING, knot2_def_color, help, KNOT_COLOR_STRING); options.registerOption(KNOT2_COLOR_STRING, KNOT2_DEF_COLOR, help, KNOT_COLOR_STRING);
options.registerOption(KNOT3_COLOR_STRING, knot3_def_color, help, KNOT_COLOR_STRING); options.registerOption(KNOT3_COLOR_STRING, KNOT3_DEF_COLOR, help, KNOT_COLOR_STRING);
options.registerOption(KNOT4_COLOR_STRING, knot4_def_color, help, KNOT_COLOR_STRING); options.registerOption(KNOT4_COLOR_STRING, KNOT4_DEF_COLOR, help, KNOT_COLOR_STRING);
options.registerOption(KNOT5_COLOR_STRING, knot5_def_color, help, KNOT_COLOR_STRING); options.registerOption(KNOT5_COLOR_STRING, KNOT5_DEF_COLOR, help, KNOT_COLOR_STRING);
options.registerOption(KNOT1_TYPE_STRING, knot1_def_type, help, KNOT_TYPE_STRING); options.registerOption(KNOT1_TYPE_STRING, KNOT1_DEF_TYPE, help, KNOT_TYPE_STRING);
options.registerOption(KNOT2_TYPE_STRING, knot2_def_type, help, KNOT_TYPE_STRING); options.registerOption(KNOT2_TYPE_STRING, KNOT2_DEF_TYPE, help, KNOT_TYPE_STRING);
options.registerOption(KNOT3_TYPE_STRING, knot3_def_type, help, KNOT_TYPE_STRING); options.registerOption(KNOT3_TYPE_STRING, KNOT3_DEF_TYPE, help, KNOT_TYPE_STRING);
options.registerOption(KNOT4_TYPE_STRING, knot4_def_type, help, KNOT_TYPE_STRING); options.registerOption(KNOT4_TYPE_STRING, KNOT4_DEF_TYPE, help, KNOT_TYPE_STRING);
options.registerOption(KNOT5_TYPE_STRING, knot5_def_type, help, KNOT_TYPE_STRING); options.registerOption(KNOT5_TYPE_STRING, KNOT5_DEF_TYPE, help, KNOT_TYPE_STRING);
readOptions(options); readOptions(options);
updatePalettes(); updatePalettes();
@ -104,23 +122,23 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
} }
private void readOptions(ToolOptions options) { private void readOptions(ToolOptions options) {
chunksize = options.getEnum(CHUNKSIZE_STRING, chunksize_def); chunksize = options.getEnum(CHUNKSIZE_STRING, CHUNKSIZE_DEF);
knot1color = options.getColor(KNOT1_COLOR_STRING, knot1_def_color); knot1color = options.getColor(KNOT1_COLOR_STRING, KNOT1_DEF_COLOR);
knot2color = options.getColor(KNOT2_COLOR_STRING, knot2_def_color); knot2color = options.getColor(KNOT2_COLOR_STRING, KNOT2_DEF_COLOR);
knot3color = options.getColor(KNOT3_COLOR_STRING, knot3_def_color); knot3color = options.getColor(KNOT3_COLOR_STRING, KNOT3_DEF_COLOR);
knot4color = options.getColor(KNOT4_COLOR_STRING, knot4_def_color); knot4color = options.getColor(KNOT4_COLOR_STRING, KNOT4_DEF_COLOR);
knot5color = options.getColor(KNOT5_COLOR_STRING, knot5_def_color); knot5color = options.getColor(KNOT5_COLOR_STRING, KNOT5_DEF_COLOR);
knot1type = options.getEnum(KNOT1_TYPE_STRING, knot1_def_type); knot1type = options.getEnum(KNOT1_TYPE_STRING, KNOT1_DEF_TYPE);
knot2type = options.getEnum(KNOT2_TYPE_STRING, knot2_def_type); knot2type = options.getEnum(KNOT2_TYPE_STRING, KNOT2_DEF_TYPE);
knot3type = options.getEnum(KNOT3_TYPE_STRING, knot3_def_type); knot3type = options.getEnum(KNOT3_TYPE_STRING, KNOT3_DEF_TYPE);
knot4type = options.getEnum(KNOT4_TYPE_STRING, knot4_def_type); knot4type = options.getEnum(KNOT4_TYPE_STRING, KNOT4_DEF_TYPE);
knot5type = options.getEnum(KNOT5_TYPE_STRING, knot5_def_type); knot5type = options.getEnum(KNOT5_TYPE_STRING, KNOT5_DEF_TYPE);
} }
private void addPaletteKnot(String name, Color col, double point, double width) { private void addPaletteKnot(String name, Color color, double point, double width) {
int palettewidth = 256; int palettewidth = 256;
int pointint = (int) Math.floor((palettewidth / 8.0) * point); int pointint = (int) Math.floor((palettewidth / 8.0) * point);
if (pointint > 255) { if (pointint > 255) {
@ -131,11 +149,11 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
if (start < 0) { if (start < 0) {
start = 0; start = 0;
} }
palette.addKnot(name, col, start, pointint); palette.addKnot(name, color, start, pointint);
} }
private void updatePalettes() { private void updatePalettes() {
palette.setBase(Color.decode("0x000000"), Color.decode("0xffffff")); palette.setBase(PALETTE_COLOR_LOW, PALETTE_COLOR_HIGH);
addPaletteKnots(); addPaletteKnots();
service.paletteChanged(); service.paletteChanged();
} }

View file

@ -20,6 +20,8 @@ import java.util.ArrayList;
import javax.swing.JPanel; import javax.swing.JPanel;
import generic.theme.GThemeDefaults.Colors.Java;
public class KnotLabelPanel extends JPanel { public class KnotLabelPanel extends JPanel {
private static final Font FONT = new Font("Times New Roman", Font.BOLD, 16); private static final Font FONT = new Font("Times New Roman", Font.BOLD, 16);
private int topBottomMargin = 10; private int topBottomMargin = 10;
@ -52,7 +54,7 @@ public class KnotLabelPanel extends JPanel {
int fontOffset = ascent / 3; // this looks about right int fontOffset = ascent / 3; // this looks about right
ArrayList<KnotRecord> knots = palette.getKnots(); ArrayList<KnotRecord> knots = palette.getKnots();
g.setColor(Color.BLACK); g.setColor(Java.BORDER);
g.drawLine(5, topBottomMargin - 6, 10, topBottomMargin - ascent + 2); g.drawLine(5, topBottomMargin - 6, 10, topBottomMargin - ascent + 2);
g.drawString("min entropy (0.0)", 20, topBottomMargin - ascent - descent); g.drawString("min entropy (0.0)", 20, topBottomMargin - ascent - descent);
@ -67,7 +69,7 @@ public class KnotLabelPanel extends JPanel {
g.drawLine(5, y, 10, y); g.drawLine(5, y, 10, y);
} }
g.setColor(Color.BLACK); g.setColor(Java.BORDER);
g.drawLine(5, height + topBottomMargin + 4, 10, height + topBottomMargin + 8); g.drawLine(5, height + topBottomMargin + 4, 10, height + topBottomMargin + 8);
g.drawString("max entropy (8.0)", 20, topBottomMargin + height + ascent + descent); g.drawString("max entropy (8.0)", 20, topBottomMargin + height + ascent + descent);

View file

@ -22,28 +22,27 @@ import java.util.ArrayList;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.util.GraphicsUtils; import docking.util.GraphicsUtils;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Java;
/** /**
* Class used by the entropy legend panel to show known entropy ranges. * Class used by the entropy legend panel to show known entropy ranges.
*/ */
public class KnotPanel extends JPanel implements ComponentListener { public class KnotPanel extends JPanel implements ComponentListener {
private static final long serialVersionUID = 1L;
private static final int SPACING = 5; private static final int SPACING = 5;
private static final Font FONT = new Font("SansSerif", Font.PLAIN, 10); private static final Font FONT = new Font("SansSerif", Font.PLAIN, 10);
private static final Color FG_COLOR_TEXT =
new GColor("color.bg.plugin.overview.entropy.palette.text");
private Palette palette = null; private Palette palette = null;
private FontMetrics metrics; private FontMetrics metrics;
private ChangeListener paletteListener = new ChangeListener() { private ChangeListener paletteListener = e -> buildLabels();
@Override
public void stateChanged(ChangeEvent e) {
buildLabels();
}
};
public KnotPanel() { public KnotPanel() {
super(); super();
@ -63,7 +62,6 @@ public class KnotPanel extends JPanel implements ComponentListener {
return; return;
} }
g.setColor(Color.BLACK);
g.setFont(FONT); g.setFont(FONT);
int height = getHeight(); int height = getHeight();
int width = getWidth(); int width = getWidth();
@ -72,8 +70,8 @@ public class KnotPanel extends JPanel implements ComponentListener {
int baseline = (height - fontHeight - 1) / 2 + metrics.getMaxAscent(); int baseline = (height - fontHeight - 1) / 2 + metrics.getMaxAscent();
ArrayList<KnotRecord> knots = palette.getKnots(); ArrayList<KnotRecord> knots = palette.getKnots();
for (int i = 0; i < knots.size(); i++) { for (KnotRecord rec : knots) {
KnotRecord rec = knots.get(i); g.setColor(Java.BORDER);
int start = (rec.start * width) / palsize; int start = (rec.start * width) / palsize;
int end = (rec.end * width) / palsize; int end = (rec.end * width) / palsize;
g.drawLine(start, 0, start, height - 1); g.drawLine(start, 0, start, height - 1);
@ -92,6 +90,7 @@ public class KnotPanel extends JPanel implements ComponentListener {
} }
} }
g.setColor(FG_COLOR_TEXT);
if (w < knotwidth) { // we found a suitable font if (w < knotwidth) { // we found a suitable font
g.setFont(currentMetrics.getFont()); g.setFont(currentMetrics.getFont());
GraphicsUtils.drawString(this, g, rec.name, start + (knotwidth - 1) / 2 - w / 2, GraphicsUtils.drawString(this, g, rec.name, start + (knotwidth - 1) / 2 - w / 2,
@ -136,7 +135,7 @@ public class KnotPanel extends JPanel implements ComponentListener {
for (KnotRecord record : knots) { for (KnotRecord record : knots) {
JLabel label = new GLabel(record.name); JLabel label = new GLabel(record.name);
label.setFont(FONT); label.setFont(FONT);
label.setBorder(new ToplessLineBorder(Color.BLACK)); label.setBorder(new ToplessLineBorder(Java.BORDER));
label.setHorizontalAlignment(SwingConstants.CENTER); label.setHorizontalAlignment(SwingConstants.CENTER);
label.setToolTipText(record.name); label.setToolTipText(record.name);

View file

@ -21,6 +21,7 @@ import java.util.ArrayList;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import generic.theme.TempColorUtils;
import ghidra.util.datastruct.WeakDataStructureFactory; import ghidra.util.datastruct.WeakDataStructureFactory;
import ghidra.util.datastruct.WeakSet; import ghidra.util.datastruct.WeakSet;
@ -75,7 +76,7 @@ public class Palette {
int green = (int) (lo.getGreen() * (1.0 - t) + hi.getGreen() * t); int green = (int) (lo.getGreen() * (1.0 - t) + hi.getGreen() * t);
int blue = (int) (lo.getBlue() * (1.0 - t) + hi.getGreen() * t); int blue = (int) (lo.getBlue() * (1.0 - t) + hi.getGreen() * t);
t += step; t += step;
colors[i] = new Color(red, green, blue); colors[i] = TempColorUtils.fromRgb(red, green, blue);
} }
knots.clear(); knots.clear();
firePaletteChanged(); firePaletteChanged();
@ -111,7 +112,7 @@ public class Palette {
int green = (int) Math.floor(tmp); int green = (int) Math.floor(tmp);
tmp = (knot.getBlue() - oldcolor.getBlue()) * t + oldcolor.getBlue(); tmp = (knot.getBlue() - oldcolor.getBlue()) * t + oldcolor.getBlue();
int blue = (int) Math.floor(tmp); int blue = (int) Math.floor(tmp);
colors[start] = new Color(red, green, blue); colors[start] = TempColorUtils.fromRgb(red, green, blue);
cur += radianstep; cur += radianstep;
start += 1; start += 1;
} }

View file

@ -19,6 +19,8 @@ import java.awt.*;
import javax.swing.JPanel; import javax.swing.JPanel;
import generic.theme.GThemeDefaults.Colors.Java;
public class PalettePanel extends JPanel { public class PalettePanel extends JPanel {
private Palette palette; private Palette palette;
@ -45,12 +47,12 @@ public class PalettePanel extends JPanel {
g.setColor(getBackground()); g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.BLACK); g.setColor(Java.BORDER);
if (palette == null) { if (palette == null) {
g.setColor(Color.BLACK);
g.drawRect(0, 0, width - 1, height - 1); g.drawRect(0, 0, width - 1, height - 1);
return; return;
} }
int palsize = palette.getSize(); int palsize = palette.getSize();
//Draw the rectangles for each pixel //Draw the rectangles for each pixel
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
@ -62,7 +64,7 @@ public class PalettePanel extends JPanel {
g.setColor(c); g.setColor(c);
g.fillRect(0, topBottomMargin + i, width, 1); g.fillRect(0, topBottomMargin + i, width, 1);
} }
g.setColor(Color.BLACK); g.setColor(Java.BORDER);
g.drawRect(0, topBottomMargin, width - 1, height); g.drawRect(0, topBottomMargin, width - 1, height);
} }

View file

@ -27,13 +27,14 @@ import docking.widgets.fieldpanel.LayoutModel;
import docking.widgets.fieldpanel.internal.EmptyLayoutBackgroundColorManager; import docking.widgets.fieldpanel.internal.EmptyLayoutBackgroundColorManager;
import docking.widgets.fieldpanel.internal.LayoutBackgroundColorManager; import docking.widgets.fieldpanel.internal.LayoutBackgroundColorManager;
import docking.widgets.fieldpanel.internal.PaintContext; import docking.widgets.fieldpanel.internal.PaintContext;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import ghidra.util.DateUtils; import ghidra.util.DateUtils;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
public class CodeUnitPrintable implements Printable { public class CodeUnitPrintable implements Printable {
//private FieldPanel panel;
private LayoutModel lm; private LayoutModel lm;
private int startIndex; private int startIndex;
private int endIndex; private int endIndex;
@ -48,11 +49,11 @@ public class CodeUnitPrintable implements Printable {
private static final PaintContext PAINT_CONTEXT = new PaintContext(); private static final PaintContext PAINT_CONTEXT = new PaintContext();
static { static {
PAINT_CONTEXT.setForegroundColor(Color.BLACK); PAINT_CONTEXT.setForegroundColor(Colors.FOREGROUND);
PAINT_CONTEXT.setBackgroundColor(Color.WHITE); PAINT_CONTEXT.setBackgroundColor(Colors.BACKGROUND);
PAINT_CONTEXT.setCursorColor(Color.RED); PAINT_CONTEXT.setCursorColor(Colors.CURSOR);
PAINT_CONTEXT.setSelectionColor(new Color(180, 255, 180)); PAINT_CONTEXT.setSelectionColor(new GColor("color.bg.selection"));
PAINT_CONTEXT.setHighlightColor(new Color(255, 255, 150)); PAINT_CONTEXT.setHighlightColor(new GColor("color.bg.highlight"));
PAINT_CONTEXT.setPrinting(true); PAINT_CONTEXT.setPrinting(true);
} }
@ -69,13 +70,6 @@ public class CodeUnitPrintable implements Printable {
this.book = book; this.book = book;
this.job = job; this.job = job;
this.startDate = startDate; this.startDate = startDate;
if (pod.getMonochrome()) {
PAINT_CONTEXT.setPrintColor(Color.BLACK);
}
else {
PAINT_CONTEXT.setPrintColor(null);
}
} }
public CodeUnitPrintable(LayoutModel lm, java.util.List<Layout> layouts, double scaleAmount, public CodeUnitPrintable(LayoutModel lm, java.util.List<Layout> layouts, double scaleAmount,
@ -89,20 +83,13 @@ public class CodeUnitPrintable implements Printable {
this.book = book; this.book = book;
this.job = job; this.job = job;
this.startDate = startDate; this.startDate = startDate;
if (pod.getMonochrome()) {
PAINT_CONTEXT.setPrintColor(Color.BLACK);
}
else {
PAINT_CONTEXT.setPrintColor(null);
}
} }
@Override @Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
throws PrinterException { throws PrinterException {
Graphics2D g2 = GraphicsUtils.getGraphics2D(graphics); Graphics2D g2 = GraphicsUtils.getGraphics2D(graphics);
g2.setColor(Color.BLACK); g2.setColor(Colors.FOREGROUND);
monitor.setMessage("Printing Page " + (pageIndex + 1)); monitor.setMessage("Printing Page " + (pageIndex + 1));
monitor.initialize(100); monitor.initialize(100);

View file

@ -56,6 +56,8 @@ public class MultiTabPanel extends JPanel {
private final static Color BG_SELECTION_COLOR = SELECTED_TAB_COLOR; private final static Color BG_SELECTION_COLOR = SELECTED_TAB_COLOR;
private final static Color BG_NON_SELECTION_COLOR = private final static Color BG_NON_SELECTION_COLOR =
new GColor("color.bg.listing.tabs.unselected"); new GColor("color.bg.listing.tabs.unselected");
private static final Color BG_COLOR_MORE_TABS_HOVER =
new GColor("color.bg.listing.tabs.more.tabs.hover");
private static final Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 11); private static final Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 11);
private static final Font LIST_LABEL_FONT = new Font("Tahoma", Font.BOLD, 9); private static final Font LIST_LABEL_FONT = new Font("Tahoma", Font.BOLD, 9);
@ -209,8 +211,6 @@ public class MultiTabPanel extends JPanel {
return false; return false;
} }
////////////////////////////////////////////////////////////
private TabPanel createProgramTab(final Program program, boolean isSelected) { private TabPanel createProgramTab(final Program program, boolean isSelected) {
final JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 1)); final JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 1));
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
@ -639,7 +639,7 @@ public class MultiTabPanel extends JPanel {
newLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4)); newLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4));
newLabel.setToolTipText("Show Tab List"); newLabel.setToolTipText("Show Tab List");
newLabel.setName("showList"); newLabel.setName("showList");
newLabel.setBackground(new Color(255, 226, 213)); newLabel.setBackground(BG_COLOR_MORE_TABS_HOVER);
defaultListLabelBorder = newLabel.getBorder(); defaultListLabelBorder = newLabel.getBorder();
final Border hoverBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED); final Border hoverBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED);

View file

@ -24,6 +24,7 @@ import javax.swing.tree.DefaultTreeCellRenderer;
import docking.widgets.GComponent; import docking.widgets.GComponent;
import generic.theme.GColor; import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import ghidra.program.model.listing.Group; import ghidra.program.model.listing.Group;
import resources.ResourceManager; import resources.ResourceManager;
@ -344,7 +345,7 @@ class DnDTreeCellRenderer extends DefaultTreeCellRenderer {
cutImage.getHeight(null), BufferedImage.TYPE_INT_ARGB); cutImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bufferedImage.createGraphics(); Graphics2D g2d = bufferedImage.createGraphics();
g2d.drawImage(cutImage, 0, 0, null); g2d.drawImage(cutImage, 0, 0, null);
g2d.setColor(new Color(255, 255, 255, 128)); g2d.setColor(Colors.DISABLED);
g2d.fillRect(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight()); g2d.fillRect(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight());
return ResourceManager.getImageIconFromImage(imageName, bufferedImage); return ResourceManager.getImageIconFromImage(imageName, bufferedImage);
} }

View file

@ -29,6 +29,8 @@ import docking.DockingUtils;
import docking.actions.KeyBindingUtils; import docking.actions.KeyBindingUtils;
import docking.dnd.*; import docking.dnd.*;
import docking.widgets.table.AutoscrollAdapter; import docking.widgets.table.AutoscrollAdapter;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
/** /**
* Class to support Drag and Drop; it is also responsible for * Class to support Drag and Drop; it is also responsible for
@ -37,6 +39,9 @@ import docking.widgets.table.AutoscrollAdapter;
*/ */
public abstract class DragNDropTree extends JTree implements Draggable, Droppable, Autoscroll { public abstract class DragNDropTree extends JTree implements Draggable, Droppable, Autoscroll {
private static final Color BG_COLOR_DRAG_NO_SELECTION =
new GColor("color.bg.tree.drag.no.selection");
private AutoscrollAdapter autoscroller; private AutoscrollAdapter autoscroller;
protected DefaultTreeModel treeModel; protected DefaultTreeModel treeModel;
@ -63,13 +68,6 @@ public abstract class DragNDropTree extends JTree implements Draggable, Droppabl
protected Color nonSelectionDragColor; protected Color nonSelectionDragColor;
protected int relativeMousePos; // mouse position within the node: protected int relativeMousePos; // mouse position within the node:
// -1 --> above node,
// 0 --> at the node
// 1 --> below the node
/**
* Construct a new DragNDropTree.
*/
public DragNDropTree(DefaultTreeModel model) { public DragNDropTree(DefaultTreeModel model) {
super(model); super(model);
treeModel = model; treeModel = model;
@ -82,7 +80,7 @@ public abstract class DragNDropTree extends JTree implements Draggable, Droppabl
dndCellRenderer = new DnDTreeCellRenderer(); dndCellRenderer = new DnDTreeCellRenderer();
setCellRenderer(dndCellRenderer); setCellRenderer(dndCellRenderer);
plafSelectionColor = dndCellRenderer.getBackgroundSelectionColor(); plafSelectionColor = dndCellRenderer.getBackgroundSelectionColor();
nonSelectionDragColor = new Color(204, 204, 255); nonSelectionDragColor = BG_COLOR_DRAG_NO_SELECTION;
initDragNDrop(); initDragNDrop();
ToolTipManager.sharedInstance().registerComponent(this); ToolTipManager.sharedInstance().registerComponent(this);
autoscroller = new AutoscrollAdapter(this, getRowHeight()); autoscroller = new AutoscrollAdapter(this, getRowHeight());
@ -164,7 +162,8 @@ public abstract class DragNDropTree extends JTree implements Draggable, Droppabl
public void dragCanceled(DragSourceDropEvent event) { public void dragCanceled(DragSourceDropEvent event) {
draggedNodes = null; draggedNodes = null;
dndCellRenderer.setBackgroundSelectionColor(plafSelectionColor); dndCellRenderer.setBackgroundSelectionColor(plafSelectionColor);
dndCellRenderer.setBackgroundNonSelectionColor(dndCellRenderer.getBackgroundNonSelectionColor()); dndCellRenderer
.setBackgroundNonSelectionColor(dndCellRenderer.getBackgroundNonSelectionColor());
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -263,8 +262,8 @@ public abstract class DragNDropTree extends JTree implements Draggable, Droppabl
} }
else { else {
destinationNode = null; destinationNode = null;
dndCellRenderer.setSelectionForDrag(Color.red); dndCellRenderer.setSelectionForDrag(Colors.ERROR);
dndCellRenderer.setNonSelectionForDrag(Color.red); dndCellRenderer.setNonSelectionForDrag(Colors.ERROR);
} }
Point p = e.getLocation(); Point p = e.getLocation();
dndCellRenderer.setRowForFeedback(getRowForLocation(p.x, p.y)); dndCellRenderer.setRowForFeedback(getRowForLocation(p.x, p.y));

View file

@ -24,8 +24,6 @@ import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import org.jdom.Element; import org.jdom.Element;
@ -34,6 +32,8 @@ import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GhidraComboBox; import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Java;
import ghidra.app.util.AddressInput; import ghidra.app.util.AddressInput;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
@ -83,13 +83,7 @@ class EditMemoryReferencePanel extends EditReferencePanel {
@Override @Override
public void requestFocus() { public void requestFocus() {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(() -> toAddressField.requestFocus());
@Override
public void run() {
// do later to override the default later nature of focus
toAddressField.requestFocus();
}
});
} }
private void buildPanel() { private void buildPanel() {
@ -97,12 +91,7 @@ class EditMemoryReferencePanel extends EditReferencePanel {
offsetCheckbox = new GCheckBox("Offset:"); offsetCheckbox = new GCheckBox("Offset:");
offsetCheckbox.setHorizontalAlignment(SwingConstants.RIGHT); offsetCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
offsetCheckbox.addChangeListener(new ChangeListener() { offsetCheckbox.addChangeListener(e -> enableOffsetField(offsetCheckbox.isSelected()));
@Override
public void stateChanged(ChangeEvent e) {
enableOffsetField(offsetCheckbox.isSelected());
}
});
offsetField = new JTextField(); offsetField = new JTextField();
addrLabel = new GDLabel("Base Address:"); addrLabel = new GDLabel("Base Address:");
@ -150,11 +139,11 @@ class EditMemoryReferencePanel extends EditReferencePanel {
enableOffsetField(false); enableOffsetField(false);
} }
private void enableOffsetField(boolean state) { private void enableOffsetField(boolean enabled) {
offsetCheckbox.setSelected(state); offsetCheckbox.setSelected(enabled);
offsetField.setEnabled(state); offsetField.setEnabled(enabled);
offsetField.setBackground(state ? Color.WHITE : getBackground()); offsetField.setBackground(enabled ? Colors.BACKGROUND : getBackground());
if (!state) { if (!enabled) {
offsetField.setText("0x0"); offsetField.setText("0x0");
} }
else { else {
@ -173,7 +162,7 @@ class EditMemoryReferencePanel extends EditReferencePanel {
} }
} }
} }
addrLabel.setText(state ? "Base Address:" : "To Address:"); addrLabel.setText(enabled ? "Base Address:" : "To Address:");
} }
private void populateRefTypes(RefType adhocType) { private void populateRefTypes(RefType adhocType) {
@ -304,8 +293,9 @@ class EditMemoryReferencePanel extends EditReferencePanel {
toAddr = fromCu.getAddress(fromOpIndex); toAddr = fromCu.getAddress(fromOpIndex);
} }
if (toAddr != null) { if (toAddr != null) {
Reference r = p.getReferenceManager().getReference(fromCu.getMinAddress(), toAddr, Reference r = p.getReferenceManager()
fromOpIndex); .getReference(fromCu.getMinAddress(), toAddr,
fromOpIndex);
if (r != null) { if (r != null) {
toAddr = null; toAddr = null;
if (r.isOffsetReference()) { if (r.isOffsetReference()) {
@ -540,7 +530,7 @@ class EditMemoryReferencePanel extends EditReferencePanel {
model = new HistoryTableModel(fromCodeUnit.getProgram()); model = new HistoryTableModel(fromCodeUnit.getProgram());
displayTable = new JTable(model); displayTable = new JTable(model);
displayTable.setTableHeader(null); displayTable.setTableHeader(null);
displayTable.setBorder(new LineBorder(Color.BLACK)); displayTable.setBorder(new LineBorder(Java.BORDER));
displayTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); displayTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
displayTable.addMouseListener(new MouseAdapter() { displayTable.addMouseListener(new MouseAdapter() {
@ -588,24 +578,26 @@ class EditMemoryReferencePanel extends EditReferencePanel {
p.y += toAddressField.getHeight(); p.y += toAddressField.getHeight();
historyWin.setLocation(p); historyWin.setLocation(p);
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener( KeyboardFocusManager.getCurrentKeyboardFocusManager()
"focusOwner", new PropertyChangeListener() { .addPropertyChangeListener(
boolean hasFocus = false; "focusOwner", new PropertyChangeListener() {
boolean hasFocus = false;
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
Object focusOwner = evt.getNewValue(); Object focusOwner = evt.getNewValue();
if (focusOwner == displayTable || focusOwner == historyWin) { if (focusOwner == displayTable || focusOwner == historyWin) {
hasFocus = true; hasFocus = true;
} }
else if (hasFocus) { else if (hasFocus) {
hasFocus = false; hasFocus = false;
KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener( KeyboardFocusManager.getCurrentKeyboardFocusManager()
"focusOwner", this); .removePropertyChangeListener(
hideAddressHistoryPopup(); "focusOwner", this);
} hideAddressHistoryPopup();
} }
}); }
});
historyWin.setVisible(true); historyWin.setVisible(true);

View file

@ -35,6 +35,8 @@ import docking.dnd.DropTgtAdapter;
import docking.dnd.Droppable; import docking.dnd.Droppable;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.table.*; import docking.widgets.table.*;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Tables;
import ghidra.app.events.ProgramSelectionPluginEvent; import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.util.SelectionTransferData; import ghidra.app.util.SelectionTransferData;
import ghidra.app.util.SelectionTransferable; import ghidra.app.util.SelectionTransferable;
@ -76,7 +78,8 @@ public class EditReferencesProvider extends ComponentProviderAdapter
static int MNEMONIC_OPINDEX = ReferenceManager.MNEMONIC; static int MNEMONIC_OPINDEX = ReferenceManager.MNEMONIC;
static Color HIGHLIGHT_COLOR = new Color(205, 205, 205); static Color BG_COLOR_ACTIVE_OPERAND =
new GColor("color.bg.plugin.references.table.active.operand");
private static final DataFlavor[] ACCEPTABLE_DROP_FLAVORS = private static final DataFlavor[] ACCEPTABLE_DROP_FLAVORS =
new DataFlavor[] { SelectionTransferable.localProgramSelectionFlavor }; new DataFlavor[] { SelectionTransferable.localProgramSelectionFlavor };
@ -132,8 +135,9 @@ public class EditReferencesProvider extends ComponentProviderAdapter
if (currentCodeUnit != null) { if (currentCodeUnit != null) {
Memory memory = currentCodeUnit.getProgram().getMemory(); Memory memory = currentCodeUnit.getProgram().getMemory();
try { try {
Object data = e.getTransferable().getTransferData( Object data = e.getTransferable()
SelectionTransferable.localProgramSelectionFlavor); .getTransferData(
SelectionTransferable.localProgramSelectionFlavor);
AddressSetView view = ((SelectionTransferData) data).getAddressSet(); AddressSetView view = ((SelectionTransferData) data).getAddressSet();
if (memory.contains(view)) { if (memory.contains(view)) {
return true; return true;
@ -530,7 +534,7 @@ public class EditReferencesProvider extends ComponentProviderAdapter
private Data findComponent(Data data, Address addr) { private Data findComponent(Data data, Address addr) {
while (addr.compareTo(data.getMinAddress()) >= 0) { while (addr.compareTo(data.getMinAddress()) >= 0) {
long offset = addr.subtract(data.getMinAddress()); long offset = addr.subtract(data.getMinAddress());
Data d = data.getComponentAt((int) offset); Data d = data.getComponentContaining((int) offset);
if (d == null) { if (d == null) {
break; break;
} }
@ -954,8 +958,8 @@ public class EditReferencesProvider extends ComponentProviderAdapter
if (!isSelected) { if (!isSelected) {
if (ref.getOperandIndex() == instrPanel.getSelectedOpIndex()) { if (ref.getOperandIndex() == instrPanel.getSelectedOpIndex()) {
cb.setBackground(HIGHLIGHT_COLOR); cb.setBackground(BG_COLOR_ACTIVE_OPERAND);
setBackground(HIGHLIGHT_COLOR); setBackground(BG_COLOR_ACTIVE_OPERAND);
cb.setOpaque(true); cb.setOpaque(true);
} }
} }
@ -1004,7 +1008,7 @@ public class EditReferencesProvider extends ComponentProviderAdapter
else { else {
if (ref.getOperandIndex() == instrPanel.getSelectedOpIndex()) { if (ref.getOperandIndex() == instrPanel.getSelectedOpIndex()) {
checkbox.setForeground(table.getForeground()); checkbox.setForeground(table.getForeground());
checkbox.setBackground(HIGHLIGHT_COLOR); checkbox.setBackground(BG_COLOR_ACTIVE_OPERAND);
checkbox.setOpaque(true); checkbox.setOpaque(true);
} }
else { else {
@ -1047,7 +1051,7 @@ public class EditReferencesProvider extends ComponentProviderAdapter
if (isSelected) { if (isSelected) {
if (bad) { if (bad) {
setForeground(Color.pink); setForeground(Tables.FG_ERROR_SELECTED);
setFont(boldFont); setFont(boldFont);
} }
else { else {
@ -1060,14 +1064,14 @@ public class EditReferencesProvider extends ComponentProviderAdapter
// set color to red if address does not exist in memory // set color to red if address does not exist in memory
if (bad) { if (bad) {
setForeground(Color.red); setForeground(Tables.FG_ERROR_UNSELECTED);
setFont(boldFont); setFont(boldFont);
} }
else { else {
setFont(defaultFont); setFont(defaultFont);
} }
if (ref.getOperandIndex() == instrPanel.getSelectedOpIndex()) { if (ref.getOperandIndex() == instrPanel.getSelectedOpIndex()) {
setBackground(HIGHLIGHT_COLOR); setBackground(BG_COLOR_ACTIVE_OPERAND);
setOpaque(true); setOpaque(true);
} }
} }

View file

@ -32,6 +32,7 @@ import docking.actions.KeyBindingUtils;
import docking.dnd.DropTgtAdapter; import docking.dnd.DropTgtAdapter;
import docking.dnd.Droppable; import docking.dnd.Droppable;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.util.*; import ghidra.app.util.*;
import ghidra.app.util.viewer.field.BrowserCodeUnitFormat; import ghidra.app.util.viewer.field.BrowserCodeUnitFormat;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -43,15 +44,13 @@ import ghidra.program.model.symbol.*;
class InstructionPanel extends JPanel implements ChangeListener { class InstructionPanel extends JPanel implements ChangeListener {
private static final int ETCHED_BORDER_THICKNESS = 2; private static final int BORDER_SIZE = 2;
private static final Border EMPTY_BORDER = new EmptyBorder(BORDER_SIZE,
BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
private static final Border ETCHED_BORDER = new EtchedBorder();
private static final Border ETCHED_BORDER = new EtchedBorder(Color.BLACK, Color.GRAY); private final static Color NOT_IN_MEMORY_COLOR = Colors.ERROR;
private static final Border EMPTY_BORDER = new EmptyBorder(ETCHED_BORDER_THICKNESS, private final static Color DEFAULT_FG_COLOR = Colors.FOREGROUND;
ETCHED_BORDER_THICKNESS, ETCHED_BORDER_THICKNESS, ETCHED_BORDER_THICKNESS);
private final static Color UNLOCKED_LABEL_COLOR = Color.blue;
private final static Color NOT_IN_MEMORY_COLOR = Color.red;
private final static Color DEFAULT_FG_COLOR = Color.black;
private static final DataFlavor[] ACCEPTABLE_DROP_FLAVORS = private static final DataFlavor[] ACCEPTABLE_DROP_FLAVORS =
new DataFlavor[] { SelectionTransferable.localProgramSelectionFlavor }; new DataFlavor[] { SelectionTransferable.localProgramSelectionFlavor };
@ -85,13 +84,13 @@ class InstructionPanel extends JPanel implements ChangeListener {
*/ */
@Override @Override
public void dragUnderFeedback(boolean ok, DropTargetDragEvent e) { public void dragUnderFeedback(boolean ok, DropTargetDragEvent e) {
// stub
} }
/** /**
* Return true if is OK to drop the transferable at the location * Return true if is OK to drop the transferable at the location
* specified the event. * specified the event.
* @param e event that has current state of drag and drop operation * @param e event that has current state of drag and drop operation
* @param data data that is being dragged
*/ */
@Override @Override
public boolean isDropOk(DropTargetDragEvent e) { public boolean isDropOk(DropTargetDragEvent e) {
@ -102,26 +101,27 @@ class InstructionPanel extends JPanel implements ChangeListener {
updateLabels(getLabelIndex((JLabel) targetComp), -1); updateLabels(getLabelIndex((JLabel) targetComp), -1);
try { try {
Object data = e.getTransferable().getTransferData( Object data = e.getTransferable()
SelectionTransferable.localProgramSelectionFlavor); .getTransferData(
SelectionTransferable.localProgramSelectionFlavor);
AddressSetView view = ((SelectionTransferData) data).getAddressSet(); AddressSetView view = ((SelectionTransferData) data).getAddressSet();
if (memory.contains(view)) { if (memory.contains(view)) {
return true; return true;
} }
} }
catch (UnsupportedFlavorException e1) { catch (UnsupportedFlavorException e1) {
// return false
} }
catch (IOException e1) { catch (IOException e1) {
// return false
} }
} }
return false; return false;
} }
/**
* Revert back to normal if any drag feedback was set.
*/
@Override @Override
public void undoDragUnderFeedback() { public void undoDragUnderFeedback() {
// stub
} }
/** /**
@ -156,9 +156,6 @@ class InstructionPanel extends JPanel implements ChangeListener {
create(topPad, leftPad, bottomPad, rightPad); create(topPad, leftPad, bottomPad, rightPad);
} }
/**
* Returns the current code unit displayed.
*/
CodeUnit getCurrentCodeUnit() { CodeUnit getCurrentCodeUnit() {
return currentCodeUnit; return currentCodeUnit;
} }
@ -168,14 +165,6 @@ class InstructionPanel extends JPanel implements ChangeListener {
updateLabels(activeIndex, activeSubIndex); updateLabels(activeIndex, activeSubIndex);
} }
/**
* Set the code unit location.
* @param cu code unit
* @param loc location
* @param opIndex operand index
* @param showBlockID ID for what to show for the block name in the
* operand
*/
void setCodeUnitLocation(CodeUnit cu, int opIndex, int subIndex, boolean locked) { void setCodeUnitLocation(CodeUnit cu, int opIndex, int subIndex, boolean locked) {
if (cu != null) { if (cu != null) {
this.locked = locked; this.locked = locked;
@ -286,7 +275,7 @@ class InstructionPanel extends JPanel implements ChangeListener {
/** /**
* Enable drop on specified number of operands. * Enable drop on specified number of operands.
* A value of -1 will disable all drop targets. * A value of -1 will disable all drop targets.
* @param numOperands * @param numOperands the number of operands
*/ */
private void updateDropTargets(int numOperands) { private void updateDropTargets(int numOperands) {
++numOperands; ++numOperands;
@ -374,7 +363,7 @@ class InstructionPanel extends JPanel implements ChangeListener {
if (activeIndex == opIndex) { if (activeIndex == opIndex) {
operandLabels[opIndex].setBorder(ETCHED_BORDER); operandLabels[opIndex].setBorder(ETCHED_BORDER);
operandLabels[opIndex].setBackground(EditReferencesProvider.HIGHLIGHT_COLOR); operandLabels[opIndex].setBackground(EditReferencesProvider.BG_COLOR_ACTIVE_OPERAND);
operandLabels[opIndex].setOpaque(true); operandLabels[opIndex].setOpaque(true);
} }
else { else {
@ -393,7 +382,7 @@ class InstructionPanel extends JPanel implements ChangeListener {
mnemonicLabel.setForeground(DEFAULT_FG_COLOR); mnemonicLabel.setForeground(DEFAULT_FG_COLOR);
if (activeIndex == ReferenceManager.MNEMONIC) { if (activeIndex == ReferenceManager.MNEMONIC) {
mnemonicLabel.setBackground(EditReferencesProvider.HIGHLIGHT_COLOR); mnemonicLabel.setBackground(EditReferencesProvider.BG_COLOR_ACTIVE_OPERAND);
mnemonicLabel.setBorder(ETCHED_BORDER); mnemonicLabel.setBorder(ETCHED_BORDER);
mnemonicLabel.setOpaque(true); mnemonicLabel.setOpaque(true);
} }

View file

@ -26,6 +26,7 @@ import javax.swing.*;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.table.*; import docking.widgets.table.*;
import generic.theme.GColor;
import ghidra.app.cmd.register.SetRegisterCmd; import ghidra.app.cmd.register.SetRegisterCmd;
import ghidra.app.events.ProgramSelectionPluginEvent; import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.services.*; import ghidra.app.services.*;
@ -45,7 +46,8 @@ class RegisterValuesPanel extends JPanel {
private static final String VALUE_COLUMN_NAME = "Value"; private static final String VALUE_COLUMN_NAME = "Value";
private static final String START_ADDRESS_COLUMN_NAME = "Start Address"; private static final String START_ADDRESS_COLUMN_NAME = "Start Address";
private static final String END_ADDRESS_COLUMN_NAME = "End Address"; private static final String END_ADDRESS_COLUMN_NAME = "End Address";
private static final Color REGISTER_MARKER_COLOR = new Color(0, 153, 153); private static final Color REGISTER_MARKER_COLOR =
new GColor("color.bg.plugin.register.marker");
private Program currentProgram; private Program currentProgram;
private GhidraTable table; private GhidraTable table;

View file

@ -33,6 +33,7 @@ import docking.actions.KeyBindingUtils;
import docking.options.editor.FontEditor; import docking.options.editor.FontEditor;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import generic.jar.ResourceFile; import generic.jar.ResourceFile;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.script.GhidraScriptUtil; import ghidra.app.script.GhidraScriptUtil;
import ghidra.framework.options.SaveState; import ghidra.framework.options.SaveState;
import ghidra.util.*; import ghidra.util.*;
@ -41,7 +42,7 @@ import resources.Icons;
import resources.ResourceManager; import resources.ResourceManager;
public class GhidraScriptEditorComponentProvider extends ComponentProvider { public class GhidraScriptEditorComponentProvider extends ComponentProvider {
static final String EDITOR_COMPONENT_NAME="EDITOR"; static final String EDITOR_COMPONENT_NAME = "EDITOR";
static final String CHANGE_DESTINATION_TITLE = "Where Would You Like to Store Your Changes?"; static final String CHANGE_DESTINATION_TITLE = "Where Would You Like to Store Your Changes?";
static final String FILE_ON_DISK_CHANGED_TITLE = "File Changed on Disk"; static final String FILE_ON_DISK_CHANGED_TITLE = "File Changed on Disk";
@ -69,7 +70,6 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
saveState.putInt("DEFAULT_FONT_SIZE", defaultFont.getSize()); saveState.putInt("DEFAULT_FONT_SIZE", defaultFont.getSize());
} }
private GhidraScriptMgrPlugin plugin; private GhidraScriptMgrPlugin plugin;
private GhidraScriptComponentProvider provider; private GhidraScriptComponentProvider provider;
private String title; private String title;
@ -227,7 +227,8 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
@Override @Override
public boolean isEnabledForContext(ActionContext context) { public boolean isEnabledForContext(ActionContext context) {
Object contextObject = context.getContextObject(); Object contextObject = context.getContextObject();
return contextObject == GhidraScriptEditorComponentProvider.this && !undoStack.isEmpty(); return contextObject == GhidraScriptEditorComponentProvider.this &&
!undoStack.isEmpty();
} }
}; };
undoAction.setDescription("Undo"); undoAction.setDescription("Undo");
@ -247,7 +248,8 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
@Override @Override
public boolean isEnabledForContext(ActionContext context) { public boolean isEnabledForContext(ActionContext context) {
Object contextObject = context.getContextObject(); Object contextObject = context.getContextObject();
return contextObject == GhidraScriptEditorComponentProvider.this && !redoStack.isEmpty(); return contextObject == GhidraScriptEditorComponentProvider.this &&
!redoStack.isEmpty();
} }
}; };
redoAction.setDescription("Redo"); redoAction.setDescription("Redo");
@ -447,7 +449,8 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
int choice = OptionDialog.showOptionDialog(scrollPane, FILE_ON_DISK_CHANGED_TITLE, int choice = OptionDialog.showOptionDialog(scrollPane, FILE_ON_DISK_CHANGED_TITLE,
"<html>The contents of the script file have changed on disk.<br><br>Would " + "<html>The contents of the script file have changed on disk.<br><br>Would " +
"you like to <b>keep your changes</b> in the editor or <b><font color=\"red\">" + "you like to <b>keep your changes</b> in the editor or <b><font color=\"" +
Colors.ERROR.toHexString() + "\">" +
"discard</font></b> your changes?", "discard</font></b> your changes?",
KEEP_CHANGES_TEXT, DISCARD_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE); KEEP_CHANGES_TEXT, DISCARD_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE);
@ -469,7 +472,9 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
// //
choice = OptionDialog.showOptionDialog(scrollPane, CHANGE_DESTINATION_TITLE, choice = OptionDialog.showOptionDialog(scrollPane, CHANGE_DESTINATION_TITLE,
"<html>You can save your current changes to <b>another file</b> or " + "<html>You can save your current changes to <b>another file</b> or " +
"<b><font color=\"red\">overwrite</font></b> the contents of the file on disk.", "<b><font color=\"" +
Colors.ERROR.toHexString() +
"\">overwrite</font></b> the contents of the file on disk.",
SAVE_CHANGES_AS_TEXT, OVERWRITE_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE); SAVE_CHANGES_AS_TEXT, OVERWRITE_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE);
// //

View file

@ -24,6 +24,8 @@ import javax.swing.event.TableModelEvent;
import docking.widgets.table.*; import docking.widgets.table.*;
import generic.jar.ResourceFile; import generic.jar.ResourceFile;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Tables;
import ghidra.app.script.GhidraScriptInfoManager; import ghidra.app.script.GhidraScriptInfoManager;
import ghidra.app.script.ScriptInfo; import ghidra.app.script.ScriptInfo;
import ghidra.docking.settings.Settings; import ghidra.docking.settings.Settings;
@ -370,7 +372,7 @@ class GhidraScriptTableModel extends GDynamicColumnTableModel<ResourceFile, Obje
KeyBindingsInfo info = (KeyBindingsInfo) value; KeyBindingsInfo info = (KeyBindingsInfo) value;
if (info.errorMessage != null) { if (info.errorMessage != null) {
component.setForeground(Color.RED); component.setForeground(Tables.FG_ERROR_UNSELECTED);
component.setToolTipText(info.errorMessage); component.setToolTipText(info.errorMessage);
} }
else { else {
@ -380,18 +382,20 @@ class GhidraScriptTableModel extends GDynamicColumnTableModel<ResourceFile, Obje
} }
if (info.hasAction) { if (info.hasAction) {
component.setForeground(Color.BLACK); component.setForeground(Colors.FOREGROUND);
component.setToolTipText("Keybinding for action in tool" + keybindingText); component.setToolTipText("Keybinding for action in tool" + keybindingText);
} }
else { else {
component.setForeground(Color.LIGHT_GRAY); component.setForeground(Colors.FOREGROUND_DISABLED);
component.setToolTipText("Keybinding for script" + keybindingText); component.setToolTipText("Keybinding for script" + keybindingText);
} }
} }
if (isSelected) { if (isSelected) {
JTable table = data.getTable();
Color selectedForegroundColor = Color selectedForegroundColor =
(info.errorMessage != null) ? Color.PINK : Color.WHITE; (info.errorMessage != null) ? Tables.FG_ERROR_SELECTED
: table.getSelectionForeground();
component.setForeground(selectedForegroundColor); component.setForeground(selectedForegroundColor);
} }
return component; return component;

View file

@ -25,6 +25,7 @@ import javax.swing.event.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import docking.widgets.*; import docking.widgets.*;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.app.script.ScriptInfo; import ghidra.app.script.ScriptInfo;
import ghidra.util.HTMLUtilities; import ghidra.util.HTMLUtilities;
import ghidra.util.UserSearchUtils; import ghidra.util.UserSearchUtils;
@ -271,7 +272,8 @@ public class ScriptSelectionEditor {
// show the keybinding at the top softly so the user can quickly see it without // show the keybinding at the top softly so the user can quickly see it without
// it interfering with the overall description // it interfering with the overall description
buffy.append("<P>"); buffy.append("<P>");
buffy.append("<FONT COLOR=\"GRAY\"><I>&nbsp;"); buffy.append("<FONT COLOR=\"" +
Palette.GRAY.toHexString() + "\"><I>&nbsp;");
buffy.append(keyBinding.toString()); buffy.append(keyBinding.toString());
buffy.append("</I></FONT>"); buffy.append("</I></FONT>");
buffy.append("<P><P>"); buffy.append("<P><P>");

View file

@ -1,107 +0,0 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.plugin.core.spaceview;
import java.awt.Color;
import java.awt.image.IndexColorModel;
public class GhidraColorMap {
/*
tier 1
undefined (GRAY)
zero (BLACK)
low (DARK ORANGE)
whitespace (PALE BLUE)
digit (LIGHT BLUE)
upper (LIGHT BLUE)
lower (MED BLUE)
symbol (DARK BLUE)
high (DARK RED)
full (-1, 255) (WHITE)
tier 2
float? (GREEN)
double? (GREEN)
int? (ORANGE)
long? (ORANGE)
instruction? (PINK)
address? (YELLOW)
tier 3
SEAFOAM
defined data (simple types)
defined data (structs)
defined data (unions)
MAGENTA
code (memory)
code (flow)
code (special)
code (normal)
PURPLE
fun code (memory)
fun code (flow)
fun code (special)
fun code (normal)
RED
error bookmarks
tier 4
selected (BRIGHT GREEN)
highlighted (BRIGHT YELLOW)
selected and highlighted (BRIGHT YELLOW GREEN)
immutables needed:
segmenting
hilbert ordering
maximuming
from array
cache
iterator
also:
bijection from address to index in array space
bijection from pixelspace to indexspace
*/
public IndexColorModel getColorModel() {
Color[] colors =
new Color[] { new Color(190, 255, 0), Color.red, new Color(128, 128, 128), Color.cyan,
Color.magenta, };
byte[] red = new byte[colors.length];
byte[] grn = new byte[colors.length];
byte[] blu = new byte[colors.length];
for (int ii = 0; ii < colors.length; ++ii) {
red[ii] = (byte) colors[ii].getRed();
grn[ii] = (byte) colors[ii].getGreen();
blu[ii] = (byte) colors[ii].getBlue();
}
IndexColorModel colorModel = new IndexColorModel(8, colors.length, red, grn, blu);
return colorModel;
}
}

View file

@ -1,63 +0,0 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.plugin.core.spaceview;
public enum PixelType {
UNUSED_TYPE,
ERROR,
UNINIT_UNUSED,
UNINIT_DATA,
EXTERNAL,
UNDEF_DATA0,
UNDEF_DATA1,
UNDEF_DATA2,
UNDEF_DATA3,
UNDEF_DATA4,
UNDEF_DATA5,
UNDEF_DATA6,
UNDEF_DATA7,
DEF_DATA0,
DEF_DATA1,
DEF_DATA2,
DEF_DATA3,
DEF_DATA4,
DEF_DATA5,
DEF_DATA6,
DEF_DATA7,
CODE_MEMORY,
CODE_FLOW,
CODE_SPECIAL,
CODE_NORMAL,
FUN_CODE_MEMORY,
FUN_CODE_FLOW,
FUN_CODE_SPECIAL,
FUN_CODE_NORMAL,
SELECTED,
HIGHLIGHTED,
SEL_AND_HIGH;
public byte type() {
return (byte) ordinal();
}
}

View file

@ -1,99 +0,0 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.plugin.core.spaceview;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.*;
import java.util.Hashtable;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SpacecurveRasterPanel extends JPanel {
protected static final Hashtable<?, ?> EMPTY_HASHTABLE = new Hashtable<Object, Object>();
byte[] raster;
private int width;
private int height;
private IndexColorModel colorModel;
public SpacecurveRasterPanel(IndexColorModel colorModel) {
this.colorModel = colorModel;
}
public void setRaster(byte[] raster, int width, int height) {
if (raster.length != width * height) {
throw new IllegalArgumentException("raster.length != width * height");
}
this.raster = raster;
this.width = width;
this.height = height;
repaint();
}
public void setColorModel(IndexColorModel colorModel) {
this.colorModel = colorModel;
repaint();
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
if (raster != null) {
DataBufferByte dbb = new DataBufferByte(raster, height * width, 0);
ComponentSampleModel sm = getComponentSampleModel();
WritableRaster wr = Raster.createWritableRaster(sm, dbb, null);
BufferedImage img = new BufferedImage(colorModel, wr, true, EMPTY_HASHTABLE);
g2.drawImage(img, 0, 0, null);
}
}
protected ComponentSampleModel getComponentSampleModel() {
return new ComponentSampleModel(DataBuffer.TYPE_BYTE, width, height, 1, width,
new int[] { 0 });
}
public static void main(String[] args) {
byte[] red = new byte[256];
byte[] grn = new byte[256];
byte[] blu = new byte[256];
for (int ii = 0; ii < 256; ++ii) {
int jj = (255 - ii);
red[ii] = (byte) jj;
grn[ii] = (byte) (jj * jj / 255);
blu[ii] = (byte) (Math.sqrt(jj) / Math.sqrt(255.0) * 255.0);
}
IndexColorModel colorModel = new IndexColorModel(8, 256, red, grn, blu);
final int width = 256;
final int height = 256;
byte[] raster = new byte[width * height];
for (int ii = 0; ii < raster.length; ++ii) {
raster[ii] = (byte) ((ii * 1) % 256);
}
SpacecurveRasterPanel panel = new SpacecurveRasterPanel(colorModel);
panel.setRaster(raster, width, height);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.setSize(width, height);
frame.setVisible(true);
}
}

View file

@ -1,455 +0,0 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.plugin.core.symboltree;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class InfiniteProgressPanel extends JComponent implements MouseListener {
private static final String DEFAULT_MESSAGE_TEXT = "";
private static final int DEFAULT_NUMBER_OF_BARS = 14;
private static final float DEFAULT_SHIELD = .60F;
private static final int DEFAULT_FRAMES_PER_SECOND = 7;
private static final int DEFAULT_FADEIN_DELAY = 300;
protected String text = DEFAULT_MESSAGE_TEXT;
protected int fadeDelay = DEFAULT_FADEIN_DELAY;
protected float shield = DEFAULT_SHIELD;
protected int barsCount = DEFAULT_NUMBER_OF_BARS;
protected int fps = DEFAULT_FRAMES_PER_SECOND;
protected RenderingHints hints;
protected Area[] ticker;
// state values
protected Thread animation;
protected boolean paintAnimation = false;
protected int alphaLevel = 0;
public InfiniteProgressPanel() {
this( DEFAULT_MESSAGE_TEXT );
}
public InfiniteProgressPanel( String text ) {
this( text, DEFAULT_NUMBER_OF_BARS );
}
public InfiniteProgressPanel( String text, int barsCount ) {
this( text, barsCount, DEFAULT_SHIELD );
}
public InfiniteProgressPanel( String text, int barsCount, float shield ) {
this( text, barsCount, shield, DEFAULT_FRAMES_PER_SECOND );
}
public InfiniteProgressPanel( String text, int barsCount, float shield, int fps ) {
this( text, barsCount, shield, fps, DEFAULT_FADEIN_DELAY );
}
public InfiniteProgressPanel( String text, int barsCount, float shield, int fps, int rampDelay ) {
setText( text );
this.fadeDelay = rampDelay >= 0 ? rampDelay : 0;
this.shield = shield >= 0.0f ? shield : 0.0f;
this.fps = fps > 0 ? fps : 15;
this.barsCount = barsCount > 0 ? barsCount : 14;
this.hints = new RenderingHints( RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY );
this.hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
this.hints.put( RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON );
}
public void setText( String newText ) {
text = newText;
if ( text == null ) {
text = "";
}
repaint();
}
public String getText() {
return text;
}
public void start() {
if ( animation != null ) {
animation.interrupt();
}
removeMouseListener( this ); // be sure not to add the listener twice
addMouseListener( this );
setVisible( true );
ticker = buildTicker( barsCount );
double fixIncrement = 2.0 * Math.PI / (barsCount);
animation = new Thread( new Animator( fixIncrement, fadeDelay ) );
animation.start();
}
public void stop() {
if ( animation != null ) {
animation.interrupt();
animation = null;
double fixIncrement = 2.0 * Math.PI / (barsCount);
animation = new Thread( new FadeOutAnimator( fixIncrement, fadeDelay) );
animation.start();
}
}
public void interrupt() {
if ( animation != null ) {
animation.interrupt();
animation = null;
removeMouseListener(this);
setVisible(false);
}
}
private Area[] buildTicker( int barCount ) {
Area[] newTicker = new Area[barCount];
Point2D.Double center = new Point2D.Double( (double) getWidth() / 2,
(double) getHeight() / 2 );
double fixedAngle = 2.0 * Math.PI / (barCount);
for ( double i = 0.0; i < barCount; i++ ) {
Area primitive = buildPrimitive();
AffineTransform toCenter = AffineTransform.getTranslateInstance(center.getX(),
center.getY() );
AffineTransform toBorder = AffineTransform.getTranslateInstance(45.0, -6.0 );
AffineTransform toCircle = AffineTransform.getRotateInstance(-i * fixedAngle,
center.getX(), center.getY() );
AffineTransform toWheel = new AffineTransform();
toWheel.concatenate(toCenter);
toWheel.concatenate(toBorder);
primitive.transform(toWheel);
primitive.transform(toCircle);
newTicker[(int) i] = primitive;
}
return newTicker;
}
private Area buildPrimitive() {
Rectangle2D.Double body = new Rectangle2D.Double( 6, 0, 30, 12 ); // location and size
Ellipse2D.Double head = new Ellipse2D.Double( 0, 0, 12, 12 );
Ellipse2D.Double tail = new Ellipse2D.Double( 30, 0, 12, 12 );
Area tick = new Area(body);
tick.add( new Area( head ) );
tick.add( new Area( tail ) );
return tick;
}
@Override
public void paintComponent( Graphics g ) {
if ( !paintAnimation ) {
return;
}
int width = getWidth();
int height = getHeight();
double maxY = 0.0;
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHints(hints);
g2.setColor( new Color( 255, 255, 255, (int) (alphaLevel * shield) ) );
g2.fillRect(0, 0, width, height);
double textPosition = 0.0;
for ( Area element : ticker ) {
Rectangle2D bounds = element.getBounds2D();
if ( bounds.getMaxY() > textPosition ) {
textPosition = bounds.getMaxY();
}
}
int channel = 0;
int blue = 255;
Color textColor = Color.BLACK;
for ( int i = 0; i < ticker.length; i++ ) {
channel = 264 - 128 / (i + 1);
blue = channel+126 > 255 ? 255 : channel+126;
Color color = new Color( channel, channel, blue, (int) (alphaLevel * shield) );
if ( i == 0 ) {
textColor = color;
}
g2.setColor( color );
g2.fill( ticker[i] );
Rectangle2D bounds = ticker[i].getBounds2D();
if ( bounds.getMaxY() > maxY ) {
maxY = bounds.getMaxY();
}
}
paintText( g2, textColor, textPosition );
}
private void paintText( Graphics2D graphics, Color color, double textPosition ) {
if ( text == null || text.trim().length() == 0 ) {
return;
}
FontRenderContext context = graphics.getFontRenderContext();
TextLayout layout = new TextLayout( text, getFont(), context );
Rectangle2D bounds = layout.getBounds();
graphics.setColor( Color.BLACK );
layout.draw( graphics, (float) (getWidth() - bounds.getWidth()) / 2,
(float) (textPosition + layout.getLeading() + 2 * layout.getAscent() ) );
}
// fade out
private class FadeOutAnimator implements Runnable {
private final int fadeDelayTime;
private AffineTransform transformToCircle;
private long startRampupTime;
private FadeOutAnimator( double transformTheta, int fadeDelayTime ) {
this.fadeDelayTime = fadeDelayTime;
Point2D.Double center = new Point2D.Double( (double) getWidth() / 2,
(double) getHeight() / 2 );
transformToCircle = AffineTransform.getRotateInstance(transformTheta,
center.getX(), center.getY() );
}
public void run() {
startRampupTime = System.currentTimeMillis();
if ( fadeDelayTime == 0 ) {
alphaLevel = 0;
}
while ( !Thread.interrupted() && (alphaLevel > 0) ) {
transformTicker();
repaint();
updateBackgroundAlpha();
if ( !pauseForEffect() ) {
break;
}
}
paintAnimation = false;
repaint();
setVisible(false);
removeMouseListener( InfiniteProgressPanel.this );
}
// true indicates a successful pause
protected boolean pauseForEffect() {
try {
Thread.sleep( (1000/fps) );
} catch ( InterruptedException ie ) {
return false; // we've stopped the thread
}
Thread.yield();
return true;
}
protected void transformTicker() {
for ( Area element : ticker ) {
element.transform( transformToCircle );
}
}
protected void updateBackgroundAlpha() {
if ( alphaLevel <= 0 ) {
return;
}
int elapsedTime = (int) (System.currentTimeMillis() - startRampupTime);
int increment = (255 * elapsedTime) / fadeDelayTime;
alphaLevel = 255 - increment;
if ( alphaLevel <= 0 ) {
alphaLevel = 0;
}
}
}
private class Animator implements Runnable {
private boolean inRampUpPeriod = false;
private final int rampDelayTime;
private AffineTransform transformToCircle;
private long startRampupTime;
protected Animator( double transformTheta, int rampDelayTime ) {
this.rampDelayTime = rampDelayTime;
Point2D.Double center = new Point2D.Double( (double) getWidth() / 2,
(double) getHeight() / 2 );
transformToCircle = AffineTransform.getRotateInstance(transformTheta,
center.getX(), center.getY() );
}
public void run() {
startRampupTime = System.currentTimeMillis();
if ( rampDelayTime == 0 ) {
alphaLevel = 255;
}
paintAnimation = true;
inRampUpPeriod = true;
while ( !Thread.interrupted() ) {
transformTicker();
repaint();
updateBackgroundAlpha();
if ( !pauseForEffect() ) {
break;
}
}
}
// true indicates a successful pause
protected boolean pauseForEffect() {
try {
Thread.sleep( (1000/fps) );
} catch ( InterruptedException ie ) {
return false; // we've stopped the thread
}
Thread.yield();
return true;
}
protected void transformTicker() {
if ( inRampUpPeriod ) {
return;
}
for ( Area element : ticker ) {
element.transform( transformToCircle );
}
}
protected void updateBackgroundAlpha() {
if ( alphaLevel >= 255 ) {
inRampUpPeriod = false;
return;
}
int elapsedTime = (int) (System.currentTimeMillis() - startRampupTime);
int increment = (255 * elapsedTime) / rampDelayTime;
alphaLevel = increment;
if ( alphaLevel >= 255 ) {
alphaLevel = 255;
inRampUpPeriod = false;
}
}
}
public void mouseClicked(MouseEvent e) {
Toolkit.getDefaultToolkit().beep();
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public static void main( String[] args ) {
final JFrame frame = new JFrame( "Ticker Test" );
frame.setSize( 400, 600 );
final Component originalGlassPane = frame.getGlassPane();
final InfiniteProgressPanel progressPanel = new InfiniteProgressPanel("Processing request...");
progressPanel.fps = 7;
progressPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked( MouseEvent e ) {
//progressPanel.interrupt();
progressPanel.stop();
frame.setGlassPane(originalGlassPane);
}
} );
JPanel mainPanel = new JPanel( new BorderLayout() );
JScrollPane scrollPane = new JScrollPane();
final JTextArea textArea = new JTextArea( 50, 40 );
textArea.setText("some text here..." );
scrollPane.getViewport().add( textArea );
mainPanel.add( scrollPane, BorderLayout.CENTER );
JButton button = new JButton( "Start" );
button.addActionListener(new ActionListener() {
public void actionPerformed( ActionEvent event ) {
frame.setGlassPane(progressPanel);
progressPanel.start();
}
} );
mainPanel.add( button, BorderLayout.SOUTH );
frame.setSize( 400, 400 );
frame.setLocation( GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint() );
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add( mainPanel );
frame.setVisible( true );
}
}

View file

@ -19,6 +19,7 @@ import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import docking.widgets.table.GTableCellRenderingData; import docking.widgets.table.GTableCellRenderingData;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.util.SymbolInspector; import ghidra.app.util.SymbolInspector;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.lang.Register; import ghidra.program.model.lang.Register;
@ -78,7 +79,7 @@ class SymbolRenderer extends GhidraTableCellRenderer {
setBold(); setBold();
Color color = Color color =
(inspector != null) && (value instanceof Symbol) ? inspector.getColor((Symbol) value) (inspector != null) && (value instanceof Symbol) ? inspector.getColor((Symbol) value)
: Color.BLACK; : Colors.FOREGROUND;
if (!isSelected) { if (!isSelected) {
setForeground(color); setForeground(color);

View file

@ -16,7 +16,6 @@
package ghidra.app.plugin.core.totd; package ghidra.app.plugin.core.totd;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.util.List; import java.util.List;
import javax.swing.*; import javax.swing.*;
@ -26,6 +25,8 @@ import docking.DialogComponentProvider;
import docking.DockingWindowManager; import docking.DockingWindowManager;
import docking.widgets.checkbox.GCheckBox; import docking.widgets.checkbox.GCheckBox;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Java;
import resources.ResourceManager; import resources.ResourceManager;
class TipOfTheDayDialog extends DialogComponentProvider { class TipOfTheDayDialog extends DialogComponentProvider {
@ -65,38 +66,25 @@ class TipOfTheDayDialog extends DialogComponentProvider {
showTipsCheckbox = new GCheckBox("Show Tips on Startup?"); showTipsCheckbox = new GCheckBox("Show Tips on Startup?");
showTipsCheckbox.setSelected(true); // TODO (FixMe) Moved this before its listener to prevent project save for now. showTipsCheckbox.setSelected(true); // TODO (FixMe) Moved this before its listener to prevent project save for now.
showTipsCheckbox.addItemListener(new ItemListener() { showTipsCheckbox.addItemListener(e -> showTipsChanged());
@Override
public void itemStateChanged(ItemEvent e) {
showTipsChanged();
}
});
nextTipButton = new JButton("Next Tip"); nextTipButton = new JButton("Next Tip");
nextTipButton.addActionListener(new ActionListener() { nextTipButton.addActionListener(e -> {
@Override incrementTipIndex();
public void actionPerformed(ActionEvent e) { loadNextTip();
incrementTipIndex();
loadNextTip();
}
}); });
addButton(nextTipButton); addButton(nextTipButton);
closeButton = new JButton("Close"); closeButton = new JButton("Close");
closeButton.addActionListener(new ActionListener() { closeButton.addActionListener(e -> close());
@Override
public void actionPerformed(ActionEvent e) {
close();
}
});
addButton(closeButton); addButton(closeButton);
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
Border panelBorder = Border panelBorder =
BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10), BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10),
BorderFactory.createLineBorder(Color.BLACK)); BorderFactory.createLineBorder(Java.BORDER));
panel.setBorder(panelBorder); panel.setBorder(panelBorder);
panel.setBackground(Color.WHITE); panel.setBackground(Colors.BACKGROUND);
JLabel label = new GLabel("Did you know...", tipIcon, SwingConstants.LEFT); JLabel label = new GLabel("Did you know...", tipIcon, SwingConstants.LEFT);
label.setFont(new Font("dialog", Font.BOLD, 12)); label.setFont(new Font("dialog", Font.BOLD, 12));

View file

@ -15,6 +15,10 @@
*/ */
package ghidra.app.plugin.debug.propertymanager; package ghidra.app.plugin.debug.propertymanager;
import javax.swing.ImageIcon;
import javax.swing.Timer;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin; import ghidra.app.plugin.ProgramPlugin;
@ -28,17 +32,8 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView; import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.util.*; import ghidra.program.util.*;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.Timer;
import resources.ResourceManager; import resources.ResourceManager;
/** /**
* PropertyManagerPlugin * PropertyManagerPlugin
*/ */
@ -62,9 +57,9 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
final static String PROPERTY_MARKER_NAME = "Property Locations"; final static String PROPERTY_MARKER_NAME = "Property Locations";
private PropertyManagerProvider propertyViewProvider; private PropertyManagerProvider propertyViewProvider;
private MarkerService markerService; private MarkerService markerService;
private MarkerSet searchMarks; private MarkerSet searchMarks;
private Timer updateTimer; private Timer updateTimer;
public PropertyManagerPlugin(PluginTool tool) { public PropertyManagerPlugin(PluginTool tool) {
super(tool); super(tool);
@ -76,16 +71,13 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
* @see ghidra.framework.plugintool.Plugin#init() * @see ghidra.framework.plugintool.Plugin#init()
*/ */
@Override @Override
protected void init() { protected void init() {
markerService = tool.getService(MarkerService.class); markerService = tool.getService(MarkerService.class);
updateTimer = new Timer(500, e -> {
updateTimer = new Timer(500, new ActionListener() { if (propertyViewProvider != null && propertyViewProvider.isVisible()) {
public void actionPerformed(ActionEvent e) { propertyViewProvider.refresh();
if (propertyViewProvider != null && propertyViewProvider.isVisible()) {
propertyViewProvider.refresh();
}
} }
}); });
updateTimer.setRepeats(false); updateTimer.setRepeats(false);
@ -95,7 +87,8 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
* (non-Javadoc) * (non-Javadoc)
* @see ghidra.framework.model.DomainObjectListener#domainObjectChanged(ghidra.framework.model.DomainObjectChangedEvent) * @see ghidra.framework.model.DomainObjectListener#domainObjectChanged(ghidra.framework.model.DomainObjectChangedEvent)
*/ */
public void domainObjectChanged(DomainObjectChangedEvent ev) { @Override
public void domainObjectChanged(DomainObjectChangedEvent ev) {
if (propertyViewProvider == null || !propertyViewProvider.isVisible()) { if (propertyViewProvider == null || !propertyViewProvider.isVisible()) {
return; return;
} }
@ -110,8 +103,7 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
if (eventType == DomainObject.DO_OBJECT_RESTORED || if (eventType == DomainObject.DO_OBJECT_RESTORED ||
eventType == ChangeManager.DOCR_MEMORY_BLOCK_MOVED || eventType == ChangeManager.DOCR_MEMORY_BLOCK_MOVED ||
eventType == ChangeManager.DOCR_MEMORY_BLOCK_REMOVED || eventType == ChangeManager.DOCR_MEMORY_BLOCK_REMOVED ||
eventType == ChangeManager.DOCR_CODE_UNIT_PROPERTY_ALL_REMOVED) eventType == ChangeManager.DOCR_CODE_UNIT_PROPERTY_ALL_REMOVED) {
{
affectedByChange = true; affectedByChange = true;
break; break;
} }
@ -124,7 +116,7 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
break; break;
} }
CodeUnitPropertyChangeRecord pcr = (CodeUnitPropertyChangeRecord)record; CodeUnitPropertyChangeRecord pcr = (CodeUnitPropertyChangeRecord) record;
Address addr = pcr.getAddress(); Address addr = pcr.getAddress();
if (addr != null) { if (addr != null) {
if (currentSelection.contains(addr)) { if (currentSelection.contains(addr)) {
@ -145,16 +137,16 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
if (affectedByChange) { if (affectedByChange) {
updateTimer.restart(); updateTimer.restart();
} }
} }
@Override @Override
protected void programActivated(Program program) { protected void programActivated(Program program) {
program.addListener(this); program.addListener(this);
propertyViewProvider.programActivated(program); propertyViewProvider.programActivated(program);
} }
@Override @Override
protected void programDeactivated(Program program) { protected void programDeactivated(Program program) {
disposeSearchMarks(program); disposeSearchMarks(program);
if (program != null) { if (program != null) {
program.removeListener(this); program.removeListener(this);
@ -162,12 +154,12 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
propertyViewProvider.programDeactivated(); propertyViewProvider.programDeactivated();
} }
@Override @Override
protected void selectionChanged(ProgramSelection sel) { protected void selectionChanged(ProgramSelection sel) {
if (propertyViewProvider != null && propertyViewProvider.isVisible()) { if (propertyViewProvider != null && propertyViewProvider.isVisible()) {
updateTimer.restart(); updateTimer.restart();
} }
} }
/** /**
* Initialize search marker manager * Initialize search marker manager
@ -175,8 +167,8 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
MarkerSet getSearchMarks() { MarkerSet getSearchMarks() {
if (searchMarks == null && currentProgram != null) { if (searchMarks == null && currentProgram != null) {
searchMarks = markerService.createPointMarker(PROPERTY_MARKER_NAME, searchMarks = markerService.createPointMarker(PROPERTY_MARKER_NAME,
"Locations where properties are set", currentProgram, "Locations where properties are set", currentProgram,
MarkerService.PROPERTY_PRIORITY, true, true, false, Color.pink, propIcon); MarkerService.PROPERTY_PRIORITY, true, true, false, Palette.PINK, propIcon);
} }
return searchMarks; return searchMarks;
} }
@ -185,34 +177,34 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
* Dispose search marker manager * Dispose search marker manager
*/ */
void disposeSearchMarks() { void disposeSearchMarks() {
disposeSearchMarks( currentProgram ); disposeSearchMarks(currentProgram);
} }
private void disposeSearchMarks( Program program ) { private void disposeSearchMarks(Program program) {
if (searchMarks != null && program != null) { if (searchMarks != null && program != null) {
markerService.removeMarker(searchMarks, program); markerService.removeMarker(searchMarks, program);
searchMarks = null; searchMarks = null;
} }
} }
void clearSearchMarks() { void clearSearchMarks() {
if ( searchMarks != null ) { if (searchMarks != null) {
searchMarks.clearAll(); searchMarks.clearAll();
} }
} }
/** /**
* @see ghidra.framework.plugintool.Plugin#dispose() * @see ghidra.framework.plugintool.Plugin#dispose()
*/ */
@Override @Override
public void dispose() { public void dispose() {
super.dispose(); super.dispose();
disposeSearchMarks(); disposeSearchMarks();
if (currentProgram != null) { if (currentProgram != null) {
currentProgram.removeListener(this); currentProgram.removeListener(this);
} }
if (propertyViewProvider != null) { if (propertyViewProvider != null) {
propertyViewProvider.dispose(); propertyViewProvider.dispose();

View file

@ -26,6 +26,7 @@ import javax.swing.*;
import docking.ComponentProvider; import docking.ComponentProvider;
import docking.Tool; import docking.Tool;
import generic.theme.GColor;
import generic.util.WindowUtilities; import generic.util.WindowUtilities;
import generic.util.image.ImageUtils; import generic.util.image.ImageUtils;
import ghidra.app.DeveloperPluginPackage; import ghidra.app.DeveloperPluginPackage;
@ -46,6 +47,18 @@ import ghidra.util.Swing;
//@formatter:on //@formatter:on
public class WindowLocationPlugin extends Plugin { public class WindowLocationPlugin extends Plugin {
private static final Color BG_COLOR = new GColor("color.bg.plugin.windowlocation");
private static final Color BG_COLOR_BOUNDS_VIRTUAL =
new GColor("color.bg.plugin.windowlocation.bounds.virtual");
private static final Color BG_COLOR_BOUNDS_VISIBLE =
new GColor("color.bg.plugin.windowlocation.bounds.visible");
private static final Color BG_COLOR_SCREENS =
new GColor("color.bg.plugin.windowlocation.screens");
private static final Color BG_COLOR_WINDOW_SELECTED =
new GColor("color.bg.plugin.windowlocation.window.selected");
private static final Color FG_COLOR_WINDOW_TEXT =
new GColor("color.fg.plugin.windowlocation.window.text");
static final String NAME = "Window Locations"; static final String NAME = "Window Locations";
private WindowLocationProvider provider; private WindowLocationProvider provider;
@ -75,12 +88,7 @@ public class WindowLocationPlugin extends Plugin {
windowPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); windowPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
AWTEventListener listener = new AWTEventListener() { AWTEventListener listener = event -> windowPanel.repaint();
@Override
public void eventDispatched(AWTEvent event) {
windowPanel.repaint();
}
};
toolkit.addAWTEventListener(listener, AWTEvent.MOUSE_MOTION_EVENT_MASK); toolkit.addAWTEventListener(listener, AWTEvent.MOUSE_MOTION_EVENT_MASK);
toolkit.addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK); toolkit.addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK);
} }
@ -124,7 +132,7 @@ public class WindowLocationPlugin extends Plugin {
Dimension size = getSize(); Dimension size = getSize();
double panelWidth = size.getWidth(); double panelWidth = size.getWidth();
double panelHeight = size.getHeight(); double panelHeight = size.getHeight();
setBackground(Color.BLACK); setBackground(BG_COLOR);
g.fillRect(0, 0, (int) panelWidth, (int) panelHeight); g.fillRect(0, 0, (int) panelWidth, (int) panelHeight);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
@ -135,9 +143,9 @@ public class WindowLocationPlugin extends Plugin {
clone.concatenate(newxform); clone.concatenate(newxform);
g2d.setTransform(clone); g2d.setTransform(clone);
paintVirtualBounds(g2d, Color.RED); paintVirtualBounds(g2d, BG_COLOR_BOUNDS_VIRTUAL);
paintVisibleBounds(g2d, Color.GREEN); paintVisibleBounds(g2d, BG_COLOR_BOUNDS_VISIBLE);
paintScreens(g2d, Color.ORANGE); paintScreens(g2d, BG_COLOR_SCREENS);
paintWindows(g2d, newxform); paintWindows(g2d, newxform);
} }
finally { finally {
@ -183,7 +191,7 @@ public class WindowLocationPlugin extends Plugin {
Font f = g2d.getFont(); Font f = g2d.getFont();
Font biggerFont = f.deriveFont(40f); Font biggerFont = f.deriveFont(40f);
g2d.setFont(biggerFont); g2d.setFont(biggerFont);
g2d.setColor(Color.GRAY); g2d.setColor(FG_COLOR_WINDOW_TEXT);
Window[] windows = Window.getWindows(); Window[] windows = Window.getWindows();
@ -380,8 +388,7 @@ public class WindowLocationPlugin extends Plugin {
Color bg = g2d.getColor(); Color bg = g2d.getColor();
try { try {
Color withAlpha = new Color(0, 255, 0, 200); g2d.setColor(BG_COLOR_WINDOW_SELECTED);
g2d.setColor(withAlpha);
g2d.fill(b); g2d.fill(b);
} }
finally { finally {

View file

@ -103,6 +103,6 @@ public interface PluginConstants {
* address. * address.
*/ */
public static final Color SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR = public static final Color SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR =
new GColor("color.bg.search.current-line.highlight"); new GColor("color.bg.search.current.line.highlight");
} }

View file

@ -95,13 +95,13 @@ public class OptionsGui extends JPanel {
"Function Auto-Parameters", new GColor("color.fg.listing.function.param.auto")); "Function Auto-Parameters", new GColor("color.fg.listing.function.param.auto"));
public static final ScreenElement FUN_RET_TYPE = new ScreenElement("Function Return Type", public static final ScreenElement FUN_RET_TYPE = new ScreenElement("Function Return Type",
new GColor("color.fg.listing.function.return-type")); new GColor("color.fg.listing.function.return.type"));
public static final ScreenElement COMMENT_REPEATABLE = public static final ScreenElement COMMENT_REPEATABLE =
new ScreenElement("Comment, Repeatable", new GColor("color.fg.listing.comment.repeatable")); new ScreenElement("Comment, Repeatable", new GColor("color.fg.listing.comment.repeatable"));
public static final ScreenElement COMMENT_REF_REPEAT = new ScreenElement( public static final ScreenElement COMMENT_REF_REPEAT = new ScreenElement(
"Comment, Referenced Repeatable", new GColor("color.fg.listing.comment.ref-repeatable")); "Comment, Referenced Repeatable", new GColor("color.fg.listing.comment.ref.repeatable"));
public static final ScreenElement LABELS_LOCAL = public static final ScreenElement LABELS_LOCAL =
new ScreenElement("Labels, Local", new GColor("color.fg.listing.label.local")); new ScreenElement("Labels, Local", new GColor("color.fg.listing.label.local"));
@ -116,16 +116,16 @@ public class OptionsGui extends JPanel {
new GColor("color.fg.listing.mnemonic.unimplemented")); new GColor("color.fg.listing.mnemonic.unimplemented"));
public static final ScreenElement FLOW_ARROW_NON_ACTIVE = new ScreenElement( public static final ScreenElement FLOW_ARROW_NON_ACTIVE = new ScreenElement(
"Flow Arrow, Not Active", new GColor("color.fg.listing.flow-arrow.inactive")); "Flow Arrow, Not Active", new GColor("color.fg.listing.flow.arrow.inactive"));
public static final ScreenElement FLOW_ARROW_ACTIVE = public static final ScreenElement FLOW_ARROW_ACTIVE =
new ScreenElement("Flow Arrow, Active", new GColor("color.fg.listing.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( public static final ScreenElement FLOW_ARROW_SELECTED = new ScreenElement(
"Flow Arrow, Selected", new GColor("color.fg.listing.flow-arrow.selected")); "Flow Arrow, Selected", new GColor("color.fg.listing.flow.arrow.selected"));
public static final ScreenElement LABELS_NON_PRIMARY = public static final ScreenElement LABELS_NON_PRIMARY =
new ScreenElement("Labels, Non-primary", new GColor("color.fg.listing.label.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", public static final ScreenElement COMMENT_PLATE = new ScreenElement("Comment, Plate",
"Plate Comment", new GColor("color.fg.listing.comment.plate")); "Plate Comment", new GColor("color.fg.listing.comment.plate"));
@ -152,7 +152,7 @@ public class OptionsGui extends JPanel {
"Parameter, Dynamic Storage", new GColor("color.fg.listing.function.param.dynamic")); "Parameter, Dynamic Storage", new GColor("color.fg.listing.function.param.dynamic"));
public static final ScreenElement VERSION_TRAK = public static final ScreenElement VERSION_TRAK =
new ScreenElement("Version Track", new GColor("color.fg.listing.version-tracking")); new ScreenElement("Version Track", new GColor("color.fg.listing.version.tracking"));
public static final ScreenElement XREF = public static final ScreenElement XREF =
new ScreenElement("XRef", new GColor("color.fg.listing.xref")); new ScreenElement("XRef", new GColor("color.fg.listing.xref"));

View file

@ -1,7 +1,31 @@
[Defaults] [Defaults]
color.bg.decompiler = color.bg
color.fg.decompiler = color.fg
color.fg.decompiler.keyword = #0001e6
color.fg.decompiler.function.name = blue
color.fg.decompiler.comment = blueViolet
color.fg.decompiler.variable = #999900 // close to oliveDrab
color.fg.decompiler.constant = forestGreen
color.fg.decompiler.type = mediumBlue
color.fg.decompiler.parameter = darkMagenta
color.fg.decompiler.global = darkCyan
color.bg.decompiler.middle.mouse = rgba(255,255,0,.5)
color.bg.decompiler.current.variable = rgba(255,255,0,0.5)
[Dark Defaults] [Dark Defaults]
color.fg.decompiler.keyword = peru
color.fg.decompiler.function.name = cadetBlue
color.fg.decompiler.comment = lightSlateGray
color.fg.decompiler.variable = #999900 // close to oliveDrab
color.fg.decompiler.constant = forestGreen
color.fg.decompiler.type = blue
color.fg.decompiler.parameter = darkMagenta
color.fg.decompiler.global = darkCyan
color.bg.decompiler.middle.mouse = rgb(55,59,65)
color.bg.decompiler.current.variable = rgb(55, 59, 65)

View file

@ -303,12 +303,12 @@ public class DecompileOptions {
private final static IntegerFormatEnum INTEGERFORMAT_OPTIONDEFAULT = IntegerFormatEnum.BestFit; // Must match PrintLanguage::resetDefaultsInternal private final static IntegerFormatEnum INTEGERFORMAT_OPTIONDEFAULT = IntegerFormatEnum.BestFit; // Must match PrintLanguage::resetDefaultsInternal
private IntegerFormatEnum integerFormat; private IntegerFormatEnum integerFormat;
private final static Color HIGHLIGHT_MIDDLE_MOUSE_DEF = new GColor("color.bg.decompiler.middle-mouse"); private final static Color HIGHLIGHT_MIDDLE_MOUSE_DEF = new GColor("color.bg.decompiler.middle.mouse");
private Color middleMouseHighlightColor; private Color middleMouseHighlightColor;
private int middleMouseHighlightButton = MouseEvent.BUTTON2; private int middleMouseHighlightButton = MouseEvent.BUTTON2;
private final static String HIGHLIGHT_CURRENT_VARIABLE_MSG ="Display.Color for Current Variable Highlight"; private final static String HIGHLIGHT_CURRENT_VARIABLE_MSG ="Display.Color for Current Variable Highlight";
private final static Color HIGHLIGHT_CURRENT_VARIABLE_DEF = new GColor("color.bg.decompiler.current-variable"); private final static Color HIGHLIGHT_CURRENT_VARIABLE_DEF = new GColor("color.bg.decompiler.current.variable");
private Color currentVariableHighlightColor; private Color currentVariableHighlightColor;
private final static String HIGHLIGHT_KEYWORD_MSG = "Display.Color for Keywords"; private final static String HIGHLIGHT_KEYWORD_MSG = "Display.Color for Keywords";

View file

@ -4,15 +4,15 @@
color.bg.functiongraph = color.bg color.bg.functiongraph = color.bg
color.fg.label.picked = color.fg color.fg.label.picked = color.fg
color.fg.label.non-picked = color.fg.disabled color.fg.label.non.picked = color.fg.disabled
color.bg.functiongraph.vertex.group = rgb(226, 255, 155) color.bg.functiongraph.vertex.group = rgb(226, 255, 155)
color.bg.functiongraph.vertex.entry = color.palette.lightgreen color.bg.functiongraph.vertex.entry = color.palette.lightgreen
color.bg.functiongraph.vertex.exit = color.palette.lightred color.bg.functiongraph.vertex.exit = color.palette.lightred
color.bg.functiongraph.vertex.picked = color.palette.yellow color.bg.functiongraph.vertex.picked = color.palette.yellow
color.bg.functiongraph.edge.fall-through = color.flowtype.fall-through color.bg.functiongraph.edge.fall.through = color.flowtype.fall.through
color.bg.functiongraph.edge.fall-through.highlight = rgb(255, 127, 127) color.bg.functiongraph.edge.fall.through.highlight = rgb(255, 127, 127)
color.bg.functiongraph.edge.jump.conditional = color.flowtype.jump.conditional color.bg.functiongraph.edge.jump.conditional = color.flowtype.jump.conditional
color.bg.functiongraph.edge.jump.conditional.highlight = lime color.bg.functiongraph.edge.jump.conditional.highlight = lime
color.bg.functiongraph.edge.jump.unconditional = color.flowtype.jump.unconditional color.bg.functiongraph.edge.jump.unconditional = color.flowtype.jump.unconditional
@ -27,15 +27,15 @@ color.bg.functiongraph.paint.icon = rgb(189, 221, 252) // gentle pale blue
// color.bg.functiongraph = color.bg // color.bg.functiongraph = color.bg
// color.fg.label.picked = color.fg // color.fg.label.picked = color.fg
// color.fg.label.non-picked = color.fg.disabled // color.fg.label.non.picked = color.fg.disabled
color.bg.functiongraph.vertex.group = rgb(226, 222, 179) // TODO confirm value color.bg.functiongraph.vertex.group = rgb(226, 222, 179) // TODO confirm value
// color.bg.functiongraph.vertex.entry = color.palette.lightgreen // color.bg.functiongraph.vertex.entry = color.palette.lightgreen
// color.bg.functiongraph.vertex.exit = color.palette.lightred // color.bg.functiongraph.vertex.exit = color.palette.lightred
// color.bg.functiongraph.vertex.picked = color.palette.yellow // color.bg.functiongraph.vertex.picked = color.palette.yellow
// color.bg.functiongraph.edge.fall-through = color.flowtype.fall-through // color.bg.functiongraph.edge.fall.through = color.flowtype.fall.through
color.bg.functiongraph.edge.fall-through.highlight = rgb(165, 76, 80) color.bg.functiongraph.edge.fall.through.highlight = rgb(165, 76, 80)
// color.bg.functiongraph.edge.jump.conditional = color.flowtype.jump.conditional // color.bg.functiongraph.edge.jump.conditional = color.flowtype.jump.conditional
color.bg.functiongraph.edge.jump.conditional.highlight = rgb(95, 160, 196) color.bg.functiongraph.edge.jump.conditional.highlight = rgb(95, 160, 196)
// color.bg.functiongraph.edge.jump.unconditional = color.flowtype.jump.unconditional // color.bg.functiongraph.edge.jump.unconditional = color.flowtype.jump.unconditional

View file

@ -221,7 +221,7 @@ public class FGComponent extends GraphComponent<FGVertex, FGEdge, FunctionGraph>
// renderer inside of the VisualGraphRenderer // renderer inside of the VisualGraphRenderer
VisualGraphEdgeLabelRenderer edgeLabelRenderer = VisualGraphEdgeLabelRenderer edgeLabelRenderer =
new VisualGraphEdgeLabelRenderer(new GColor("color.fg.label.picked")); new VisualGraphEdgeLabelRenderer(new GColor("color.fg.label.picked"));
edgeLabelRenderer.setNonPickedForegroundColor(new GColor("color.fg.label.non-picked")); edgeLabelRenderer.setNonPickedForegroundColor(new GColor("color.fg.label.non.picked"));
edgeLabelRenderer.setRotateEdgeLabels(false); edgeLabelRenderer.setRotateEdgeLabels(false);
renderContext.setEdgeLabelRenderer(edgeLabelRenderer); renderContext.setEdgeLabelRenderer(edgeLabelRenderer);

View file

@ -94,11 +94,11 @@ public class FunctionGraphOptions extends VisualGraphOptions {
private Color defaultVertexBackgroundColor = new GColor("color.bg.functiongraph"); private Color defaultVertexBackgroundColor = new GColor("color.bg.functiongraph");
private Color defaultGroupBackgroundColor = new GColor("color.bg.functiongraph.vertex.group"); private Color defaultGroupBackgroundColor = new GColor("color.bg.functiongraph.vertex.group");
private Color fallthroughEdgeColor = new GColor("color.bg.functiongraph.edge.fall-through"); private Color fallthroughEdgeColor = new GColor("color.bg.functiongraph.edge.fall.through");
private Color conditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.conditional"); private Color conditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.conditional");
private Color unconditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.unconditional"); private Color unconditionalJumpEdgeColor = new GColor("color.bg.functiongraph.edge.jump.unconditional");
private Color fallthroughEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.fall-through.highlight"); private Color fallthroughEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.fall.through.highlight");
private Color conditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.conditional.highlight"); private Color conditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.conditional.highlight");
private Color unconditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.unconditional.highlight"); private Color unconditionalJumpEdgeHighlightColor = new GColor("color.bg.functiongraph.edge.jump.unconditional.highlight");
//@formatter:on //@formatter:on

View file

@ -1,6 +1,7 @@
[Defaults] [Defaults]
color.palette.nocolor = rgba(255,255,255,0) color.palette.nocolor = rgba(255,255,255,0)
color.palette.disabled = rgba(255,255,255,0)
color.palette.black = black color.palette.black = black
color.palette.blue = blue color.palette.blue = blue
@ -40,3 +41,5 @@ color.palette.white = white
#color.palette.yellow = rgb(191, 191, 64) // olive #color.palette.yellow = rgb(191, 191, 64) // olive
color.palette.cyan = #00CCCC // less harsh color.palette.cyan = #00CCCC // less harsh
color.palette.blue = deepskyblue
color.palette.magenta = plum

View file

@ -1,6 +1,6 @@
[Defaults] [Defaults]
color.bg = white color.bg = white // note: this is the text/widget bg color
color.fg = black color.fg = black
color.fg.error = red color.fg.error = red
color.fg.disabled = lightGray color.fg.disabled = lightGray
@ -33,8 +33,13 @@ color.bg.currentline = rgb(232,242,254)
color.cursor.focused = red color.cursor.focused = red
color.cursor.unfocused = pink color.cursor.unfocused = pink
color.bg.table.grid = gray
color.bg.table.row = color.bg color.bg.table.row = color.bg
color.bg.table.row.alt = rgb(237,243,254) color.bg.table.row.alt = rgb(237,243,254)
color.fg.table.uneditable.selected = yellow
color.fg.table.uneditable.unselected = lightgray
color.fg.error.table.unselected = color.fg.error
color.fg.error.table.selected = lightpink
color.bg.tableheader.gradient.start = color.bg color.bg.tableheader.gradient.start = color.bg
color.bg.tableheader.gradient.end = lightGray color.bg.tableheader.gradient.end = lightGray
@ -45,6 +50,8 @@ color.bg.textfield.hint.valid = color.bg
color.bg.textfield.hint.invalid = rgb(255,225,225) color.bg.textfield.hint.invalid = rgb(255,225,225)
color.fg.textfield.hint = color.fg color.fg.textfield.hint = color.fg
color.bg.tree.drag.no.selection = rgb(204, 204, 255)
color.bg.filterfield = yellow color.bg.filterfield = yellow
color.fg.filterfield = black color.fg.filterfield = black
@ -64,7 +71,7 @@ color.bg.fieldpanel = color.bg
color.fg.fieldpanel = color.fg color.fg.fieldpanel = color.fg
color.bg.fieldpanel.selection = color.bg.selection color.bg.fieldpanel.selection = color.bg.selection
color.bg.fieldpanel.highlight = color.bg.highlight color.bg.fieldpanel.highlight = color.bg.highlight
color.bg.fieldpanel.selection-highlight = green color.bg.fieldpanel.selection.and.highlight = green
// Icons files // Icons files
icon.empty = images/EmptyIcon16.gif icon.empty = images/EmptyIcon16.gif
@ -106,6 +113,7 @@ icon.theme.export = images/mail-folder-outbox.png
color.bg = #46494B // color used by flatlaf dark theme color.bg = #46494B // color used by flatlaf dark theme
color.fg = lightgray color.fg = lightgray
color.fg.error = indianRed color.fg.error = indianRed
color.fg.disabled = gray
color.fg.help.selector.h1 = #66AAF4 color.fg.help.selector.h1 = #66AAF4
color.fg.help.selector.h2 = #9999F9 color.fg.help.selector.h2 = #9999F9
@ -140,11 +148,15 @@ color.fg.filterfield = darkSlateGray
color.bg.selection = teal color.bg.selection = teal
color.bg.highlight = olive color.bg.highlight = olive
color.bg.fieldpanel.selection-highlight = darkGreen color.bg.fieldpanel.selection.and.highlight = darkGreen
color.bg.table.row.alt = rgb(45,47,65)
color.fg.table.uneditable.selected = lemonchiffon
color.fg.table.uneditable.unselected = lightgray
color.bg.tableheader.gradient.start = color.bg color.bg.tableheader.gradient.start = color.bg
color.bg.tableheader.gradient.end = darkGray color.bg.tableheader.gradient.end = darkGray
color.bg.tableheader.gradient.start.primary = color.bg color.bg.tableheader.gradient.start.primary = color.bg
color.bg.tableheader.gradient.end.primary = darkBlue color.bg.tableheader.gradient.end.primary = darkBlue
color.bg.table.row.alt = rgb(45,47,65)

View file

@ -29,7 +29,6 @@ public class PaintContext {
private Color selectionColor; private Color selectionColor;
private Color highlightColor; private Color highlightColor;
private Color selectedHighlightColor; private Color selectedHighlightColor;
private Color printColor;
private Color cursorColor; private Color cursorColor;
private Color focusedCursorColor; private Color focusedCursorColor;
@ -47,7 +46,7 @@ public class PaintContext {
foreground = new GColor("color.fg.fieldpanel"); foreground = new GColor("color.fg.fieldpanel");
selectionColor = new GColor("color.bg.fieldpanel.selection"); selectionColor = new GColor("color.bg.fieldpanel.selection");
highlightColor = new GColor("color.bg.fieldpanel.highlight"); highlightColor = new GColor("color.bg.fieldpanel.highlight");
selectedHighlightColor = new GColor("color.bg.fieldpanel.selection-highlight"); selectedHighlightColor = new GColor("color.bg.fieldpanel.selection.and.highlight");
focusedCursorColor = new GColor("color.cursor.focused"); focusedCursorColor = new GColor("color.cursor.focused");
notFocusedCursorColor = new GColor("color.cursor.unfocused"); notFocusedCursorColor = new GColor("color.cursor.unfocused");
cursorColor = focusedCursorColor; cursorColor = focusedCursorColor;
@ -64,7 +63,6 @@ public class PaintContext {
focusedCursorColor = other.focusedCursorColor; focusedCursorColor = other.focusedCursorColor;
notFocusedCursorColor = other.notFocusedCursorColor; notFocusedCursorColor = other.notFocusedCursorColor;
invisibleCursorColor = other.invisibleCursorColor; invisibleCursorColor = other.invisibleCursorColor;
printColor = other.printColor;
} }
/** /**
@ -177,10 +175,6 @@ public class PaintContext {
return notFocusedCursorColor; return notFocusedCursorColor;
} }
public void setPrintColor(Color c) {
printColor = c;
}
public void setPrinting(boolean b) { public void setPrinting(boolean b) {
printing = b; printing = b;
} }

View file

@ -23,6 +23,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import docking.widgets.table.constraint.ColumnConstraint; import docking.widgets.table.constraint.ColumnConstraint;
import generic.theme.GThemeDefaults.Colors;
import ghidra.util.HTMLUtilities; import ghidra.util.HTMLUtilities;
import ghidra.util.datastruct.WeakDataStructureFactory; import ghidra.util.datastruct.WeakDataStructureFactory;
import ghidra.util.datastruct.WeakSet; import ghidra.util.datastruct.WeakSet;
@ -206,7 +207,7 @@ public abstract class AbstractColumnConstraintEditor<T> implements ColumnConstra
* @return an HTML string suitable for a JLabel. * @return an HTML string suitable for a JLabel.
*/ */
protected final static String formatStatus(String message, boolean error) { protected final static String formatStatus(String message, boolean error) {
Color color = error ? Color.RED : Color.BLACK; Color color = error ? Colors.ERROR : Colors.FOREGROUND;
String messageWithFont = HTMLUtilities.setFont(message, color, 12); String messageWithFont = HTMLUtilities.setFont(message, color, 12);
String html = HTMLUtilities.wrapAsHTML(messageWithFont); String html = HTMLUtilities.wrapAsHTML(messageWithFont);
return html; return html;

View file

@ -78,7 +78,7 @@ public class GColor extends Color {
* Creates a transparent version of this GColor. If the underlying value of this GColor changes, * Creates a transparent version of this GColor. If the underlying value of this GColor changes,
* the transparent version will also change. * the transparent version will also change.
* @param newAlpha the transparency level for the new color * @param newAlpha the transparency level for the new color
* @return a tranparent version of this GColor * @return a transparent version of this GColor
*/ */
public GColor withAlpha(int newAlpha) { public GColor withAlpha(int newAlpha) {
return new GColor(id, newAlpha); return new GColor(id, newAlpha);

View file

@ -44,8 +44,12 @@ public class GThemeDefaults {
// generic color concepts // generic color concepts
//@formatter:off //@formatter:off
public static final GColor BACKGROUND = new GColor("color.bg"); public static final GColor BACKGROUND = new GColor("color.bg");
public static final GColor CURSOR = new GColor("color.cursor.focused");
public static final GColor DISABLED = new GColor("color.palette.disabled");
public static final GColor ERROR = new GColor("color.fg.error"); public static final GColor ERROR = new GColor("color.fg.error");
public static final GColor FOREGROUND = new GColor("color.fg"); public static final GColor FOREGROUND = new GColor("color.fg");
public static final GColor FOREGROUND_DISABLED = new GColor("color.fg.disabled");
public static final GColor TOOLTIP_BACKGROUND = new GColor("color.bg.tooltip"); public static final GColor TOOLTIP_BACKGROUND = new GColor("color.bg.tooltip");
//@formatter:on //@formatter:on
@ -53,6 +57,26 @@ public class GThemeDefaults {
public static final GColor BORDER = new GColor(Ids.Java.BORDER); public static final GColor BORDER = new GColor(Ids.Java.BORDER);
} }
public static class Tables {
public static final GColor FG_ERROR_SELECTED =
new GColor("color.fg.error.table.selected");
public static final GColor FG_ERROR_UNSELECTED =
new GColor("color.fg.error.table.unselected");
public static final GColor FG_UNEDITABLE_SELECTED =
new GColor("color.fg.table.uneditable.selected");
public static final GColor FG_UNEDITABLE_UNSELECTED =
new GColor("color.fg.table.uneditable.unselected");
}
public static class Dialogs {
public static final GColor FG_MESSAGE_NORMAL =
new GColor("color.fg.dialog.status.normal");
public static final GColor FG_MESSAGE_ERROR =
new GColor("color.fg.dialog.status.error");
}
/** /**
* Generic palette colors, using color names, that may be changed along with the theme * Generic palette colors, using color names, that may be changed along with the theme
*/ */
@ -69,6 +93,7 @@ public class GThemeDefaults {
public static final GColor GREEN = new GColor("color.palette.green"); public static final GColor GREEN = new GColor("color.palette.green");
public static final GColor LIGHT_GRAY = new GColor("color.palette.lightgray"); public static final GColor LIGHT_GRAY = new GColor("color.palette.lightgray");
public static final GColor LIME = new GColor("color.palette.lime"); public static final GColor LIME = new GColor("color.palette.lime");
public static final GColor MAGENTA = new GColor("color.palette.magenta");
public static final GColor ORANGE = new GColor("color.palette.orange"); public static final GColor ORANGE = new GColor("color.palette.orange");
public static final GColor PINK = new GColor("color.palette.pink"); public static final GColor PINK = new GColor("color.palette.pink");
public static final GColor RED = new GColor("color.palette.red"); public static final GColor RED = new GColor("color.palette.red");

View file

@ -0,0 +1,51 @@
/* ###
* 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 generic.theme;
import java.awt.Color;
/**
* A class to serve as a placeholder for migrating code. After the migration is complete, uses
* of this class can be removed, with the original code being restored in the process.
*/
public class TempColorUtils {
public static Color fromRgb(int rgb) {
return new Color(rgb);
}
public static Color fromRgba(int rgba) {
return new Color(rgba, true);
}
public static Color fromRgb(int r, int g, int b) {
return new Color(r, g, b);
}
public static Color blend1(Color primary, Color secondary) {
int red = (primary.getRed() * 2 + secondary.getRed()) / 3;
int green = (primary.getGreen() * 2 + secondary.getGreen()) / 3;
int blue = (primary.getBlue() * 2 + secondary.getBlue()) / 3;
return new Color(red, green, blue);
}
public static Color blend2(Color c, int value) {
int red = (c.getRed() + 3 * value) / 4;
int green = (c.getGreen() + 3 * value) / 4;
int blue = (c.getBlue() + 3 * value) / 4;
return new Color(red, green, blue);
}
}

View file

@ -6,8 +6,8 @@ color.fg.pluginpanel.description = gray
color.bg.panel.details = color.bg color.bg.panel.details = color.bg
color.fg.pluginpanel.details.title = maroon color.fg.pluginpanel.details.title = maroon
color.fg.pluginpanel.details.name.no-dependents = limeGreen color.fg.pluginpanel.details.name.no.dependents = limeGreen
color.fg.pluginpanel.details.name.has-dependents = red color.fg.pluginpanel.details.name.has.dependents = red
color.fg.pluginpanel.details.description = blue color.fg.pluginpanel.details.description = blue
color.fg.pluginpanel.details.category = magenta color.fg.pluginpanel.details.category = magenta
color.fg.pluginpanel.details.class = black color.fg.pluginpanel.details.class = black
@ -21,17 +21,12 @@ color.border.pluginpanel = darkGray
color.fg.plugin.installer.table.has.dependents = red color.fg.plugin.installer.table.has.dependents = red
color.fg.plugin.installer.table.has.dependents.selected = pink color.fg.plugin.installer.table.has.dependents.selected = pink
[Dark Defaults] [Dark Defaults]
color.fg.pluginpanel.details.title = indianRed
color.fg.pluginpanel.details.name.no-dependents = forestGreen
color.fg.pluginpanel.details.name.has-dependents = indianRed
color.fg.pluginpanel.details.description = blue
color.fg.pluginpanel.details.category = darkMagenta
color.fg.pluginpanel.details.class = gray
color.fg.pluginpanel.details.loc = darkGray
color.fg.pluginpanel.details.developer =mediumVioletRed
color.fg.pluginpanel.details.dependency = forestGreen
color.fg.pluginpanel.details.novalue = dimGray
color.fg.pluginpanel.name = #d3d3d3 // LightGray color.fg.pluginpanel.name = #d3d3d3 // LightGray
color.fg.pluginpanel.description = #808080 // Gray color.fg.pluginpanel.description = #808080 // Gray
@ -42,8 +37,8 @@ color.fg.pluginpanel.details.dependency = #228b22 // ForestGreen
color.fg.pluginpanel.details.description = #aaaaff color.fg.pluginpanel.details.description = #aaaaff
color.fg.pluginpanel.details.developer = #c71585 // MediumVioletRed color.fg.pluginpanel.details.developer = #c71585 // MediumVioletRed
color.fg.pluginpanel.details.loc = #a9a9a9 // DarkGray color.fg.pluginpanel.details.loc = #a9a9a9 // DarkGray
color.fg.pluginpanel.details.name.has-dependents = #cd939f color.fg.pluginpanel.details.name.has.dependents = #cd939f
color.fg.pluginpanel.details.name.no-dependents = #66ff66 color.fg.pluginpanel.details.name.no.dependents = #66ff66
color.fg.pluginpanel.details.novalue = #999900 color.fg.pluginpanel.details.novalue = #999900
color.fg.pluginpanel.details.title = #cd939f color.fg.pluginpanel.details.title = #cd939f

View file

@ -254,14 +254,14 @@ class PluginDetailsPanel extends AbstractDetailsPanel {
nameAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11)); nameAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
nameAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); nameAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
nameAttrSet.addAttribute(StyleConstants.Foreground, nameAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.name.no-dependents")); new GColor("color.fg.pluginpanel.details.name.no.dependents"));
depNameAttrSet = new SimpleAttributeSet(); depNameAttrSet = new SimpleAttributeSet();
depNameAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); depNameAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");
depNameAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11)); depNameAttrSet.addAttribute(StyleConstants.FontSize, Integer.valueOf(11));
depNameAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE); depNameAttrSet.addAttribute(StyleConstants.Bold, Boolean.TRUE);
depNameAttrSet.addAttribute(StyleConstants.Foreground, depNameAttrSet.addAttribute(StyleConstants.Foreground,
new GColor("color.fg.pluginpanel.details.name.has-dependents")); new GColor("color.fg.pluginpanel.details.name.has.dependents"));
descrAttrSet = new SimpleAttributeSet(); descrAttrSet = new SimpleAttributeSet();
descrAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma"); descrAttrSet.addAttribute(StyleConstants.FontFamily, "Tahoma");