GP-5947 - Created new theme value for the Decompiler's middle-mouse

highlight color so that the Listing and Decompiler colors may change
independently.
This commit is contained in:
dragonmacher 2025-08-22 18:00:48 -04:00
parent 4fcc1febdd
commit aae2843f4d
11 changed files with 86 additions and 52 deletions

View file

@ -7,7 +7,7 @@ color.bg.highlight.listing = color.bg.highlight
color.bg.highlight.listing.diff = moccasin // bisque / blanchedalmond / peachpuff / navajowhite
color.bg.listing.highlighter.default = color.palette.yellow
color.bg.listing.highlighter.middle.mouse = color.palette.yellow
color.bg.listing.highlighter.scoped.read = color.palette.darkkhaki
color.bg.listing.highlighter.scoped.write = color.palette.lightgreen
@ -116,7 +116,7 @@ font.listing.header = SansSerif-PLAIN-11
color.bg.highlight.listing.diff = #4D4D2A
color.bg.listing.highlighter.default = #666600
color.bg.listing.highlighter.middle.mouse = #666600
color.bg.listing.highlighter.scoped.read = #996600
color.bg.listing.highlighter.scoped.write = #009900

View file

@ -498,14 +498,9 @@
<P>Use the following options to customize <A href=
"CodeBrowser.htm#cursorTextHighlight">Cursor Text Highlighting</A>:</P>
<P><B>Alternate Highlight Color -</B> Sets the alternate color used for cursor text
highlighting. Double click on the color bar to bring up a color chooser dialog.</P>
<P><B>Enabled - </B> Select this checkbox to enable cursor text highlighting.</P>
<P><B>Enabled -</B> Select this checkbox to enable cursor text highlighting.</P>
<P><B>Highlight Color -</B> Sets the color used for cursor text highlighting. Double click
on the color bar to bring up a color chooser dialog.<BR>
<B><BR>
<P><B>
Mouse Button To Activate</B> - Use the combo box to select which mouse button will be used
to highlight text (Left, Right, Middle).</P>
@ -513,6 +508,24 @@
enable <A href="CodeBrowser.htm#Scope">Scoped highlighting</A> of registers within the
operand field. If turned off, cursor highlighted text within an operand field is treated
the same as text in other fields.</P>
<P><B>Scoped Default Color -</B> Sets the color used for cursor text highlighting via
middle-mouse. Double-click on the color bar to bring up a color chooser dialog.
</P>
<P><B>Scoped Read Highlight Color -</B> Sets the color used for cursor text highlighting a
register when the register value is read. The <I>Scope Register Operand</I> option
above must be on for this value to be used.
Double-click on the color bar to bring up a color chooser dialog.
</P>
<P><B>Scoped Write Highlight Color -</B> Sets the color used for cursor text highlighting a
register when the register value is written to. The <I>Scope Register Operand</I> option
above must be on for this value to be used.
Double-click on the color bar to bring up a color chooser dialog.
</P>
</BLOCKQUOTE>
<H3><A name="EOL_Comments_Field"></A>EOL Comments Field</H3>

View file

