Some small improvements

This commit is contained in:
SuspiciousActivity committed 2019-02-28 15:23:07 +01:00
1 parent e4cc2e5489
commit 123ad89c0d
10 files changed
+106 -38

No files matched your search

+3 -3
View File
@@ -56,7 +56,7 @@ public class CompilationBox extends JFrame {
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
contentPane = new JPanel();
contentPane.setBackground(Main.dark ? Color.DARK_GRAY : Color.GRAY);
contentPane.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));
@@ -65,13 +65,13 @@ public class CompilationBox extends JFrame {
textArea.setEditable(true);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setCodeFoldingEnabled(true);
textArea.setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
textArea.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
RTextScrollPane scrollPane = new RTextScrollPane();
scrollPane.setViewportView(textArea);
scrollPane.setLineNumbersEnabled(true);
scrollPane.setFoldIndicatorEnabled(true);
scrollPane.getGutter().setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
scrollPane.getGutter().setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
contentPane.add(scrollPane);
KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK);
@@ -61,7 +61,7 @@ public class CompilationSuccess extends JFrame {
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
contentPane = new JPanel();
contentPane.setBackground(Main.dark ? Color.DARK_GRAY : Color.GRAY);
contentPane.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));
@@ -70,13 +70,13 @@ public class CompilationSuccess extends JFrame {
textArea.setEditable(true);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA_DISASSEMBLE);
textArea.setCodeFoldingEnabled(true);
textArea.setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
textArea.setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
RTextScrollPane scrollPane = new RTextScrollPane();
scrollPane.setViewportView(textArea);
scrollPane.setLineNumbersEnabled(true);
scrollPane.setFoldIndicatorEnabled(true);
scrollPane.getGutter().setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
scrollPane.getGutter().setBackground(Main.dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
contentPane.add(scrollPane);
}
}
+58 -2
View File
@@ -80,10 +80,66 @@ public class Assembler {
clazz.innerClasses = new ArrayList<>();
} else {
String split[] = s.split(" ");
int access = 0;
String cons = s
.substring(
split[0].length() + split[1].length() + split[2].length() + split[3].length() + 3)
.trim();
if (cons.startsWith("0x")) {
access = Integer.parseInt(cons.substring(2), 16);
} else {
if (cons.contains("public")) {
access ^= ClassUtil.ACC_PUBLIC;
}
if (cons.contains("private")) {
access ^= ClassUtil.ACC_PRIVATE;
}
if (cons.contains("protected")) {
access ^= ClassUtil.ACC_PROTECTED;
}
if (cons.contains("static")) {
access ^= ClassUtil.ACC_STATIC;
}
if (cons.contains("final")) {
access ^= ClassUtil.ACC_FINAL;
}
if (cons.contains("synchronized")) {
access ^= ClassUtil.ACC_SYNCHRONIZED;
}
if (cons.contains("bridge")) {
access ^= ClassUtil.ACC_BRIDGE;
}
if (cons.contains("transient")) {
access ^= ClassUtil.ACC_VARARGS;
}
if (cons.contains("native")) {
access ^= ClassUtil.ACC_NATIVE;
}
if (cons.contains("interface")) {
access ^= ClassUtil.ACC_INTERFACE;
}
if (cons.contains("abstract")) {
access ^= ClassUtil.ACC_ABSTRACT;
}
if (cons.contains("strictfp")) {
access ^= ClassUtil.ACC_STRICTFP;
}
if (cons.contains("synthetic")) {
access ^= ClassUtil.ACC_SYNTHETIC;
}
if (cons.contains("annotation")) {
access ^= ClassUtil.ACC_ANNOTATION;
}
if (cons.contains("enum")) {
access ^= ClassUtil.ACC_ENUM;
}
if (cons.contains("mandated")) {
access ^= ClassUtil.ACC_MANDATED;
}
}
clazz.innerClasses.add(new InnerClassNode(UnicodeUtils.unescape(split[1]),
split[2].equals("null") ? null : UnicodeUtils.unescape(split[2]),
split[3].equals("null") ? null : UnicodeUtils.unescape(split[3]),
Integer.parseInt(split[4].substring(2), 16)));
split[3].equals("null") ? null : UnicodeUtils.unescape(split[3]), access));
}
}
{
+12 -7
View File
@@ -77,7 +77,7 @@ public class Disassembler {
try {
int lineFound = -1;
String s = "";
s += "// #Annotations\n";
s += "// #Annotations:\n";
if (classNode.visibleAnnotations != null && !classNode.visibleAnnotations.isEmpty()) {
for (AnnotationNode annotationNode : classNode.visibleAnnotations) {
s += "@" + UnicodeUtils.escapeWithSpaces(annotationNode.desc);
@@ -138,19 +138,22 @@ public class Disassembler {
}
}
s += "// #Class v:" + classNode.version + "\n";
if (classNode.signature != null)
s += "// #Signature: " + UnicodeUtils.escapeWithSpaces(classNode.signature) + "\n";
if (classNode.outerMethod != null)
s += "// #OuterMethod: " + (classNode.outerMethod == null ? "null"
: (UnicodeUtils.escapeWithSpaces(classNode.outerMethod) + " "
+ UnicodeUtils.escapeWithSpaces(classNode.outerMethodDesc)))
+ "\n";
if (classNode.outerClass != null)
s += "// #OuterClass: " + UnicodeUtils.escapeWithSpaces(classNode.outerClass) + "\n";
s += "// #InnerClasses:\n";
if (classNode.innerClasses != null) {
for (InnerClassNode icn : classNode.innerClasses) {
s += "// " + UnicodeUtils.escapeWithSpaces(icn.name) + " "
+ UnicodeUtils.escapeWithSpaces(icn.outerName) + " "
+ UnicodeUtils.escapeWithSpaces(icn.innerName) + " 0x" + Integer.toHexString(icn.access)
+ "\n";
+ UnicodeUtils.escapeWithSpaces(icn.innerName)
+ (icn.access == 0 ? "" : " " + ClassUtil.getAccessFlagsFull(icn.access).trim()) + "\n";
}
}
s += ClassUtil.getAccessFlagsClass(classNode.access) + UnicodeUtils.escapeWithSpaces(classNode.name) + " ";
@@ -350,14 +353,15 @@ public class Disassembler {
private static String[] disassembleMethod(String className, MethodNode mn) {
HashMap<Label, Integer> labels = new HashMap<Label, Integer>();
String s = "";
String localVarTable = "\t// #LocalVars:\n";
String tryCatchTable = "\t// #TryCatch:\n";
String localVarTable = "";
String tryCatchTable = "";
for (AbstractInsnNode n : mn.instructions.toArray()) {
if (n instanceof LabelNode) {
labels.put(((LabelNode) n).getLabel(), labels.size() + 1);
}
}
if (mn.localVariables != null) {
if (mn.localVariables != null && !mn.localVariables.isEmpty()) {
localVarTable = "\t// #LocalVars:\n";
for (LocalVariableNode lvn : mn.localVariables) {
localVarTable += "\t// " + UnicodeUtils.escapeWithSpaces(lvn.name) + ": "
+ UnicodeUtils.escapeWithSpaces(lvn.desc) + " i:" + lvn.index + " s:"
@@ -365,7 +369,8 @@ public class Disassembler {
+ UnicodeUtils.escapeWithSpaces(lvn.signature) + "\n";
}
}
if (mn.tryCatchBlocks != null) {
if (mn.tryCatchBlocks != null && !mn.tryCatchBlocks.isEmpty()) {
tryCatchTable = "\t// #TryCatch:\n";
for (TryCatchBlockNode tcbn : mn.tryCatchBlocks) {
tryCatchTable += "\t// " + UnicodeUtils.escapeWithSpaces(tcbn.type) + " s:"
+ labels.get(tcbn.start.getLabel()) + " e:" + labels.get(tcbn.end.getLabel()) + " h:"
+8 -8
View File
@@ -177,7 +177,7 @@ public class Main extends JFrame {
"getstatic Ljava/io/PrintStream; java/lang/System/out\n\t\tldc \"text\"\n\t\tinvokevirtual (Ljava/lang/String;)V java/io/PrintStream/println",
null, "<html><b><u>sysout</u></b><br>Writes a System.out.println(\"text\"); as bytecode</html>"));
provider.addCompletion(new ShorthandCompletion(provider, "clazz",
"// #Annotations\n// #Class v:52\n// #Signature: null\n// #OuterClass: null\n// #InnerClasses:\npublic class Main extends java/lang/Object {\n// #SourceFile: Main.java\n\n// #Fields\n\n// #Methods\n\n}\n",
"// #Annotations:\n// #Class v:52\n// #Signature: null\n// #OuterClass: null\n// #InnerClasses:\npublic class Main extends java/lang/Object {\n// #SourceFile: Main.java\n\n// #Fields\n\n// #Methods\n\n}\n",
null, "<html><b><u>clazz</u></b><br>Creates an example class</html>"));
provider.addCompletion(new ShorthandCompletion(provider, "method",
"// #Max: l:0 s:0\n\t// #TryCatch:\n\t// #LocalVars:\n\tpublic static method ()V {\n\t\treturn\n\t}",
@@ -221,12 +221,12 @@ public class Main extends JFrame {
e.printStackTrace();
}
contentPane = new JPanel();
contentPane.setBackground(dark ? Color.DARK_GRAY : Color.GRAY);
contentPane.setBackground(dark ? new Color(0x2F2F2F) : Color.GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new GridLayout(0, 1, 0, 0));
JSplitPane splitPane = new JSplitPane();
splitPane.setBackground(dark ? Color.DARK_GRAY : Color.GRAY);
splitPane.setBackground(dark ? new Color(0x2F2F2F) : Color.GRAY);
splitPane.setResizeWeight(0.2);
contentPane.add(splitPane);
JScrollPane scrollPane = new JScrollPane();
@@ -295,10 +295,10 @@ public class Main extends JFrame {
}
});
tree.setFont(new Font("Verdana", Font.PLAIN, 11));
tree.setBackground(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
tree.setBackground(dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
if (tree.getCellRenderer() instanceof DefaultTreeCellRenderer) {
final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) (tree.getCellRenderer());
renderer.setBackgroundNonSelectionColor(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
renderer.setBackgroundNonSelectionColor(dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
renderer.setBackgroundSelectionColor(Color.GRAY);
renderer.setTextNonSelectionColor(dark ? new Color(0xeeeeee) : Color.BLACK);
renderer.setTextSelectionColor(dark ? new Color(0xeeeeee) : Color.BLACK);
@@ -531,11 +531,11 @@ public class Main extends JFrame {
theme.apply(txtByteEditView);
splitPane.setRightComponent(scrollPane_ByteEdit);
txtByteEditView.setBackground(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
txtByteEditView.setBackground(dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
scrollPane_ByteEdit.setViewportView(txtByteEditView);
scrollPane_ByteEdit.setLineNumbersEnabled(true);
scrollPane_ByteEdit.setFoldIndicatorEnabled(true);
scrollPane_ByteEdit.getGutter().setBackground(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
scrollPane_ByteEdit.getGutter().setBackground(dark ? new Color(0x2F2F2F) : Color.LIGHT_GRAY);
}
private final Pattern jumpableInstructionPattern = Pattern.compile("^\t\t(?!//|\t+).+ .+");
@@ -665,7 +665,7 @@ public class Main extends JFrame {
private void saveCurrentClassNode() {
String txt = txtByteEditView.getText();
for (String s : txt.split("\\/\\/ #Annotations\n")) {
for (String s : txt.split("\\/\\/ #Annotations:\n")) {
if (s.isEmpty())
continue;
ClassNode node = Assembler.assemble(s);
+8 -8
View File
@@ -286,10 +286,6 @@ public class ClassUtil {
s += "native ";
acc ^= ACC_NATIVE;
}
if ((ACC_INTERFACE & access) != 0) {
s += "interface ";
acc ^= ACC_INTERFACE;
}
if ((ACC_ABSTRACT & access) != 0) {
s += "abstract ";
acc ^= ACC_ABSTRACT;
@@ -306,6 +302,14 @@ public class ClassUtil {
s += "bridge ";
acc ^= ACC_BRIDGE;
}
if ((ACC_MANDATED & access) != 0) {
s += "mandated ";
acc ^= ACC_MANDATED;
}
if ((ACC_INTERFACE & access) != 0) {
s += "interface ";
acc ^= ACC_INTERFACE;
}
if ((ACC_ANNOTATION & access) != 0) {
s += "annotation ";
acc ^= ACC_ANNOTATION;
@@ -314,10 +318,6 @@ public class ClassUtil {
s += "enum ";
acc ^= ACC_ENUM;
}
if ((ACC_MANDATED & access) != 0) {
s += "mandated ";
acc ^= ACC_MANDATED;
}
if (acc == access) {
return s;
} else {
+8 -1
View File
@@ -81,7 +81,14 @@ public class UnicodeUtils {
if (s == null) {
return null;
}
return escape(s).replace(" ", "\\u0020");
s = escape(s).replace(" ", "\\u0020");
if (s.startsWith("/")) {
s = "\\u002F" + s.substring(1);
}
if (s.endsWith("/")) {
s = s.substring(0, s.length() - 1) + "\\u002F";
}
return s;
}
public static String escape(String s) {
+4 -4
View File
@@ -70,10 +70,10 @@
<style token="VARIABLE" fg="ff9900" bold="true"/>
<style token="WHITESPACE" fg="eeeeee"/>
<style token="ERROR_IDENTIFIER" fg="eeeeee" bg="ffcccc"/>
<style token="ERROR_NUMBER_FORMAT" fg="eeeeee" bg="ffcccc"/>
<style token="ERROR_STRING_DOUBLE" fg="eeeeee" bg="ffcccc"/>
<style token="ERROR_CHAR" fg="eeeeee" bg="ffcccc"/>
<style token="ERROR_IDENTIFIER" fg="eeeeee" bg="003333"/>
<style token="ERROR_NUMBER_FORMAT" fg="eeeeee" bg="003333"/>
<style token="ERROR_STRING_DOUBLE" fg="eeeeee" bg="003333"/>
<style token="ERROR_CHAR" fg="eeeeee" bg="003333"/>
</tokenStyles>
</RSyntaxTheme>
@@ -819,7 +819,7 @@ public class ErrorStrip extends JPanel {
// highest priority (e.g. parsing errors will usually be red).
Color borderColor = getColor();
if (borderColor == null) {
borderColor = Color.DARK_GRAY;
borderColor = new Color(0x2F2F2F);
}
Color fillColor = getBrighterColor(borderColor);
int w = getWidth();
+1 -1
View File
@@ -136,7 +136,7 @@ public class RTextAreaUI extends BasicTextAreaUI {
if (c == null) { // Not Nimbus, but still need a value - fallback
c = UIManager.getColor("textInactiveText");
if (c == null) {
c = new ColorUIResource(Color.DARK_GRAY);
c = new ColorUIResource(new Color(0x2F2F2F));
}
}
editor.setDisabledTextColor(c);