Merge pull request #331 from ThexXTURBOXx/fixes

Some more stuff again
This commit is contained in:
Konloch 2021-07-21 14:59:48 -07:00 committed by GitHub
commit 96935050fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 107 deletions

13
pom.xml
View file

@ -181,7 +181,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.31</version>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>org.smali</groupId>
@ -225,14 +225,15 @@
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-core</artifactId>
<version>2.6.2-20210719.010320-83</version> <!-- TODO Change to release when ready -->
<artifactId>darklaf-core-jawt-dll</artifactId>
<version>2.6.2-jawt-dll-SNAPSHOT</version> <!-- TODO Change to release when ready, see below -->
</dependency>
<!-- RELEASE VERSION:
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-windows</artifactId>
<version>2.6.2-20210719.010320-83</version> <!-- TODO Remove when ready -->
</dependency>
<artifactId>darklaf-core</artifactId>
<version>2.6.2</version>
</dependency>-->
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf-extensions-rsyntaxarea</artifactId>

View file

@ -11,6 +11,7 @@ import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.*;
import javax.swing.*;
import the.bytecode.club.bytecodeviewer.Configuration;
/**
* @author laullon
@ -22,22 +23,22 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
protected int textLength = 16;
protected int lastWidth;
byte[] buff;
byte[] buf;
public int cursor;
public Font font;
protected int border = 2;
public boolean DEBUG = false;
private final JScrollBar sb;
private int inicio = 0;
private int lineas = 10;
private JHexEditorHEX hex;
private JHexEditorASCII ascii;
private int begin = 0;
private int lines = 10;
private final JHexEditorHEX hex;
private final JHexEditorASCII ascii;
public JHexEditor(byte[] buff)
{
super();
this.buff = buff;
this.buf = buff;
this.font = new Font(Font.MONOSPACED, Font.PLAIN, BytecodeViewer.viewer.getFontSize());
checkSize();
@ -47,26 +48,25 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
sb = new JScrollBar(JScrollBar.VERTICAL);
sb.addAdjustmentListener(this);
sb.setMinimum(0);
sb.setMaximum(buff.length / getLineas());
sb.setMaximum(buff.length / getLines());
JPanel p1, p2, p3;
// centro
// HEX Editor
hex = new JHexEditorHEX(this);
p1 = new JPanel(new BorderLayout(1, 1));
p1.add(hex, BorderLayout.CENTER);
p1.add(new Columnas(), BorderLayout.NORTH);
p1.add(new Column(), BorderLayout.NORTH);
// izq.
p2 = new JPanel(new BorderLayout(1, 1));
p2.add(new Filas(), BorderLayout.CENTER);
p2.add(new Caja(), BorderLayout.NORTH);
p2.add(new Row(), BorderLayout.CENTER);
p2.add(new Cell(), BorderLayout.NORTH);
// der
// ASCII Editor
ascii = new JHexEditorASCII(this);
p3 = new JPanel(new BorderLayout(1, 1));
p3.add(sb, BorderLayout.EAST);
p3.add(ascii, BorderLayout.CENTER);
p3.add(new Caja(), BorderLayout.NORTH);
p3.add(new Cell(), BorderLayout.NORTH);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(1, 1));
@ -89,14 +89,14 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
FontMetrics fn = getFontMetrics(font);
Rectangle rec = this.getBounds();
lineas = (rec.height / fn.getHeight()) - 1;
int n = (buff.length / textLength) - 1;
if (lineas > n) {
lineas = n;
inicio = 0;
lines = (rec.height / fn.getHeight()) - 1;
int n = (buf.length / textLength) - 1;
if (lines > n) {
lines = n;
begin = 0;
}
sb.setValues(getInicio(), +getLineas(), 0, buff.length / textLength);
sb.setValues(getBegin(), +getLines(), 0, buf.length / textLength);
sb.setValueIsAdjusting(true);
super.paint(g);
}
@ -138,22 +138,22 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
});
}
protected int getInicio() {
return inicio;
protected int getBegin() {
return begin;
}
protected int getLineas() {
return lineas;
protected int getLines() {
return lines;
}
protected void fondo(Graphics g, int x, int y, int s) {
protected void background(Graphics g, int x, int y, int s) {
FontMetrics fn = getFontMetrics(font);
g.fillRect(((fn.stringWidth(" ") + 1) * x) + border,
(fn.getHeight() * y) + border, ((fn.stringWidth(" ") + 1) * s),
fn.getHeight() + 1);
}
protected void cuadro(Graphics g, int x, int y, int s) {
protected void border(Graphics g, int x, int y, int s) {
FontMetrics fn = getFontMetrics(font);
g.drawRect(((fn.stringWidth(" ") + 1) * x) + border,
(fn.getHeight() * y) + border, ((fn.stringWidth(" ") + 1) * s),
@ -178,41 +178,39 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
inicio = e.getValue();
if (inicio < 0)
inicio = 0;
begin = e.getValue();
if (begin < 0)
begin = 0;
repaint();
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
inicio += (e.getUnitsToScroll());
if ((inicio + lineas) >= buff.length / textLength)
inicio = (buff.length / textLength) - lineas;
if (inicio < 0)
inicio = 0;
begin += (e.getUnitsToScroll());
if ((begin + lines) >= buf.length / textLength)
begin = (buf.length / textLength) - lines;
if (begin < 0)
begin = 0;
repaint();
}
public void keyPressed(KeyEvent e) {
/*
* switch(e.getKeyCode()) { case 33: // rep if(cursor>=(16*lineas))
* cursor-=(16*lineas); actualizaCursor(); break; case 34: // fin
* if(cursor<(buff.length-(16*lineas))) cursor+=(16*lineas);
* actualizaCursor(); break; case 35: // fin cursor=buff.length-1;
* actualizaCursor(); break; case 36: // ini cursor=0;
* actualizaCursor(); break; case 37: // <-- if(cursor!=0) cursor--;
* actualizaCursor(); break; case 38: // <-- if(cursor>15) cursor-=16;
* actualizaCursor(); break; case 39: // --> if(cursor!=(buff.length-1))
* cursor++; actualizaCursor(); break; case 40: // -->
* if(cursor<(buff.length-16)) cursor+=16; actualizaCursor(); break; }
*/
/* switch(e.getKeyCode()) { case 33: // rep if(cursor>=(16*lines))
cursor-=(16*lines); refreshCursor(); break; case 34: // fin
if(cursor<(buff.length-(16*lines))) cursor+=(16*lines);
refreshCursor(); break; case 35: // fin cursor=buff.length-1;
refreshCursor(); break; case 36: // ini cursor=0;
refreshCursor(); break; case 37: // <-- if(cursor!=0) cursor--;
refreshCursor(); break; case 38: // <-- if(cursor>15) cursor-=16;
refreshCursor(); break; case 39: // --> if(cursor!=(buff.length-1))
cursor++; refreshCursor(); break; case 40: // -->
if(cursor<(buff.length-16)) cursor+=16; refreshCursor(); break; } */
}
private class Columnas extends JPanel {
private class Column extends JPanel {
private static final long serialVersionUID = -1734199617526339842L;
public Columnas() {
public Column() {
this.setLayout(new BorderLayout(1, 1));
}
@ -227,7 +225,7 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
FontMetrics fn = getFontMetrics(font);
int h = fn.getHeight();
int nl = 1;
d.setSize(((fn.stringWidth(" ") + 1) * +((textLength * 3) - 1))
d.setSize(((fn.stringWidth(" ") + 1) * ((textLength * 3) - 1))
+ (border * 2) + 1, h * nl + (border * 2) + 1);
return d;
}
@ -235,14 +233,14 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
@Override
public void paint(Graphics g) {
Dimension d = getMinimumSize();
g.setColor(Color.white);
g.setColor(Configuration.lafTheme.isDark() ? Color.darkGray : Color.white);
g.fillRect(0, 0, d.width, d.height);
g.setColor(Color.black);
g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black);
g.setFont(font);
for (int n = 0; n < textLength; n++) {
if (n == (cursor % textLength))
cuadro(g, n * 3, 0, 2);
border(g, n * 3, 0, 2);
String s = "00" + Integer.toHexString(n);
s = s.substring(s.length() - 2);
printString(g, s, n * 3, 0);
@ -250,7 +248,7 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
}
}
private class Caja extends JPanel {
private class Cell extends JPanel {
private static final long serialVersionUID = -6124062720565016834L;
@Override
@ -270,10 +268,10 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
}
private class Filas extends JPanel {
private class Row extends JPanel {
private static final long serialVersionUID = 8797347523486018051L;
public Filas() {
public Row() {
this.setLayout(new BorderLayout(1, 1));
}
@ -287,7 +285,7 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
Dimension d = new Dimension();
FontMetrics fn = getFontMetrics(font);
int h = fn.getHeight();
int nl = getLineas();
int nl = getLines();
d.setSize((fn.stringWidth(" ") + 1) * (8) + (border * 2) + 1, h
* nl + (border * 2) + 1);
return d;
@ -297,18 +295,18 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
public void paint(Graphics g)
{
Dimension d = getMinimumSize();
g.setColor(Color.white);
g.setColor(Configuration.lafTheme.isDark() ? Color.darkGray : Color.white);
g.fillRect(0, 0, d.width, d.height);
g.setColor(Color.black);
g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black);
g.setFont(font);
int ini = getInicio();
int fin = ini + getLineas();
int ini = getBegin();
int fin = ini + getLines();
int y = 0;
for (int n = ini; n < fin; n++)
{
if (n == (cursor / textLength))
cuadro(g, 0, y, 8);
border(g, 0, y, 8);
String s = "0000000000000" + Integer.toHexString(n);
s = s.substring(s.length() - 8);
printString(g, s, 0, y++);

View file

@ -9,6 +9,7 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComponent;
import the.bytecode.club.bytecodeviewer.Configuration;
/**
* @author laullon
@ -41,7 +42,7 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis
FontMetrics fn = getFontMetrics(he.font);
int w = fn.stringWidth(" ");
int h = fn.getHeight();
int nl = he.getLineas();
int nl = he.getLines();
int len = he.textLength + 1;
int width = (len * w) + (he.border * 2) + 5;
@ -63,39 +64,39 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis
@Override
public void paint(Graphics g) {
debug("paint(" + g + ")");
debug("cursor=" + he.cursor + " buff.length=" + he.buff.length);
debug("cursor=" + he.cursor + " buff.length=" + he.buf.length);
Dimension d = getMinimumSize();
g.setColor(Color.white);
g.setColor(Configuration.lafTheme.isDark() ? Color.darkGray : Color.white);
g.fillRect(0, 0, d.width, d.height);
g.setColor(Color.black);
g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black);
g.setFont(he.font);
// datos ascii
int ini = he.getInicio() * he.textLength;
int fin = ini + (he.getLineas() * he.textLength);
if (fin > he.buff.length)
fin = he.buff.length;
// ASCII data
int start = he.getBegin() * he.textLength;
int stop = start + (he.getLines() * he.textLength);
if (stop > he.buf.length)
stop = he.buf.length;
int x = 0;
int y = 0;
for (int n = ini; n < fin; n++) {
for (int n = start; n < stop; n++) {
if (n == he.cursor) {
g.setColor(Color.blue);
if (hasFocus())
he.fondo(g, x, y, 1);
he.background(g, x, y, 1);
else
he.cuadro(g, x, y, 1);
he.border(g, x, y, 1);
if (hasFocus())
g.setColor(Color.white);
g.setColor(Configuration.lafTheme.isDark() ? Color.black : Color.white);
else
g.setColor(Color.black);
g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black);
} else {
g.setColor(Color.black);
g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black);
}
String s = String.valueOf((char) (he.buff[n] & 0xFF));//"" + new Character((char) he.buff[n]);
if ((he.buff[n] < 20) || (he.buff[n] > 126))
String s = String.valueOf((char) (he.buf[n] & 0xFF));//"" + new Character((char) he.buff[n]);
if ((he.buf[n] < 20) || (he.buf[n] > 126))
s = ".";//"" + (char) 16;
he.printString(g, s, (x++), y);
if (x == he.textLength) {
@ -111,20 +112,18 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis
System.out.println("JHexEditorASCII ==> " + s);
}
// calcular la posicion del raton
public int calcularPosicionRaton(int x, int y) {
public int calculateMousePosition(int x, int y) {
FontMetrics fn = getFontMetrics(he.font);
x = x / (fn.stringWidth(" ") + 1);
y = y / fn.getHeight();
debug("x=" + x + " ,y=" + y);
return x + ((y + he.getInicio()) * he.textLength);
return x + ((y + he.getBegin()) * he.textLength);
}
// mouselistener
@Override
public void mouseClicked(MouseEvent e) {
debug("mouseClicked(" + e + ")");
he.cursor = calcularPosicionRaton(e.getX(), e.getY());
he.cursor = calculateMousePosition(e.getX(), e.getY());
this.requestFocus();
he.repaint();
}

View file

@ -40,7 +40,7 @@ public class JHexEditorHEX extends JComponent implements MouseListener, KeyListe
public void paint(Graphics g)
{
debug("paint(" + g + ")");
debug("cursor=" + he.cursor + " buff.length=" + he.buff.length);
debug("cursor=" + he.cursor + " buff.length=" + he.buf.length);
if(!Configuration.lafTheme.isDark())
{
@ -56,25 +56,25 @@ public class JHexEditorHEX extends JComponent implements MouseListener, KeyListe
g.setFont(he.font);
int ini = he.getInicio() * he.textLength;
int fin = ini + (he.getLineas() * he.textLength);
if (fin > he.buff.length)
fin = he.buff.length;
int start = he.getBegin() * he.textLength;
int stop = start + (he.getLines() * he.textLength);
if (stop > he.buf.length)
stop = he.buf.length;
// datos hex
// HEX data
int x = 0;
int y = 0;
for (int n = ini; n < fin; n++) {
for (int n = start; n < stop; n++) {
if (n == he.cursor) {
if (hasFocus()) {
g.setColor(Color.black);
he.fondo(g, (x * 3), y, 2);
he.background(g, (x * 3), y, 2);
g.setColor(Color.blue);
int cursor = 0;
he.fondo(g, (x * 3) + cursor, y, 1);
he.background(g, (x * 3) + cursor, y, 1);
} else {
g.setColor(Color.blue);
he.cuadro(g, (x * 3), y, 2);
he.border(g, (x * 3), y, 2);
}
if (hasFocus())
@ -85,7 +85,7 @@ public class JHexEditorHEX extends JComponent implements MouseListener, KeyListe
g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black);
}
String s = ("0" + Integer.toHexString(he.buff[n]));
String s = ("0" + Integer.toHexString(he.buf[n]));
s = s.substring(s.length() - 2);
he.printString(g, s, ((x++) * 3), y);
if (x == he.textLength) {
@ -100,20 +100,18 @@ public class JHexEditorHEX extends JComponent implements MouseListener, KeyListe
System.out.println("JHexEditorHEX ==> " + s);
}
// calcular la posicion del raton
public int calcularPosicionRaton(int x, int y) {
public int calculateMousePosition(int x, int y) {
FontMetrics fn = getFontMetrics(he.font);
x = x / ((fn.stringWidth(" ") + 1) * 3);
y = y / fn.getHeight();
debug("x=" + x + " ,y=" + y);
return x + ((y + he.getInicio()) * he.textLength);
return x + ((y + he.getBegin()) * he.textLength);
}
// mouselistener
@Override
public void mouseClicked(MouseEvent e) {
debug("mouseClicked(" + e + ")");
he.cursor = calcularPosicionRaton(e.getX(), e.getY());
he.cursor = calculateMousePosition(e.getX(), e.getY());
this.requestFocus();
he.repaint();
}
@ -149,7 +147,7 @@ public class JHexEditorHEX extends JComponent implements MouseListener, KeyListe
* he.buff[he.cursor]=(byte)Integer.parseInt(new String(str),16);
*
* if(cursor!=1) cursor=1; else if(he.cursor!=(he.buff.length-1)){
* he.cursor++; cursor=0;} he.actualizaCursor(); }
* he.cursor++; cursor=0;} he.refreshCursor(); }
*/
}

View file

@ -237,5 +237,20 @@
"APK_CONVERSION_DECODING": "APK-Konvertierung",
"CFR_SETTINGS": "CFR-Einstellungen",
"FERNFLOWER_SETTINGS": "FernFlower Einstellungen",
"SUGGESTED_FIX_NO_DECOMPILER_WARNING": "WARNUNG: Derzeit ist kein Decompiler ausgewählt. Versuchen Sie Ansicht>Fenster und wählen Sie einen Decompiler."
"SUGGESTED_FIX_NO_DECOMPILER_WARNING": "ACHTUNG: Derzeit ist kein Dekompilierer ausgewählt. Versuchen Sie unter Ansicht>Fenster einen Dekompilierer auszuwählen.",
"RELOAD_RESOURCES_TITLE": "{PRODUCT_NAME} - Ressourcen neu laden",
"RELOAD_RESOURCES_CONFIRM": "Sind Sie sicher, dass Sie die Ressourcen neu laden möchten?",
"SELECT_FILE_TITLE": "Wählen Sie Datei oder Ordner zum Öffnen in {BCV}",
"SELECT_FILE_DESCRIPTION": "APKs, DEX, Klassen oder Zip/Jar/War-Archive",
"SELECT_EXTERNAL_PLUGIN_TITLE": "Externes Plugin auswählen",
"SELECT_EXTERNAL_PLUGIN_DESCRIPTION": "BCV Externes Plugin in js, java, python, ruby oder groovy",
"FOREIGN_LIBRARY_WARNING": "ACHTUNG: Wenn dies ausgeschaltet ist, werden veraltete Bibliotheken NICHT entfernt.\nDies stellt auch ein Sicherheitsproblem dar.\nSCHALTEN SIE ES NUR AUS, WENN SIE WISSEN, WAS SIE TUN.",
"EXIT_TITLE": "{PRODUCT_NAME} - Beenden",
"EXIT_CONFIRM": "Sind Sie sicher, dass Sie das Programm beenden wollen?",
"ABOUT_TITLE": "{PRODUCT_NAME} - Über - {WEBSITE} | {TBC}",
"PLUGIN_CONSOLE_TITLE": "{PRODUCT_NAME} - Plugin-Konsole",
"RESET_TITLE": "{PRODUCT_NAME} - Arbeitsbereich zurücksetzen",
"RESET_CONFIRM": "Sind Sie sicher, dass Sie den Arbeitsbereich zurücksetzen wollen?\n\rDadurch werden auch der Datei-Navigator und die Suche zurückgesetzt.",
"CLOSE_ALL_BUT_THIS": "Alle außer diesen schließen",
"CLOSE_TAB": "Tab schließen"
}