mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-1981 converting option colors to theme colors and font usages to
theme properties
This commit is contained in:
parent
79b95702ba
commit
45395d7575
110 changed files with 888 additions and 1151 deletions
|
@ -63,6 +63,8 @@ color.debugger.plugin.resources.breakpoint.marker.disabled.ineffective = color.d
|
|||
icon.debugger.object.populated = object-populated.png
|
||||
icon.debugger.object.unpopulated = object-unpopulated.png
|
||||
|
||||
font.debugger.object.tree.renderer = Tahoma-plain-11
|
||||
|
||||
icon.debugger.display.graph = breakpoint-enable.png // TODO this icon was missing 'breakpoints.png'
|
||||
icon.debugger.display.graph.filtered = icon.debugger.display.graph
|
||||
icon.debugger.display.xml = text-xml.png
|
||||
|
|
|
@ -23,21 +23,18 @@ import javax.swing.tree.TreePath;
|
|||
|
||||
import docking.widgets.tree.support.GTreeRenderer;
|
||||
import generic.theme.GThemeDefaults.Colors.Tables;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.plugin.core.debug.gui.objects.DebuggerObjectsProvider;
|
||||
import ghidra.app.plugin.core.debug.gui.objects.ObjectContainer;
|
||||
import ghidra.dbg.target.TargetExecutionStateful;
|
||||
import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
|
||||
import ghidra.dbg.target.TargetObject;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
||||
// TODO: In the new scheme, I'm not sure this is applicable anymore.
|
||||
class ObjectTreeCellRenderer extends GTreeRenderer {
|
||||
private static final String FONT_ID = "font.debugger.object.tree.renderer";
|
||||
|
||||
private final DebuggerObjectsProvider provider;
|
||||
private Font defaultFont =
|
||||
SystemUtilities.adjustForFontSizeOverride(new Font("Tahoma", Font.PLAIN, 11));
|
||||
private Font unsubscribedFont =
|
||||
SystemUtilities.adjustForFontSizeOverride(new Font("Tahoma", Font.ITALIC, 11));
|
||||
|
||||
public ObjectTreeCellRenderer(DebuggerObjectsProvider provider) {
|
||||
this.provider = provider;
|
||||
|
@ -102,7 +99,11 @@ class ObjectTreeCellRenderer extends GTreeRenderer {
|
|||
}
|
||||
}
|
||||
}
|
||||
component.setFont(container.isSubscribed() ? defaultFont : unsubscribedFont);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
if (container.isSubscribed()) {
|
||||
font = font.deriveFont(Font.ITALIC);
|
||||
}
|
||||
component.setFont(font);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public class HelloWorldComponentProvider extends ComponentProviderAdapter {
|
|||
panel.setBorder(BorderFactory.createTitledBorder("Example of a Component"));
|
||||
activeButtonObj = new MyButton("Hello World");
|
||||
Font f = activeButtonObj.getFont();
|
||||
activeButtonObj.setFont(new Font(f.getFontName(), Font.BOLD, 14));
|
||||
activeButtonObj.setFont(f.deriveFont(Font.BOLD, 14));
|
||||
panel.add(activeButtonObj);
|
||||
mainPanel.add(panel, BorderLayout.CENTER);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ color.bg.listing.comparison.operand = chartreuse
|
|||
color.bg.listing.comparison.code.units.diff = silver
|
||||
color.bg.listing.comparison.code.units.unmatched = skyblue
|
||||
|
||||
|
||||
font.listing.base = font.monospaced
|
||||
font.listing.header = SansSerif-PLAIN-11
|
||||
|
||||
|
||||
[Dark Defaults]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
|
||||
[Defaults]
|
||||
|
||||
|
||||
color.bg.plugin.programgraph.vertex.selection = color.graphdisplay.vertex.selected
|
||||
color.bg.plugin.programgraph.edge.selection = color.graphdisplay.edge.selected
|
||||
|
||||
color.bg.plugin.programgraph.edge.call.callother.override = red
|
||||
color.bg.plugin.programgraph.edge.call.computed = cyan
|
||||
|
@ -50,7 +51,7 @@ color.bg.plugin.programgraph.vertex.entry.nexus = wheat
|
|||
color.bg.plugin.programgraph.vertex.instruction = blue
|
||||
color.bg.plugin.programgraph.vertex.stack = green
|
||||
|
||||
|
||||
font.plugin.programgraph = font.graphdisplay.default
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
|
|
|
@ -158,8 +158,18 @@ color.bg.plugin.windowlocation.screens = orange
|
|||
color.bg.plugin.windowlocation.window.selected = rgba(0, 255, 0, 200)
|
||||
color.fg.plugin.windowlocation.window.text = gray
|
||||
|
||||
|
||||
|
||||
font.print = SansSerif-PLAIN-10
|
||||
font.plugin.console = font.monospaced
|
||||
font.plugin.service.text.editor = font.monospaced
|
||||
font.plugin.scripts.text.editor = font.monospaced
|
||||
font.plugin.assembly.dual.text.field = font.monospaced
|
||||
font.plugin.instruction.table.renderer = courier-plain-14
|
||||
font.plugin.entropy.label.knot = SansSerif-BOLD-12
|
||||
font.plugin.instruction.info = font.monospaced[14]
|
||||
font.plugin.tabs = SansSerif-PLAIN-11
|
||||
font.plugin.tabs.list = SansSerif-BOLD-9
|
||||
font.plugin.tips = Dialog-PLAIN-12
|
||||
font.plugin.tips.label = font.plugin.tips[BOLD]
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
|
|
|
@ -15,15 +15,8 @@
|
|||
*/
|
||||
package ghidra.app.merge.tool;
|
||||
|
||||
import ghidra.app.context.ListingActionContext;
|
||||
import ghidra.app.context.ListingContextAction;
|
||||
import ghidra.app.merge.listing.CodeUnitDetails;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
|
@ -33,6 +26,14 @@ import docking.DialogComponentProvider;
|
|||
import docking.action.KeyBindingData;
|
||||
import docking.action.MenuData;
|
||||
import docking.widgets.fieldpanel.FieldPanel;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.context.ListingActionContext;
|
||||
import ghidra.app.context.ListingContextAction;
|
||||
import ghidra.app.merge.listing.CodeUnitDetails;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
||||
public class ViewInstructionDetailsAction extends ListingContextAction {
|
||||
|
||||
|
@ -47,8 +48,8 @@ public class ViewInstructionDetailsAction extends ListingContextAction {
|
|||
setKeyBindingData(new KeyBindingData(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK |
|
||||
InputEvent.SHIFT_DOWN_MASK));
|
||||
setEnabled(true);
|
||||
setDescription("Display a dialog indicating details, such as references, for the "
|
||||
+ "instruction at the current cursor location.");
|
||||
setDescription("Display a dialog indicating details, such as references, for the " +
|
||||
"instruction at the current cursor location.");
|
||||
setHelpLocation(HELP_LOCATION);
|
||||
}
|
||||
|
||||
|
@ -87,13 +88,11 @@ public class ViewInstructionDetailsAction extends ListingContextAction {
|
|||
}
|
||||
|
||||
private JScrollPane createDetailsPane(String details) {
|
||||
Font font = new Font("Monospaced", Font.PLAIN, 12);
|
||||
|
||||
JTextArea textArea = new JTextArea();
|
||||
Gui.registerFont(textArea, "font.monospaced");
|
||||
textArea.setLineWrap(false);
|
||||
textArea.setEditable(false);
|
||||
textArea.setMargin(new Insets(5, 5, 5, 5));
|
||||
textArea.setFont(font);
|
||||
textArea.setOpaque(true);
|
||||
textArea.setCaretPosition(0);
|
||||
textArea.setText(details);
|
||||
|
@ -102,8 +101,10 @@ public class ViewInstructionDetailsAction extends ListingContextAction {
|
|||
JViewport vp = scrolledDetails.getViewport();
|
||||
vp.add(textArea);
|
||||
|
||||
scrolledDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scrolledDetails.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
scrolledDetails
|
||||
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scrolledDetails
|
||||
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
return scrolledDetails;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class TreeChangePanel extends JPanel {
|
|||
|
||||
treeNameLabel = new GDLabel("Tree Name");
|
||||
Font font = treeNameLabel.getFont();
|
||||
font = new Font(font.getName(), Font.BOLD, font.getSize());
|
||||
font = font.deriveFont(Font.BOLD);
|
||||
treeNameLabel.setFont(font);
|
||||
|
||||
nameLabel = new GDLabel("Name Changed");
|
||||
|
|
|
@ -94,7 +94,7 @@ public class ArchiveDialog extends DialogComponentProvider {
|
|||
}
|
||||
});
|
||||
Font font = archiveBrowse.getFont();
|
||||
archiveBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
|
||||
archiveBrowse.setFont(font.deriveFont(Font.BOLD));
|
||||
archiveBrowse.setName("archiveBrowse");
|
||||
|
||||
// Layout the components.
|
||||
|
@ -269,7 +269,9 @@ public class ArchiveDialog extends DialogComponentProvider {
|
|||
return true;
|
||||
}
|
||||
|
||||
return file.getAbsolutePath().toLowerCase().endsWith(
|
||||
return file.getAbsolutePath()
|
||||
.toLowerCase()
|
||||
.endsWith(
|
||||
ArchivePlugin.ARCHIVE_EXTENSION);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class RestoreDialog extends DialogComponentProvider {
|
|||
}
|
||||
});
|
||||
Font font = archiveBrowse.getFont();
|
||||
archiveBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
|
||||
archiveBrowse.setFont(font.deriveFont(Font.BOLD));
|
||||
|
||||
restoreLabel = new GDLabel(" Restore Directory ");
|
||||
restoreField = new JTextField();
|
||||
|
@ -131,7 +131,7 @@ public class RestoreDialog extends DialogComponentProvider {
|
|||
}
|
||||
});
|
||||
font = restoreBrowse.getFont();
|
||||
restoreBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
|
||||
restoreBrowse.setFont(font.deriveFont(Font.BOLD));
|
||||
|
||||
projectNameLabel = new GDLabel(" Project Name ");
|
||||
projectNameField = new JTextField();
|
||||
|
|
|
@ -27,8 +27,7 @@ import docking.EmptyBorderToggleButton;
|
|||
import docking.widgets.autocomplete.*;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import docking.widgets.textfield.TextFieldLinker;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.*;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import ghidra.GhidraApplicationLayout;
|
||||
import ghidra.GhidraLaunchable;
|
||||
|
@ -62,7 +61,7 @@ import ghidra.util.NumericUtilities;
|
|||
* Otherwise, the usual autocompletion behavior is applied automatically.
|
||||
*/
|
||||
public class AssemblyDualTextField {
|
||||
|
||||
private static final String FONT_ID = "font.plugin.assembly.dual.text.field";
|
||||
private static Color FG_PREFERENCE_MOST =
|
||||
new GColor("color.fg.plugin.assembler.completion.most");
|
||||
private static Color FG_PREFERENCE_MIDDLE =
|
||||
|
@ -659,8 +658,7 @@ public class AssemblyDualTextField {
|
|||
* @param field the field to configure
|
||||
*/
|
||||
protected void configureField(JTextField field) {
|
||||
Font mono = new Font(Font.MONOSPACED, Font.PLAIN, 12); // TODO: Font size from options
|
||||
field.setFont(mono);
|
||||
Gui.registerFont(field, FONT_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,9 +26,10 @@ import javax.swing.text.Document;
|
|||
import docking.*;
|
||||
import docking.action.*;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.services.*;
|
||||
import ghidra.framework.main.ConsoleTextPane;
|
||||
import ghidra.framework.options.OptionsChangeListener;
|
||||
import ghidra.framework.options.OptionType;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.ComponentProviderAdapter;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
|
@ -36,21 +37,21 @@ import ghidra.program.model.address.Address;
|
|||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.SymbolIterator;
|
||||
import ghidra.program.model.symbol.SymbolTable;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
public class ConsoleComponentProvider extends ComponentProviderAdapter
|
||||
implements ConsoleService, OptionsChangeListener {
|
||||
implements ConsoleService {
|
||||
|
||||
private static final String OLD_NAME = "ConsolePlugin";
|
||||
private static final String NAME = "Console";
|
||||
|
||||
private static final Font DEFAULT_FONT = new Font("monospaced", Font.PLAIN, 12);
|
||||
private static final String DEFAULT_FONT_ID = "font.plugin.console";
|
||||
private static final String FONT_OPTION_LABEL = "Font";
|
||||
private static final String FONT_DESCRIPTION =
|
||||
"This is the font that will be used in the Console. " +
|
||||
"Double-click the font example to change it.";
|
||||
|
||||
private Font font;
|
||||
private ConsoleTextPane textPane;
|
||||
private JScrollPane scroller;
|
||||
private JComponent component;
|
||||
|
@ -103,27 +104,16 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
|
|||
private void createOptions() {
|
||||
ToolOptions options = tool.getOptions("Console");
|
||||
HelpLocation help = new HelpLocation(getOwner(), getOwner());
|
||||
options.registerOption(FONT_OPTION_LABEL, DEFAULT_FONT, help, FONT_DESCRIPTION);
|
||||
options.registerOption(FONT_OPTION_LABEL, OptionType.FONT_TYPE, DEFAULT_FONT_ID, help,
|
||||
FONT_DESCRIPTION);
|
||||
options.setOptionsHelpLocation(help);
|
||||
font = options.getFont(FONT_OPTION_LABEL, DEFAULT_FONT);
|
||||
font = SystemUtilities.adjustForFontSizeOverride(font);
|
||||
options.addOptionsChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
|
||||
Object newValue) {
|
||||
if (optionName.equals(FONT_OPTION_LABEL)) {
|
||||
font = SystemUtilities.adjustForFontSizeOverride((Font) newValue);
|
||||
textPane.setFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
private void build() {
|
||||
|
||||
textPane = new ConsoleTextPane(tool);
|
||||
textPane.setName("CONSOLE");
|
||||
textPane.setFont(font);
|
||||
Gui.registerFont(textPane, DEFAULT_FONT_ID);
|
||||
textPane.setEditable(false);
|
||||
textPane.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
|
|
|
@ -491,7 +491,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
|
|||
OptionsGui.BACKGROUND.getDefaultColor());
|
||||
|
||||
// font
|
||||
font = opt.getFont(ADDRESS_FONT_OPTION, FieldFactory.DEFAULT_FIELD_FONT);
|
||||
font = Gui.getFont(FieldFactory.BASE_LISTING_FONT_ID);
|
||||
|
||||
contentList.setForeground(addressForegroundColor);
|
||||
contentList.setBackground(backgroundColor);
|
||||
|
@ -580,7 +580,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
|
|||
contentList.setBackground(backgroundColor);
|
||||
}
|
||||
else if (optionName.equals(ADDRESS_FONT_OPTION)) {
|
||||
font = (Font) newValue;
|
||||
font = Gui.getFont(FieldFactory.BASE_LISTING_FONT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ import java.awt.Dimension;
|
|||
import java.awt.Font;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.*;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
|
@ -36,7 +34,7 @@ import docking.options.editor.FontEditor;
|
|||
import docking.widgets.OptionDialog;
|
||||
import docking.widgets.filechooser.GhidraFileChooser;
|
||||
import generic.theme.GIcon;
|
||||
import ghidra.framework.options.SaveState;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.framework.plugintool.ComponentProviderAdapter;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -45,24 +43,9 @@ import resources.Icons;
|
|||
|
||||
public class TextEditorComponentProvider extends ComponentProviderAdapter {
|
||||
private static final String TITLE = "Text Editor";
|
||||
|
||||
private static final String FONT_ID = "font.plugin.service.text.editor";
|
||||
private static final int MAX_UNDO_REDO_SIZE = 50;
|
||||
|
||||
static Font defaultFont = new Font("monospaced", Font.PLAIN, 12);
|
||||
|
||||
static void restoreState(SaveState saveState) {
|
||||
String name = saveState.getString("DEFAULT_FONT_NAME", "Monospaced");
|
||||
int style = saveState.getInt("DEFAULT_FONT_STYLE", Font.PLAIN);
|
||||
int size = saveState.getInt("DEFAULT_FONT_SIZE", 12);
|
||||
defaultFont = new Font(name, style, size);
|
||||
}
|
||||
|
||||
static void saveState(SaveState saveState) {
|
||||
saveState.putString("DEFAULT_FONT_NAME", defaultFont.getName());
|
||||
saveState.putInt("DEFAULT_FONT_STYLE", defaultFont.getStyle());
|
||||
saveState.putInt("DEFAULT_FONT_SIZE", defaultFont.getSize());
|
||||
}
|
||||
|
||||
private TextEditorManagerPlugin plugin;
|
||||
private GhidraFileChooser chooser;
|
||||
private File textFile;
|
||||
|
@ -289,16 +272,9 @@ public class TextEditorComponentProvider extends ComponentProviderAdapter {
|
|||
|
||||
protected void doSelectFont() {
|
||||
FontEditor editor = new FontEditor();
|
||||
editor.setValue(defaultFont);
|
||||
editor.setValue(Gui.getFont(FONT_ID));
|
||||
editor.showDialog();
|
||||
defaultFont = (Font) editor.getValue();
|
||||
|
||||
List<TextEditorComponentProvider> values = plugin.getEditors();
|
||||
Iterator<TextEditorComponentProvider> iterator = values.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TextEditorComponentProvider editorComponent = iterator.next();
|
||||
editorComponent.textarea.setFont(defaultFont);
|
||||
}
|
||||
Gui.setFont(FONT_ID, (Font) editor.getValue());
|
||||
}
|
||||
|
||||
private void save() {
|
||||
|
@ -391,8 +367,7 @@ public class TextEditorComponentProvider extends ComponentProviderAdapter {
|
|||
|
||||
private KeyMasterTextArea(String text) {
|
||||
super(text);
|
||||
|
||||
setFont(defaultFont);
|
||||
Gui.registerFont(this, FONT_ID);
|
||||
setName("EDITOR");
|
||||
setWrapStyleWord(false);
|
||||
Document document = getDocument();
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.swing.event.ChangeListener;
|
|||
import docking.DialogComponentProvider;
|
||||
import docking.widgets.button.GRadioButton;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.util.AddressInput;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
@ -162,8 +163,7 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
|
|||
|
||||
addressLabel = new GDLabel("01001000");
|
||||
|
||||
Font font = addressLabel.getFont();
|
||||
Font monoFont = new Font("monospaced", font.getStyle(), font.getSize());
|
||||
Font monoFont = Gui.getFont("font.monospaced");
|
||||
addressLabel.setFont(monoFont);
|
||||
|
||||
instLabel = new GDLabel("jmp DAT_01001000");
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.instructionsearch.ui;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
|
@ -58,8 +56,7 @@ public abstract class AbstractInstructionTable extends GhidraTable {
|
|||
|
||||
protected JToolBar toolbar;
|
||||
|
||||
protected InstructionTableCellRenderer renderer =
|
||||
new InstructionTableCellRenderer(new Font("Courier", Font.PLAIN, 14));
|
||||
protected InstructionTableCellRenderer renderer = new InstructionTableCellRenderer();
|
||||
|
||||
protected InstructionSearchData searchData;
|
||||
|
||||
|
|
|
@ -30,9 +30,10 @@ import ghidra.util.table.GhidraTableCellRenderer;
|
|||
* while adding some custom logic for changing background/foreground attributes.
|
||||
*/
|
||||
public class InstructionTableCellRenderer extends GhidraTableCellRenderer {
|
||||
private static final String FONT_ID = "font.plugin.instruction.table.renderer";
|
||||
|
||||
public InstructionTableCellRenderer(Font font) {
|
||||
super(font);
|
||||
public InstructionTableCellRenderer() {
|
||||
super(Gui.getFont(FONT_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,20 +29,21 @@ import javax.swing.text.*;
|
|||
import docking.DockingUtils;
|
||||
import docking.actions.KeyBindingUtils;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.Gui;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.app.plugin.core.console.CodeCompletion;
|
||||
import ghidra.framework.options.OptionsChangeListener;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.options.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
public class InterpreterPanel extends JPanel implements OptionsChangeListener {
|
||||
|
||||
private static final String COLOR_ID = "interpreterpanel.color";
|
||||
private static final String COMPLETION_WINDOW_TRIGGER_LABEL = "Completion Window Trigger";
|
||||
private static final String COMPLETION_WINDOW_TRIGGER_DESCRIPTION =
|
||||
"The key binding used to show the auto-complete window " +
|
||||
"(for those consoles that have auto-complete).";
|
||||
private static final String FONT_ID = "font.plugin.console";
|
||||
private static final String FONT_OPTION_LABEL = "Font";
|
||||
private static final String FONT_DESCRIPTION =
|
||||
"This is the font that will be used in the Console. " +
|
||||
|
@ -70,8 +71,6 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
|
|||
private PrintWriter outWriter;
|
||||
private PrintWriter errWriter;
|
||||
|
||||
private Font basicFont = getBasicFont();
|
||||
private Font basicBoldFont = getBoldFont(basicFont);
|
||||
private SimpleAttributeSet STDOUT_SET;
|
||||
private SimpleAttributeSet STDERR_SET;
|
||||
private SimpleAttributeSet STDIN_SET;
|
||||
|
@ -83,14 +82,6 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
|
|||
private boolean caretGuard = true;
|
||||
private PluginTool tool;
|
||||
|
||||
private static Font getBasicFont() {
|
||||
return new Font(Font.MONOSPACED, Font.PLAIN, 20);
|
||||
}
|
||||
|
||||
private static Font getBoldFont(Font font) {
|
||||
return font.deriveFont(Font.BOLD);
|
||||
}
|
||||
|
||||
private static SimpleAttributeSet createAttributes(Font font, Color color) {
|
||||
SimpleAttributeSet attributeSet = new SimpleAttributeSet();
|
||||
attributeSet.addAttribute(StyleConstants.FontFamily, font.getFamily());
|
||||
|
@ -370,15 +361,14 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateFontAttributes(Font newFont) {
|
||||
basicFont = newFont;
|
||||
basicBoldFont = getBoldFont(newFont);
|
||||
STDOUT_SET = createAttributes(basicFont, NORMAL_COLOR);
|
||||
STDERR_SET = createAttributes(basicFont, ERROR_COLOR);
|
||||
STDIN_SET = createAttributes(basicBoldFont, NORMAL_COLOR);
|
||||
private void updateFontAttributes(Font font) {
|
||||
Font boldFont = font.deriveFont(Font.BOLD);
|
||||
STDOUT_SET = createAttributes(font, NORMAL_COLOR);
|
||||
STDERR_SET = createAttributes(font, ERROR_COLOR);
|
||||
STDIN_SET = createAttributes(boldFont, NORMAL_COLOR);
|
||||
|
||||
setTextPaneFont(inputTextPane, basicBoldFont);
|
||||
setTextPaneFont(promptTextPane, basicFont);
|
||||
setTextPaneFont(inputTextPane, boldFont);
|
||||
setTextPaneFont(promptTextPane, font);
|
||||
setPrompt(promptTextPane.getText());
|
||||
}
|
||||
|
||||
|
@ -389,13 +379,13 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
|
|||
HelpLocation help = new HelpLocation(getName(), "ConsolePlugin");
|
||||
options.setOptionsHelpLocation(help);
|
||||
|
||||
options.registerOption(FONT_OPTION_LABEL, basicFont, help, FONT_DESCRIPTION);
|
||||
options.registerOption(FONT_OPTION_LABEL, OptionType.FONT_TYPE, FONT_ID, help,
|
||||
FONT_DESCRIPTION);
|
||||
options.registerOption(COMPLETION_WINDOW_TRIGGER_LABEL, CompletionWindowTrigger.TAB, help,
|
||||
COMPLETION_WINDOW_TRIGGER_DESCRIPTION);
|
||||
|
||||
basicFont = options.getFont(FONT_OPTION_LABEL, basicFont);
|
||||
basicFont = SystemUtilities.adjustForFontSizeOverride(basicFont);
|
||||
updateFontAttributes(basicFont);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
updateFontAttributes(font);
|
||||
|
||||
completionWindowTrigger =
|
||||
options.getEnum(COMPLETION_WINDOW_TRIGGER_LABEL, CompletionWindowTrigger.TAB);
|
||||
|
@ -413,8 +403,8 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
|
|||
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
|
||||
Object newValue) {
|
||||
if (optionName.equals(FONT_OPTION_LABEL)) {
|
||||
basicFont = SystemUtilities.adjustForFontSizeOverride((Font) newValue);
|
||||
updateFontAttributes(basicFont);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
updateFontAttributes(font);
|
||||
}
|
||||
else if (optionName.equals(COMPLETION_WINDOW_TRIGGER_LABEL)) {
|
||||
completionWindowTrigger = (CompletionWindowTrigger) newValue;
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.swing.table.TableColumnModel;
|
|||
import docking.widgets.GenericDateCellRenderer;
|
||||
import docking.widgets.table.GTableCellRenderer;
|
||||
import docking.widgets.table.GTableCellRenderingData;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.LabelHistory;
|
||||
import ghidra.util.table.GhidraTable;
|
||||
|
@ -126,16 +127,11 @@ class LabelHistoryPanel extends JPanel {
|
|||
|
||||
private Font monoFont;
|
||||
|
||||
LabelCellRenderer() {
|
||||
Font f = getFont();
|
||||
monoFont = new Font("monospaced", f.getStyle(), f.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
|
||||
|
||||
Component c = super.getTableCellRendererComponent(data);
|
||||
c.setFont(monoFont);
|
||||
c.setFont(Gui.getFont("font.monospaced"));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,34 +39,29 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
|
|||
"Color to use for highlighting a specific range of entropy values";
|
||||
private static final String KNOT_TYPE_STRING = "Type of range to highlight";
|
||||
|
||||
private static final String KNOT1_COLOR_STRING = "Range 1 color";
|
||||
private static final String KNOT1_TYPE_STRING = "Entropy Range 1";
|
||||
private static final Color KNOT1_DEF_COLOR =
|
||||
new GColor("color.bg.plugin.overview.entropy.knot.1");
|
||||
private static final String KNOT1_COLOR_OPTION_NAME = "Range 1 color";
|
||||
private static final String KNOT1_TYPE_OPTION_NAME = "Entropy Range 1";
|
||||
private static final Color KNOT1_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.1");
|
||||
private static final EntropyKnot KNOT1_DEF_TYPE = EntropyKnot.COMPRESSED;
|
||||
|
||||
private static final String KNOT2_COLOR_STRING = "Range 2 color";
|
||||
private static final String KNOT2_TYPE_STRING = "Entropy Range 2";
|
||||
private static final Color KNOT2_DEF_COLOR =
|
||||
new GColor("color.bg.plugin.overview.entropy.knot.2");
|
||||
private static final String KNOT2_COLOR_OPTION_NAME = "Range 2 color";
|
||||
private static final String KNOT2_TYPE_OPTION_NAME = "Entropy Range 2";
|
||||
private static final Color KNOT2_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.2");
|
||||
private static final EntropyKnot KNOT2_DEF_TYPE = EntropyKnot.X86;
|
||||
|
||||
private static final String KNOT3_COLOR_STRING = "Range 3 color";
|
||||
private static final String KNOT3_TYPE_STRING = "Entropy Range 3";
|
||||
private static final Color KNOT3_DEF_COLOR =
|
||||
new GColor("color.bg.plugin.overview.entropy.knot.3");
|
||||
private static final String KNOT3_COLOR_OPTION_NAME = "Range 3 color";
|
||||
private static final String KNOT3_TYPE_OPTION_NAME = "Entropy Range 3";
|
||||
private static final Color KNOT3_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.3");
|
||||
private static final EntropyKnot KNOT3_DEF_TYPE = EntropyKnot.ASCII;
|
||||
|
||||
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 String KNOT4_COLOR_OPTION_NAME = "Range 4 color";
|
||||
private static final String KNOT4_TYPE_OPTION_NAME = "Entropy Range 4";
|
||||
private static final Color KNOT4_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.4");
|
||||
private static final 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 String KNOT5_COLOR_OPTION_NAME = "Range 5 color";
|
||||
private static final String KNOT5_TYPE_OPTION_NAME = "Entropy Range 5";
|
||||
private static final Color KNOT5_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.5");
|
||||
private static final EntropyKnot KNOT5_DEF_TYPE = EntropyKnot.NONE;
|
||||
|
||||
private static final Color PALETTE_COLOR_HIGH =
|
||||
|
@ -75,15 +70,10 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
|
|||
new GColor("color.bg.plugin.overview.entropy.palette.base.low");
|
||||
|
||||
private EntropyChunkSize chunksize;
|
||||
private Color knot1color;
|
||||
private EntropyKnot knot1type;
|
||||
private Color knot2color;
|
||||
private EntropyKnot knot2type;
|
||||
private Color knot3color;
|
||||
private EntropyKnot knot3type;
|
||||
private Color knot4color;
|
||||
private EntropyKnot knot4type;
|
||||
private Color knot5color;
|
||||
private EntropyKnot knot5type;
|
||||
private OverviewPalette palette = new OverviewPalette(256, UNINITIALIZED_COLOR);
|
||||
private EntropyOverviewColorService service;
|
||||
|
@ -97,17 +87,22 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
|
|||
options.setOptionsHelpLocation(help);
|
||||
|
||||
options.registerOption(CHUNKSIZE_STRING, CHUNKSIZE_DEF, help, CHUNKSIZE_DESC_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(KNOT3_COLOR_STRING, KNOT3_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(KNOT1_COLOR_OPTION_NAME, KNOT1_COLOR, help,
|
||||
KNOT_COLOR_STRING);
|
||||
options.registerOption(KNOT2_COLOR_OPTION_NAME, KNOT2_COLOR, help,
|
||||
KNOT_COLOR_STRING);
|
||||
options.registerOption(KNOT3_COLOR_OPTION_NAME, KNOT3_COLOR, help,
|
||||
KNOT_COLOR_STRING);
|
||||
options.registerOption(KNOT4_COLOR_OPTION_NAME, KNOT4_COLOR, help,
|
||||
KNOT_COLOR_STRING);
|
||||
options.registerOption(KNOT5_COLOR_OPTION_NAME, KNOT5_COLOR, help,
|
||||
KNOT_COLOR_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(KNOT3_TYPE_STRING, KNOT3_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(KNOT1_TYPE_OPTION_NAME, KNOT1_DEF_TYPE, help, KNOT_TYPE_STRING);
|
||||
options.registerOption(KNOT2_TYPE_OPTION_NAME, KNOT2_DEF_TYPE, help, KNOT_TYPE_STRING);
|
||||
options.registerOption(KNOT3_TYPE_OPTION_NAME, KNOT3_DEF_TYPE, help, KNOT_TYPE_STRING);
|
||||
options.registerOption(KNOT4_TYPE_OPTION_NAME, KNOT4_DEF_TYPE, help, KNOT_TYPE_STRING);
|
||||
options.registerOption(KNOT5_TYPE_OPTION_NAME, KNOT5_DEF_TYPE, help, KNOT_TYPE_STRING);
|
||||
|
||||
readOptions(options);
|
||||
updatePalettes();
|
||||
|
@ -124,17 +119,11 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
|
|||
private void readOptions(ToolOptions options) {
|
||||
chunksize = options.getEnum(CHUNKSIZE_STRING, CHUNKSIZE_DEF);
|
||||
|
||||
knot1color = options.getColor(KNOT1_COLOR_STRING, KNOT1_DEF_COLOR);
|
||||
knot2color = options.getColor(KNOT2_COLOR_STRING, KNOT2_DEF_COLOR);
|
||||
knot3color = options.getColor(KNOT3_COLOR_STRING, KNOT3_DEF_COLOR);
|
||||
knot4color = options.getColor(KNOT4_COLOR_STRING, KNOT4_DEF_COLOR);
|
||||
knot5color = options.getColor(KNOT5_COLOR_STRING, KNOT5_DEF_COLOR);
|
||||
|
||||
knot1type = options.getEnum(KNOT1_TYPE_STRING, KNOT1_DEF_TYPE);
|
||||
knot2type = options.getEnum(KNOT2_TYPE_STRING, KNOT2_DEF_TYPE);
|
||||
knot3type = options.getEnum(KNOT3_TYPE_STRING, KNOT3_DEF_TYPE);
|
||||
knot4type = options.getEnum(KNOT4_TYPE_STRING, KNOT4_DEF_TYPE);
|
||||
knot5type = options.getEnum(KNOT5_TYPE_STRING, KNOT5_DEF_TYPE);
|
||||
knot1type = options.getEnum(KNOT1_TYPE_OPTION_NAME, KNOT1_DEF_TYPE);
|
||||
knot2type = options.getEnum(KNOT2_TYPE_OPTION_NAME, KNOT2_DEF_TYPE);
|
||||
knot3type = options.getEnum(KNOT3_TYPE_OPTION_NAME, KNOT3_DEF_TYPE);
|
||||
knot4type = options.getEnum(KNOT4_TYPE_OPTION_NAME, KNOT4_DEF_TYPE);
|
||||
knot5type = options.getEnum(KNOT5_TYPE_OPTION_NAME, KNOT5_DEF_TYPE);
|
||||
|
||||
}
|
||||
|
||||
|
@ -161,23 +150,23 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
|
|||
private void addPaletteKnots() {
|
||||
EntropyRecord rec = knot1type.getRecord();
|
||||
if (rec != null) {
|
||||
addPaletteKnot(rec.name, knot1color, rec.center, rec.width);
|
||||
addPaletteKnot(rec.name, KNOT1_COLOR, rec.center, rec.width);
|
||||
}
|
||||
rec = knot2type.getRecord();
|
||||
if (rec != null) {
|
||||
addPaletteKnot(rec.name, knot2color, rec.center, rec.width);
|
||||
addPaletteKnot(rec.name, KNOT2_COLOR, rec.center, rec.width);
|
||||
}
|
||||
rec = knot3type.getRecord();
|
||||
if (rec != null) {
|
||||
addPaletteKnot(rec.name, knot3color, rec.center, rec.width);
|
||||
addPaletteKnot(rec.name, KNOT3_COLOR, rec.center, rec.width);
|
||||
}
|
||||
rec = knot4type.getRecord();
|
||||
if (rec != null) {
|
||||
addPaletteKnot(rec.name, knot4color, rec.center, rec.width);
|
||||
addPaletteKnot(rec.name, KNOT4_COLOR, rec.center, rec.width);
|
||||
}
|
||||
rec = knot5type.getRecord();
|
||||
if (rec != null) {
|
||||
addPaletteKnot(rec.name, knot5color, rec.center, rec.width);
|
||||
addPaletteKnot(rec.name, KNOT5_COLOR, rec.center, rec.width);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,10 @@ import java.util.ArrayList;
|
|||
import javax.swing.JPanel;
|
||||
|
||||
import generic.theme.GThemeDefaults.Colors.Java;
|
||||
import generic.theme.Gui;
|
||||
|
||||
public class KnotLabelPanel extends JPanel {
|
||||
private static final Font FONT = new Font("Times New Roman", Font.BOLD, 16);
|
||||
private static final String FONT_ID = "font.plugin.entropy.label.knot";
|
||||
private int topBottomMargin = 10;
|
||||
private OverviewPalette palette;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public class KnotLabelPanel extends JPanel {
|
|||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, width, height);
|
||||
int paletteSize = palette.getSize();
|
||||
g.setFont(FONT);
|
||||
g.setFont(Gui.getFont(FONT_ID));
|
||||
FontMetrics fontMetrics = g.getFontMetrics();
|
||||
int ascent = fontMetrics.getAscent();
|
||||
int descent = fontMetrics.getDescent();
|
||||
|
|
|
@ -1,194 +0,0 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.core.overview.entropy;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.util.GraphicsUtils;
|
||||
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.
|
||||
*/
|
||||
public class KnotPanel extends JPanel implements ComponentListener {
|
||||
|
||||
private static final int SPACING = 5;
|
||||
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 OverviewPalette palette = null;
|
||||
private FontMetrics metrics;
|
||||
|
||||
private ChangeListener paletteListener = e -> buildLabels();
|
||||
|
||||
public KnotPanel() {
|
||||
super();
|
||||
addComponentListener(this);
|
||||
metrics = getFontMetrics(FONT);
|
||||
setPreferredSize(
|
||||
new Dimension(100, SPACING + metrics.getMaxAscent() + metrics.getMaxDescent()));
|
||||
}
|
||||
|
||||
public void oldPaintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.setColor(getBackground());
|
||||
Rectangle clip = g.getClipBounds();
|
||||
g.fillRect(clip.x, clip.y, clip.width, clip.height);
|
||||
|
||||
if (palette == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
g.setFont(FONT);
|
||||
int height = getHeight();
|
||||
int width = getWidth();
|
||||
int palsize = palette.getSize();
|
||||
int fontHeight = metrics.getMaxAscent() + metrics.getMaxDescent();
|
||||
int baseline = (height - fontHeight - 1) / 2 + metrics.getMaxAscent();
|
||||
|
||||
ArrayList<KnotRecord> knots = palette.getKnots();
|
||||
for (KnotRecord rec : knots) {
|
||||
g.setColor(Java.BORDER);
|
||||
int start = (rec.start * width) / palsize;
|
||||
int end = (rec.end * width) / palsize;
|
||||
g.drawLine(start, 0, start, height - 1);
|
||||
g.drawLine(end, 0, end, height - 1);
|
||||
g.drawLine(start, height - 1, end, height - 1);
|
||||
|
||||
FontMetrics currentMetrics = metrics;
|
||||
int w = currentMetrics.stringWidth(rec.name);
|
||||
int knotwidth = end - start;
|
||||
while (w > knotwidth) {
|
||||
currentMetrics = getSmallerFontMetrics(currentMetrics);
|
||||
w = currentMetrics.stringWidth(rec.name);
|
||||
|
||||
if (currentMetrics.getFont().getSize() <= 4) {
|
||||
break; // can't go any smaller
|
||||
}
|
||||
}
|
||||
|
||||
g.setColor(FG_COLOR_TEXT);
|
||||
if (w < knotwidth) { // we found a suitable font
|
||||
g.setFont(currentMetrics.getFont());
|
||||
GraphicsUtils.drawString(this, g, rec.name, start + (knotwidth - 1) / 2 - w / 2,
|
||||
baseline);
|
||||
g.setFont(FONT);
|
||||
}
|
||||
else { // must be no room to paint the string, even with a small font
|
||||
String ellipsis = "...";
|
||||
w = metrics.stringWidth(ellipsis);
|
||||
GraphicsUtils.drawString(this, g, ellipsis, start + (knotwidth - 1) / 2 - w / 2,
|
||||
baseline);
|
||||
}
|
||||
|
||||
// reset the font
|
||||
currentMetrics = metrics;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private FontMetrics getSmallerFontMetrics(FontMetrics fontMetrics) {
|
||||
Font currentFont = fontMetrics.getFont();
|
||||
int size = currentFont.getSize();
|
||||
Font newFont = currentFont.deriveFont((float) --size);
|
||||
return getFontMetrics(newFont);
|
||||
}
|
||||
|
||||
public void setPalette(OverviewPalette pal) {
|
||||
palette = pal;
|
||||
palette.addPaletteListener(paletteListener);
|
||||
buildLabels();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void buildLabels() {
|
||||
removeAll();
|
||||
setLayout(null);
|
||||
|
||||
int paletteSize = palette.getSize();
|
||||
Container parent = getParent();
|
||||
|
||||
ArrayList<KnotRecord> knots = palette.getKnots();
|
||||
for (KnotRecord record : knots) {
|
||||
JLabel label = new GLabel(record.name);
|
||||
label.setFont(FONT);
|
||||
label.setBorder(new ToplessLineBorder(Java.BORDER));
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setToolTipText(record.name);
|
||||
|
||||
int height = getHeight();
|
||||
int width = getWidth();
|
||||
int start = (record.start * width) / paletteSize;
|
||||
int end = (record.end * width) / paletteSize;
|
||||
|
||||
int labelWidth = end - start;
|
||||
int labelHeight = height - 1;
|
||||
int x = start + ((end - start >> 1) - (labelWidth >> 1));
|
||||
int y = 0;
|
||||
|
||||
label.setBounds(x, y, labelWidth, labelHeight);
|
||||
add(label);
|
||||
}
|
||||
invalidate();
|
||||
if (parent != null) {
|
||||
parent.validate();
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
buildLabels();
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
}
|
||||
|
||||
private class ToplessLineBorder extends LineBorder {
|
||||
|
||||
public ToplessLineBorder(Color color) {
|
||||
super(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
super.paintBorder(c, g, x, y - 1, width, height + 1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,13 +23,12 @@ import javax.swing.*;
|
|||
import docking.DialogComponentProvider;
|
||||
import docking.widgets.button.GRadioButton;
|
||||
import docking.widgets.checkbox.GCheckBox;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
||||
public class PrintOptionsDialog extends DialogComponentProvider {
|
||||
|
||||
private final Font HEADER_FONT = new Font("SansSerif", Font.PLAIN, 10);
|
||||
private final FontMetrics HEADER_METRICS = rootPanel.getFontMetrics(HEADER_FONT);
|
||||
|
||||
private static final String FONT_ID = "font.print";
|
||||
private boolean selectionEnabled;
|
||||
private boolean cancelled = false;
|
||||
|
||||
|
@ -163,11 +162,11 @@ public class PrintOptionsDialog extends DialogComponentProvider {
|
|||
}
|
||||
|
||||
public Font getHeaderFont() {
|
||||
return HEADER_FONT;
|
||||
return Gui.getFont(FONT_ID);
|
||||
}
|
||||
|
||||
public FontMetrics getHeaderMetrics() {
|
||||
return HEADER_METRICS;
|
||||
return rootPanel.getFontMetrics(getHeaderFont());
|
||||
}
|
||||
|
||||
public boolean showHeader() {
|
||||
|
@ -183,7 +182,8 @@ public class PrintOptionsDialog extends DialogComponentProvider {
|
|||
}
|
||||
|
||||
public int getHeaderHeight() {
|
||||
return HEADER_METRICS.getMaxAscent() + HEADER_METRICS.getMaxDescent();
|
||||
FontMetrics metrics = getHeaderMetrics();
|
||||
return metrics.getMaxAscent() + metrics.getMaxDescent();
|
||||
}
|
||||
|
||||
public void setSelectionEnabled(boolean selectionEnabled) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.swing.*;
|
|||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import docking.widgets.checkbox.GCheckBox;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.plugin.processors.sleigh.SleighDebugLogger;
|
||||
import ghidra.app.plugin.processors.sleigh.SleighDebugLogger.SleighDebugMode;
|
||||
import ghidra.framework.model.DomainObjectChangedEvent;
|
||||
|
@ -38,6 +39,7 @@ import ghidra.util.table.GhidraTable;
|
|||
*
|
||||
*/
|
||||
class InstructionInfoProvider extends ComponentProviderAdapter implements DomainObjectListener {
|
||||
private static final String FONT_ID = "font.plugin.instruction.info";
|
||||
private JPanel mainPanel;
|
||||
private JSplitPane pane;
|
||||
private ShowInstructionInfoPlugin plugin;
|
||||
|
@ -99,14 +101,12 @@ class InstructionInfoProvider extends ComponentProviderAdapter implements Domain
|
|||
mainPanel = new JPanel(new BorderLayout());
|
||||
|
||||
instructionText = new JTextArea();
|
||||
Font defaultFont = instructionText.getFont();
|
||||
Font fixedWidthFont = new Font("monospaced", defaultFont.getStyle(), 14);
|
||||
instructionText.setFont(fixedWidthFont);
|
||||
Gui.registerFont(instructionText, FONT_ID);
|
||||
instructionText.setEditable(false);
|
||||
|
||||
operandModel = new OperandModel();
|
||||
opTable = new GhidraTable(operandModel);
|
||||
opTable.setFont(fixedWidthFont);
|
||||
Gui.registerFont(opTable, FONT_ID);
|
||||
opTable.setPreferredScrollableViewportSize(new Dimension(425, 105));
|
||||
//opTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@ import javax.swing.border.*;
|
|||
import docking.actions.KeyBindingUtils;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import docking.widgets.label.GIconLabel;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.*;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.framework.model.ProjectLocator;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -39,7 +38,8 @@ import resources.Icons;
|
|||
* Panel to show a "tab" for an object. ChangeListeners are notified when a tab is selected.
|
||||
*/
|
||||
public class MultiTabPanel extends JPanel {
|
||||
|
||||
private static final String FONT_TABS_ID = "font.plugin.tabs";
|
||||
private static final String FONT_TABS_LIST_ID = "font.plugin.tabs.list";
|
||||
//@formatter:off
|
||||
private final static Color SELECTED_TAB_COLOR = new GColor("color.bg.listing.tabs.selected");
|
||||
private final static Color HIGHLIGHTED_TAB_BG_COLOR = new GColor("color.bg.listing.tabs.highlighted");
|
||||
|
@ -61,8 +61,6 @@ public class MultiTabPanel extends JPanel {
|
|||
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 LIST_LABEL_FONT = new Font("Tahoma", Font.BOLD, 9);
|
||||
private static final String DEFAULT_HIDDEN_COUNT_STR = "99";
|
||||
|
||||
/** A list of tabs that are hidden from view due to space constraints */
|
||||
|
@ -220,7 +218,7 @@ public class MultiTabPanel extends JPanel {
|
|||
JLabel nameLabel = new GDLabel();
|
||||
nameLabel.setIconTextGap(1);
|
||||
nameLabel.setName("objectName"); // junit access
|
||||
nameLabel.setFont(LABEL_FONT);
|
||||
Gui.registerFont(nameLabel, FONT_TABS_ID);
|
||||
Color foregroundColor = isSelected ? TEXT_SELECTION_COLOR : TEXT_NON_SELECTION_COLOR;
|
||||
nameLabel.setForeground(foregroundColor);
|
||||
|
||||
|
@ -637,7 +635,7 @@ public class MultiTabPanel extends JPanel {
|
|||
private JLabel createLabel() {
|
||||
JLabel newLabel = new GDLabel(DEFAULT_HIDDEN_COUNT_STR, LIST_ICON, SwingConstants.LEFT);
|
||||
newLabel.setIconTextGap(0);
|
||||
newLabel.setFont(LIST_LABEL_FONT);
|
||||
Gui.registerFont(newLabel, FONT_TABS_LIST_ID);
|
||||
newLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4));
|
||||
newLabel.setToolTipText("Show Tab List");
|
||||
newLabel.setName("showList");
|
||||
|
|
|
@ -1026,8 +1026,7 @@ public class EditReferencesProvider extends ComponentProviderAdapter
|
|||
|
||||
RefCellTextRenderer() {
|
||||
defaultFont = getFont();
|
||||
boldFont = new Font(defaultFont.getName(), defaultFont.getStyle() | Font.BOLD,
|
||||
defaultFont.getSize());
|
||||
boldFont = defaultFont.deriveFont(defaultFont.getStyle() | Font.BOLD);
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import docking.dnd.DropTgtAdapter;
|
|||
import docking.dnd.Droppable;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.util.*;
|
||||
import ghidra.app.util.viewer.field.BrowserCodeUnitFormat;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -64,7 +65,6 @@ class InstructionPanel extends JPanel implements ChangeListener {
|
|||
private JLabel[] operandLabels;
|
||||
private DropTarget[] dropTargets; // 0: mnemonic, >= 1: operands
|
||||
private JPanel innerPanel;
|
||||
private Font monoFont;
|
||||
private int activeIndex;
|
||||
private int activeSubIndex;
|
||||
private CodeUnit currentCodeUnit;
|
||||
|
@ -207,14 +207,11 @@ class InstructionPanel extends JPanel implements ChangeListener {
|
|||
setBorder(border);
|
||||
|
||||
addressLabel = new GDLabel("FFFFFFFF"); // use a default
|
||||
|
||||
Font font = addressLabel.getFont();
|
||||
monoFont = new Font("monospaced", font.getStyle(), font.getSize());
|
||||
addressLabel.setFont(monoFont);
|
||||
Gui.registerFont(addressLabel, "font.monospaced");
|
||||
addressLabel.setName("addressLabel");
|
||||
|
||||
mnemonicLabel = new GDLabel("movl");
|
||||
mnemonicLabel.setFont(monoFont);
|
||||
Gui.registerFont(mnemonicLabel, "font.monospaced");
|
||||
mnemonicLabel.setName("mnemonicLabel");
|
||||
mnemonicLabel.addMouseListener(mouseListener);
|
||||
|
||||
|
@ -222,8 +219,8 @@ class InstructionPanel extends JPanel implements ChangeListener {
|
|||
for (int i = 0; i < operandLabels.length; i++) {
|
||||
operandLabels[i] = new GDLabel("%ebp, ");
|
||||
operandLabels[i].setName("operandLabels[" + i + "]");
|
||||
operandLabels[i].setFont(monoFont);
|
||||
operandLabels[i].addMouseListener(mouseListener);
|
||||
Gui.registerFont(operandLabels[i], "font.monospaced");
|
||||
}
|
||||
|
||||
innerPanel = new JPanel();
|
||||
|
|
|
@ -28,6 +28,7 @@ import docking.widgets.OptionDialog;
|
|||
import docking.widgets.table.*;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.cmd.register.SetRegisterCmd;
|
||||
import ghidra.app.events.ProgramSelectionPluginEvent;
|
||||
import ghidra.app.services.*;
|
||||
|
@ -497,7 +498,7 @@ class RegisterValueRenderer extends GTableCellRenderer {
|
|||
|
||||
RegisterValueRenderer(JTable table) {
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
|
||||
setFont(new Font("monospaced", Font.PLAIN, 12));
|
||||
Gui.registerFont(this, "font.monospaced");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.swing.event.ChangeListener;
|
|||
import docking.DialogComponentProvider;
|
||||
import docking.widgets.combobox.GComboBox;
|
||||
import docking.widgets.label.GLabel;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.util.bean.FixedBitSizeValueField;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.Register;
|
||||
|
@ -92,7 +93,7 @@ public class SetRegisterValueDialog extends DialogComponentProvider {
|
|||
registerChanged();
|
||||
}
|
||||
});
|
||||
f = new Font("monospaced", Font.PLAIN, 13);
|
||||
f = Gui.getFont("font.monospaced");
|
||||
|
||||
addressRangeList = new JList();
|
||||
addressRangeList.setEnabled(false);
|
||||
|
|
|
@ -20,8 +20,6 @@ import java.awt.Font;
|
|||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.Document;
|
||||
|
@ -35,14 +33,15 @@ import docking.widgets.OptionDialog;
|
|||
import generic.jar.ResourceFile;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.script.GhidraScriptUtil;
|
||||
import ghidra.framework.options.SaveState;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.datastruct.FixedSizeStack;
|
||||
import resources.Icons;
|
||||
|
||||
public class GhidraScriptEditorComponentProvider extends ComponentProvider {
|
||||
static final String EDITOR_COMPONENT_NAME = "EDITOR";
|
||||
private static final String FONT_ID = "font.plugin.scripts.text.editor";
|
||||
|
||||
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";
|
||||
|
@ -55,21 +54,6 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
|
|||
|
||||
private static final int MAX_UNDO_REDO_SIZE = 50;
|
||||
|
||||
private static Font defaultFont = new Font("monospaced", Font.PLAIN, 12);
|
||||
|
||||
static void restoreState(SaveState saveState) {
|
||||
String name = saveState.getString("DEFAULT_FONT_NAME", "Monospaced");
|
||||
int style = saveState.getInt("DEFAULT_FONT_STYLE", Font.PLAIN);
|
||||
int size = saveState.getInt("DEFAULT_FONT_SIZE", 12);
|
||||
defaultFont = new Font(name, style, size);
|
||||
}
|
||||
|
||||
static void saveState(SaveState saveState) {
|
||||
saveState.putString("DEFAULT_FONT_NAME", defaultFont.getName());
|
||||
saveState.putInt("DEFAULT_FONT_STYLE", defaultFont.getStyle());
|
||||
saveState.putInt("DEFAULT_FONT_SIZE", defaultFont.getSize());
|
||||
}
|
||||
|
||||
private GhidraScriptMgrPlugin plugin;
|
||||
private GhidraScriptComponentProvider provider;
|
||||
private String title;
|
||||
|
@ -520,18 +504,11 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private void doSelectFont() {
|
||||
protected void doSelectFont() {
|
||||
FontEditor editor = new FontEditor();
|
||||
editor.setValue(defaultFont);
|
||||
editor.setValue(Gui.getFont(FONT_ID));
|
||||
editor.showDialog();
|
||||
defaultFont = (Font) editor.getValue();
|
||||
|
||||
Collection<GhidraScriptEditorComponentProvider> values = provider.getEditorMap().values();
|
||||
Iterator<GhidraScriptEditorComponentProvider> iterator = values.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
GhidraScriptEditorComponentProvider editorComponent = iterator.next();
|
||||
editorComponent.textArea.setFont(defaultFont);
|
||||
}
|
||||
Gui.setFont(FONT_ID, (Font) editor.getValue());
|
||||
}
|
||||
|
||||
private void save() {
|
||||
|
@ -681,7 +658,7 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
|
|||
private KeyMasterTextArea(String text) {
|
||||
super(text);
|
||||
|
||||
setFont(defaultFont);
|
||||
Gui.registerFont(this, FONT_ID);
|
||||
setName(EDITOR_COMPONENT_NAME);
|
||||
setWrapStyleWord(false);
|
||||
Document document = getDocument();
|
||||
|
|
|
@ -78,14 +78,12 @@ public class GhidraScriptMgrPlugin extends ProgramPlugin implements GhidraScript
|
|||
public void readConfigState(SaveState saveState) {
|
||||
super.readConfigState(saveState);
|
||||
provider.readConfigState(saveState);
|
||||
GhidraScriptEditorComponentProvider.restoreState(saveState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfigState(SaveState saveState) {
|
||||
super.writeConfigState(saveState);
|
||||
provider.writeConfigState(saveState);
|
||||
GhidraScriptEditorComponentProvider.saveState(saveState);
|
||||
}
|
||||
|
||||
GhidraState getCurrentState() {
|
||||
|
|
|
@ -387,10 +387,10 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
|
|||
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_NAME, true, null,
|
||||
"Toggles highlight search results");
|
||||
|
||||
opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_COLOR_ID, null, "The search result highlight color");
|
||||
opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_ID, null,
|
||||
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_COLOR, null, "The search result highlight color");
|
||||
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR, null,
|
||||
"The search result highlight color for the currently selected match");
|
||||
|
||||
opt.addOptionsChangeListener(this);
|
||||
|
|
|
@ -435,10 +435,10 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
|
|||
|
||||
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_NAME, true, loc,
|
||||
"Determines whether to highlight the matched string for a search in the listing.");
|
||||
opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_COLOR_ID, null, "The search result highlight color");
|
||||
opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_ID, null,
|
||||
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_COLOR, null, "The search result highlight color");
|
||||
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
|
||||
PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR, null,
|
||||
"The search result highlight color for the currently selected match");
|
||||
|
||||
searchLimit =
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.totd;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -28,8 +29,11 @@ import docking.widgets.label.GLabel;
|
|||
import generic.theme.GIcon;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.GThemeDefaults.Colors.Java;
|
||||
import generic.theme.Gui;
|
||||
|
||||
class TipOfTheDayDialog extends DialogComponentProvider {
|
||||
private static final String FONT_ID = "font.plugin.tips";
|
||||
private static final String FONT_LABEL_ID = "font.plugin.tips.label";
|
||||
private static final int _24_HOURS = 86400000;
|
||||
private TipOfTheDayPlugin plugin;
|
||||
private JCheckBox showTipsCheckbox;
|
||||
|
@ -53,7 +57,7 @@ class TipOfTheDayDialog extends DialogComponentProvider {
|
|||
|
||||
tipArea = new JTextArea(4, 30);
|
||||
tipArea.setEditable(false);
|
||||
tipArea.setFont(new Font("dialog", Font.PLAIN, 12));
|
||||
tipArea.setFont(Gui.getFont(FONT_ID));
|
||||
tipArea.setWrapStyleWord(true);
|
||||
tipArea.setLineWrap(true);
|
||||
tipArea.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
@ -87,7 +91,7 @@ class TipOfTheDayDialog extends DialogComponentProvider {
|
|||
panel.setBackground(Colors.BACKGROUND);
|
||||
|
||||
JLabel label = new GLabel("Did you know...", tipIcon, SwingConstants.LEFT);
|
||||
label.setFont(new Font("dialog", Font.BOLD, 12));
|
||||
Gui.registerFont(label, FONT_LABEL_ID);
|
||||
panel.add(label, BorderLayout.NORTH);
|
||||
|
||||
panel.add(tipScroll, BorderLayout.CENTER);
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import ghidra.app.util.viewer.util.AddressPixelMap;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
|
||||
public class BlockPanel extends JPanel implements ComponentListener {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final int SPACING = 5;
|
||||
private static final Font FONT = new Font("SansSerif", Font.PLAIN, 10);
|
||||
private AddressPixelMap map;
|
||||
private FontMetrics metrics;
|
||||
|
||||
public BlockPanel() {
|
||||
super();
|
||||
setBackground(Colors.BACKGROUND);
|
||||
addComponentListener(this);
|
||||
metrics = getFontMetrics(FONT);
|
||||
setPreferredSize(
|
||||
new Dimension(100, SPACING + metrics.getMaxAscent() + metrics.getMaxDescent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
|
||||
g.setColor(Colors.FOREGROUND);
|
||||
g.setFont(FONT);
|
||||
int height = getHeight();
|
||||
|
||||
MemoryBlock[] blocks = map.getBlocks();
|
||||
if (blocks == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MemoryBlock block : blocks) {
|
||||
Rectangle rect = map.getBlockPosition(block);
|
||||
g.drawLine(rect.x, 0, rect.x, height - 1);
|
||||
}
|
||||
g.drawLine(getWidth() - 1, 0, getWidth() - 1, height - 1);
|
||||
|
||||
g.drawLine(0, height - 1, getWidth() - 1, height - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintChildren(Graphics g) {
|
||||
//
|
||||
// clear the background; paint our labels; paint our divider lines
|
||||
//
|
||||
Color oldColor = g.getColor();
|
||||
g.setColor(getBackground());
|
||||
Rectangle clip = g.getClipBounds();
|
||||
g.fillRect(clip.x, clip.y, clip.width, clip.height);
|
||||
g.setColor(oldColor);
|
||||
super.paintChildren(g);
|
||||
paintComponent(g);
|
||||
}
|
||||
|
||||
public void setMemoryBlockMap(AddressPixelMap map) {
|
||||
this.map = map;
|
||||
repaint();
|
||||
}
|
||||
|
||||
/** Creates labels for the block names */
|
||||
private void buildLabels() {
|
||||
removeAll();
|
||||
setLayout(null);
|
||||
|
||||
Container parent = getParent();
|
||||
|
||||
MemoryBlock[] blocks = map.getBlocks();
|
||||
if (blocks == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MemoryBlock block : blocks) {
|
||||
JLabel label = new GDLabel(block.getName());
|
||||
label.setFont(FONT);
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setToolTipText(block.getName());
|
||||
|
||||
Rectangle rect = map.getBlockPosition(block);
|
||||
int height = getHeight();
|
||||
int width = metrics.stringWidth(block.getName());
|
||||
if (rect.width < width) {
|
||||
label.setText("...");
|
||||
}
|
||||
int labelWidth = Math.min(rect.width, width);
|
||||
labelWidth = Math.max(labelWidth, 3);
|
||||
int labelHeight = height - 1;
|
||||
int x = rect.x + (rect.width - 1) / 2 - labelWidth / 2;
|
||||
int y = 0;
|
||||
|
||||
label.setBounds(x, y, labelWidth, labelHeight);
|
||||
add(label);
|
||||
}
|
||||
invalidate();
|
||||
if (parent != null) {
|
||||
parent.validate();
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
buildLabels();
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
}
|
||||
}
|
|
@ -90,8 +90,7 @@ public interface PluginConstants {
|
|||
* Color for highlighting for searches.
|
||||
*/
|
||||
public static final String SEARCH_HIGHLIGHT_COLOR_OPTION_NAME = " Highlight Color";
|
||||
public static final String SEARCH_HIGHLIGHT_COLOR_ID = "color.bg.search.highlight";
|
||||
public static final Color SEARCH_HIGHLIGHT_COLOR = new GColor(SEARCH_HIGHLIGHT_COLOR_ID);
|
||||
public static final Color SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.search.highlight");
|
||||
|
||||
/**
|
||||
* Default highlight color used when something to highlight is at the current
|
||||
|
@ -99,9 +98,7 @@ public interface PluginConstants {
|
|||
*/
|
||||
public static final String SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME =
|
||||
"Highlight Color for Current Match";
|
||||
public static final String SEARCH_HIGHLIGHT_CURRENT_COLOR_ID =
|
||||
"color.bg.search.current.line.highlight";
|
||||
public static final Color SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR =
|
||||
new GColor(SEARCH_HIGHLIGHT_CURRENT_COLOR_ID);
|
||||
new GColor("color.bg.search.current.line.highlight");
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.swing.text.*;
|
|||
|
||||
import docking.widgets.SmallBorderButton;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.Gui;
|
||||
|
||||
public class FixedBitSizeValueField extends JPanel {
|
||||
|
||||
|
@ -64,7 +65,7 @@ public class FixedBitSizeValueField extends JPanel {
|
|||
|
||||
}
|
||||
add(valueField, BorderLayout.CENTER);
|
||||
Font f2 = new Font("monospaced", Font.PLAIN, 14);
|
||||
Font f2 = Gui.getFont("font.monospaced");
|
||||
valueField.setFont(f2);
|
||||
valueField.setMargin(new Insets(0, 2, 0, 2));
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.app.util.viewer.options.ScreenElement;
|
|||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.listing.Parameter;
|
||||
import ghidra.program.model.listing.Variable;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
||||
public abstract class AbstractVariableFieldFactory extends FieldFactory {
|
||||
|
||||
|
@ -110,7 +109,7 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {
|
|||
Object newValue) {
|
||||
|
||||
if (optionName.equals(FONT_OPTION_NAME)) {
|
||||
baseFont = SystemUtilities.adjustForFontSizeOverride((Font) newValue);
|
||||
baseFont = (Font) newValue;
|
||||
setMetrics(baseFont, parameterFieldOptions[CUSTOM_PARAM_INDEX]);
|
||||
setMetrics(baseFont, parameterFieldOptions[DYNAMIC_PARAM_INDEX]);
|
||||
}
|
||||
|
@ -133,7 +132,7 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {
|
|||
private void setMetrics(Font newFont, ParameterFieldOptions paramFieldOptions) {
|
||||
paramFieldOptions.defaultMetrics = Toolkit.getDefaultToolkit().getFontMetrics(newFont);
|
||||
for (int i = 0; i < paramFieldOptions.fontMetrics.length; i++) {
|
||||
Font font = new Font(newFont.getFamily(), i, newFont.getSize());
|
||||
Font font = newFont.deriveFont(i); // i is looping over the 4 font styles PLAIN, BOLD, ITALIC, and BOLDITALIC
|
||||
paramFieldOptions.fontMetrics[i] = Toolkit.getDefaultToolkit().getFontMetrics(font);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import docking.widgets.fieldpanel.field.*;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.StringUtilities;
|
||||
import ghidra.util.WordLocation;
|
||||
|
@ -94,7 +95,7 @@ public class CommentUtils {
|
|||
}
|
||||
|
||||
private static AttributedString createPrototype() {
|
||||
Font dummyFont = new Font("monospaced", Font.PLAIN, 12);
|
||||
Font dummyFont = Gui.getFont("font.monospaced");
|
||||
@SuppressWarnings("deprecation")
|
||||
FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(dummyFont);
|
||||
return new AttributedString("", Colors.FOREGROUND, fontMetrics);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.math.BigInteger;
|
|||
import docking.widgets.fieldpanel.support.FieldLocation;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.util.HighlightProvider;
|
||||
import ghidra.app.util.viewer.format.FieldFormatModel;
|
||||
import ghidra.app.util.viewer.options.OptionsGui;
|
||||
|
@ -41,7 +42,7 @@ import ghidra.util.classfinder.ExtensionPoint;
|
|||
*/
|
||||
public abstract class FieldFactory implements ExtensionPoint {
|
||||
public static final String FONT_OPTION_NAME = "BASE FONT";
|
||||
public static final Font DEFAULT_FIELD_FONT = new Font("monospaced", Font.PLAIN, 12);
|
||||
public static final String BASE_LISTING_FONT_ID = "font.listing.base";
|
||||
|
||||
protected FieldFormatModel model;
|
||||
protected String name;
|
||||
|
@ -86,8 +87,7 @@ public abstract class FieldFactory implements ExtensionPoint {
|
|||
}
|
||||
|
||||
protected void initDisplayOptions() {
|
||||
baseFont = SystemUtilities.adjustForFontSizeOverride(
|
||||
displayOptions.getFont(FONT_OPTION_NAME, DEFAULT_FIELD_FONT));
|
||||
baseFont = Gui.getFont(BASE_LISTING_FONT_ID);
|
||||
// For most fields (defined in optionsGui) these will be set. But "ad hoc" fields won't,
|
||||
// so register something. A second registration won't change the original
|
||||
|
||||
|
@ -351,7 +351,7 @@ public abstract class FieldFactory implements ExtensionPoint {
|
|||
private void setMetrics(Font newFont) {
|
||||
defaultMetrics = Toolkit.getDefaultToolkit().getFontMetrics(newFont);
|
||||
for (int i = 0; i < fontMetrics.length; i++) {
|
||||
Font font = new Font(newFont.getFamily(), i, newFont.getSize());
|
||||
Font font = newFont.deriveFont(i); // i is looping over the 4 font styles PLAIN, BOLD, ITALIC, and BOLDITALIC
|
||||
fontMetrics[i] = Toolkit.getDefaultToolkit().getFontMetrics(font);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.swing.border.Border;
|
|||
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.util.viewer.field.FieldFactory;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Swing;
|
||||
|
@ -33,6 +34,8 @@ import help.HelpService;
|
|||
* Class manage a header for the FieldViewer.
|
||||
*/
|
||||
public class FieldHeaderComp extends JPanel {
|
||||
private static final String FONT_ID = "font.listing.header";
|
||||
|
||||
private enum CursorState {
|
||||
NOWHERE, NEAR_EDGE, OVER_FIELD
|
||||
}
|
||||
|
@ -87,7 +90,7 @@ public class FieldHeaderComp extends JPanel {
|
|||
defaultButtonBgColor = label.getBackground();
|
||||
defaultButtonFgColor = label.getForeground();
|
||||
label.setBorder(BorderFactory.createCompoundBorder(border2, border1));
|
||||
label.setFont(new Font("Tahoma", Font.PLAIN, 11));
|
||||
label.setFont(Gui.getFont(FONT_ID));
|
||||
Dimension d = label.getPreferredSize();
|
||||
rowHeight = d.height;
|
||||
this.setMinimumSize(new Dimension(0, 2 * rowHeight));
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.beans.PropertyChangeListener;
|
|||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import generic.theme.Gui;
|
||||
import ghidra.GhidraOptions;
|
||||
import ghidra.framework.options.*;
|
||||
|
||||
|
@ -28,7 +29,7 @@ import ghidra.framework.options.*;
|
|||
* Class for editing Listing display properties.
|
||||
*/
|
||||
public class ListingDisplayOptionsEditor implements OptionsEditor {
|
||||
public static final Font DEFAULT_FONT = new Font("Monospaced", Font.PLAIN, 12);
|
||||
public static final String DEFAULT_FONT_ID = "font.listing.base";
|
||||
|
||||
private OptionsGui optionsGui;
|
||||
private Options options;
|
||||
|
@ -53,8 +54,8 @@ public class ListingDisplayOptionsEditor implements OptionsEditor {
|
|||
|
||||
private void registerOptions() {
|
||||
String prefix = "Sets the ";
|
||||
options.registerOption(GhidraOptions.OPTION_BASE_FONT, DEFAULT_FONT, null,
|
||||
prefix + GhidraOptions.OPTION_BASE_FONT);
|
||||
options.registerOption(GhidraOptions.OPTION_BASE_FONT, OptionType.FONT_TYPE,
|
||||
DEFAULT_FONT_ID, null, prefix + GhidraOptions.OPTION_BASE_FONT);
|
||||
for (ScreenElement element : OptionsGui.elements) {
|
||||
String colorOptionName = element.getColorOptionName();
|
||||
options.registerOption(colorOptionName, element.getDefaultColor(), null,
|
||||
|
@ -68,7 +69,7 @@ public class ListingDisplayOptionsEditor implements OptionsEditor {
|
|||
public void apply() {
|
||||
if (optionsGui != null) {
|
||||
|
||||
Font font = options.getFont(GhidraOptions.OPTION_BASE_FONT, DEFAULT_FONT);
|
||||
Font font = Gui.getFont(DEFAULT_FONT_ID);
|
||||
Font newFont = optionsGui.getBaseFont();
|
||||
if (!newFont.equals(font)) {
|
||||
options.setFont(GhidraOptions.OPTION_BASE_FONT, newFont);
|
||||
|
@ -123,7 +124,7 @@ public class ListingDisplayOptionsEditor implements OptionsEditor {
|
|||
@Override
|
||||
public JComponent getEditorComponent(Options editableOptions,
|
||||
EditorStateFactory editorStateFactory) {
|
||||
Font font = options.getFont(GhidraOptions.OPTION_BASE_FONT, DEFAULT_FONT);
|
||||
Font font = Gui.getFont(DEFAULT_FONT_ID);
|
||||
for (ScreenElement element : OptionsGui.elements) {
|
||||
Color c = options.getColor(element.getColorOptionName(), element.getDefaultColor());
|
||||
int style = options.getInt(element.getStyleOptionName(), -1);
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.swing.JTextPane;
|
|||
import javax.swing.text.*;
|
||||
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.framework.options.*;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -202,7 +203,7 @@ public class ConsoleTextPane extends JTextPane implements OptionsChangeListener
|
|||
}
|
||||
|
||||
private void createAttribtues() {
|
||||
createAttributes(new Font("monospaced", Font.PLAIN, 12));
|
||||
createAttributes(Gui.getFont("font.monospaced"));
|
||||
}
|
||||
|
||||
private void createAttributes(Font font) {
|
||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.graph;
|
|||
import static ghidra.graph.ProgramGraphType.*;
|
||||
import static ghidra.service.graph.VertexShape.*;
|
||||
|
||||
import generic.theme.GColor;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.service.graph.GraphDisplayOptions;
|
||||
import ghidra.service.graph.VertexShape;
|
||||
|
@ -40,60 +39,64 @@ public class ProgramGraphDisplayOptions extends GraphDisplayOptions {
|
|||
@Override
|
||||
protected void initializeDefaults() {
|
||||
setDefaultVertexShape(ELLIPSE);
|
||||
setDefaultVertexColor(new GColor("color.bg.plugin.programgraph.vertex.default"));
|
||||
setDefaultEdgeColor(new GColor("color.bg.plugin.programgraph.edge.default"));
|
||||
setDefaultVertexColor("color.bg.plugin.programgraph.vertex.default");
|
||||
setDefaultEdgeColor("color.bg.plugin.programgraph.edge.default");
|
||||
setVertexSelectionColor("color.bg.plugin.programgraph.vertex.selection");
|
||||
setEdgeSelectionColor("color.bg.plugin.programgraph.edge.selection");
|
||||
setFavoredEdgeType(FALL_THROUGH);
|
||||
|
||||
//@formatter:off
|
||||
configureVertexType(BODY, RECTANGLE, new GColor("color.bg.plugin.programgraph.vertex.body"));
|
||||
configureVertexType(ENTRY, TRIANGLE_DOWN, new GColor("color.bg.plugin.programgraph.vertex.entry"));
|
||||
configureVertexType(EXIT, TRIANGLE_UP, new GColor("color.bg.plugin.programgraph.vertex.exit"));
|
||||
configureVertexType(SWITCH, DIAMOND, new GColor("color.bg.plugin.programgraph.vertex.switch"));
|
||||
configureVertexType(EXTERNAL, RECTANGLE, new GColor("color.bg.plugin.programgraph.vertex.external"));
|
||||
configureVertexType(BAD, ELLIPSE, new GColor("color.bg.plugin.programgraph.vertex.bad"));
|
||||
configureVertexType(DATA, ELLIPSE, new GColor("color.bg.plugin.programgraph.vertex.data"));
|
||||
configureVertexType(ENTRY_NEXUS, ELLIPSE, new GColor("color.bg.plugin.programgraph.vertex.entry.nexus"));
|
||||
configureVertexType(INSTRUCTION, VertexShape.HEXAGON, new GColor("color.bg.plugin.programgraph.vertex.instruction"));
|
||||
configureVertexType(STACK, RECTANGLE, new GColor("color.bg.plugin.programgraph.vertex.stack"));
|
||||
configureVertexType(BODY, RECTANGLE, "color.bg.plugin.programgraph.vertex.body");
|
||||
configureVertexType(ENTRY, TRIANGLE_DOWN, "color.bg.plugin.programgraph.vertex.entry");
|
||||
configureVertexType(EXIT, TRIANGLE_UP, "color.bg.plugin.programgraph.vertex.exit");
|
||||
configureVertexType(SWITCH, DIAMOND, "color.bg.plugin.programgraph.vertex.switch");
|
||||
configureVertexType(EXTERNAL, RECTANGLE, "color.bg.plugin.programgraph.vertex.external");
|
||||
configureVertexType(BAD, ELLIPSE, "color.bg.plugin.programgraph.vertex.bad");
|
||||
configureVertexType(DATA, ELLIPSE, "color.bg.plugin.programgraph.vertex.data");
|
||||
configureVertexType(ENTRY_NEXUS, ELLIPSE, "color.bg.plugin.programgraph.vertex.entry.nexus");
|
||||
configureVertexType(INSTRUCTION, VertexShape.HEXAGON, "color.bg.plugin.programgraph.vertex.instruction");
|
||||
configureVertexType(STACK, RECTANGLE, "color.bg.plugin.programgraph.vertex.stack");
|
||||
|
||||
configureEdgeType(ENTRY_EDGE, new GColor("color.bg.plugin.programgraph.edge.entry"));
|
||||
configureEdgeType(FALL_THROUGH, new GColor("color.bg.plugin.programgraph.edge.fall.through"));
|
||||
configureEdgeType(UNCONDITIONAL_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.unconditional"));
|
||||
configureEdgeType(UNCONDITIONAL_CALL, new GColor("color.bg.plugin.programgraph.edge.call.unconditional"));
|
||||
configureEdgeType(TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.terminator"));
|
||||
configureEdgeType(JUMP_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.jump.terminator"));
|
||||
configureEdgeType(INDIRECTION, new GColor("color.bg.plugin.programgraph.edge.indirection"));
|
||||
configureEdgeType(ENTRY_EDGE, "color.bg.plugin.programgraph.edge.entry");
|
||||
configureEdgeType(FALL_THROUGH, "color.bg.plugin.programgraph.edge.fall.through");
|
||||
configureEdgeType(UNCONDITIONAL_JUMP, "color.bg.plugin.programgraph.edge.jump.unconditional");
|
||||
configureEdgeType(UNCONDITIONAL_CALL, "color.bg.plugin.programgraph.edge.call.unconditional");
|
||||
configureEdgeType(TERMINATOR, "color.bg.plugin.programgraph.edge.terminator");
|
||||
configureEdgeType(JUMP_TERMINATOR, "color.bg.plugin.programgraph.edge.jump.terminator");
|
||||
configureEdgeType(INDIRECTION, "color.bg.plugin.programgraph.edge.indirection");
|
||||
|
||||
configureEdgeType(CONDITIONAL_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.conditional"));
|
||||
configureEdgeType(CONDITIONAL_CALL, new GColor("color.bg.plugin.programgraph.edge.call.conditional"));
|
||||
configureEdgeType(CONDITIONAL_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.conditional.terminator"));
|
||||
configureEdgeType(CONDITIONAL_CALL_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.call.conditional.terminator"));
|
||||
configureEdgeType(CONDITIONAL_JUMP, "color.bg.plugin.programgraph.edge.jump.conditional");
|
||||
configureEdgeType(CONDITIONAL_CALL, "color.bg.plugin.programgraph.edge.call.conditional");
|
||||
configureEdgeType(CONDITIONAL_TERMINATOR, "color.bg.plugin.programgraph.edge.conditional.terminator");
|
||||
configureEdgeType(CONDITIONAL_CALL_TERMINATOR, "color.bg.plugin.programgraph.edge.call.conditional.terminator");
|
||||
|
||||
configureEdgeType(COMPUTED_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.computed"));
|
||||
configureEdgeType(COMPUTED_CALL, new GColor("color.bg.plugin.programgraph.edge.call.computed"));
|
||||
configureEdgeType(COMPUTED_CALL_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.call.computed.terminator"));
|
||||
configureEdgeType(COMPUTED_JUMP, "color.bg.plugin.programgraph.edge.jump.computed");
|
||||
configureEdgeType(COMPUTED_CALL, "color.bg.plugin.programgraph.edge.call.computed");
|
||||
configureEdgeType(COMPUTED_CALL_TERMINATOR, "color.bg.plugin.programgraph.edge.call.computed.terminator");
|
||||
|
||||
configureEdgeType(CONDITIONAL_COMPUTED_CALL, new GColor("color.bg.plugin.programgraph.edge.call.conditional.computed"));
|
||||
configureEdgeType(CONDITIONAL_COMPUTED_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.conitional.computed"));
|
||||
configureEdgeType(CONDITIONAL_COMPUTED_CALL, "color.bg.plugin.programgraph.edge.call.conditional.computed");
|
||||
configureEdgeType(CONDITIONAL_COMPUTED_JUMP, "color.bg.plugin.programgraph.edge.jump.conitional.computed");
|
||||
|
||||
configureEdgeType(CALL_OVERRIDE_UNCONDITIONAL, new GColor("color.bg.plugin.programgraph.edge.call.unconditional.override"));
|
||||
configureEdgeType(JUMP_OVERRIDE_UNCONDITIONAL, new GColor("color.bg.plugin.programgraph.edge.jump.unconditional.override"));
|
||||
configureEdgeType(CALLOTHER_OVERRIDE_CALL, new GColor("color.bg.plugin.programgraph.edge.call.callother.override"));
|
||||
configureEdgeType(CALLOTHER_OVERRIDE_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.callother.override"));
|
||||
configureEdgeType(CALL_OVERRIDE_UNCONDITIONAL, "color.bg.plugin.programgraph.edge.call.unconditional.override");
|
||||
configureEdgeType(JUMP_OVERRIDE_UNCONDITIONAL, "color.bg.plugin.programgraph.edge.jump.unconditional.override");
|
||||
configureEdgeType(CALLOTHER_OVERRIDE_CALL, "color.bg.plugin.programgraph.edge.call.callother.override");
|
||||
configureEdgeType(CALLOTHER_OVERRIDE_JUMP, "color.bg.plugin.programgraph.edge.jump.callother.override");
|
||||
|
||||
configureEdgeType(READ, new GColor("color.bg.plugin.programgraph.edge.read"));
|
||||
configureEdgeType(WRITE, new GColor("color.bg.plugin.programgraph.edge.write"));
|
||||
configureEdgeType(READ_WRITE, new GColor("color.bg.plugin.programgraph.edge.read.write"));
|
||||
configureEdgeType(UNKNOWN_DATA, new GColor("color.bg.plugin.programgraph.edge.data.unknown"));
|
||||
configureEdgeType(EXTERNAL_REF, new GColor("color.bg.plugin.programgraph.edge.external.ref"));
|
||||
configureEdgeType(READ, "color.bg.plugin.programgraph.edge.read");
|
||||
configureEdgeType(WRITE, "color.bg.plugin.programgraph.edge.write");
|
||||
configureEdgeType(READ_WRITE, "color.bg.plugin.programgraph.edge.read.write");
|
||||
configureEdgeType(UNKNOWN_DATA, "color.bg.plugin.programgraph.edge.data.unknown");
|
||||
configureEdgeType(EXTERNAL_REF, "color.bg.plugin.programgraph.edge.external.ref");
|
||||
|
||||
configureEdgeType(READ_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.read.indirect"));
|
||||
configureEdgeType(WRITE_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.write.indirect"));
|
||||
configureEdgeType(READ_WRITE_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.read.write.indirect"));
|
||||
configureEdgeType(DATA_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.data.indirect"));
|
||||
configureEdgeType(READ_INDIRECT, "color.bg.plugin.programgraph.edge.read.indirect");
|
||||
configureEdgeType(WRITE_INDIRECT, "color.bg.plugin.programgraph.edge.write.indirect");
|
||||
configureEdgeType(READ_WRITE_INDIRECT, "color.bg.plugin.programgraph.edge.read.write.indirect");
|
||||
configureEdgeType(DATA_INDIRECT, "color.bg.plugin.programgraph.edge.data.indirect");
|
||||
|
||||
configureEdgeType(PARAM, new GColor("color.bg.plugin.programgraph.edge.param"));
|
||||
configureEdgeType(THUNK, new GColor("color.bg.plugin.programgraph.edge.thunk"));
|
||||
configureEdgeType(PARAM, "color.bg.plugin.programgraph.edge.param");
|
||||
configureEdgeType(THUNK, "color.bg.plugin.programgraph.edge.thunk");
|
||||
|
||||
setFont("font.plugin.programgraph");
|
||||
//@formatter:on
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ public class ImporterDialog extends DialogComponentProvider {
|
|||
});
|
||||
|
||||
Font font = languageButton.getFont();
|
||||
languageButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
|
||||
languageButton.setFont(font.deriveFont(Font.BOLD));
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(languageTextField, BorderLayout.CENTER);
|
||||
|
|
|
@ -309,7 +309,6 @@ public class OptionsDBTest extends AbstractGenericTest {
|
|||
assertEquals(Palette.BLUE, options.getColor("Foo", null));
|
||||
options.restoreDefaultValue("Foo");
|
||||
assertEquals(Palette.RED, options.getColor("Foo", null));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -12,6 +12,7 @@ icon.bytepatterns.pattern.mining.analyzer = magnifier.png
|
|||
|
||||
icon.bytepatterns.function.bit.patterns.disabled = ledred.png
|
||||
icon.bytepatterns.function.bit.patterns.enabled = ledgreen.png
|
||||
font.bytepatterns.table = monospaced-PLAIN-16
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
|
|
|
@ -18,15 +18,13 @@
|
|||
*/
|
||||
package ghidra.bitpatterns.gui;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Component;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import docking.widgets.table.AbstractDynamicTableColumn;
|
||||
import docking.widgets.table.TableColumnDescriptor;
|
||||
import docking.widgets.table.threaded.ThreadedTableModelStub;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.bitpatterns.info.ByteSequenceRowObject;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
|
@ -38,7 +36,7 @@ import ghidra.util.table.column.GColumnRenderer;
|
|||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class ByteSequenceTableModel extends ThreadedTableModelStub<ByteSequenceRowObject> {
|
||||
private static final int MONOSPACE_FONT_SIZE = 16;
|
||||
private static final String FONT_ID = "font.bytepatterns.table";
|
||||
List<ByteSequenceRowObject> rowObjects;
|
||||
|
||||
public ByteSequenceTableModel(FunctionBitPatternsExplorerPlugin plugin,
|
||||
|
@ -51,10 +49,13 @@ public class ByteSequenceTableModel extends ThreadedTableModelStub<ByteSequenceR
|
|||
* Displays the byte sequences in monospace font
|
||||
*/
|
||||
protected GColumnRenderer<String> monospacedRenderer = new AbstractGColumnRenderer<String>() {
|
||||
|
||||
@Override
|
||||
protected void configureFont(JTable table, TableModel model, int column) {
|
||||
Font f = new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
|
||||
setFont(f);
|
||||
public Component getTableCellRendererComponent(
|
||||
docking.widgets.table.GTableCellRenderingData data) {
|
||||
Component component = super.getTableCellRendererComponent(data);
|
||||
component.setFont(Gui.getFont(FONT_ID));
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,15 +15,13 @@
|
|||
*/
|
||||
package ghidra.bitpatterns.gui;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Component;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import docking.widgets.table.AbstractDynamicTableColumn;
|
||||
import docking.widgets.table.TableColumnDescriptor;
|
||||
import docking.widgets.table.threaded.ThreadedTableModelStub;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.util.datastruct.Accumulator;
|
||||
|
@ -42,12 +40,13 @@ public class ClosedPatternTableModel extends ThreadedTableModelStub<ClosedPatter
|
|||
private List<ClosedPatternRowObject> rowObjects;
|
||||
|
||||
private static final String MODEL_NAME = "Closed Patterns";
|
||||
private static final int MONOSPACE_FONT_SIZE = 16;
|
||||
|
||||
protected static final String FONT_ID = "font.bytepatterns.table";
|
||||
|
||||
/**
|
||||
* Creates a table model for closed patterns mined from byte sequences
|
||||
* @param rowObjects
|
||||
* @param serviceProvider
|
||||
* @param rowObjects the row objects
|
||||
* @param serviceProvider the service provider
|
||||
*/
|
||||
public ClosedPatternTableModel(List<ClosedPatternRowObject> rowObjects,
|
||||
ServiceProvider serviceProvider) {
|
||||
|
@ -57,11 +56,12 @@ public class ClosedPatternTableModel extends ThreadedTableModelStub<ClosedPatter
|
|||
}
|
||||
|
||||
protected GColumnRenderer<String> monospacedRenderer = new AbstractGColumnRenderer<String>() {
|
||||
@Override
|
||||
protected void configureFont(JTable table, TableModel model, int column) {
|
||||
Font f = new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
|
||||
setFont(f);
|
||||
}
|
||||
public java.awt.Component getTableCellRendererComponent(
|
||||
docking.widgets.table.GTableCellRenderingData data) {
|
||||
Component component = super.getTableCellRendererComponent(data);
|
||||
component.setFont(Gui.getFont(FONT_ID));
|
||||
return component;
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getFilterString(String t, Settings settings) {
|
||||
|
|
|
@ -15,14 +15,12 @@
|
|||
*/
|
||||
package ghidra.bitpatterns.gui;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Component;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import docking.widgets.table.AbstractDynamicTableColumn;
|
||||
import docking.widgets.table.TableColumnDescriptor;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.bitpatterns.info.PatternEvalRowObject;
|
||||
import ghidra.bitpatterns.info.PatternMatchType;
|
||||
import ghidra.docking.settings.Settings;
|
||||
|
@ -37,7 +35,7 @@ import ghidra.util.table.column.GColumnRenderer;
|
|||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class PatternEvalTabelModel extends AddressBasedTableModel<PatternEvalRowObject> {
|
||||
private static final int MONOSPACE_FONT_SIZE = 14;
|
||||
protected static final String FONT_ID = "font.bytepatterns.table";
|
||||
private List<PatternEvalRowObject> rowObjects;
|
||||
|
||||
/**
|
||||
|
@ -62,10 +60,11 @@ public class PatternEvalTabelModel extends AddressBasedTableModel<PatternEvalRow
|
|||
protected final GColumnRenderer<String> monospacedRenderer =
|
||||
new AbstractGColumnRenderer<String>() {
|
||||
@Override
|
||||
protected void configureFont(JTable table, TableModel model, int column) {
|
||||
Font f =
|
||||
new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
|
||||
setFont(f);
|
||||
public java.awt.Component getTableCellRendererComponent(
|
||||
docking.widgets.table.GTableCellRenderingData data) {
|
||||
Component component = super.getTableCellRendererComponent(data);
|
||||
component.setFont(Gui.getFont(FONT_ID));
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,14 +15,12 @@
|
|||
*/
|
||||
package ghidra.bitpatterns.gui;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.TableModel;
|
||||
import java.awt.Component;
|
||||
|
||||
import docking.widgets.table.AbstractDynamicTableColumn;
|
||||
import docking.widgets.table.TableColumnDescriptor;
|
||||
import docking.widgets.table.threaded.ThreadedTableModelStub;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.bitpatterns.info.PatternType;
|
||||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
|
@ -42,7 +40,7 @@ public class PatternInfoTableModel extends ThreadedTableModelStub<PatternInfoRow
|
|||
private FunctionBitPatternsExplorerPlugin plugin;
|
||||
private static final int NOTE_COLUMN = 2;
|
||||
private static final int ALIGNMENT_COLUMN = 5;
|
||||
private static final int MONOSPACE_FONT_SIZE = 14;
|
||||
protected static final String FONT_ID = "font.bytepatterns.table";
|
||||
|
||||
public PatternInfoTableModel(FunctionBitPatternsExplorerPlugin plugin) {
|
||||
super(MODEL_NAME, plugin.getTool());
|
||||
|
@ -56,10 +54,11 @@ public class PatternInfoTableModel extends ThreadedTableModelStub<PatternInfoRow
|
|||
}
|
||||
|
||||
protected GColumnRenderer<String> monospacedRenderer = new AbstractGColumnRenderer<String>() {
|
||||
@Override
|
||||
protected void configureFont(JTable table, TableModel model, int column) {
|
||||
Font f = new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
|
||||
setFont(f);
|
||||
public Component getTableCellRendererComponent(
|
||||
docking.widgets.table.GTableCellRenderingData data) {
|
||||
Component component = super.getTableCellRendererComponent(data);
|
||||
component.setFont(Gui.getFont(FONT_ID));
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,15 +3,17 @@
|
|||
color.bg.byteviewer = color.bg
|
||||
color.bg.byteviewer.highlight = yellow
|
||||
|
||||
color.fg.byteviewer.novalue = blue
|
||||
color.fg.byteviewer.separator = blue
|
||||
color.fg.byteviewer.changed = red
|
||||
color.cursor.focused.byteviewer.current = color.cursor.focused
|
||||
color.cursor.focused.byteviewer.noncurrent = black
|
||||
color.cursor.unfocused.byteviewer = color.cursor.unfocused
|
||||
color.cursor.byteviewer.focused.active = color.cursor.focused
|
||||
color.cursor.byteviewer.focused.not.active = black
|
||||
color.cursor.byteviewer.unfocused = color.cursor.unfocused
|
||||
|
||||
icon.plugin.byteviewer.provider = binaryData.gif
|
||||
icon.plugin.byteviewer.options = wrench.png
|
||||
|
||||
font.byteviewer = font.monospaced
|
||||
font.byteviewer.header = SansSerif-PLAIN-11
|
||||
font.byteviewer.status = SansSerif-PLAIN-11
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
|
|
|
@ -730,9 +730,9 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
|
|||
createFields();
|
||||
|
||||
setCursorOn(true);
|
||||
editColor = ByteViewerComponentProvider.DEFAULT_EDIT_COLOR;
|
||||
currentCursorColor = ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR;
|
||||
setNonFocusCursorColor(ByteViewerComponentProvider.DEFAULT_NONFOCUS_CURSOR_COLOR);
|
||||
editColor = ByteViewerComponentProvider.CHANGED_VALUE_COLOR;
|
||||
currentCursorColor = ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR;
|
||||
setNonFocusCursorColor(ByteViewerComponentProvider.CURSOR_NOT_FOCUSED_COLOR);
|
||||
setFocusedCursorColor(currentCursorColor);
|
||||
|
||||
updateColorRunner = () -> updateColor();
|
||||
|
|
|
@ -25,8 +25,7 @@ import java.util.List;
|
|||
import javax.swing.JComponent;
|
||||
|
||||
import docking.action.ToggleDockingAction;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.*;
|
||||
import ghidra.GhidraOptions;
|
||||
import ghidra.GhidraOptions.CURSOR_MOUSE_BUTTON_NAMES;
|
||||
import ghidra.app.plugin.core.format.*;
|
||||
|
@ -54,42 +53,40 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
|||
private static final String OFFSET_NAME = "Offset";
|
||||
static final int DEFAULT_NUMBER_OF_CHARS = 8;
|
||||
|
||||
static final Font DEFAULT_FONT = new Font("Monospaced", Font.PLAIN, 12);
|
||||
static final String DEFAULT_FONT_ID = "font.byteviewer";
|
||||
static final int DEFAULT_BYTES_PER_LINE = 16;
|
||||
|
||||
//@formatter:off
|
||||
static final String FG = "byteviewer.color.fg";
|
||||
static final String CURSOR = "byteviewer.color.cursor";
|
||||
static final Color DEFAULT_MISSING_VALUE_COLOR = new GColor("color.fg.byteviewer.novalue");
|
||||
static final Color DEFAULT_EDIT_COLOR = new GColor("color.fg.byteviewer.changed");
|
||||
static final Color DEFAULT_CURRENT_CURSOR_COLOR = new GColor("color.cursor.focused.byteviewer.current");
|
||||
static final Color DEFAULT_CURSOR_COLOR = new GColor("color.cursor.focused.byteviewer.noncurrent");
|
||||
static final Color DEFAULT_NONFOCUS_CURSOR_COLOR = new GColor("color.cursor.unfocused.byteviewer");
|
||||
//@formatter:on
|
||||
|
||||
private static final Color DEFAULT_CURSOR_LINE_COLOR = GhidraOptions.DEFAULT_CURSOR_LINE_COLOR;
|
||||
static final Color SEPARATOR_COLOR = new GColor("color.fg.byteviewer.separator");
|
||||
static final Color CHANGED_VALUE_COLOR = new GColor("color.fg.byteviewer.changed");
|
||||
static final Color CURSOR_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.active");
|
||||
static final Color CURSOR_NON_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.not.active");
|
||||
static final Color CURSOR_NOT_FOCUSED_COLOR = new GColor("color.cursor.byteviewer.unfocused");
|
||||
|
||||
static final Color CURRENT_LINE_COLOR = GhidraOptions.DEFAULT_CURSOR_LINE_COLOR;
|
||||
//@formatter:on
|
||||
|
||||
static final String DEFAULT_INDEX_NAME = "Addresses";
|
||||
|
||||
static final String OPTION_EDIT_COLOR = "Edit Cursor Color";
|
||||
static final String OPTION_SEPARATOR_COLOR = "Block Separator Color";
|
||||
static final String OPTION_CURRENT_VIEW_CURSOR_COLOR = "Current View Cursor Color";
|
||||
static final String OPTION_CURSOR_COLOR = "Cursor Color";
|
||||
static final String SEPARATOR_COLOR_OPTION_NAME = "Block Separator Color";
|
||||
static final String CHANGED_VALUE_COLOR_OPTION_NAME = "Changed Values Color";
|
||||
static final String CURSOR_ACTIVE_COLOR_OPTION_NAME = "Active Cursor Color";
|
||||
static final String CURSOR_NON_ACTIVE_COLOR_OPTION_NAME = "Non-Active Cursor Color";
|
||||
static final String CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME = "Non-Focused Cursor Color";
|
||||
|
||||
static final String OPTION_FONT = "Font";
|
||||
static final String OPTION_NONFOCUS_CURSOR_COLOR = "Non-Focus Cursor Color";
|
||||
|
||||
private static final String DEFAULT_VIEW = "Hex";
|
||||
private static final String OPTION_CURRENT_LINE_COLOR =
|
||||
private static final String CURRENT_LINE_COLOR_OPTION_NAME =
|
||||
GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR_OPTION_NAME;
|
||||
private static final String OPTION_HIGHLIGHT_CURSOR_LINE =
|
||||
GhidraOptions.HIGHLIGHT_CURSOR_LINE_OPTION_NAME;
|
||||
|
||||
protected ByteViewerPanel panel;
|
||||
|
||||
private Color editColor;
|
||||
private Color currentCursorColor;
|
||||
private Color defaultCursorColor;
|
||||
|
||||
private int bytesPerLine;
|
||||
private int offset;
|
||||
private int hexGroupSize = 1;
|
||||
|
@ -174,26 +171,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
|||
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
|
||||
Object newValue) {
|
||||
if (options.getName().equals("ByteViewer")) {
|
||||
|
||||
if (optionName.equals(OPTION_CURRENT_VIEW_CURSOR_COLOR)) {
|
||||
panel.setCurrentCursorColor((Color) newValue);
|
||||
}
|
||||
else if (optionName.equals(OPTION_CURSOR_COLOR)) {
|
||||
panel.setCursorColor((Color) newValue);
|
||||
}
|
||||
else if (optionName.equals(OPTION_CURRENT_LINE_COLOR)) {
|
||||
panel.setCurrentCursorLineColor((Color) newValue);
|
||||
}
|
||||
else if (optionName.equals(OPTION_EDIT_COLOR)) {
|
||||
panel.setEditColor((Color) newValue);
|
||||
}
|
||||
else if (optionName.equals(OPTION_SEPARATOR_COLOR)) {
|
||||
panel.setSeparatorColor((Color) newValue);
|
||||
}
|
||||
else if (optionName.equals(OPTION_NONFOCUS_CURSOR_COLOR)) {
|
||||
panel.setNonFocusCursorColor((Color) newValue);
|
||||
}
|
||||
else if (optionName.equals(OPTION_FONT)) {
|
||||
if (optionName.equals(OPTION_FONT)) {
|
||||
setFont(SystemUtilities.adjustForFontSizeOverride((Font) newValue));
|
||||
}
|
||||
}
|
||||
|
@ -220,48 +198,45 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
|||
HelpLocation help = new HelpLocation("ByteViewerPlugin", "Option");
|
||||
opt.setOptionsHelpLocation(help);
|
||||
|
||||
opt.registerOption(OPTION_SEPARATOR_COLOR, DEFAULT_MISSING_VALUE_COLOR, help,
|
||||
opt.registerOption(SEPARATOR_COLOR_OPTION_NAME, SEPARATOR_COLOR, help,
|
||||
"Color used for separator shown between memory blocks.");
|
||||
opt.registerOption(OPTION_SEPARATOR_COLOR, DEFAULT_MISSING_VALUE_COLOR, help,
|
||||
"Color used for separator shown between memory blocks.");
|
||||
opt.registerOption(OPTION_EDIT_COLOR, DEFAULT_EDIT_COLOR,
|
||||
|
||||
opt.registerOption(CHANGED_VALUE_COLOR_OPTION_NAME, CHANGED_VALUE_COLOR,
|
||||
new HelpLocation("ByteViewerPlugin", "EditColor"),
|
||||
"Color of cursor when the current view is in edit mode and can support editing.");
|
||||
opt.registerOption(OPTION_CURRENT_VIEW_CURSOR_COLOR, DEFAULT_CURRENT_CURSOR_COLOR, help,
|
||||
"Color of cursor when it is in the current view.");
|
||||
opt.registerOption(OPTION_NONFOCUS_CURSOR_COLOR, DEFAULT_NONFOCUS_CURSOR_COLOR, help,
|
||||
"Color of cursor when it is not the current view.");
|
||||
opt.registerOption(OPTION_CURSOR_COLOR, DEFAULT_CURSOR_COLOR, help,
|
||||
"Color of cursor for other views other than the current view.");
|
||||
opt.registerOption(OPTION_FONT, DEFAULT_FONT, help, "Font used in the views.");
|
||||
opt.registerOption(OPTION_CURRENT_LINE_COLOR, DEFAULT_CURSOR_LINE_COLOR, help,
|
||||
"Color of changed bytes when editing.");
|
||||
|
||||
opt.registerOption(CURSOR_ACTIVE_COLOR_OPTION_NAME, CURSOR_ACTIVE_COLOR,
|
||||
help, "Color of cursor in the active view.");
|
||||
|
||||
opt.registerOption(CURSOR_NON_ACTIVE_COLOR_OPTION_NAME,
|
||||
CURSOR_NON_ACTIVE_COLOR,
|
||||
help, "Color of cursor in the non-active views.");
|
||||
|
||||
opt.registerOption(CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME,
|
||||
CURSOR_NOT_FOCUSED_COLOR,
|
||||
help, "Color of cursor when the byteview does not have focus.");
|
||||
|
||||
opt.registerOption(CURRENT_LINE_COLOR_OPTION_NAME,
|
||||
GhidraOptions.DEFAULT_CURSOR_LINE_COLOR, help,
|
||||
"Color of the line containing the cursor");
|
||||
|
||||
opt.registerOption(OPTION_FONT, OptionType.FONT_TYPE, DEFAULT_FONT_ID, help,
|
||||
"Font used in the views.");
|
||||
opt.registerOption(OPTION_HIGHLIGHT_CURSOR_LINE, true, help,
|
||||
"Toggles highlighting background color of line containing the cursor");
|
||||
|
||||
Color missingValueColor = opt.getColor(OPTION_SEPARATOR_COLOR, DEFAULT_MISSING_VALUE_COLOR);
|
||||
Color missingValueColor = opt.getColor(SEPARATOR_COLOR_OPTION_NAME, SEPARATOR_COLOR);
|
||||
panel.setSeparatorColor(missingValueColor);
|
||||
|
||||
editColor = opt.getColor(OPTION_EDIT_COLOR, DEFAULT_EDIT_COLOR);
|
||||
currentCursorColor =
|
||||
opt.getColor(OPTION_CURRENT_VIEW_CURSOR_COLOR, DEFAULT_CURRENT_CURSOR_COLOR);
|
||||
panel.setCurrentCursorColor(currentCursorColor);
|
||||
panel.setCurrentCursorColor(CURSOR_ACTIVE_COLOR);
|
||||
panel.setNonFocusCursorColor(CURSOR_NOT_FOCUSED_COLOR);
|
||||
panel.setCursorColor(CURSOR_NON_ACTIVE_COLOR);
|
||||
panel.setCurrentCursorLineColor(CURRENT_LINE_COLOR);
|
||||
|
||||
Color nonFocusCursorColor =
|
||||
opt.getColor(OPTION_NONFOCUS_CURSOR_COLOR, DEFAULT_NONFOCUS_CURSOR_COLOR);
|
||||
panel.setNonFocusCursorColor(nonFocusCursorColor);
|
||||
|
||||
defaultCursorColor = opt.getColor(OPTION_CURSOR_COLOR, DEFAULT_CURSOR_COLOR);
|
||||
panel.setCursorColor(defaultCursorColor);
|
||||
|
||||
Color cursorLineColor = opt.getColor(OPTION_CURRENT_LINE_COLOR, DEFAULT_CURSOR_LINE_COLOR);
|
||||
panel.setCurrentCursorLineColor(cursorLineColor);
|
||||
|
||||
Font font =
|
||||
SystemUtilities.adjustForFontSizeOverride(opt.getFont(OPTION_FONT, DEFAULT_FONT));
|
||||
Font font = Gui.getFont(DEFAULT_FONT_ID);
|
||||
FontMetrics fm = panel.getFontMetrics(font);
|
||||
|
||||
panel.restoreConfigState(fm, editColor);
|
||||
panel.restoreConfigState(fm, CHANGED_VALUE_COLOR);
|
||||
|
||||
opt.addOptionsChangeListener(this);
|
||||
|
||||
|
@ -279,6 +254,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
|||
|
||||
/**
|
||||
* Set the offset that is applied to each block.
|
||||
* @param blockOffset the new block offset
|
||||
*/
|
||||
void setBlockOffset(int blockOffset) {
|
||||
if (blockOffset == offset) {
|
||||
|
@ -311,6 +287,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
|||
|
||||
/**
|
||||
* Get the number of bytes displayed in a line.
|
||||
* @return the number of bytes displayed in a line
|
||||
*/
|
||||
int getBytesPerLine() {
|
||||
return bytesPerLine;
|
||||
|
@ -318,13 +295,14 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
|||
|
||||
/**
|
||||
* Get the offset that should be applied to each byte block.
|
||||
* @return the offset that should be applied to each byte block
|
||||
*/
|
||||
int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
Color getCursorColor() {
|
||||
return defaultCursorColor;
|
||||
return CURSOR_NON_ACTIVE_COLOR;
|
||||
}
|
||||
|
||||
int getGroupSize() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,8 +15,6 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.byteviewer;
|
||||
|
||||
import ghidra.util.table.GhidraTable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -26,6 +23,9 @@ import javax.swing.*;
|
|||
import javax.swing.event.TableColumnModelListener;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import generic.theme.Gui;
|
||||
import ghidra.util.table.GhidraTable;
|
||||
|
||||
/**
|
||||
* JTableHeader that uses the default table column model to manage
|
||||
* TableColumns. Sizes the column according to its corresponding viewer
|
||||
|
@ -33,6 +33,7 @@ import javax.swing.table.*;
|
|||
*/
|
||||
class ByteViewerHeader extends JTableHeader implements Scrollable {
|
||||
|
||||
private static final String FONT_ID = "font.byteviewer.header";
|
||||
private TableColumnModel columnModel;
|
||||
private Component container;
|
||||
|
||||
|
@ -50,8 +51,7 @@ class ByteViewerHeader extends JTableHeader implements Scrollable {
|
|||
|
||||
this.container = container;
|
||||
components = new HashMap<Component, TableColumn>();
|
||||
Font font = new Font("Tahoma", Font.PLAIN, 11);
|
||||
setFont(font);
|
||||
Gui.registerFont(this, FONT_ID);
|
||||
setResizingAllowed(false);
|
||||
table = new GhidraTable();
|
||||
setTable(table);
|
||||
|
|
|
@ -32,6 +32,7 @@ import docking.widgets.indexedscrollpane.*;
|
|||
import docking.widgets.label.GDLabel;
|
||||
import docking.widgets.label.GLabel;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.plugin.core.format.*;
|
||||
import ghidra.app.util.viewer.listingpanel.AddressSetDisplayListener;
|
||||
import ghidra.program.model.address.AddressSet;
|
||||
|
@ -45,11 +46,12 @@ import help.Help;
|
|||
import help.HelpService;
|
||||
|
||||
/**
|
||||
* Top level component that contains has a scrolled pane for the panel of components that show the
|
||||
* Top level component that has a scrolled pane for the panel of components that show the
|
||||
* view for each format.
|
||||
*/
|
||||
public class ByteViewerPanel extends JPanel
|
||||
implements TableColumnModelListener, LayoutModel, LayoutListener {
|
||||
private static final String FONT_STATUS_ID = "font.byteviewer.status";
|
||||
// private ByteViewerPlugin plugin;
|
||||
private List<ByteViewerComponent> viewList; // list of field viewers
|
||||
private FieldPanel indexPanel; // panel for showing indexes
|
||||
|
@ -94,7 +96,7 @@ public class ByteViewerPanel extends JPanel
|
|||
viewList = new ArrayList<>();
|
||||
indexMap = new IndexMap();
|
||||
create();
|
||||
editColor = ByteViewerComponentProvider.DEFAULT_EDIT_COLOR;
|
||||
editColor = ByteViewerComponentProvider.CHANGED_VALUE_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -812,7 +814,7 @@ public class ByteViewerPanel extends JPanel
|
|||
|
||||
columnHeader = new ByteViewerHeader(this);
|
||||
|
||||
fm = getFontMetrics(ByteViewerComponentProvider.DEFAULT_FONT);
|
||||
fm = getFontMetrics(Gui.getFont(ByteViewerComponentProvider.DEFAULT_FONT_ID));
|
||||
fontHeight = fm.getHeight();
|
||||
|
||||
// for the index/address column
|
||||
|
@ -864,15 +866,14 @@ public class ByteViewerPanel extends JPanel
|
|||
insertionField = new GDLabel("00000000");
|
||||
insertionField.setName("Insertion");
|
||||
|
||||
Font f = new Font("SansSerif", Font.PLAIN, 11);
|
||||
startLabel.setFont(f);
|
||||
endLabel.setFont(f);
|
||||
offsetLabel.setFont(f);
|
||||
insertionLabel.setFont(f);
|
||||
startField.setFont(f);
|
||||
endField.setFont(f);
|
||||
offsetField.setFont(f);
|
||||
insertionField.setFont(f);
|
||||
Gui.registerFont(startLabel, FONT_STATUS_ID);
|
||||
Gui.registerFont(endLabel, FONT_STATUS_ID);
|
||||
Gui.registerFont(offsetLabel, FONT_STATUS_ID);
|
||||
Gui.registerFont(insertionLabel, FONT_STATUS_ID);
|
||||
Gui.registerFont(startField, FONT_STATUS_ID);
|
||||
Gui.registerFont(endField, FONT_STATUS_ID);
|
||||
Gui.registerFont(offsetField, FONT_STATUS_ID);
|
||||
Gui.registerFont(insertionField, FONT_STATUS_ID);
|
||||
|
||||
// make a panel for each label/value pair
|
||||
JPanel p1 = new JPanel(new PairLayout(0, 5));
|
||||
|
|
|
@ -61,8 +61,8 @@ class FieldFactory {
|
|||
this.highlightFactory = new SimpleHighlightFactory(highlightProvider);
|
||||
charWidth = fm.charWidth('W');
|
||||
width = charWidth * model.getDataUnitSymbolSize();
|
||||
editColor = ByteViewerComponentProvider.DEFAULT_EDIT_COLOR;
|
||||
separatorColor = ByteViewerComponentProvider.DEFAULT_MISSING_VALUE_COLOR;
|
||||
editColor = ByteViewerComponentProvider.CHANGED_VALUE_COLOR;
|
||||
separatorColor = ByteViewerComponentProvider.SEPARATOR_COLOR;
|
||||
unitByteSize = model.getUnitByteSize();
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class IndexFieldFactory {
|
|||
|
||||
charWidth = fm.charWidth('W');
|
||||
width = ByteViewerComponentProvider.DEFAULT_NUMBER_OF_CHARS * charWidth;
|
||||
missingValueColor = ByteViewerComponentProvider.DEFAULT_MISSING_VALUE_COLOR;
|
||||
missingValueColor = ByteViewerComponentProvider.SEPARATOR_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -157,7 +157,8 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
|
|||
});
|
||||
assertTrue(action.isSelected());
|
||||
final ByteViewerComponent c = panelOne.getCurrentComponent();
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR,
|
||||
c.getFocusedCursorColor());
|
||||
runSwing(() -> {
|
||||
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_1, '1');
|
||||
c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
|
||||
|
@ -167,7 +168,7 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
|
|||
|
||||
ByteViewerComponent c2 = panel2.getCurrentComponent();
|
||||
ByteField f2 = c2.getField(BigInteger.ZERO, 0);
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, f2.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR, f2.getForeground());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -188,7 +189,8 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
|
|||
});
|
||||
assertTrue(action.isSelected());
|
||||
final ByteViewerComponent c = panelOne.getCurrentComponent();
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR,
|
||||
c.getFocusedCursorColor());
|
||||
runSwing(() -> {
|
||||
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_1, '1');
|
||||
c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
|
||||
|
@ -198,7 +200,7 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
|
|||
|
||||
ByteViewerComponent c2 = panel2.getCurrentComponent();
|
||||
ByteField f2 = c2.getField(BigInteger.ZERO, 0);
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, f2.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR, f2.getForeground());
|
||||
|
||||
undo(program);
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
});
|
||||
assertTrue(action.isSelected());
|
||||
final ByteViewerComponent c = panel.getCurrentComponent();
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_A, 'a');
|
||||
|
@ -157,7 +157,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
});
|
||||
program.flushEvents();
|
||||
assertEquals((byte) 0xa0, program.getMemory().getByte(getAddr(0x01001000)));
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR,
|
||||
((ByteField) c.getCurrentField()).getForeground());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
|
@ -165,7 +165,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
action.actionPerformed(new ActionContext());
|
||||
});
|
||||
assertTrue(!action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
|
||||
c.getFocusedCursorColor());
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
});
|
||||
assertTrue(action.isSelected());
|
||||
final ByteViewerComponent c = panel.getCurrentComponent();
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_A, 'a');
|
||||
|
@ -205,7 +205,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals(b, program.getMemory().getByte(addr));
|
||||
Color fg = ((ByteField) c.getCurrentField()).getForeground();
|
||||
if (fg != null) {
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR, fg);
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR, fg);
|
||||
}
|
||||
Window w = windowForComponent(plugin.getProvider().getComponent());
|
||||
String str = findLabelStr(w, "Tool Status");
|
||||
|
@ -251,7 +251,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals((byte) 0xa0, program.getMemory().getByte(addr));
|
||||
FieldLocation loc = getFieldLocation(addr);
|
||||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
|
||||
}
|
||||
|
||||
|
@ -296,21 +296,21 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals((byte) 0xa0, program.getMemory().getByte(addr));
|
||||
FieldLocation loc = getFieldLocation(addr);
|
||||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
|
||||
final ByteViewerComponent asciiC = findComponent(panel, "Ascii");
|
||||
SwingUtilities.invokeAndWait(() -> panel.setCurrentView(asciiC));
|
||||
|
||||
loc = getFieldLocation(addr);
|
||||
field = asciiC.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
|
||||
final ByteViewerComponent hexIntC = findComponent(panel, "HexInteger");
|
||||
SwingUtilities.invokeAndWait(() -> panel.setCurrentView(hexIntC));
|
||||
|
||||
loc = getFieldLocation(addr);
|
||||
field = asciiC.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -346,7 +346,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
Color fg = field.getForeground();
|
||||
assertTrue(fg == null ||
|
||||
ByteViewerComponentProvider.DEFAULT_CURSOR_COLOR == field.getForeground());
|
||||
ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR == field.getForeground());
|
||||
|
||||
redo(program);
|
||||
program.flushEvents();
|
||||
|
@ -354,7 +354,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
// field color should show edit color
|
||||
loc = getFieldLocation(addr);
|
||||
field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
|
||||
}
|
||||
|
||||
|
@ -404,19 +404,19 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
FieldLocation loc2 = new FieldLocation(0, 1, 0, 0); // second byte on first line
|
||||
|
||||
undo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
|
||||
undo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
|
||||
undo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, null);
|
||||
|
||||
undo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, null);
|
||||
|
||||
undo(program);
|
||||
|
@ -425,24 +425,24 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertTrue(!program.canUndo());
|
||||
|
||||
redo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, null);
|
||||
|
||||
redo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, null);
|
||||
|
||||
redo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
|
||||
redo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
|
||||
redo(program);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
|
||||
assertTrue(program.canUndo());
|
||||
}
|
||||
|
@ -493,14 +493,14 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
Color fg = field.getForeground();
|
||||
assertTrue(fg == null ||
|
||||
ByteViewerComponentProvider.DEFAULT_CURSOR_COLOR == field.getForeground());
|
||||
ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR == field.getForeground());
|
||||
|
||||
redo(program);
|
||||
|
||||
// field color should show edit color
|
||||
loc = getFieldLocation(addr);
|
||||
field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
|
||||
}
|
||||
|
||||
|
@ -558,10 +558,10 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
Color fg = field.getForeground();
|
||||
if (i == 4) {
|
||||
assertTrue(fg == null ||
|
||||
ByteViewerComponentProvider.DEFAULT_CURSOR_COLOR == field.getForeground());
|
||||
ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR == field.getForeground());
|
||||
}
|
||||
else {
|
||||
assertEquals(fg, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
assertEquals(fg, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
}
|
||||
}
|
||||
assertTrue(!program.canUndo());
|
||||
|
@ -573,7 +573,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
FieldLocation loc = c.getCursorLocation();
|
||||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
Color fg = field.getForeground();
|
||||
assertEquals(fg, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
|
||||
assertEquals(fg, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
|
||||
}
|
||||
|
||||
assertTrue(program.canUndo());
|
||||
|
@ -593,7 +593,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
});
|
||||
assertTrue(action.isSelected());
|
||||
final ByteViewerComponent c = panel.getCurrentComponent();
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
|
||||
byte value = program.getMemory().getByte(getAddr(0x01001000));
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_P, 'p');
|
||||
|
@ -623,7 +623,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
});
|
||||
waitForPostedSwingRunnables();
|
||||
assertTrue(action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_Z, 'z');
|
||||
|
@ -634,14 +634,14 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
Address addr = getAddr(0x01001000);
|
||||
assertEquals((byte) 0x7a, program.getMemory().getByte(addr));
|
||||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
action.setSelected(false);
|
||||
action.actionPerformed(new ActionContext());
|
||||
});
|
||||
assertTrue(!action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
|
||||
c.getFocusedCursorColor());
|
||||
}
|
||||
|
||||
|
@ -663,7 +663,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
action.actionPerformed(new ActionContext());
|
||||
});
|
||||
assertTrue(action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
FieldLocation loc = getFieldLocation(addr);
|
||||
|
@ -676,14 +676,14 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals((byte) 0x40, program.getMemory().getByte(addr));
|
||||
FieldLocation loc = getFieldLocation(addr);
|
||||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
action.setSelected(false);
|
||||
action.actionPerformed(new ActionContext());
|
||||
});
|
||||
assertTrue(!action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
|
||||
c.getFocusedCursorColor());
|
||||
}
|
||||
|
||||
|
@ -705,7 +705,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
action.actionPerformed(new ActionContext());
|
||||
});
|
||||
assertTrue(action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
|
||||
|
||||
byte value = program.getMemory().getByte(getAddr(0x01001000));
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
|
@ -735,7 +735,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
action.actionPerformed(new ActionContext());
|
||||
});
|
||||
assertTrue(action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_1, '1');
|
||||
|
@ -744,7 +744,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
});
|
||||
program.flushEvents();
|
||||
assertEquals((byte) 0x10, program.getMemory().getByte(getAddr(0x01001003)));
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR,
|
||||
((ByteField) c.getCurrentField()).getForeground());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
|
@ -752,7 +752,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
action.actionPerformed(new ActionContext());
|
||||
});
|
||||
assertTrue(!action.isSelected());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
|
||||
c.getFocusedCursorColor());
|
||||
}
|
||||
|
||||
|
@ -802,7 +802,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
// verify that the bytes are rendered in red
|
||||
FieldLocation loc = getFieldLocation(addr);
|
||||
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
|
||||
addr = addr.add(i);
|
||||
}
|
||||
}
|
||||
|
@ -1216,7 +1216,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
Options opt = tool.getOptions("ByteViewer");
|
||||
// change the color for Current View Cursor Color
|
||||
putColor(opt, ByteViewerComponentProvider.OPTION_CURRENT_VIEW_CURSOR_COLOR, Palette.GREEN);
|
||||
putColor(opt, ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR_OPTION_NAME, Palette.GREEN);
|
||||
|
||||
ByteViewerComponent c = panel.getCurrentComponent();
|
||||
assertEquals(Palette.GREEN, c.getFocusedCursorColor());
|
||||
|
@ -1236,7 +1236,8 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
Options opt = tool.getOptions("ByteViewer");
|
||||
// change the color for Current View Cursor Color
|
||||
putColor(opt, ByteViewerComponentProvider.OPTION_CURSOR_COLOR, Palette.GREEN);
|
||||
putColor(opt, ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR_OPTION_NAME,
|
||||
Palette.GREEN);
|
||||
|
||||
ByteViewerComponent c = findComponent(panel, "Octal");
|
||||
assertEquals(Palette.GREEN, c.getNonFocusCursorColor());
|
||||
|
@ -1255,7 +1256,8 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
Options opt = tool.getOptions("ByteViewer");
|
||||
// change the color for Current View Cursor Color
|
||||
putColor(opt, ByteViewerComponentProvider.OPTION_NONFOCUS_CURSOR_COLOR, Palette.CYAN);
|
||||
putColor(opt, ByteViewerComponentProvider.CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME,
|
||||
Palette.CYAN);
|
||||
|
||||
ByteViewerComponent c = findComponent(panel, "Octal");
|
||||
assertEquals(Palette.CYAN, c.getNonFocusCursorColor());
|
||||
|
@ -1283,7 +1285,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
Options opt = tool.getOptions("ByteViewer");
|
||||
// change the color for Edit Color
|
||||
putColor(opt, ByteViewerComponentProvider.OPTION_EDIT_COLOR, Palette.GREEN);
|
||||
putColor(opt, ByteViewerComponentProvider.CHANGED_VALUE_COLOR_OPTION_NAME, Palette.GREEN);
|
||||
|
||||
final FieldLocation loc = getFieldLocation(getAddr(0x01001000));
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
|
@ -1341,7 +1343,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
Options opt = tool.getOptions("ByteViewer");
|
||||
// change the color for block separator
|
||||
putColor(opt, ByteViewerComponentProvider.OPTION_SEPARATOR_COLOR, Palette.GREEN);
|
||||
putColor(opt, ByteViewerComponentProvider.SEPARATOR_COLOR_OPTION_NAME, Palette.GREEN);
|
||||
|
||||
ByteViewerComponent c = panel.getCurrentComponent();
|
||||
FieldLocation loc = getFieldLocation(getAddr(0x0f001000));
|
||||
|
|
|
@ -292,7 +292,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
|
|||
hexComp.setCursorPosition(l.getIndex(), l.getFieldNum(), 0, 0);
|
||||
});
|
||||
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR,
|
||||
((ByteField) hexComp.getCurrentField()).getForeground());
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
|
|||
// does not support editing
|
||||
Color fg = ((ByteField) c.getCurrentField()).getForeground();
|
||||
if (fg != null) {
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR, fg);
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR, fg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
|
|||
// does not support editing
|
||||
Color fg = ((ByteField) c.getCurrentField()).getForeground();
|
||||
if (fg != null) {
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR, fg);
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR, fg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
|
|||
intComp.setCursorPosition(l.getIndex(), l.getFieldNum(), 0, 0);
|
||||
});
|
||||
// color should indicate the edit
|
||||
assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
|
||||
assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR,
|
||||
((ByteField) intComp.getCurrentField()).getForeground());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ 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)
|
||||
color.fg.line.numbers = gray
|
||||
|
||||
|
@ -33,13 +32,13 @@ color.bg.decompiler.pcode.dfg.edge.default = navy
|
|||
color.bg.decompiler.pcode.dfg.edge.selected = deeppink
|
||||
color.bg.decompiler.pcode.dfg.edge.within.block = black
|
||||
color.bg.decompiler.pcode.dfg.edge.between.blocks = red
|
||||
|
||||
font.decompiler.pcode.dfg = font.graphdisplay.default
|
||||
|
||||
icon.decompiler.action.provider = decompileFunction.gif
|
||||
icon.decompiler.action.provider.clone = icon.provider.clone
|
||||
icon.decompiler.action.export = page_edit.png
|
||||
|
||||
|
||||
font.decompiler = font.monospaced
|
||||
[Dark Defaults]
|
||||
|
||||
color.fg.decompiler.keyword = peru
|
||||
|
|
|
@ -25,10 +25,11 @@ import java.awt.event.MouseEvent;
|
|||
import java.io.IOException;
|
||||
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.GhidraOptions;
|
||||
import ghidra.GhidraOptions.CURSOR_MOUSE_BUTTON_NAMES;
|
||||
import ghidra.app.util.HelpTopics;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.options.*;
|
||||
import ghidra.framework.plugintool.Plugin;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.database.ProgramCompilerSpec;
|
||||
|
@ -38,7 +39,6 @@ import ghidra.program.model.listing.Program;
|
|||
import ghidra.program.model.pcode.ElementId;
|
||||
import ghidra.program.model.pcode.Encoder;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
||||
/**
|
||||
* Configuration options for the decompiler
|
||||
|
@ -303,62 +303,57 @@ public class DecompileOptions {
|
|||
private final static IntegerFormatEnum INTEGERFORMAT_OPTIONDEFAULT = IntegerFormatEnum.BestFit; // Must match PrintLanguage::resetDefaultsInternal
|
||||
private IntegerFormatEnum integerFormat;
|
||||
|
||||
private final static Color HIGHLIGHT_MIDDLE_MOUSE_DEF = new GColor("color.bg.decompiler.middle.mouse");
|
||||
private Color middleMouseHighlightColor;
|
||||
private int middleMouseHighlightButton = MouseEvent.BUTTON2;
|
||||
|
||||
private final static String HIGHLIGHT_CURRENT_VARIABLE_MSG ="Display.Color for Current Variable Highlight";
|
||||
private final static Color HIGHLIGHT_CURRENT_VARIABLE_DEF = new GColor("color.bg.decompiler.current.variable");
|
||||
private Color currentVariableHighlightColor;
|
||||
private final static Color HIGHLIGHT_CURRENT_VARIABLE_COLOR = new GColor("color.bg.decompiler.current.variable");
|
||||
|
||||
private final static String HIGHLIGHT_KEYWORD_MSG = "Display.Color for Keywords";
|
||||
private final static Color HIGHLIGHT_KEYWORD_DEF = new GColor("color.fg.decompiler.keyword");
|
||||
private Color keywordColor;
|
||||
private final static Color HIGHLIGHT_KEYWORD_COLOR = new GColor("color.fg.decompiler.keyword");
|
||||
|
||||
private final static String HIGHLIGHT_FUNCTION_MSG = "Display.Color for Function names";
|
||||
private final static Color HIGHLIGHT_FUNCTION_DEF = new GColor("color.fg.decompiler.keyword");
|
||||
private Color functionColor;
|
||||
private final static Color HIGHLIGHT_FUNCTION_COLOR = new GColor("color.fg.decompiler.function.name");
|
||||
|
||||
private final static String HIGHLIGHT_COMMENT_MSG = "Display.Color for Comments";
|
||||
private final static Color HIGHLIGHT_COMMENT_DEF = new GColor("color.fg.decompiler.comment");
|
||||
private Color commentColor;
|
||||
private final static Color HIGHLIGHT_COMMENT_COLOR = new GColor( "color.fg.decompiler.comment");
|
||||
|
||||
private final static String HIGHLIGHT_VARIABLE_MSG = "Display.Color for Variables";
|
||||
private final static Color HIGHLIGHT_VARIABLE_DEF = new GColor( "color.fg.decompiler.variable");
|
||||
private Color variableColor;
|
||||
private final static Color HIGHLIGHT_VARIABLE_COLOR = new GColor("color.fg.decompiler.variable");
|
||||
|
||||
private final static String HIGHLIGHT_CONST_MSG = "Display.Color for Constants";
|
||||
private final static Color HIGHLIGHT_CONST_DEF = new GColor( "color.fg.decompiler.constant");
|
||||
private Color constantColor;
|
||||
private final static Color HIGHLIGHT_CONST_COLOR = new GColor("color.fg.decompiler.constant");
|
||||
|
||||
private final static String HIGHLIGHT_TYPE_MSG = "Display.Color for Types";
|
||||
private final static Color HIGHLIGHT_TYPE_DEF = new GColor( "color.fg.decompiler.type");
|
||||
private Color typeColor;
|
||||
private final static Color HIGHLIGHT_TYPE_COLOR = new GColor("color.fg.decompiler.type");
|
||||
|
||||
private final static String HIGHLIGHT_PARAMETER_MSG = "Display.Color for Parameters";
|
||||
private final static Color HIGHLIGHT_PARAMETER_DEF = new GColor( "color.fg.decompiler.parameter");
|
||||
private Color parameterColor;
|
||||
private final static Color HIGHLIGHT_PARAMETER_COLOR = new GColor("color.fg.decompiler.parameter");
|
||||
|
||||
private final static String HIGHLIGHT_GLOBAL_MSG = "Display.Color for Globals";
|
||||
private final static Color HIGHLIGHT_GLOBAL_DEF = new GColor( "color.fg.decompiler.global");
|
||||
private Color globalColor;
|
||||
private final static String HIGHLIGHT_SPECIAL_MSG = "Display.Color for Special";
|
||||
private final static Color HIGHLIGHT_SPECIAL_DEF = Color.decode("0xCC0033");
|
||||
private Color specialColor;
|
||||
private final static Color HIGHLIGHT_GLOBAL_COLOR = new GColor("color.fg.decompiler.global");
|
||||
private final static String HIGHLIGHT_DEFAULT_MSG = "Display.Color Default";
|
||||
private final static Color HIGHLIGHT_DEFAULT_DEF = new GColor("color.fg.decompiler");
|
||||
private Color defaultColor;
|
||||
private final static Color HIGHLIGHT_DEFAULT_COLOR = new GColor("color.fg.decompiler");
|
||||
|
||||
private static final String SEARCH_HIGHLIGHT_MSG = "Display.Color for Highlighting Find Matches";
|
||||
private static final Color SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.decompiler.highlights.search");
|
||||
|
||||
|
||||
//@formatter:on
|
||||
|
||||
private static final String CODE_VIEWER_BACKGROUND_COLOR_MSG = "Display.Background Color";
|
||||
private static final Color CODE_VIEWER_BACKGROUND_COLOR = new GColor("color.bg.decompiler");
|
||||
private Color codeViewerBackgroundColor;
|
||||
|
||||
private static final String SEARCH_HIGHLIGHT_MSG =
|
||||
"Display.Color for Highlighting Find Matches";
|
||||
private static final Color SEARCH_HIGHLIGHT_DEF =
|
||||
new GColor("color.bg.decompiler.highlights.search");
|
||||
private Color defaultSearchHighlightColor = SEARCH_HIGHLIGHT_DEF;
|
||||
private static final String BACKGROUND_COLOR_MSG = "Display.Background Color";
|
||||
private static final String BACKGROUND_COLOR_ID = "color.bg.decompiler";
|
||||
private static final Color BACKGROUND_COLOR = new GColor(BACKGROUND_COLOR_ID);
|
||||
|
||||
// Color applied to a token to indicate warning/error
|
||||
private final static Color ERROR_COLOR = new GColor("color.fg.decompiler.comment");
|
||||
|
||||
final static String FONT_MSG = "Display.Font";
|
||||
final static Font DEFAULT_FONT = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||
private Font defaultFont;
|
||||
final static String DEFAULT_FONT_ID = "font.decompiler";
|
||||
private Font font;
|
||||
|
||||
private final static String CACHED_RESULTS_SIZE_MSG = "Cache Size (Functions)";
|
||||
private final static int SUGGESTED_CACHED_RESULTS_SIZE = 10;
|
||||
|
@ -405,6 +400,7 @@ public class DecompileOptions {
|
|||
commentHeadInclude = COMMENTHEAD_OPTIONDEFAULT;
|
||||
namespaceStrategy = NAMESPACE_OPTIONDEFAULT;
|
||||
integerFormat = INTEGERFORMAT_OPTIONDEFAULT;
|
||||
<<<<<<< Upstream, based on origin/master
|
||||
keywordColor = HIGHLIGHT_KEYWORD_DEF;
|
||||
functionColor = HIGHLIGHT_FUNCTION_DEF;
|
||||
commentColor = HIGHLIGHT_COMMENT_DEF;
|
||||
|
@ -417,6 +413,8 @@ public class DecompileOptions {
|
|||
defaultColor = HIGHLIGHT_DEFAULT_DEF;
|
||||
codeViewerBackgroundColor = CODE_VIEWER_BACKGROUND_COLOR;
|
||||
defaultFont = DEFAULT_FONT;
|
||||
=======
|
||||
>>>>>>> 47fa38a GP-1981 converting option colors to theme colors and font usages to theme properties
|
||||
displayLineNumbers = LINE_NUMBER_DEF;
|
||||
displayLanguage = ProgramCompilerSpec.DECOMPILER_OUTPUT_DEF;
|
||||
protoEvalModel = "default";
|
||||
|
@ -469,6 +467,7 @@ public class DecompileOptions {
|
|||
commentHeadInclude = opt.getBoolean(COMMENTHEAD_OPTIONSTRING, COMMENTHEAD_OPTIONDEFAULT);
|
||||
namespaceStrategy = opt.getEnum(NAMESPACE_OPTIONSTRING, NAMESPACE_OPTIONDEFAULT);
|
||||
integerFormat = opt.getEnum(INTEGERFORMAT_OPTIONSTRING, INTEGERFORMAT_OPTIONDEFAULT);
|
||||
<<<<<<< Upstream, based on origin/master
|
||||
keywordColor = opt.getColor(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_DEF);
|
||||
typeColor = opt.getColor(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_DEF);
|
||||
functionColor = opt.getColor(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_DEF);
|
||||
|
@ -486,6 +485,8 @@ public class DecompileOptions {
|
|||
defaultFont = opt.getFont(FONT_MSG, DEFAULT_FONT);
|
||||
defaultFont = SystemUtilities.adjustForFontSizeOverride(defaultFont);
|
||||
defaultSearchHighlightColor = opt.getColor(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_DEF);
|
||||
=======
|
||||
>>>>>>> 47fa38a GP-1981 converting option colors to theme colors and font usages to theme properties
|
||||
displayLineNumbers = opt.getBoolean(LINE_NUMBER_MSG, LINE_NUMBER_DEF);
|
||||
decompileTimeoutSeconds = opt.getInt(DECOMPILE_TIMEOUT, SUGGESTED_DECOMPILE_TIMEOUT_SECS);
|
||||
payloadLimitMBytes = opt.getInt(PAYLOAD_LIMIT, SUGGESTED_MAX_PAYLOAD_BYTES);
|
||||
|
@ -503,9 +504,6 @@ public class DecompileOptions {
|
|||
PluginTool tool = ownerPlugin.getTool();
|
||||
Options toolOptions = tool.getOptions(CATEGORY_BROWSER_FIELDS);
|
||||
|
||||
middleMouseHighlightColor =
|
||||
toolOptions.getColor(HIGHLIGHT_COLOR_NAME, HIGHLIGHT_MIDDLE_MOUSE_DEF);
|
||||
|
||||
CURSOR_MOUSE_BUTTON_NAMES mouseEvent =
|
||||
toolOptions.getEnum(CURSOR_HIGHLIGHT_BUTTON_NAME, CURSOR_MOUSE_BUTTON_NAMES.MIDDLE);
|
||||
middleMouseHighlightButton = mouseEvent.getMouseEventID();
|
||||
|
@ -622,43 +620,47 @@ public class DecompileOptions {
|
|||
opt.registerOption(INTEGERFORMAT_OPTIONSTRING, INTEGERFORMAT_OPTIONDEFAULT,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayIntegerFormat"),
|
||||
INTEGERFORMAT_OPTIONDESCRIPTION);
|
||||
opt.registerOption(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_DEF,
|
||||
opt.registerOption(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting keywords.");
|
||||
opt.registerOption(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_DEF,
|
||||
opt.registerOption(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting types.");
|
||||
opt.registerOption(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_DEF,
|
||||
opt.registerOption(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting function names.");
|
||||
opt.registerOption(HIGHLIGHT_COMMENT_MSG, HIGHLIGHT_COMMENT_DEF,
|
||||
opt.registerOption(HIGHLIGHT_COMMENT_MSG, HIGHLIGHT_COMMENT_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting comments.");
|
||||
opt.registerOption(HIGHLIGHT_VARIABLE_MSG, HIGHLIGHT_VARIABLE_DEF,
|
||||
opt.registerOption(HIGHLIGHT_VARIABLE_MSG, HIGHLIGHT_VARIABLE_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting variables.");
|
||||
opt.registerOption(HIGHLIGHT_CONST_MSG, HIGHLIGHT_CONST_DEF,
|
||||
opt.registerOption(HIGHLIGHT_CONST_MSG, HIGHLIGHT_CONST_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting constants.");
|
||||
opt.registerOption(HIGHLIGHT_PARAMETER_MSG, HIGHLIGHT_PARAMETER_DEF,
|
||||
opt.registerOption(HIGHLIGHT_PARAMETER_MSG, HIGHLIGHT_PARAMETER_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting parameters.");
|
||||
opt.registerOption(HIGHLIGHT_GLOBAL_MSG, HIGHLIGHT_GLOBAL_DEF,
|
||||
opt.registerOption(HIGHLIGHT_GLOBAL_MSG, HIGHLIGHT_GLOBAL_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for highlighting global variables.");
|
||||
<<<<<<< Upstream, based on origin/master
|
||||
opt.registerOption(HIGHLIGHT_SPECIAL_MSG, HIGHLIGHT_SPECIAL_DEF,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
|
||||
"Color used for volatile or other exceptional variables.");
|
||||
opt.registerOption(HIGHLIGHT_DEFAULT_MSG, HIGHLIGHT_DEFAULT_DEF,
|
||||
=======
|
||||
opt.registerOption(HIGHLIGHT_DEFAULT_MSG, HIGHLIGHT_DEFAULT_COLOR,
|
||||
>>>>>>> 47fa38a GP-1981 converting option colors to theme colors and font usages to theme properties
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayColorDefault"),
|
||||
"The color used when a specific color is not specified.");
|
||||
opt.registerOption(CODE_VIEWER_BACKGROUND_COLOR_MSG, CODE_VIEWER_BACKGROUND_COLOR,
|
||||
opt.registerOption(BACKGROUND_COLOR_MSG, BACKGROUND_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayBackgroundColor"),
|
||||
"The background color of the decompiler window.");
|
||||
opt.registerOption(FONT_MSG, DEFAULT_FONT,
|
||||
opt.registerOption(FONT_MSG, OptionType.FONT_TYPE, DEFAULT_FONT_ID,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayFont"),
|
||||
"The font used to render text in the decompiler.");
|
||||
opt.registerOption(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_DEF,
|
||||
opt.registerOption(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayFindHighlight"),
|
||||
"The color used to highlight matches using the Find Dialog.");
|
||||
opt.registerOption(LINE_NUMBER_MSG, LINE_NUMBER_DEF,
|
||||
|
@ -675,7 +677,8 @@ public class DecompileOptions {
|
|||
opt.registerOption(MAX_INSTRUCTIONS, SUGGESTED_MAX_INSTRUCTIONS,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "GeneralMaxInstruction"),
|
||||
"The maximum number of instructions decompiled in a single function");
|
||||
opt.registerOption(HIGHLIGHT_CURRENT_VARIABLE_MSG, HIGHLIGHT_CURRENT_VARIABLE_DEF,
|
||||
opt.registerOption(HIGHLIGHT_CURRENT_VARIABLE_MSG,
|
||||
HIGHLIGHT_CURRENT_VARIABLE_COLOR,
|
||||
new HelpLocation(HelpTopics.DECOMPILER, "DisplayCurrentHighlight"),
|
||||
"Current variable highlight");
|
||||
opt.registerOption(CACHED_RESULTS_SIZE_MSG, SUGGESTED_CACHED_RESULTS_SIZE,
|
||||
|
@ -816,56 +819,56 @@ public class DecompileOptions {
|
|||
* @return color associated with keyword tokens
|
||||
*/
|
||||
public Color getKeywordColor() {
|
||||
return keywordColor;
|
||||
return HIGHLIGHT_KEYWORD_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color associated with data-type tokens
|
||||
*/
|
||||
public Color getTypeColor() {
|
||||
return typeColor;
|
||||
return HIGHLIGHT_TYPE_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color associated with a function name token
|
||||
*/
|
||||
public Color getFunctionColor() {
|
||||
return functionColor;
|
||||
return HIGHLIGHT_FUNCTION_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color used to display comments
|
||||
*/
|
||||
public Color getCommentColor() {
|
||||
return commentColor;
|
||||
return HIGHLIGHT_COMMENT_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color associated with constant tokens
|
||||
*/
|
||||
public Color getConstantColor() {
|
||||
return constantColor;
|
||||
return HIGHLIGHT_CONST_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color associated with (local) variable tokens
|
||||
*/
|
||||
public Color getVariableColor() {
|
||||
return variableColor;
|
||||
return HIGHLIGHT_VARIABLE_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color associated with parameter tokens
|
||||
*/
|
||||
public Color getParameterColor() {
|
||||
return parameterColor;
|
||||
return HIGHLIGHT_PARAMETER_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color associated with global variable tokens
|
||||
*/
|
||||
public Color getGlobalColor() {
|
||||
return globalColor;
|
||||
return HIGHLIGHT_GLOBAL_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -879,7 +882,7 @@ public class DecompileOptions {
|
|||
* @return color for generic syntax or other unspecified tokens
|
||||
*/
|
||||
public Color getDefaultColor() {
|
||||
return defaultColor;
|
||||
return HIGHLIGHT_DEFAULT_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -892,29 +895,29 @@ public class DecompileOptions {
|
|||
/**
|
||||
* @return the background color for the decompiler window
|
||||
*/
|
||||
public Color getCodeViewerBackgroundColor() {
|
||||
return codeViewerBackgroundColor;
|
||||
public Color getBackgroundColor() {
|
||||
return BACKGROUND_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the color used display the current highlighted variable
|
||||
*/
|
||||
public Color getCurrentVariableHighlightColor() {
|
||||
return currentVariableHighlightColor;
|
||||
return HIGHLIGHT_CURRENT_VARIABLE_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color used to highlight token(s) selected with a middle button clock
|
||||
*/
|
||||
public Color getMiddleMouseHighlightColor() {
|
||||
return middleMouseHighlightColor;
|
||||
return GhidraOptions.DEFAULT_HIGHLIGHT_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return color used to highlight search results
|
||||
*/
|
||||
public Color getSearchHighlightColor() {
|
||||
return defaultSearchHighlightColor;
|
||||
return SEARCH_HIGHLIGHT_COLOR;
|
||||
}
|
||||
|
||||
public int getMiddleMouseHighlightButton() {
|
||||
|
@ -1014,7 +1017,7 @@ public class DecompileOptions {
|
|||
}
|
||||
|
||||
public Font getDefaultFont() {
|
||||
return defaultFont;
|
||||
return Gui.getFont(DEFAULT_FONT_ID);
|
||||
}
|
||||
|
||||
public int getDefaultTimeout() {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
|
||||
layoutController = new ClangLayoutController(options, this, metrics, hlFactory);
|
||||
fieldPanel = new DecompilerFieldPanel(layoutController);
|
||||
setBackground(options.getCodeViewerBackgroundColor());
|
||||
setBackground(options.getBackgroundColor());
|
||||
|
||||
scroller = new IndexedScrollPane(fieldPanel);
|
||||
fieldPanel.addFieldSelectionListener(this);
|
||||
|
@ -522,7 +522,8 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
return;
|
||||
}
|
||||
|
||||
List<ClangToken> tokens = DecompilerUtils.getTokensFromView(layoutController.getFields(), address);
|
||||
List<ClangToken> tokens =
|
||||
DecompilerUtils.getTokensFromView(layoutController.getFields(), address);
|
||||
goToBeginningOfLine(tokens);
|
||||
}
|
||||
|
||||
|
@ -572,7 +573,8 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
return;
|
||||
}
|
||||
|
||||
int firstLineNumber = DecompilerUtils.findIndexOfFirstField(tokens, layoutController.getFields());
|
||||
int firstLineNumber =
|
||||
DecompilerUtils.findIndexOfFirstField(tokens, layoutController.getFields());
|
||||
if (firstLineNumber != -1) {
|
||||
fieldPanel.goTo(BigInteger.valueOf(firstLineNumber), 0, 0, 0, false);
|
||||
}
|
||||
|
@ -631,7 +633,8 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
fieldSelection = new FieldSelection();
|
||||
}
|
||||
else {
|
||||
List<ClangToken> tokens = DecompilerUtils.getTokens(layoutController.getRoot(), selection);
|
||||
List<ClangToken> tokens =
|
||||
DecompilerUtils.getTokens(layoutController.getRoot(), selection);
|
||||
fieldSelection = DecompilerUtils.getFieldSelection(tokens);
|
||||
}
|
||||
fieldPanel.setSelection(fieldSelection);
|
||||
|
@ -1161,7 +1164,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
}
|
||||
|
||||
public void optionsChanged(DecompileOptions decompilerOptions) {
|
||||
setBackground(decompilerOptions.getCodeViewerBackgroundColor());
|
||||
setBackground(decompilerOptions.getBackgroundColor());
|
||||
currentVariableHighlightColor = options.getCurrentVariableHighlightColor();
|
||||
middleMouseHighlightColor = decompilerOptions.getMiddleMouseHighlightColor();
|
||||
middleMouseHighlightButton = decompilerOptions.getMiddleMouseHighlightButton();
|
||||
|
|
|
@ -18,9 +18,6 @@ package ghidra.app.plugin.core.decompile.actions;
|
|||
import static ghidra.app.plugin.core.decompile.actions.PCodeDfgGraphType.*;
|
||||
import static ghidra.service.graph.VertexShape.*;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import generic.theme.GColor;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.service.graph.*;
|
||||
|
||||
|
@ -30,31 +27,21 @@ import ghidra.service.graph.*;
|
|||
public class PCodeDfgDisplayOptions extends GraphDisplayOptions {
|
||||
public static final String SHAPE_ATTRIBUTE = "Shape";
|
||||
|
||||
private static final Color BG_VERTEX_DEFAULT =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.default");
|
||||
private static final Color BG_VERTEX_SELECTED =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.selected");
|
||||
private static final Color BG_VERTEX_CONSTANT =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.constant");
|
||||
private static final Color BG_VERTEX_REGISTER =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.register");
|
||||
private static final Color BG_VERTEX_UNIQUE =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.unique");
|
||||
private static final Color BG_VERTEX_PERSISTENT =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.persistent");
|
||||
private static final Color BG_VERTEX_ADDRESS_TIED =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.address.tied");
|
||||
private static final Color BG_VERTEX_OP =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.vertex.op");
|
||||
// @formatter:off
|
||||
private static final String BG_VERTEX_DEFAULT = "color.bg.decompiler.pcode.dfg.vertex.default";
|
||||
private static final String BG_VERTEX_SELECTED ="color.bg.decompiler.pcode.dfg.vertex.selected";
|
||||
private static final String BG_VERTEX_CONSTANT ="color.bg.decompiler.pcode.dfg.vertex.constant";
|
||||
private static final String BG_VERTEX_REGISTER ="color.bg.decompiler.pcode.dfg.vertex.register";
|
||||
private static final String BG_VERTEX_UNIQUE ="color.bg.decompiler.pcode.dfg.vertex.unique";
|
||||
private static final String BG_VERTEX_PERSISTENT ="color.bg.decompiler.pcode.dfg.vertex.persistent";
|
||||
private static final String BG_VERTEX_ADDRESS_TIED ="color.bg.decompiler.pcode.dfg.vertex.address.tied";
|
||||
private static final String BG_VERTEX_OP ="color.bg.decompiler.pcode.dfg.vertex.op";
|
||||
|
||||
private static final Color BG_EDGE_DEFAULT =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.edge.default");
|
||||
private static final Color BG_EDGE_SELECTED =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.edge.selected");
|
||||
private static final Color BG_EDGE_WITHIN_BLOCK =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.edge.within.block");
|
||||
private static final Color BG_EDGE_BETWEEN_BLOCKS =
|
||||
new GColor("color.bg.decompiler.pcode.dfg.edge.between.blocks");
|
||||
private static final String BG_EDGE_DEFAULT ="color.bg.decompiler.pcode.dfg.edge.default";
|
||||
private static final String BG_EDGE_SELECTED ="color.bg.decompiler.pcode.dfg.edge.selected";
|
||||
private static final String BG_EDGE_WITHIN_BLOCK ="color.bg.decompiler.pcode.dfg.edge.within.block";
|
||||
private static final String BG_EDGE_BETWEEN_BLOCKS ="color.bg.decompiler.pcode.dfg.edge.between.blocks";
|
||||
// @formatter:on
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
@ -89,5 +76,7 @@ public class PCodeDfgDisplayOptions extends GraphDisplayOptions {
|
|||
configureEdgeType(DEFAULT_EDGE, BG_EDGE_DEFAULT);
|
||||
configureEdgeType(WITHIN_BLOCK, BG_EDGE_WITHIN_BLOCK);
|
||||
configureEdgeType(BETWEEN_BLOCKS, BG_EDGE_BETWEEN_BLOCKS);
|
||||
|
||||
setFont("font.decompiler.pcode.dfg");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package ghidra.feature.fid.debug;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -29,7 +28,6 @@ import ghidra.util.NumericUtilities;
|
|||
* Utility class to handle some debug functions for the FID database.
|
||||
*/
|
||||
public class FidDebugUtils {
|
||||
public static final Font MONOSPACED_FONT = new Font("monospaced", Font.PLAIN, 12);
|
||||
|
||||
/**
|
||||
* Search the FID system for function records by name substring.
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.awt.event.ActionListener;
|
|||
import javax.swing.*;
|
||||
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.feature.fid.db.*;
|
||||
import ghidra.feature.fid.service.FidService;
|
||||
import ghidra.program.model.lang.LanguageID;
|
||||
|
@ -55,7 +56,7 @@ public class FidFunctionDebugPanel extends JPanel {
|
|||
JButton button = new JButton(text);
|
||||
button.addActionListener(listener);
|
||||
button.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
button.setFont(FidDebugUtils.MONOSPACED_FONT);
|
||||
button.setFont(Gui.getFont("font.monospaced"));
|
||||
add(button);
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class FidFunctionDebugPanel extends JPanel {
|
|||
private void addLabel(String text) {
|
||||
JLabel label = new GDLabel(text);
|
||||
label.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
label.setFont(FidDebugUtils.MONOSPACED_FONT);
|
||||
label.setFont(Gui.getFont("font.monospaced"));
|
||||
add(label);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.swing.*;
|
|||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.feature.fid.db.FidFileManager;
|
||||
import ghidra.feature.fid.db.FidQueryService;
|
||||
import ghidra.feature.fid.plugin.FidPlugin;
|
||||
|
@ -75,13 +76,13 @@ public class FidSearchDebugDialog extends DialogComponentProvider {
|
|||
|
||||
private JLabel getPreparedLabel(String text) {
|
||||
JLabel label = new GDLabel(text, SwingConstants.RIGHT);
|
||||
label.setFont(FidDebugUtils.MONOSPACED_FONT);
|
||||
label.setFont(Gui.getFont("font.monospaced"));
|
||||
return label;
|
||||
}
|
||||
|
||||
private JTextField getPreparedTextField() {
|
||||
JTextField textField = new JTextField(25);
|
||||
textField.setFont(FidDebugUtils.MONOSPACED_FONT);
|
||||
textField.setFont(Gui.getFont("font.monospaced"));
|
||||
return textField;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.swing.table.TableColumn;
|
|||
import javax.swing.table.TableColumnModel;
|
||||
|
||||
import docking.widgets.table.*;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.feature.fid.db.*;
|
||||
import ghidra.feature.fid.service.FidService;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -64,7 +65,7 @@ public class FidSearchResultFrame extends JFrame implements FidQueryCloseListene
|
|||
|
||||
private void buildFrame() {
|
||||
GTableCellRenderer renderer = new GTableCellRenderer();
|
||||
renderer.setFont(FidDebugUtils.MONOSPACED_FONT);
|
||||
renderer.setFont(Gui.getFont("font.monospaced"));
|
||||
int columnCount = table.getColumnCount();
|
||||
for (int ii = 0; ii < columnCount; ++ii) {
|
||||
Class<?> columnClass = table.getColumnClass(ii);
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
package ghidra.feature.fid.plugin;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -279,10 +280,7 @@ public class PopulateFidDialog extends DialogComponentProvider {
|
|||
}
|
||||
|
||||
private JButton createBrowseButton() {
|
||||
JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
|
||||
Font font = browseButton.getFont();
|
||||
browseButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
|
||||
return browseButton;
|
||||
return ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
|
||||
}
|
||||
|
||||
private static class LibraryChoice {
|
||||
|
|
|
@ -30,6 +30,7 @@ import docking.action.DockingAction;
|
|||
import docking.action.ToolBarData;
|
||||
import docking.widgets.checkbox.GCheckBox;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.app.util.HelpTopics;
|
||||
import ghidra.framework.plugintool.ComponentProviderAdapter;
|
||||
import ghidra.framework.plugintool.Plugin;
|
||||
|
@ -288,13 +289,12 @@ public class DiffDetailsProvider extends ComponentProviderAdapter {
|
|||
}
|
||||
|
||||
private JScrollPane createDetailsPane() {
|
||||
Font font = new Font("Monospaced", Font.PLAIN, 12);
|
||||
textPane = new JTextPane();
|
||||
doc = textPane.getStyledDocument();
|
||||
textPane.setName(DIFF_DETAILS_TEXT_AREA);
|
||||
textPane.setEditable(false);
|
||||
textPane.setMargin(new Insets(5, 5, 5, 5));
|
||||
textPane.setFont(font);
|
||||
Gui.registerFont(textPane, "font.monospaced");
|
||||
textPane.setOpaque(true);
|
||||
textPane.setCaretPosition(0);
|
||||
JScrollPane scrolledDetails = new JScrollPane(textPane);
|
||||
|
|
|
@ -79,8 +79,6 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
|
|||
JButton browseFolderButton =
|
||||
ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
|
||||
browseFolderButton.addActionListener(e -> browseDataTreeFolders());
|
||||
Font font = browseFolderButton.getFont();
|
||||
browseFolderButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
|
||||
|
||||
JLabel newSessionLabel = new GDLabel("New Session Name: ");
|
||||
newSessionLabel.setToolTipText("The name for the new Version Tracking Session");
|
||||
|
|
|
@ -221,9 +221,10 @@ icon.task.progress.hourglass.11 = hourglass24_11.png
|
|||
|
||||
// Fonts
|
||||
|
||||
|
||||
|
||||
|
||||
font.splash.header.default = Serif-BOLD-35
|
||||
font.splash.status = Serif-BOLD-12
|
||||
font.table.header.number = arial-BOLD-12
|
||||
font.input.hint = monospaced-PLAIN-10
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ import javax.swing.*;
|
|||
|
||||
import docking.widgets.label.GIconLabel;
|
||||
import docking.widgets.label.GLabel;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.*;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.PluggableServiceRegistry;
|
||||
|
@ -126,7 +125,7 @@ public class ApplicationInformationDisplayFactory {
|
|||
|
||||
JLabel nameLabel = new GLabel(Application.getName());
|
||||
nameLabel.setForeground(Palette.GRAY);
|
||||
Font newFont = new Font("Garamond", Font.BOLD, 35);
|
||||
Font newFont = Gui.getFont("font.splash.header.default");
|
||||
nameLabel.setFont(newFont);
|
||||
nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
nameLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.swing.border.BevelBorder;
|
|||
import docking.*;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.Gui;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -39,6 +40,8 @@ public class SplashScreen extends JWindow {
|
|||
|
||||
private static final Color BG_COLOR = new GColor("color.bg.splashscreen");
|
||||
|
||||
private static final String FONT_ID = "font.splash.status";
|
||||
|
||||
private static SplashScreen splashWindow; // splash window displayed while ghidra is coming up
|
||||
private static DockingFrame hiddenFrame;
|
||||
private static JLabel statusLabel;
|
||||
|
@ -300,9 +303,9 @@ public class SplashScreen extends JWindow {
|
|||
}
|
||||
|
||||
private Component createStatusComponent() {
|
||||
Font f = new Font("serif", Font.BOLD, 12);
|
||||
statusLabel = new GDLabel(" Loading...");
|
||||
statusLabel.setFont(f);
|
||||
Gui.registerFont(statusLabel, FONT_ID);
|
||||
statusLabel.setFont(Gui.getFont(FONT_ID));
|
||||
|
||||
statusLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 2, 10));
|
||||
statusLabel.setOpaque(true);
|
||||
|
|
|
@ -116,10 +116,6 @@ public class ButtonPanelFactory {
|
|||
return 10;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Font for the browse button label.
|
||||
*/
|
||||
public final static Font BROWSE_FONT = new Font("Dialog", Font.BOLD, 12);
|
||||
|
||||
/**
|
||||
* internal values used when creating the panels and buttons
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package docking.options.editor;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.io.File;
|
||||
|
@ -107,9 +106,6 @@ public class FileChooserEditor extends PropertyEditorSupport {
|
|||
|
||||
textField.setText(currentFileValue != null ? currentFileValue.getAbsolutePath() : "");
|
||||
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
|
||||
Font f = browseButton.getFont();
|
||||
f = new Font(f.getName(), Font.BOLD, f.getSize());
|
||||
browseButton.setFont(f);
|
||||
|
||||
add(textField);
|
||||
add(Box.createHorizontalStrut(5));
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O
|
|||
private void load() {
|
||||
currentValues = Gui.getAllValues();
|
||||
colors = currentValues.getColors();
|
||||
themeValues = new GThemeValueMap(currentValues);
|
||||
themeValues = Gui.getThemeValues();
|
||||
defaultValues = Gui.getDefaults();
|
||||
lightDefaultValues = Gui.getApplicationLightDefaults();
|
||||
darkDefaultValues = Gui.getApplicationDarkDefaults();
|
||||
|
@ -189,7 +189,7 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O
|
|||
private class ThemeColorRenderer extends AbstractGColumnRenderer<ResolvedColor> {
|
||||
|
||||
public ThemeColorRenderer() {
|
||||
setFont(new Font("Monospaced", Font.PLAIN, 12));
|
||||
setFont(Gui.getFont("font.monospaced"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -106,6 +106,9 @@ public class ThemeFontTable extends JPanel implements ActionContextProvider {
|
|||
|
||||
@Override
|
||||
public ActionContext getActionContext(MouseEvent e) {
|
||||
if (e == null) {
|
||||
return null;
|
||||
}
|
||||
if (e.getSource() == table) {
|
||||
FontValue currentValue = filterTable.getSelectedRowObject();
|
||||
if (currentValue == null) {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ThemeFontTableModel extends GDynamicColumnTableModel<FontValue, Obj
|
|||
private void load() {
|
||||
currentValues = Gui.getAllValues();
|
||||
fonts = currentValues.getFonts();
|
||||
themeValues = new GThemeValueMap(currentValues);
|
||||
themeValues = Gui.getThemeValues();
|
||||
defaultValues = Gui.getDefaults();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package docking.theme.gui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -67,7 +66,7 @@ public class ThemeIconTableModel extends GDynamicColumnTableModel<IconValue, Obj
|
|||
private void load() {
|
||||
currentValues = Gui.getAllValues();
|
||||
icons = currentValues.getIcons();
|
||||
themeValues = new GThemeValueMap(currentValues);
|
||||
themeValues = Gui.getThemeValues();
|
||||
defaultValues = Gui.getDefaults();
|
||||
}
|
||||
|
||||
|
@ -175,7 +174,7 @@ public class ThemeIconTableModel extends GDynamicColumnTableModel<IconValue, Obj
|
|||
private class ThemeIconRenderer extends AbstractGColumnRenderer<ResolvedIcon> {
|
||||
|
||||
public ThemeIconRenderer() {
|
||||
setFont(new Font("Monospaced", Font.PLAIN, 12));
|
||||
setFont(Gui.getFont("font.monospaced"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -120,7 +120,7 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
|
|||
super.setFont(f);
|
||||
defaultFont = f;
|
||||
fixedWidthFont = new Font("monospaced", defaultFont.getStyle(), defaultFont.getSize());
|
||||
boldFont = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize());
|
||||
boldFont = f.deriveFont(Font.BOLD);
|
||||
}
|
||||
|
||||
protected void superSetFont(Font font) {
|
||||
|
|
|
@ -20,9 +20,10 @@ import java.awt.event.*;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.CloseIcon;
|
||||
import docking.widgets.EmptyBorderButton;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import resources.ResourceManager;
|
||||
import generic.theme.GColor;
|
||||
|
||||
/**
|
||||
* A widget that can be used to render an icon, title and close button for JTabbedPane. You would
|
||||
|
@ -31,10 +32,9 @@ import resources.ResourceManager;
|
|||
public class DockingTabRenderer extends JPanel {
|
||||
|
||||
private static final int MAX_TITLE_LENGTH = 25;
|
||||
private Icon EMPTY_ICON =
|
||||
ResourceManager.getScaledIcon(ResourceManager.loadImage("images/close16.gif"), 8, 8);
|
||||
private Icon CLOSE_ICON =
|
||||
ResourceManager.getScaledIcon(ResourceManager.loadImage("images/close16.gif"), 8, 8);
|
||||
private Icon CLOSE_ICON = new CloseIcon(8, 1, new GColor("color.fg.button"));
|
||||
private Icon EMPTY_ICON = CLOSE_ICON;
|
||||
//TODO if we don't want the close icon to come and go, then this class can be greatly simplified
|
||||
|
||||
private JLabel titleLabel;
|
||||
private JLabel iconLabel;
|
||||
|
|
|
@ -23,8 +23,7 @@ import javax.swing.*;
|
|||
import javax.swing.border.Border;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.*;
|
||||
import resources.*;
|
||||
import resources.icons.EmptyIcon;
|
||||
import resources.icons.TranslateIcon;
|
||||
|
@ -314,6 +313,7 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
|
|||
|
||||
private class NumberPainterIcon implements Icon {
|
||||
|
||||
private static final String FONT_ID = "font.table.header.number";
|
||||
private final int iconWidth;
|
||||
private int numberWidth;
|
||||
private final int iconHeight;
|
||||
|
@ -324,9 +324,7 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
|
|||
this.iconHeight = height;
|
||||
this.numberText = numberText;
|
||||
|
||||
int fontSize = 12;
|
||||
String fontFamily = "arial";
|
||||
Font font = new Font(fontFamily, Font.BOLD, fontSize);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
FontMetrics fontMetrics = getFontMetrics(font);
|
||||
numberWidth = fontMetrics.stringWidth(numberText);
|
||||
}
|
||||
|
@ -344,9 +342,7 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
|
|||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
|
||||
int fontSize = 12;
|
||||
String fontFamily = "arial";
|
||||
Font font = new Font(fontFamily, Font.BOLD, fontSize);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
g.setFont(font);
|
||||
FontMetrics fontMetrics = g.getFontMetrics();
|
||||
int numberHeight = fontMetrics.getAscent();
|
||||
|
@ -363,8 +359,8 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
|
|||
AttributedString as = new AttributedString(numberText);
|
||||
as.addAttribute(TextAttribute.FOREGROUND, SORT_NUMBER_FG_COLOR);
|
||||
as.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
|
||||
as.addAttribute(TextAttribute.FAMILY, fontFamily);
|
||||
as.addAttribute(TextAttribute.SIZE, (float) fontSize);
|
||||
as.addAttribute(TextAttribute.FAMILY, font.getFamily());
|
||||
as.addAttribute(TextAttribute.SIZE, font.getSize2D());
|
||||
|
||||
g.drawString(as.getIterator(), startX, textBaseline);
|
||||
|
||||
|
|
|
@ -24,8 +24,10 @@ import javax.swing.text.*;
|
|||
|
||||
import docking.util.GraphicsUtils;
|
||||
import generic.theme.GThemeDefaults.Colors.Messages;
|
||||
import generic.theme.Gui;
|
||||
|
||||
public class HexOrDecimalInput extends JTextField {
|
||||
private static final String FONT_ID = "font.input.hint";
|
||||
private boolean isHexMode = false;
|
||||
private boolean allowsNegative = true;
|
||||
private Long currentValue;
|
||||
|
@ -128,7 +130,7 @@ public class HexOrDecimalInput extends JTextField {
|
|||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Font font = new Font("Monospaced", Font.PLAIN, 10);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
Font savedFont = g.getFont();
|
||||
g.setFont(font);
|
||||
g.setColor(Messages.HINT);
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.swing.text.*;
|
|||
import docking.DockingUtils;
|
||||
import docking.util.GraphicsUtils;
|
||||
import generic.theme.GThemeDefaults.Colors.Messages;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
||||
/**
|
||||
|
@ -635,13 +636,13 @@ public class IntegerTextField {
|
|||
*/
|
||||
private class MyTextField extends JTextField {
|
||||
|
||||
private Font hintFont = new Font("Monospaced", Font.PLAIN, 10);
|
||||
private static final String FONT_ID = "font.input.hint";
|
||||
private int hintWidth;
|
||||
|
||||
public MyTextField(int columns) {
|
||||
super(columns);
|
||||
|
||||
FontMetrics fontMetrics = getFontMetrics(hintFont);
|
||||
FontMetrics fontMetrics = getFontMetrics(Gui.getFont(FONT_ID));
|
||||
String mode = isHexMode ? "Hex" : "Dec";
|
||||
hintWidth = fontMetrics.stringWidth(mode);
|
||||
|
||||
|
@ -682,7 +683,7 @@ public class IntegerTextField {
|
|||
}
|
||||
|
||||
Font savedFont = g.getFont();
|
||||
g.setFont(hintFont);
|
||||
g.setFont(Gui.getFont(FONT_ID));
|
||||
g.setColor(Messages.HINT);
|
||||
|
||||
Dimension size = getSize();
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.swing.event.*;
|
|||
|
||||
import docking.util.GraphicsUtils;
|
||||
import generic.theme.GThemeDefaults.Colors.Messages;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
||||
/**
|
||||
|
@ -227,12 +228,14 @@ public class LocalDateTextField {
|
|||
|
||||
private class MyTextField extends JTextField {
|
||||
|
||||
private static final String FONT_ID = "font.input.hint";
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
if (showFieldDecoration) {
|
||||
Font font = new Font("Monospaced", Font.PLAIN, 10);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
Font savedFont = g.getFont();
|
||||
g.setFont(font);
|
||||
g.setColor(Messages.HINT);
|
||||
|
|
|
@ -142,7 +142,7 @@ public class GTreeRenderer extends DefaultTreeCellRenderer implements GComponent
|
|||
// Bug Alert!:
|
||||
// We must create a new font here and not use deriveFont(). Using derive font has
|
||||
// bugs when calculating the string width for a bold derived font.
|
||||
cachedBoldFont = new Font(font.getFamily(), Font.BOLD, font.getSize());
|
||||
cachedBoldFont = font.deriveFont(Font.BOLD);
|
||||
}
|
||||
return bold ? cachedBoldFont : cachedDefaultFont;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
// Fonts
|
||||
font.standard = [font]panel.font
|
||||
font.monospaced = font.standard[monospaced]
|
||||
font.bold = font.standard[bold]
|
||||
font.italics = font.standard[italic]
|
||||
font.bold.italic = font.standard[bold][italic]
|
||||
font.monospaced = monospaced-PLAIN-12
|
||||
|
||||
|
||||
[Dark Defaults]
|
|
@ -45,6 +45,7 @@ import org.junit.runner.Description;
|
|||
import generic.jar.ResourceFile;
|
||||
import generic.test.rule.Repeated;
|
||||
import generic.test.rule.RepeatedTestRule;
|
||||
import generic.theme.Gui;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.GhidraTestApplicationLayout;
|
||||
import ghidra.framework.Application;
|
||||
|
@ -1584,7 +1585,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
|
|||
}
|
||||
});
|
||||
// Fix up the default fonts that Java 1.5.0 changed to Courier, which looked terrible.
|
||||
Font f = new Font("Monospaced", Font.PLAIN, 12);
|
||||
Font f = Gui.getFont("font.monospaced");
|
||||
UIManager.put("PasswordField.font", f);
|
||||
UIManager.put("TextArea.font", f);
|
||||
}
|
||||
|
|
|
@ -78,14 +78,19 @@ public abstract class AbstractThemeReader {
|
|||
String value = section.getValue(key);
|
||||
int lineNumber = section.getLineNumber(key);
|
||||
if (ColorValue.isColorKey(key)) {
|
||||
valueMap.addColor(parseColorProperty(key, value, lineNumber));
|
||||
ColorValue colorValue = parseColorProperty(key, value, lineNumber);
|
||||
ColorValue oldValue = valueMap.addColor(colorValue);
|
||||
reportDuplicateKey(oldValue, lineNumber);
|
||||
}
|
||||
else if (FontValue.isFontKey(key)) {
|
||||
valueMap.addFont(parseFontProperty(key, value, lineNumber));
|
||||
FontValue oldValue = valueMap.addFont(parseFontProperty(key, value, lineNumber));
|
||||
reportDuplicateKey(oldValue, lineNumber);
|
||||
}
|
||||
else if (IconValue.isIconKey(key)) {
|
||||
if (!GTheme.JAVA_ICON.equals(value)) {
|
||||
IconValue oldValue =
|
||||
valueMap.addIcon(parseIconProperty(key, value, lineNumber));
|
||||
reportDuplicateKey(oldValue, lineNumber);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -94,6 +99,12 @@ public abstract class AbstractThemeReader {
|
|||
}
|
||||
}
|
||||
|
||||
private void reportDuplicateKey(ThemeValue<?> oldValue, int lineNumber) {
|
||||
if (oldValue != null) {
|
||||
error(lineNumber, "Duplicate id found: \"" + oldValue.getId() + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
private IconValue parseIconProperty(String key, String value, int lineNumber) {
|
||||
try {
|
||||
return IconValue.parse(key, value);
|
||||
|
@ -280,6 +291,10 @@ public abstract class AbstractThemeReader {
|
|||
error(lineNumber, "Missing value for propery line: \"" + line + "\"");
|
||||
return;
|
||||
}
|
||||
if (properties.containsKey(key)) {
|
||||
error(lineNumber, "Duplicate key found in this file!: " + key + "\"");
|
||||
return;
|
||||
}
|
||||
properties.put(key, value);
|
||||
lineNumbers.put(key, lineNumber);
|
||||
|
||||
|
|
|
@ -51,33 +51,39 @@ public class GThemeValueMap {
|
|||
* Adds the {@link ColorValue} to the map. If a ColorValue already exists in the map with
|
||||
* the same id, it will be replaced
|
||||
* @param value the {@link ColorValue} to store in the map.
|
||||
* @return the previous value for the color key or null if no previous value existed
|
||||
*/
|
||||
public void addColor(ColorValue value) {
|
||||
public ColorValue addColor(ColorValue value) {
|
||||
if (value != null) {
|
||||
colorMap.put(value.getId(), value);
|
||||
return colorMap.put(value.getId(), value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the {@link FontValue} to the map. If a FontValue already exists in the map with
|
||||
* the same id, it will be replaced
|
||||
* @param value the {@link FontValue} to store in the map.
|
||||
* @return the previous value for the font key or null if no previous value existed
|
||||
*/
|
||||
public void addFont(FontValue value) {
|
||||
public FontValue addFont(FontValue value) {
|
||||
if (value != null) {
|
||||
fontMap.put(value.getId(), value);
|
||||
return fontMap.put(value.getId(), value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the {@link IconValue} to the map. If a IconValue already exists in the map with
|
||||
* the same id, it will be replaced
|
||||
* @param value the {@link IconValue} to store in the map.
|
||||
* @return the previous value for the icon key or null if no previous value existed
|
||||
*/
|
||||
public void addIcon(IconValue value) {
|
||||
public IconValue addIcon(IconValue value) {
|
||||
if (value != null) {
|
||||
iconMap.put(value.getId(), value);
|
||||
return iconMap.put(value.getId(), value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -286,6 +286,24 @@ public class Gui {
|
|||
return new GThemeValueMap(currentValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the theme values as defined by the current theme, ignoring any unsaved changes that
|
||||
* are currently applied to the application.
|
||||
* @return the theme values as defined by the current theme, ignoring any unsaved changes that
|
||||
* are currently applied to the application.
|
||||
*/
|
||||
public static GThemeValueMap getThemeValues() {
|
||||
GThemeValueMap map = new GThemeValueMap();
|
||||
map.load(javaDefaults);
|
||||
map.load(systemValues);
|
||||
map.load(applicationDefaults);
|
||||
if (activeTheme.useDarkDefaults()) {
|
||||
map.load(applicationDarkDefaults);
|
||||
}
|
||||
map.load(activeTheme);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link GThemeValueMap} contains all values that differ from the default
|
||||
* values (values defined by the {@link LookAndFeel} or in the theme.properties files.
|
||||
|
|
|
@ -193,8 +193,8 @@ public class IconValue extends ThemeValue<Icon> {
|
|||
@Override
|
||||
protected Icon getUnresolvedReferenceValue(String unresolvedId) {
|
||||
Msg.warn(this,
|
||||
"Could not resolve indirect icon path for" + unresolvedId +
|
||||
", using last resort default");
|
||||
"Could not resolve indirect icon path for \"" + unresolvedId +
|
||||
"\", using last resort default");
|
||||
return LAST_RESORT_DEFAULT;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.*;
|
|||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Msg;
|
||||
import generic.theme.*;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.datastruct.WeakDataStructureFactory;
|
||||
import ghidra.util.datastruct.WeakSet;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
@ -59,6 +59,8 @@ public abstract class AbstractOptions implements Options {
|
|||
protected Map<String, OptionsEditor> optionsEditorMap;
|
||||
protected Map<String, HelpLocation> categoryHelpMap;
|
||||
protected Map<String, AliasBinding> aliasMap;
|
||||
protected ThemeListener themeListener;
|
||||
protected Map<String, String> themeToOptionMap = new HashMap<>();
|
||||
|
||||
protected AbstractOptions(String name) {
|
||||
this.name = name;
|
||||
|
@ -67,7 +69,8 @@ public abstract class AbstractOptions implements Options {
|
|||
optionsEditorMap = new HashMap<>();
|
||||
categoryHelpMap = new HashMap<>();
|
||||
aliasMap = new HashMap<>();
|
||||
|
||||
themeListener = this::themeChanged;
|
||||
Gui.addThemeListener(themeListener);
|
||||
}
|
||||
|
||||
protected abstract Option createRegisteredOption(String optionName, OptionType type,
|
||||
|
@ -131,15 +134,32 @@ public abstract class AbstractOptions implements Options {
|
|||
public synchronized void registerOption(String optionName, OptionType type, Object defaultValue,
|
||||
HelpLocation help, String description, PropertyEditor editor) {
|
||||
|
||||
if (type == OptionType.COLOR_TYPE) {
|
||||
// Msg.warn(this, "Registering color: " + optionName,
|
||||
// ReflectionUtilities.createJavaFilteredThrowable());
|
||||
}
|
||||
if (type == OptionType.NO_TYPE) {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't register an option of type: " + OptionType.NO_TYPE);
|
||||
}
|
||||
|
||||
if (type == OptionType.COLOR_TYPE) {
|
||||
if (defaultValue instanceof GColor gColor) {
|
||||
registerThemeColor(optionName, gColor.getId(), help, description);
|
||||
return;
|
||||
}
|
||||
warnNonThemeValue("Registering non theme color: " + optionName);
|
||||
}
|
||||
if (type == OptionType.FONT_TYPE) {
|
||||
if (defaultValue instanceof String fontId) {
|
||||
registerThemeFont(optionName, fontId, help, description);
|
||||
return;
|
||||
}
|
||||
String message = "Registering non theme font: " + optionName;
|
||||
if (SystemUtilities.isInDevelopmentMode()) {
|
||||
Msg.warn(this, message, ReflectionUtilities.createJavaFilteredThrowable());
|
||||
}
|
||||
else {
|
||||
Msg.warn(this, message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!type.isCompatible(defaultValue)) {
|
||||
throw new IllegalStateException(
|
||||
"Given default value does not match the given OptionType! OptionType = " + type +
|
||||
|
@ -167,27 +187,40 @@ public abstract class AbstractOptions implements Options {
|
|||
valueMap.put(optionName, option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerThemeColorOption(String optionName, String colorId, HelpLocation help,
|
||||
protected void warnNonThemeValue(String message) {
|
||||
if (SystemUtilities.isInDevelopmentMode()) {
|
||||
Msg.warn(this, message, ReflectionUtilities.createJavaFilteredThrowable());
|
||||
}
|
||||
else {
|
||||
Msg.warn(this, message);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerThemeColor(String optionName, String colorId, HelpLocation help,
|
||||
String description) {
|
||||
Option currentOption = getExistingComptibleOption(optionName, OptionType.COLOR_TYPE);
|
||||
if (currentOption != null && currentOption instanceof ThemeColorOption) {
|
||||
currentOption.updateRegistration(description, help, null, null);
|
||||
return;
|
||||
}
|
||||
description += " (Theme Color: " + colorId + ")";
|
||||
Option option = new ThemeColorOption(optionName, colorId, description, help);
|
||||
valueMap.put(optionName, option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerThemeFontOption(String optionName, String fontId, HelpLocation help,
|
||||
private void registerThemeFont(String optionName, String fontId, HelpLocation help,
|
||||
String description) {
|
||||
if (Gui.getFont(fontId) == null) {
|
||||
throw new IllegalArgumentException("Invalid theme font id: \"" + fontId + "\"");
|
||||
}
|
||||
Option currentOption = getExistingComptibleOption(optionName, OptionType.FONT_TYPE);
|
||||
if (currentOption != null && currentOption instanceof ThemeFontOption) {
|
||||
currentOption.updateRegistration(description, help, null, null);
|
||||
return;
|
||||
}
|
||||
description += " (Theme Font: " + fontId + ")";
|
||||
Option option = new ThemeFontOption(optionName, fontId, description, help);
|
||||
themeToOptionMap.put(fontId, optionName);
|
||||
valueMap.put(optionName, option);
|
||||
}
|
||||
|
||||
|
@ -831,6 +864,18 @@ public abstract class AbstractOptions implements Options {
|
|||
return new ArrayList<>(leafNames);
|
||||
}
|
||||
|
||||
private void themeChanged(ThemeEvent e) {
|
||||
if (!e.hasAnyFontChanged()) {
|
||||
return;
|
||||
}
|
||||
for (String fontId : themeToOptionMap.keySet()) {
|
||||
if (e.isFontChanged(fontId)) {
|
||||
String optionName = themeToOptionMap.get(fontId);
|
||||
notifyOptionChanged(optionName, null, Gui.getFont(fontId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
// Inner Classes
|
||||
//==================================================================================================
|
||||
|
|
|
@ -149,32 +149,6 @@ public interface Options {
|
|||
public void registerOption(String optionName, OptionType type, Object defaultValue,
|
||||
HelpLocation help, String description, PropertyEditor editor);
|
||||
|
||||
/**
|
||||
* Registers a theme color as an option. Doing this allows the color to be edited in the
|
||||
* options Gui, but all changes result in a theme change and not an options change. In other
|
||||
* words, changes to this option causes a theme change and is saved to a theme instead of in
|
||||
* the tool with normal options
|
||||
* @param optionName the option name to bind to a theme color id
|
||||
* @param colorId the theme color id to be affected if a users changes this color option
|
||||
* @param help the {@link HelpLocation} for more information on how this color is used
|
||||
* @param description a short description of how this color is used
|
||||
*/
|
||||
public void registerThemeColorOption(String optionName, String colorId, HelpLocation help,
|
||||
String description);
|
||||
|
||||
/**
|
||||
* Registers a theme font as an option. Doing this allows the font to be edited in the
|
||||
* options Gui, but all changes result in a theme change and not an options change. In other
|
||||
* words, changes to this option causes a theme change and is saved to a theme instead of in
|
||||
* the tool with normal options
|
||||
* @param optionName the option name to bind to a theme font id
|
||||
* @param fontId the theme font id to be affected if a users changes this font option
|
||||
* @param help the {@link HelpLocation} for more information on how this font is used
|
||||
* @param description a short description of how this font is used
|
||||
*/
|
||||
public void registerThemeFontOption(String optionName, String fontId, HelpLocation help,
|
||||
String description);
|
||||
|
||||
/**
|
||||
* Register the options editor that will handle the editing for all the options or a sub group of options.
|
||||
* @param editor the custom editor panel to be used to edit the options or sub group of options.
|
||||
|
|
|
@ -92,18 +92,6 @@ public class SubOptions implements Options {
|
|||
options.registerOption(prefix + optionName, type, defaultValue, help, description, editor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerThemeColorOption(String optionName, String colorId, HelpLocation help,
|
||||
String description) {
|
||||
options.registerThemeColorOption(prefix + optionName, colorId, help, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerThemeFontOption(String optionName, String fontId, HelpLocation help,
|
||||
String description) {
|
||||
options.registerThemeFontOption(prefix + optionName, fontId, help, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putObject(String optionName, Object obj) {
|
||||
options.putObject(prefix + optionName, obj);
|
||||
|
|
|
@ -28,8 +28,8 @@ color.visualgraph.view.satellite.edge.hovered = color.palette.lime
|
|||
|
||||
|
||||
# graph display
|
||||
color.graphdisplay.vertex = green
|
||||
color.graphdisplay.edge = green
|
||||
color.graphdisplay.vertex.default = green
|
||||
color.graphdisplay.edge.default = green
|
||||
color.graphdisplay.vertex.selected = blue
|
||||
color.graphdisplay.edge.selected = blue
|
||||
|
||||
|
@ -37,6 +37,8 @@ icon.graph.satellite = network-wireless-16.png
|
|||
icon.graph.satellite.large = network-wireless.png
|
||||
icon.graph.layout.default = color_swatch.png
|
||||
|
||||
font.graphdisplay.default = dialog-bold-18
|
||||
font.graph.component.message = SansSerif-BOLDITALIC-18
|
||||
|
||||
[Dark Defaults]
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ import edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer;
|
|||
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
||||
import edu.uci.ics.jung.visualization.renderers.Renderer.Vertex;
|
||||
import edu.uci.ics.jung.visualization.util.Caching;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.*;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import ghidra.graph.VisualGraph;
|
||||
|
@ -1002,6 +1001,7 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
|||
|
||||
private class MessagePaintable implements Paintable {
|
||||
|
||||
private static final String FONT_ID = "font.graph.component.message";
|
||||
private final Color backgroundColor = new GColor("color.bg.visualgraph.message");
|
||||
private String message = null;
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
|
|||
// this composite softens the text and color of the message
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SrcOver.getRule(), .60f));
|
||||
|
||||
Font font = new Font("Sanf Serif", Font.BOLD | Font.ITALIC, 18);
|
||||
Font font = Gui.getFont(FONT_ID);
|
||||
g.setFont(font);
|
||||
|
||||
Rectangle stringBounds =
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.swing.event.ChangeListener;
|
|||
import docking.Tool;
|
||||
import docking.options.editor.*;
|
||||
import generic.theme.GColor;
|
||||
import generic.theme.Gui;
|
||||
import ghidra.framework.options.*;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.WebColors;
|
||||
|
@ -66,8 +67,8 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
|
||||
private Color vertexSelectionColor = new GColor("color.graphdisplay.vertex.selected");
|
||||
private Color edgeSelectionColor = new GColor("color.graphdisplay.edge.selected");
|
||||
private Color defaultVertexColor = new GColor("color.graphdisplay.vertex");
|
||||
private Color defaultEdgeColor = new GColor("color.graphdisplay.edge");
|
||||
private Color defaultVertexColor = new GColor("color.graphdisplay.vertex.default");
|
||||
private Color defaultEdgeColor = new GColor("color.graphdisplay.edge.default");
|
||||
private String favoredEdgeType;
|
||||
|
||||
private VertexShape defaultVertexShape = VertexShape.RECTANGLE;
|
||||
|
@ -80,11 +81,16 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
private String defaultLayoutAlgorithmName = LayoutAlgorithmNames.MIN_CROSS_COFFMAN_GRAHAM;
|
||||
private boolean useIcons = true;
|
||||
private GraphLabelPosition labelPosition = GraphLabelPosition.SOUTH;
|
||||
private Font font = new Font("Dialog", Font.BOLD, 18);
|
||||
private Font font = Gui.getFont("font.graphdisplay.default");
|
||||
private String themeFontId = null;
|
||||
private int arrowLength = 15;
|
||||
|
||||
private int maxNodeCount = 500; // graph display struggles with too many nodes
|
||||
|
||||
private Set<String> vertexRegistrations = new HashSet<>();
|
||||
private Set<String> edgeRegistrations = new HashSet<>();
|
||||
private Set<String> defaultRegistrations = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Constructs a new GraphTypeDisplayOptions for the given {@link GraphType}
|
||||
* @param graphType The {@link GraphType} for which to define display options
|
||||
|
@ -155,6 +161,16 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
this.defaultVertexColor = Objects.requireNonNull(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default color to be used by vertices that don't have a vertex type set. The
|
||||
* color is set via a themeColorId, which means the client defined a theme color for this.
|
||||
* @param themeColorId the theme color id to use for the default vertex color
|
||||
*/
|
||||
public void setDefaultVertexColor(String themeColorId) {
|
||||
this.defaultVertexColor = new GColor(themeColorId);
|
||||
defaultRegistrations.add(DEFAULT_VERTEX_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default color to be used by edges that don't have a edge type set
|
||||
* @param color the default edge shape
|
||||
|
@ -163,6 +179,16 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
this.defaultEdgeColor = Objects.requireNonNull(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default color to be used by vertices that don't have a vertex type set. The
|
||||
* color is set via a themeColorId, which means the client defined a theme color for this.
|
||||
* @param themeColorId the theme color id to use for the default vertex color
|
||||
*/
|
||||
public void setDefaultEdgeColor(String themeColorId) {
|
||||
this.defaultEdgeColor = new GColor(themeColorId);
|
||||
defaultRegistrations.add(DEFAULT_EDGE_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default color for edges that don't have an edge type set
|
||||
* @return the default color for edges that don't have an edge type set
|
||||
|
@ -353,7 +379,9 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the color for vertices with the given vertex type
|
||||
* Sets the color for vertices with the given vertex type. Note that this method does not
|
||||
* allow the vertex color to be registered in tool options.
|
||||
* See {@link #setVertexColor(String, String)}.
|
||||
* @param vertexType the vertex type for which to set its color
|
||||
* @param color the color to use for vertices with the given vertex type
|
||||
*/
|
||||
|
@ -362,6 +390,18 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
vertexColorMap.put(vertexType, Objects.requireNonNull(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vertex color using a theme color id. By using a theme color id, this property
|
||||
* is eligible to be registered as a tool option.
|
||||
* @param vertexType the vertex type for which to set its color
|
||||
* @param themeColorId the theme color id of the color for this vertex type
|
||||
*/
|
||||
public void setVertexColor(String vertexType, String themeColorId) {
|
||||
checkVertexType(vertexType);
|
||||
vertexColorMap.put(vertexType, new GColor(Objects.requireNonNull(themeColorId)));
|
||||
vertexRegistrations.add(vertexType);
|
||||
}
|
||||
|
||||
private String getVertexShapeName(String vertexType) {
|
||||
VertexShape vertexShape = vertexShapeMap.getOrDefault(vertexType, defaultVertexShape);
|
||||
return vertexShape.getName();
|
||||
|
@ -386,6 +426,18 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
return edgeColorMap.getOrDefault(edgeType, defaultEdgeColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the edge color using a theme color id. By using a theme color id, this property
|
||||
* is eligible to be registered as a tool option.
|
||||
* @param edgeType the edge type for which to set its color
|
||||
* @param themeColorId the theme color id of the color for this edge type
|
||||
*/
|
||||
public void setEdgeColor(String edgeType, String themeColorId) {
|
||||
checkEdgeType(edgeType);
|
||||
edgeColorMap.put(edgeType, new GColor(Objects.requireNonNull(themeColorId)));
|
||||
edgeRegistrations.add(edgeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color for edges with the given edge type
|
||||
* @param edgeType the edge type for which to set its color
|
||||
|
@ -459,13 +511,24 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the vertex selection color
|
||||
* Sets the vertex selection color. Use this method only if this color does not appear in
|
||||
* the tool options.
|
||||
* @param vertexSelectionColor the color to use for highlighting selected vertices
|
||||
*/
|
||||
public void setVertexSelectionColor(Color vertexSelectionColor) {
|
||||
this.vertexSelectionColor = vertexSelectionColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vertex selection color using the theme color defined by the given color id. This
|
||||
* method will allow the property to be registered to the tool options.
|
||||
* @param themeColorId the color id to use for highlighting vertices.
|
||||
*/
|
||||
public void setVertexSelectionColor(String themeColorId) {
|
||||
this.vertexSelectionColor = new GColor(themeColorId);
|
||||
defaultRegistrations.add(VERTEX_SELECTION_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color for edge selections
|
||||
* @return the color fore edge selections
|
||||
|
@ -475,13 +538,24 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the edge selection color
|
||||
* Sets the edge selection color. Using the method means the color will not appear in the
|
||||
* tool options.
|
||||
* @param edgeSelectionColor color to use for highlighting selected edges
|
||||
*/
|
||||
public void setEdgeSelectionColor(Color edgeSelectionColor) {
|
||||
this.edgeSelectionColor = edgeSelectionColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the edge selection color using the theme color defined by the given color id. This
|
||||
* method will allow the property to be registered to the tool options.
|
||||
* @param themeColorId the color id to use for highlighting edges.
|
||||
*/
|
||||
public void setEdgeSelectionColor(String themeColorId) {
|
||||
this.edgeSelectionColor = new GColor(themeColorId);
|
||||
defaultRegistrations.add(EDGE_SELECTION_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the default graph layout algorithm
|
||||
* @return the name of the default graph layout algorithms
|
||||
|
@ -543,6 +617,11 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
this.font = font;
|
||||
}
|
||||
|
||||
public void setFont(String themeFontId) {
|
||||
this.themeFontId = themeFontId;
|
||||
this.font = Gui.getFont(themeFontId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font being used to render vertex labels
|
||||
* @return the font being used to render vertex labels
|
||||
|
@ -617,25 +696,48 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets default values for vertex types
|
||||
* Sets default values for vertex types. This method does not allow the vertexType color to
|
||||
* be eligible to be registered as a tool option.
|
||||
* @param vertexType the vertex type whose default color and shape are being defined
|
||||
* @param vertexShape the default vertex shape for the given vertex type
|
||||
* @param color the default color for the given vertex type
|
||||
*/
|
||||
protected void configureVertexType(String vertexType, VertexShape vertexShape, Color color) {
|
||||
checkVertexType(vertexType);
|
||||
vertexShapeMap.put(vertexType, vertexShape);
|
||||
vertexColorMap.put(vertexType, color);
|
||||
setVertexColor(vertexType, color);
|
||||
setVertexShape(vertexType, vertexShape);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default values for edge types
|
||||
* Sets default values for vertex types using theme color ids. This makes them eligible to be
|
||||
* registered as tool options.
|
||||
* @param vertexType the vertex type whose default color and shape are being defined
|
||||
* @param vertexShape the default vertex shape for the given vertex type
|
||||
* @param themeColorId the color id for the theme color to be used as the color.
|
||||
*/
|
||||
protected void configureVertexType(String vertexType, VertexShape vertexShape,
|
||||
String themeColorId) {
|
||||
setVertexColor(vertexType, themeColorId);
|
||||
setVertexShape(vertexType, vertexShape);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default values for edge types. This method does not allow the vertexType color to
|
||||
* be eligible to be registered as a tool option.
|
||||
* @param edgeType the edge type whose default color and shape are being defined
|
||||
* @param color the default color for the given edge type
|
||||
*/
|
||||
protected void configureEdgeType(String edgeType, Color color) {
|
||||
checkEdgeType(edgeType);
|
||||
edgeColorMap.put(edgeType, color);
|
||||
setEdgeColor(edgeType, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default values for edge types using theme color ids. This makes them eligible to be
|
||||
* registered as tool options.
|
||||
* @param edgeType the edge type whose default color and shape are being defined
|
||||
* @param themeColorId the color id for the theme color to be used as the color.
|
||||
*/
|
||||
protected void configureEdgeType(String edgeType, String themeColorId) {
|
||||
setEdgeColor(edgeType, themeColorId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -727,8 +829,10 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
Options options = rootOptions.getOptions(VERTEX_COLORS);
|
||||
|
||||
for (String vertexType : graphType.getVertexTypes()) {
|
||||
options.registerOption(vertexType, OptionType.COLOR_TYPE, getVertexColor(vertexType),
|
||||
help, "Choose the color for this vertex type");
|
||||
if (vertexRegistrations.contains(vertexType)) {
|
||||
options.registerOption(vertexType, OptionType.COLOR_TYPE,
|
||||
getVertexColor(vertexType), help, "Choose the color for this vertex type");
|
||||
}
|
||||
}
|
||||
List<String> list = new ArrayList<>(graphType.getVertexTypes());
|
||||
OptionsEditor editor = new ScrollableOptionsEditor(VERTEX_COLORS, list);
|
||||
|
@ -755,8 +859,10 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
Options options = rootOptions.getOptions(EDGE_COLORS);
|
||||
|
||||
for (String edgeType : graphType.getEdgeTypes()) {
|
||||
options.registerOption(edgeType, OptionType.COLOR_TYPE, getEdgeColor(edgeType), help,
|
||||
"Choose the color for this edge type");
|
||||
if (edgeRegistrations.contains(edgeType)) {
|
||||
options.registerOption(edgeType, OptionType.COLOR_TYPE, getEdgeColor(edgeType),
|
||||
help, "Choose the color for this edge type");
|
||||
}
|
||||
}
|
||||
List<String> list = new ArrayList<>(graphType.getEdgeTypes());
|
||||
OptionsEditor editor = new ScrollableOptionsEditor(EDGE_COLORS, list);
|
||||
|
@ -764,29 +870,45 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
}
|
||||
|
||||
private void registerMiscellaneousOptions(Options rootOptions, HelpLocation help) {
|
||||
List<String> optionNamesInDisplayOrder = new ArrayList<>();
|
||||
|
||||
Options options = rootOptions.getOptions(MISCELLANEOUS_OPTIONS);
|
||||
|
||||
optionNamesInDisplayOrder.add(MAX_NODES_SIZE);
|
||||
options.registerOption(MAX_NODES_SIZE, OptionType.INT_TYPE, maxNodeCount, help,
|
||||
"Graphs with more than this number of nodes will not be displayed. (Large graphs can cause Ghidra to become unstable/sluggish)");
|
||||
StringWithChoicesEditor editor = new StringWithChoicesEditor(VertexShape.getShapeNames());
|
||||
|
||||
options.registerOption(VERTEX_SELECTION_COLOR, OptionType.COLOR_TYPE, vertexSelectionColor,
|
||||
help, "Color for highlighting selected vertices");
|
||||
if (defaultRegistrations.contains(VERTEX_SELECTION_COLOR)) {
|
||||
optionNamesInDisplayOrder.add(VERTEX_SELECTION_COLOR);
|
||||
options.registerOption(VERTEX_SELECTION_COLOR, OptionType.COLOR_TYPE,
|
||||
vertexSelectionColor, help, "Color for highlighting selected vertices");
|
||||
}
|
||||
|
||||
if (defaultRegistrations.contains(EDGE_SELECTION_COLOR)) {
|
||||
optionNamesInDisplayOrder.add(EDGE_SELECTION_COLOR);
|
||||
options.registerOption(EDGE_SELECTION_COLOR, OptionType.COLOR_TYPE, edgeSelectionColor,
|
||||
help, "Color for highlighting selected edge");
|
||||
}
|
||||
|
||||
if (defaultRegistrations.contains(DEFAULT_VERTEX_COLOR)) {
|
||||
optionNamesInDisplayOrder.add(DEFAULT_VERTEX_COLOR);
|
||||
options.registerOption(DEFAULT_VERTEX_COLOR, OptionType.COLOR_TYPE, defaultVertexColor,
|
||||
help, "Color for vertices that have no vertex type defined");
|
||||
}
|
||||
|
||||
if (defaultRegistrations.contains(DEFAULT_EDGE_COLOR)) {
|
||||
optionNamesInDisplayOrder.add(DEFAULT_EDGE_COLOR);
|
||||
options.registerOption(DEFAULT_EDGE_COLOR, OptionType.COLOR_TYPE, defaultEdgeColor,
|
||||
help, "Color for edge that have no edge type defined");
|
||||
}
|
||||
|
||||
optionNamesInDisplayOrder.add(DEFAULT_VERTEX_SHAPE);
|
||||
options.registerOption(DEFAULT_VERTEX_SHAPE, OptionType.STRING_TYPE,
|
||||
defaultVertexShape.getName(), help,
|
||||
"Shape for vertices that have no vertex type defined", editor);
|
||||
|
||||
options.registerOption(DEFAULT_VERTEX_COLOR, OptionType.COLOR_TYPE, defaultVertexColor,
|
||||
help, "Color for vertices that have no vertex type defined");
|
||||
|
||||
options.registerOption(DEFAULT_EDGE_COLOR, OptionType.COLOR_TYPE, defaultEdgeColor, help,
|
||||
"Color for edge that have no edge type defined");
|
||||
|
||||
optionNamesInDisplayOrder.add(FAVORED_EDGE_TYPE);
|
||||
List<String> edgeTypes = graphType.getEdgeTypes();
|
||||
if (!edgeTypes.isEmpty()) {
|
||||
editor = new StringWithChoicesEditor(edgeTypes);
|
||||
|
@ -794,32 +916,24 @@ public class GraphDisplayOptions implements OptionsChangeListener {
|
|||
"Favored edge is used to influence layout algorithms", editor);
|
||||
}
|
||||
|
||||
optionNamesInDisplayOrder.add(DEFAULT_LAYOUT_ALGORITHM);
|
||||
editor = new StringWithChoicesEditor(LayoutAlgorithmNames.getLayoutAlgorithmNames());
|
||||
options.registerOption(DEFAULT_LAYOUT_ALGORITHM, OptionType.STRING_TYPE,
|
||||
defaultLayoutAlgorithmName, help, "Initial layout algorithm", editor);
|
||||
|
||||
options.registerOption(USE_ICONS, OptionType.BOOLEAN_TYPE, useIcons, help,
|
||||
"If true, vertices are drawn using pre-rendered images versus compact shapes");
|
||||
|
||||
optionNamesInDisplayOrder.add(LABEL_POSITION);
|
||||
options.registerOption(LABEL_POSITION, OptionType.ENUM_TYPE, labelPosition, help,
|
||||
"Relative postion of labels to vertex shape (Only applicable if \"Use Icons\" is true");
|
||||
|
||||
options.registerOption(FONT, OptionType.FONT_TYPE, font, help,
|
||||
"Font to use for vertex labels");
|
||||
|
||||
List<String> optionNamesInDisplayOrder = new ArrayList<>();
|
||||
|
||||
optionNamesInDisplayOrder.add(MAX_NODES_SIZE);
|
||||
optionNamesInDisplayOrder.add(VERTEX_SELECTION_COLOR);
|
||||
optionNamesInDisplayOrder.add(EDGE_SELECTION_COLOR);
|
||||
optionNamesInDisplayOrder.add(DEFAULT_VERTEX_COLOR);
|
||||
optionNamesInDisplayOrder.add(DEFAULT_EDGE_COLOR);
|
||||
optionNamesInDisplayOrder.add(DEFAULT_VERTEX_SHAPE);
|
||||
optionNamesInDisplayOrder.add(FAVORED_EDGE_TYPE);
|
||||
optionNamesInDisplayOrder.add(DEFAULT_LAYOUT_ALGORITHM);
|
||||
optionNamesInDisplayOrder.add(LABEL_POSITION);
|
||||
if (themeFontId != null) {
|
||||
optionNamesInDisplayOrder.add(FONT);
|
||||
options.registerOption(FONT, OptionType.FONT_TYPE, themeFontId, help,
|
||||
"Font to use for vertex labels");
|
||||
}
|
||||
|
||||
optionNamesInDisplayOrder.add(USE_ICONS);
|
||||
options.registerOption(USE_ICONS, OptionType.BOOLEAN_TYPE, useIcons, help,
|
||||
"If true, vertices are drawn using pre-rendered images versus compact shapes");
|
||||
|
||||
OptionsEditor optionsEditor =
|
||||
new ScrollableOptionsEditor(MISCELLANEOUS_OPTIONS, optionNamesInDisplayOrder);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue