Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2943 changed Structure/Union editor to show hex values by default.

ghidragon2e317cd87f72
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htm b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htm
index 34124a1903..7dcdfdbc87 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htm
+++ b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeEditors/StructureEditor.htm
@@ -1198,25 +1198,25 @@
</OL>
</BLOCKQUOTE>
- <H2><A name="Structure_Editor_Show_Numbers_In_Hex"></A> Showing Numbers in Hexadecimal</H2>
+ <H2><A name="Structure_Editor_Show_Numbers_In_Hex"></A> Toggling Hex/Decimal Display</H2>
<BLOCKQUOTE>
<P>The Component Table contains numeric fields such as the component's offset and length. The
structure information area also shows the overall size and alignment of the structure. By
- default numbers are initially shown in decimal in the Structure Editor. There is a <A href=
- "#StructureEditorToolOptions">tool option</A>, <B>Show Numbers In Hex</B>, that lets you
- override the default and set whether these numbers should be displayed in hexadecimal when an
- editor is initially displayed.</P>
+ default, numbers are initially shown as hex values in the Structure Editor. There is
+ a <A href="#StructureEditorToolOptions">tool option</A>, <B>Show Numbers In Hex</B>, that lets
+ you override the default and set whether these numbers should be displayed as decimal or hex
+ values when an editor is initially displayed.</P>
- <P>There is also a toolbar menu item in the editor that allows you to immediately change
- whether the numbers are displayed in hexadecimal or decimal. Changing this only affects the
+ <P>The hex/decimal mode can quickly be toggled using the key binding <B>Shift H</B>
+ or the toolbar menu item in the editor. Changing this only affects the
current editor where it is changed.</P>
<P><IMG src="help/shared/note.png" alt=""> The Union Editor does not display offsets since
they are always zero.</P>
- <P>To switch between decimal and hexadecimal display of numeric values in the current
- editor:</P>
+ <P>To switch between decimal and hex display of numeric values in the current
+ editor, press <B>Shift H</B> or use the menu action as follows:</P>
<OL>
<LI>Right mouse click on the table.</LI>
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java
index 5c2ea61852..b9c4b7939b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java
@@ -19,6 +19,7 @@ import javax.swing.JMenuItem;
import docking.ActionContext;
import docking.DockingCheckBoxMenuItem;
+import docking.action.KeyBindingData;
import docking.action.ToggleDockingActionIf;
import docking.menu.DockingCheckboxMenuItemUI;
@@ -39,6 +40,7 @@ public class HexNumbersAction extends CompositeEditorTableAction implements Togg
setDescription(DESCRIPTION);
setEnabled(true);
setSelected(model.isShowingNumbersInHex());
+ setKeyBindingData(new KeyBindingData("Shift-H"));
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java
index 3a8b8054ae..dadce93f03 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java
@@ -21,19 +21,19 @@ import ghidra.framework.options.*;
import ghidra.framework.plugintool.Plugin;
import ghidra.util.HelpLocation;
-public class EditorOptionManager implements OptionsChangeListener, StructureEditorOptionManager,
- UnionEditorOptionManager {
+public class EditorOptionManager
+ implements OptionsChangeListener, StructureEditorOptionManager, UnionEditorOptionManager {
private final static String STRUCTURE_EDITOR_NAME = "Structure Editor";
private final static String UNION_EDITOR_NAME = "Union Editor";
- private final static String HEX_STRUCT_NUMBERS_OPTION_NAME = STRUCTURE_EDITOR_NAME +
- Options.DELIMITER + "Show Numbers In Hex";
- private final static String HEX_UNION_NUMBERS_OPTION_NAME = UNION_EDITOR_NAME +
- Options.DELIMITER + "Show Numbers In Hex";
+ private final static String HEX_STRUCT_NUMBERS_OPTION_NAME =
+ STRUCTURE_EDITOR_NAME + Options.DELIMITER + "Show Numbers In Hex";
+ private final static String HEX_UNION_NUMBERS_OPTION_NAME =
+ UNION_EDITOR_NAME + Options.DELIMITER + "Show Numbers In Hex";
private Plugin plugin;
- private boolean showStructureNumbersInHex = false;
- private boolean showUnionNumbersInHex = false;
+ private boolean showStructureNumbersInHex = true;
+ private boolean showUnionNumbersInHex = true;
private String HELP_TOPIC = "DataTypeEditors";
public EditorOptionManager(Plugin plugin) {
@@ -50,14 +50,14 @@ public class EditorOptionManager implements OptionsChangeListener, StructureEdit
options.getOptions(UNION_EDITOR_NAME).setOptionsHelpLocation(help);
options.registerOption(HEX_STRUCT_NUMBERS_OPTION_NAME, showStructureNumbersInHex, help,
- "Toggle for whether numeric values in the Structure Editor "
- + "should be displayed in hexadecimal or decimal "
- + "when you initially begin editing a structure.");
+ "Toggle for whether numeric values in the Structure Editor " +
+ "should be displayed in hexadecimal or decimal " +
+ "when you initially begin editing a structure.");
options.registerOption(HEX_UNION_NUMBERS_OPTION_NAME, showUnionNumbersInHex, help,
- "Toggle for whether numeric values in the Union Editor "
- + "should be displayed in hexadecimal or decimal "
- + "when you initially begin editing a union.");
+ "Toggle for whether numeric values in the Union Editor " +
+ "should be displayed in hexadecimal or decimal " +
+ "when you initially begin editing a union.");
setOptions(options);
options.addOptionsChangeListener(this);