@ -4,9 +4,9 @@
* 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.
@ -54,10 +54,11 @@ import ghidra.util.datastruct.Stack;
public class ListingMiddleMouseHighlightProvider
implements ButtonPressedListener, OptionsChangeListener, ListingHighlightProvider {
//@formatter:off
private static final GColor DEFAULT_HIGHLIGHT_COLOR = new GColor("color.bg.listing.highlighter.default");
private static final GColor DEFAULT_MIDDLE_MOUSE_HIGHLIGHT_COLOR = new GColor("color.bg.listing.highlighter.middle.mouse");
private static final GColor DEFAULT_SCOPED_READ_COLOR = new GColor("color.bg.listing.highlighter.scoped.read");
private static final GColor DEFAULT_SCOPED_WRITE_COLOR = new GColor("color.bg.listing.highlighter.scoped.write");
private static final String DISPLAY_HIGHLIGHT_NAME = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Enabled";
private static final String SCOPED_DEFAULT_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Default Color";
private static final String SCOPED_WRITE_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Write Highlight Color";
private static final String SCOPED_READ_HIGHLIGHT_COLOR = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scoped Read Highlight Color";
private static final String SCOPE_REGISTER_OPERAND = CURSOR_HIGHLIGHT_GROUP + DELIMITER + "Scope Register Operand";
@ -873,8 +874,9 @@ public class ListingMiddleMouseHighlightProvider
ToolOptions opt = tool.getOptions(CATEGORY_BROWSER_FIELDS);
HelpLocation hl = new HelpLocation("CodeBrowserPlugin", "Cursor_Text_Highlight");
opt.registerThemeColorBinding(HIGHLIGHT_COLOR_NAME, DEFAULT_HIGHLIGHT_COLOR.getId(), hl,
"The color to use to highlight text.");
opt.registerThemeColorBinding(SCOPED_DEFAULT_HIGHLIGHT_COLOR,
DEFAULT_MIDDLE_MOUSE_HIGHLIGHT_COLOR.getId(), hl,
"The color to use to highlight the register text.");
opt.registerThemeColorBinding(SCOPED_WRITE_HIGHLIGHT_COLOR,
DEFAULT_SCOPED_WRITE_COLOR.getId(), hl,
"The color to use for showing a register being written.");
@ -892,32 +894,24 @@ public class ListingMiddleMouseHighlightProvider
opt.addOptionsChangeListener(this);
/////////////////////////////////////////////////////
displayHighlight = opt.getBoolean(DISPLAY_HIGHLIGHT_NAME, true);
if (!displayHighlight) {
setHighlightString(null, null);
}
textMatchingHighlightColor = opt.getColor(HIGHLIGHT_COLOR_NAME, DEFAULT_HIGHLIGHT_COLOR);
textMatchingHighlightColor =
opt.getColor(SCOPED_DEFAULT_HIGHLIGHT_COLOR, DEFAULT_MIDDLE_MOUSE_HIGHLIGHT_COLOR);
scopeWriteHighlightColor =
opt.getColor(SCOPED_WRITE_HIGHLIGHT_COLOR, DEFAULT_SCOPED_WRITE_COLOR);
scopeReadHighlightColor =
opt.getColor(SCOPED_READ_HIGHLIGHT_COLOR, DEFAULT_SCOPED_READ_COLOR);
/////////////////////////////////////////////////////
CURSOR_MOUSE_BUTTON_NAMES mouseButton =
opt.getEnum(CURSOR_HIGHLIGHT_BUTTON_NAME, CURSOR_MOUSE_BUTTON_NAMES.MIDDLE);
highlightButtonOption = mouseButton.getMouseEventID();
//////////////////////////////////////////////////////
scopeRegisterHighlight = opt.getBoolean(SCOPE_REGISTER_OPERAND, true);
//////////////////////////////////////////////////////
opt.addOptionsChangeListener(this);
}
@ -931,7 +925,7 @@ public class ListingMiddleMouseHighlightProvider
clearHighlight();
}
}
else if (optionName.equals(HIGHLIGHT_COLOR_NAME)) {
else if (optionName.equals(SCOPED_DEFAULT_HIGHLIGHT_COLOR)) {
textMatchingHighlightColor = (Color) newValue;
}
else if (optionName.equals(SCOPED_WRITE_HIGHLIGHT_COLOR)) {

View file

@ -2,6 +2,7 @@
color.bg.byteviewer = color.bg
color.bg.byteviewer.highlight = yellow
color.bg.byteviewer.highlight.middle.mouse = color.bg.highlight
color.fg.byteviewer.separator = color.palette.blue
color.fg.byteviewer.changed = red

View file

@ -58,9 +58,14 @@
<tr>
<td width="31%"> Non-Focus Cursor Color</td>
<td width="69%"> Th/e cursor color when the Byte Viewer is not focuses</td>
<td width="69%"> The cursor color when the Byte Viewer is not focuses</td>
</tr>
<tr>
<td width="31%"> Middle-Mouse Color</td>
<td width="69%"> The color when the user middle-mouses in the Byte Viewer</td>
</tr>
</tbody>
</table>
</div>

View file

@ -86,6 +86,9 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR_OPTION_NAME;
private static final String OPTION_HIGHLIGHT_CURSOR_LINE =
GhidraOptions.HIGHLIGHT_CURSOR_LINE_OPTION_NAME;
private static final String OPTION_HIGHLIGHT_MIDDLE_MOUSE_NAME = "Middle Mouse Color";
private static final GColor HIGHLIGHT_MIDDLE_MOUSE_COLOR =
new GColor("color.bg.byteviewer.highlight.middle.mouse");
protected ByteViewerPanel panel;
@ -182,7 +185,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
CURSOR_MOUSE_BUTTON_NAMES mouseButton = (CURSOR_MOUSE_BUTTON_NAMES) newValue;
panel.setHighlightButton(mouseButton.getMouseEventID());
}
else if (optionName.equals(HIGHLIGHT_COLOR_NAME)) {
else if (optionName.equals(OPTION_HIGHLIGHT_MIDDLE_MOUSE_NAME)) {
panel.setMouseButtonHighlightColor((Color) newValue);
}
}
@ -219,15 +222,22 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
opt.registerThemeColorBinding(CURRENT_LINE_COLOR_OPTION_NAME,
GhidraOptions.DEFAULT_CURSOR_LINE_COLOR.getId(), help,
"Color of the line containing the cursor");
"Color of the line containing the cursor.");
opt.registerThemeColorBinding(OPTION_HIGHLIGHT_MIDDLE_MOUSE_NAME,
HIGHLIGHT_MIDDLE_MOUSE_COLOR.getId(), help, "The middle-mouse highlight color.");
opt.registerThemeFontBinding(OPTION_FONT, DEFAULT_FONT_ID, help, "Font used in the views.");
opt.registerOption(OPTION_HIGHLIGHT_CURSOR_LINE, true, help,
"Toggles highlighting background color of line containing the cursor");
"Toggles highlighting background color of line containing the cursor.");
Color separatorColor = opt.getColor(SEPARATOR_COLOR_OPTION_NAME, SEPARATOR_COLOR);
panel.setSeparatorColor(separatorColor);
Color middleMouseColor =
opt.getColor(OPTION_HIGHLIGHT_MIDDLE_MOUSE_NAME, HIGHLIGHT_MIDDLE_MOUSE_COLOR);
panel.setMouseButtonHighlightColor(middleMouseColor);
panel.setCurrentCursorColor(CURSOR_ACTIVE_COLOR);
panel.setNonFocusCursorColor(CURSOR_NOT_FOCUSED_COLOR);
panel.setCursorColor(CURSOR_NON_ACTIVE_COLOR);
@ -246,9 +256,6 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
CURSOR_HIGHLIGHT_BUTTON_NAME, GhidraOptions.CURSOR_MOUSE_BUTTON_NAMES.MIDDLE);
panel.setHighlightButton(mouseButton.getMouseEventID());
panel.setMouseButtonHighlightColor(
opt.getColor(HIGHLIGHT_COLOR_NAME, DEFAULT_HIGHLIGHT_COLOR));
opt.addOptionsChangeListener(this);
}

