GP-4478: More review changes

GP-4478: Review changes
GP-4478 Add help to assembler
Add help to assembler
Initial commit
This commit is contained in:
ghidranoob 2025-08-04 14:41:28 -04:00
parent 8c56fc8e04
commit 6096a50042
2 changed files with 28 additions and 11 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -46,8 +46,8 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.lang.*; import ghidra.program.model.lang.*;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.program.model.mem.ByteMemBufferImpl; import ghidra.program.model.mem.ByteMemBufferImpl;
import ghidra.util.Msg; import ghidra.util.*;
import ghidra.util.NumericUtilities; import help.Help;
/** /**
* A pair of text fields suitable for guided assembly * A pair of text fields suitable for guided assembly
@ -69,7 +69,7 @@ public class AssemblyDualTextField {
private static final String FONT_ID = "font.plugin.assembly.dual.text.field"; private static final String FONT_ID = "font.plugin.assembly.dual.text.field";
private static final Color FG_PREFERENCE_MOST = private static final Color FG_PREFERENCE_MOST =
new GColor("color.fg.plugin.assembler.completion.most"); new GColor("color.fg.plugin.assembler.completion.most");
private static final Color FG_PREFERENCE_MIDDLE = private static final Color FG_PREFERENCE_MIDDLE =
new GColor("color.fg.plugin.assembler.completion.middle"); new GColor("color.fg.plugin.assembler.completion.middle");
private static final Color FG_PREFERENCE_LEAST = private static final Color FG_PREFERENCE_LEAST =
new GColor("color.fg.plugin.assembler.completion.least"); new GColor("color.fg.plugin.assembler.completion.least");
@ -402,13 +402,14 @@ public class AssemblyDualTextField {
private static final String CMD_ZERO = "Zero undefined bits"; private static final String CMD_ZERO = "Zero undefined bits";
private JLabel hints; private JLabel hints;
private EmptyBorderToggleButton button;
@Override @Override
protected void addContent(JPanel content) { protected void addContent(JPanel content) {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
Box controls = Box.createHorizontalBox(); Box controls = Box.createHorizontalBox();
Icon icon = new GIcon("icon.plugin.assembler.question"); Icon icon = new GIcon("icon.plugin.assembler.question");
EmptyBorderToggleButton button = new EmptyBorderToggleButton(icon); button = new EmptyBorderToggleButton(icon);
button.setToolTipText("Exhaust unspecified bits, otherwise zero them"); button.setToolTipText("Exhaust unspecified bits, otherwise zero them");
button.addActionListener((e) -> { button.addActionListener((e) -> {
exhaustUndefined = CMD_EXHAUST.equals(e.getActionCommand()); exhaustUndefined = CMD_EXHAUST.equals(e.getActionCommand());
@ -426,8 +427,9 @@ public class AssemblyDualTextField {
hints = new JLabel(); hints = new JLabel();
panel.add(hints); panel.add(hints);
content.add(panel, BorderLayout.SOUTH); content.add(panel, BorderLayout.SOUTH);
addAutocompletionListener(this); addAutocompletionListener(this);
} }
@Override @Override
@ -632,6 +634,15 @@ public class AssemblyDualTextField {
public JTextField getOperandsField() { public JTextField getOperandsField() {
return operands; return operands;
} }
/**
* Get the button that toggles bit exhaustion
*
* @return the button
*/
public JButton getExhaustButton() {
return auto.button;
}
/** /**
* For single mode: Get the text field containing the full assembly text * For single mode: Get the text field containing the full assembly text

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -47,6 +47,7 @@ import ghidra.util.HelpLocation;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.task.CachingSwingWorker; import ghidra.util.task.CachingSwingWorker;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
import help.Help;
/** /**
* A context menu action to assemble an instruction at the current address * A context menu action to assemble an instruction at the current address
@ -145,14 +146,19 @@ public class PatchInstructionAction extends AbstractPatchAction {
setPopupMenuData(new MenuData(new String[] { name }, MENU_GROUP)); setPopupMenuData(new MenuData(new String[] { name }, MENU_GROUP));
setKeyBindingData(new KeyBindingData(KEYBIND_PATCH_INSTRUCTION)); setKeyBindingData(new KeyBindingData(KEYBIND_PATCH_INSTRUCTION));
setHelpLocation(new HelpLocation(owner.getName(), "patch_instruction")); HelpLocation location = new HelpLocation(owner.getName(), "patch_instruction");
setHelpLocation(location);
input.getMnemonicField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2)); input.getMnemonicField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getOperandsField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2)); input.getOperandsField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getAssemblyField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2)); input.getAssemblyField().setBorder(BorderFactory.createLineBorder(Colors.ERROR, 2));
input.getAutocompleter().addAutocompletionListener(listenerForAccept); input.getAutocompleter().addAutocompletionListener(listenerForAccept);
Help.getHelpService().registerHelp(input.getMnemonicField(), location);
Help.getHelpService().registerHelp(input.getOperandsField(), location);
Help.getHelpService().registerHelp(input.getExhaustButton(), location);
init(); init();
} }