From 2e317cd87f723be361238fe6c12a30084d6e88fd Mon Sep 17 00:00:00 2001 From: ghidragon <106987263+ghidragon@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:43:46 -0500 Subject: [PATCH] GP-2943 changed Structure/Union editor to show hex values by default. --- .../DataTypeEditors/StructureEditor.htm | 18 ++++++------ .../compositeeditor/HexNumbersAction.java | 2 ++ .../datamgr/editor/EditorOptionManager.java | 28 +++++++++---------- 3 files changed, 25 insertions(+), 23 deletions(-) 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 @@ -
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 tool option, Show Numbers In Hex, that lets you - override the default and set whether these numbers should be displayed in hexadecimal when an - editor is initially displayed.
+ default, numbers are initially shown as hex values in the Structure Editor. There is + a tool option, Show Numbers In Hex, 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. -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 +
The hex/decimal mode can quickly be toggled using the key binding Shift H + or the toolbar menu item in the editor. Changing this only affects the current editor where it is changed.
-
The Union Editor does not display offsets since they are always zero.
To switch between decimal and hexadecimal display of numeric values in the current - editor:
+To switch between decimal and hex display of numeric values in the current + editor, press Shift H or use the menu action as follows:
- Right mouse click on the table.
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);