View file

@ -16,6 +16,7 @@ color.fg.decompiler.external.function = color.palette.fuchsia
color.bg.decompiler.current.variable = color.palette.highlight.transparent.yellow
color.bg.decompiler.highlights.middle.mouse = color.bg.highlight
color.bg.decompiler.highlights.default = color.palette.highlight.transparent.yellow
color.bg.decompiler.highlights.special = color.palette.crimson
color.bg.decompiler.highlights.find = color.palette.slateblue

View file

@ -3348,6 +3348,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry id="MiddleMouseColor">
<term><emphasis role="bold">Color for Highlighting Middle-mouse Matches</emphasis></term>
<listitem>
<para>
Assign the background color used to highlight characters when highlighting using the middle-mouse button.
</para>
</listitem>
</varlistentry>
<varlistentry id="DisplayCommentIndent">
<term><emphasis role="bold">Comment line indent level</emphasis></term>
<listitem>

View file

@ -534,6 +534,16 @@
(see <a class="xref" href="DecompilerWindow.html#ActionFind" title="Find...">Find...</a>).
</p>
</dd>
<dt>
<a name="MiddleMouseColor"></a><span class="term"><span class="bold"><strong>Color for Highlighting Middle-mouse Matches</strong></span></span>
</dt>
<dd>
<p>
Assign the background color used to highlight characters when highlighting using the middle-mouse button.
</p>
</dd>
<dt>
<a name="DisplayCommentIndent"></a><span class="term"><span class="bold"><strong>Comment line indent level</strong></span></span>
</dt>

