Add Print Line Numbers Setting To Disassembler

Resolves https://github.com/Konloch/bytecode-viewer/pull/398#discussion_r826274523
This commit is contained in:
Konloch 2022-03-23 14:46:17 -05:00
parent cb6acf6c82
commit 498ea1d82b
5 changed files with 13 additions and 3 deletions

View file

@ -200,6 +200,7 @@ public class SettingsSerializer
save(Configuration.python2Extra);
save(Configuration.python3Extra);
save(BytecodeViewer.viewer.getMinSdkVersion());
save(BytecodeViewer.viewer.printLineNumbers.isSelected());
} catch (Exception e) {
BytecodeViewer.handleException(e);
}
@ -397,6 +398,7 @@ public class SettingsSerializer
Configuration.python2Extra = asBoolean(139);
Configuration.python3Extra = asBoolean(140);
BytecodeViewer.viewer.minSdkVersionSpinner.setValue(asInt(141));
BytecodeViewer.viewer.printLineNumbers.setSelected(asBoolean(142));
}
catch (IndexOutOfBoundsException e)
{

View file

@ -227,7 +227,10 @@ public class InstructionPrinter implements Opcodes {
}
protected String printLineNumberNode(LineNumberNode lnn) {
return "// line " + lnn.line;
if(BytecodeViewer.viewer.printLineNumbers.isSelected())
return "// line " + lnn.line;
return "";
}
protected String printLabelNode(LabelNode label) {

View file

@ -212,6 +212,7 @@ public class MainViewerGUI extends JFrame
public SettingsDialog bytecodeDecompilerSettingsDialog;
public final JCheckBoxMenuItem appendBracketsToLabels = new TranslatedJCheckBoxMenuItem("Append Brackets To Labels", TranslatedComponents.APPEND_BRACKETS_TO_LABEL);
public JCheckBoxMenuItem debugHelpers = new TranslatedJCheckBoxMenuItem("Debug Helpers", TranslatedComponents.DEBUG_HELPERS);
public final JCheckBoxMenuItem printLineNumbers = new TranslatedJCheckBoxMenuItem("Print Line Numbers", TranslatedComponents.PRINT_LINE_NUMBERS);
//FernFlower settings
public final JMenu fernFlowerSettingsSecondaryMenu = new TranslatedJMenu("FernFlower Settings", TranslatedComponents.FERNFLOWER_SETTINGS);
@ -658,6 +659,7 @@ public class MainViewerGUI extends JFrame
settingsMainMenu.add(useNewSettingsDialog ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu);
bytecodeDecompilerSettingsSecondaryMenu.add(debugHelpers);
bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels);
bytecodeDecompilerSettingsSecondaryMenu.add(printLineNumbers);
bytecodeDecompilerSettingsDialog = new SettingsDialog(bytecodeDecompilerSettingsSecondaryMenu, new JPanel());
bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialog.showDialog());
@ -837,6 +839,7 @@ public class MainViewerGUI extends JFrame
//CFIDE
debugHelpers.setSelected(true);
appendBracketsToLabels.setSelected(true);
printLineNumbers.setSelected(false);
}
public void calledAfterLoad() {

View file

@ -253,7 +253,8 @@ public enum TranslatedComponents
MIN_SDK_VERSION,
ANNOTATION_NAME,
MATCH_CASE,
EXACT_PATH;
EXACT_PATH, PRINT_LINE_NUMBERS,
;
private final TranslatedComponentReference componentReference;

View file

@ -284,5 +284,6 @@
"ANNOTATION_NAME": "Annotation Name",
"MATCH_CASE": "Match Case",
"EXACT_PATH": "Exact Path",
"MIN_SDK_VERSION": "Minimum SDK version"
"MIN_SDK_VERSION": "Minimum SDK version",
"PRINT_LINE_NUMBERS": "Print Line Numbers"
}