Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from Konloch:master #56

Merged
merged 5 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<annotations.version>24.1.0</annotations.version>
<apktool.version>2.9.1</apktool.version>
<asm.version>9.6</asm.version>
<bined.version>0.2.0</bined.version>
<bined.version>0.2.1</bined.version>
<byteanalysis.version>1.0bcv</byteanalysis.version>
<cfr.version>0.152</cfr.version>
<cloning.version>1.9.12</cloning.version>
Expand All @@ -41,7 +41,7 @@
<jgraphx.version>3.4.1.3</jgraphx.version>
<js.version>21.2.0</js.version>
<objenesis.version>3.3</objenesis.version>
<paged-data.version>0.2.0</paged-data.version>
<binary-data.version>0.2.1</binary-data.version>
<procyon.version>0.6.0</procyon.version>
<rsyntaxtextarea.version>3.3.4</rsyntaxtextarea.version>
<semantic-version.version>2.1.1</semantic-version.version>
Expand Down Expand Up @@ -242,8 +242,13 @@
</dependency>
<dependency>
<groupId>org.exbin.auxiliary</groupId>
<artifactId>paged_data</artifactId>
<version>${paged-data.version}</version>
<artifactId>binary_data</artifactId>
<version>${binary-data.version}</version>
</dependency>
<dependency>
<groupId>org.exbin.auxiliary</groupId>
<artifactId>binary_data-paged</artifactId>
<version>${binary-data.version}</version>
</dependency>
<dependency>
<groupId>org.bitbucket.mstrobel</groupId>
Expand Down
39 changes: 37 additions & 2 deletions src/main/java/the/bytecode/club/bytecodeviewer/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.PrintStream;

import org.objectweb.asm.Opcodes;
import the.bytecode.club.bytecodeviewer.resources.ResourceType;

Expand Down Expand Up @@ -68,8 +69,7 @@ public class Constants
public static final String fs = System.getProperty("file.separator");
public static final String nl = System.getProperty("line.separator");

//TODO check if $HOME/.local/share exists, if so reference from there instead - #250
public static final File BCVDir = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer");
public static final File BCVDir = resolveBCVRoot();
public static final File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
public static final File JAVA_BINARY = new File(System.getProperty("java.home") + fs + "bin" + fs + "java.exe");
public static final File JAVA_BINARY_NIX = new File(System.getProperty("java.home") + fs + "bin" + fs + "java");
Expand All @@ -88,6 +88,30 @@ public class Constants
public static final PrintStream ERR = System.err;
public static final PrintStream OUT = System.out;

public static File resolveBCVRoot()
{
File defaultLocation = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer");

//if BCV was previously installed using the default directory, continue to use that
if(defaultLocation.exists())
return defaultLocation;

//handle XDG Base Directory - https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
if(isNix())
{
File homeLocal = new File(System.getProperty("user.home") + fs + ".local");
if(homeLocal.exists())
return new File(homeLocal, "share" + fs + ".Bytecode-Viewer");

File homeConfig = new File(System.getProperty("user.home") + fs + ".config");
if(homeConfig.exists())
return new File(homeConfig, ".Bytecode-Viewer");
}

//return BCV default location
return defaultLocation;
}

/**
* Returns the BCV directory
*
Expand Down Expand Up @@ -126,6 +150,17 @@ private static boolean isWindows()
return System.getProperty("os.name").toLowerCase().contains("win");
}

/**
* Checks if the OS contains 'nix', 'nux', or 'bsd'
*
* @return true if the os.name property contains 'nix', 'nux', or 'bsd'
*/
private static boolean isNix()
{
String os = System.getProperty("os.name").toLowerCase();
return os.contains("nix") || os.contains("nux") || os.contains("bsd");
}

/**
* Detects developer mode or returns the current version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.hexviewer;

import org.exbin.auxiliary.paged_data.ByteArrayData;
import org.exbin.auxiliary.binary_data.ByteArrayData;
import org.exbin.bined.CodeAreaCaretPosition;
import org.exbin.bined.CodeType;
import org.exbin.bined.EditMode;
Expand Down Expand Up @@ -37,6 +37,7 @@ public class HexViewer extends JPanel {
public HexViewer(byte[] contentData) {
super(new BorderLayout());
codeArea = new CodeArea();
codeArea.setFocusTraversalKeysEnabled(false);
codeArea.setPainter(new HighlightNonAsciiCodeAreaPainter(codeArea));
toolBar = new JToolBar();
statusPanel = new BinaryStatusPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.exbin.bined.CodeAreaCaretPosition;
import org.exbin.bined.DataChangedListener;
import org.exbin.bined.swing.basic.CodeArea;
import org.exbin.auxiliary.paged_data.BinaryData;
import org.exbin.bined.capability.EditModeCapable;
import org.exbin.auxiliary.binary_data.BinaryData;

/**
* Values side panel.
Expand Down Expand Up @@ -711,7 +710,7 @@ private boolean isSigned() {
}

private boolean isEditable() {
return ((EditModeCapable) codeArea).isEditable();
return codeArea.isEditable();
}

private ByteOrder getByteOrder() {
Expand Down