Skip to content
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
6 changes: 3 additions & 3 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.11.0</apktool.version>
<asm.version>9.7</asm.version>
<bined.version>0.2.1</bined.version>
<bined.version>0.2.2</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.4</objenesis.version>
<binary-data.version>0.2.1</binary-data.version>
<binary-data.version>0.2.2</binary-data.version>
<procyon.version>0.6.0</procyon.version>
<rsyntaxtextarea.version>3.5.2</rsyntaxtextarea.version> <!-- Upcoming 4.0 release will require Java 11+ -->
<semantic-version.version>2.1.1</semantic-version.version>
Expand Down Expand Up @@ -251,7 +251,7 @@
</dependency>
<dependency>
<groupId>org.exbin.auxiliary</groupId>
<artifactId>binary_data-paged</artifactId>
<artifactId>binary_data-array</artifactId>
<version>${binary-data.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@

package the.bytecode.club.bytecodeviewer.gui.hexviewer;

import org.exbin.auxiliary.binary_data.ByteArrayData;
import org.exbin.auxiliary.binary_data.array.ByteArrayData;
import org.exbin.bined.CodeAreaCaretPosition;
import org.exbin.bined.CodeType;
import org.exbin.bined.EditMode;
import org.exbin.bined.RowWrappingMode;
import org.exbin.bined.highlight.swing.HighlightNonAsciiCodeAreaPainter;
import org.exbin.bined.swing.basic.CodeArea;

import javax.annotation.Nonnull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import org.exbin.bined.highlight.swing.NonAsciiCodeAreaColorAssessor;
import org.exbin.bined.swing.basic.DefaultCodeAreaPainter;

/**
* Binary/hexadecimal viewer based on BinEd library.
Expand All @@ -57,9 +58,10 @@ public HexViewer(byte[] contentData)
{
super(new BorderLayout());
codeArea = new CodeArea();
codeArea.setFocusTraversalKeysEnabled(false);
codeArea.setPainter(new HighlightNonAsciiCodeAreaPainter(codeArea));
DefaultCodeAreaPainter painter = (DefaultCodeAreaPainter) codeArea.getPainter();
painter.setColorAssessor(new NonAsciiCodeAreaColorAssessor(painter.getColorAssessor()));
toolBar = new JToolBar();
toolBar.setFloatable(false);
statusPanel = new BinaryStatusPanel()
{
@Override
Expand Down Expand Up @@ -91,7 +93,7 @@ public void actionPerformed(ActionEvent e)
public void actionPerformed(ActionEvent e)
{
final GoToBinaryPanel goToPanel = new GoToBinaryPanel();
goToPanel.setCursorPosition(codeArea.getCaret().getCaretPosition().getDataPosition());
goToPanel.setCursorPosition(codeArea.getActiveCaretPosition().getDataPosition());
goToPanel.setMaxPosition(codeArea.getDataSize());
final JDialog dialog = new JDialog((JFrame) SwingUtilities.getRoot(HexViewer.this), Dialog.ModalityType.APPLICATION_MODAL);
OkCancelPanel okCancelPanel = new OkCancelPanel()
Expand All @@ -100,7 +102,7 @@ public void actionPerformed(ActionEvent e)
protected void okAction()
{
goToPanel.acceptInput();
codeArea.setCaretPosition(goToPanel.getTargetPosition());
codeArea.setActiveCaretPosition(goToPanel.getTargetPosition());
codeArea.revealCursor();
dialog.setVisible(false);
dialog.dispose();
Expand Down Expand Up @@ -348,10 +350,12 @@ public void actionPerformed(ActionEvent e)
});
viewMenu.add(showValuesPanelMenuItem);
JCheckBoxMenuItem codeColorizationMenuItem = new JCheckBoxMenuItem("Code Colorization");
codeColorizationMenuItem.setSelected(((HighlightNonAsciiCodeAreaPainter) codeArea.getPainter()).isNonAsciiHighlightingEnabled());
DefaultCodeAreaPainter painter = (DefaultCodeAreaPainter) codeArea.getPainter();
NonAsciiCodeAreaColorAssessor colorAssessor = (NonAsciiCodeAreaColorAssessor) painter.getColorAssessor();
codeColorizationMenuItem.setSelected(colorAssessor.isNonAsciiHighlightingEnabled());
codeColorizationMenuItem.addActionListener((event) ->
{
((HighlightNonAsciiCodeAreaPainter) codeArea.getPainter()).setNonAsciiHighlightingEnabled(codeColorizationMenuItem.isSelected());
colorAssessor.setNonAsciiHighlightingEnabled(codeColorizationMenuItem.isSelected());
menu.setVisible(false);
});
viewMenu.add(codeColorizationMenuItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package the.bytecode.club.bytecodeviewer.gui.hexviewer;

import org.exbin.auxiliary.binary_data.BinaryData;
import org.exbin.bined.CaretMovedListener;
import org.exbin.bined.CodeAreaCaretPosition;
import org.exbin.bined.DataChangedListener;
import org.exbin.bined.swing.basic.CodeArea;
Expand All @@ -28,11 +27,13 @@
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.math.BigInteger;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Objects;
import org.exbin.bined.CodeAreaCaretListener;

/**
* Values side panel.
Expand All @@ -56,7 +57,7 @@ public class ValuesPanel extends javax.swing.JPanel
private CodeArea codeArea;
private long dataPosition;
private DataChangedListener dataChangedListener;
private CaretMovedListener caretMovedListener;
private CodeAreaCaretListener caretMovedListener;

private final byte[] valuesCache = new byte[CACHE_SIZE];
private final ByteBuffer byteBuffer = ByteBuffer.wrap(valuesCache);
Expand Down Expand Up @@ -496,7 +497,7 @@ private void longTextFieldKeyReleased(java.awt.event.KeyEvent evt)
{
long longValue = Long.parseLong(longTextField.getText());

byteBuffer.rewind();
((Buffer) byteBuffer).rewind();
if (byteBuffer.order() != byteOrder)
byteBuffer.order(byteOrder);

Expand Down Expand Up @@ -547,7 +548,7 @@ private void floatTextFieldKeyReleased(java.awt.event.KeyEvent evt)
ByteOrder byteOrder = getByteOrder();
float floatValue = Float.parseFloat(floatTextField.getText());

byteBuffer.rewind();
((Buffer) byteBuffer).rewind();

if (byteBuffer.order() != byteOrder)
byteBuffer.order(byteOrder);
Expand All @@ -573,7 +574,7 @@ private void doubleTextFieldKeyReleased(java.awt.event.KeyEvent evt)
ByteOrder byteOrder = getByteOrder();
double doubleValue = Double.parseDouble(doubleTextField.getText());

byteBuffer.rewind();
((Buffer) byteBuffer).rewind();

if (byteBuffer.order() != byteOrder)
byteBuffer.order(byteOrder);
Expand Down Expand Up @@ -696,7 +697,7 @@ public void updateEditMode()

public void updateValues()
{
CodeAreaCaretPosition caretPosition = codeArea.getCaretPosition();
CodeAreaCaretPosition caretPosition = codeArea.getActiveCaretPosition();
dataPosition = caretPosition.getDataPosition();
long dataSize = codeArea.getDataSize();

Expand Down Expand Up @@ -800,7 +801,6 @@ private void updateValue(ValuesPanelField valuesPanelField)
long dataSize = codeArea.getDataSize();

clearFields = dataPosition >= dataSize;
byteOrder = littleEndianRadioButton.isSelected() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN;
byteOrder = getByteOrder();
signed = isSigned();
values = valuesCache;
Expand Down Expand Up @@ -913,7 +913,7 @@ private void updateField(ValuesPanelField valuesPanelField)
{
if (signed)
{
byteBuffer.rewind();
((Buffer) byteBuffer).rewind();

if (byteBuffer.order() != byteOrder)
byteBuffer.order(byteOrder);
Expand All @@ -933,7 +933,7 @@ private void updateField(ValuesPanelField valuesPanelField)

case FLOAT:
{
byteBuffer.rewind();
((Buffer) byteBuffer).rewind();

if (byteBuffer.order() != byteOrder)
byteBuffer.order(byteOrder);
Expand All @@ -944,7 +944,7 @@ private void updateField(ValuesPanelField valuesPanelField)

case DOUBLE:
{
byteBuffer.rewind();
((Buffer) byteBuffer).rewind();

if (byteBuffer.order() != byteOrder)
byteBuffer.order(byteOrder);
Expand Down