View file

@ -26,7 +26,6 @@ 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.app.util.template.TemplateSimplifier;
@ -444,6 +443,9 @@ public class DecompileOptions {
private static final String SEARCH_HIGHLIGHT_MSG = "Display.Color for Highlighting Find Matches";
private static final GColor SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.decompiler.highlights.find");
private static final String HIGHLIGHT_MIDDLE_MOUSE_MSG = "Display.Color for Middle Mouse";
private static final GColor HIGHLIGHT_MIDDLE_MOUSE_COLOR = new GColor("color.bg.decompiler.highlights.middle.mouse");
//@formatter:on
private static final String BACKGROUND_COLOR_MSG = "Display.Background Color";
@ -467,6 +469,7 @@ public class DecompileOptions {
private final static String MAX_INSTRUCTIONS = "Max Instructions per Function";
private final static String MAX_JUMPTABLE_ENTRIES = "Max Entries per Jumptable";
private final static Boolean LINE_NUMBER_DEF = Boolean.TRUE;
private boolean displayLineNumbers;
private int decompileTimeoutSeconds;
private int payloadLimitMBytes;
@ -791,14 +794,20 @@ public class DecompileOptions {
"The maximum size of the decompiler result payload in MBYtes (Suggested value: 50).");
opt.registerOption(MAX_INSTRUCTIONS, SUGGESTED_MAX_INSTRUCTIONS,
new HelpLocation(HelpTopics.DECOMPILER, "GeneralMaxInstruction"),
"The maximum number of instructions decompiled in a single function");
"The maximum number of instructions decompiled in a single function.");
opt.registerOption(MAX_JUMPTABLE_ENTRIES, SUGGESTED_MAX_JUMPTABLE_ENTRIES,
new HelpLocation(HelpTopics.DECOMPILER, "GeneralMaxJumptable"),
"The maximum number of entries that can be recovered from a single jumptable");
"The maximum number of entries that can be recovered from a single jumptable.");
opt.registerThemeColorBinding(HIGHLIGHT_CURRENT_VARIABLE_MSG,
HIGHLIGHT_CURRENT_VARIABLE_COLOR.getId(),
new HelpLocation(HelpTopics.DECOMPILER, "DisplayCurrentHighlight"),
"Current variable highlight");
"Current variable highlight.");
opt.registerThemeColorBinding(HIGHLIGHT_MIDDLE_MOUSE_MSG,
HIGHLIGHT_MIDDLE_MOUSE_COLOR.getId(),
new HelpLocation(HelpTopics.DECOMPILER, "MiddleMouseColor"),
"The middle-mouse highlight color.");
opt.registerOption(CACHED_RESULTS_SIZE_MSG, SUGGESTED_CACHED_RESULTS_SIZE,
new HelpLocation(HelpTopics.DECOMPILER, "GeneralCacheSize"), CACHE_RESULTS_DESCRIPTION);
grabFromToolAndProgram(fieldOptions, opt, program);
@ -1122,7 +1131,7 @@ public class DecompileOptions {
* @return color used to highlight token(s) selected with a middle button clock
*/
public Color getMiddleMouseHighlightColor() {
return GhidraOptions.DEFAULT_HIGHLIGHT_COLOR;
return HIGHLIGHT_MIDDLE_MOUSE_COLOR;
}
/**

View file

@ -31,9 +31,7 @@ import ghidra.framework.plugintool.PluginConfigurationModel;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.PluginPackage;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import resources.Icons;
import utilities.util.reflection.ReflectionUtilities;
public class ManagePluginsDialog extends ReusableDialogComponentProvider {
@ -147,18 +145,6 @@ public class ManagePluginsDialog extends ReusableDialogComponentProvider {
public boolean isEnabledForContext(ActionContext context) {
return true;
}
@Override
public void setEnabled(boolean newValue) {
if (!newValue) {
Msg.debug(this, "disable Save As...",
ReflectionUtilities.createJavaFilteredThrowable());
}
super.setEnabled(newValue);
}
};
icon = Icons.SAVE_AS_ICON;
saveAsAction