Skip to content

Commit

Permalink
Add ability to use 'CTRL' + LMB for go to action.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bl3nd committed Sep 24, 2024
1 parent 9a08a5f commit 06e6117
Showing 1 changed file with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.*;
import java.util.Objects;
import java.util.regex.Matcher;

Expand Down Expand Up @@ -434,6 +433,48 @@ else if (isPanelEditable && decompiler == Decompiler.KRAKATAU_DISASSEMBLER)
bytecodeViewPanel.textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK), "goToAction");
bytecodeViewPanel.textArea.getActionMap().put("goToAction", new GoToAction(classFileContainer));

bytecodeViewPanel.textArea.addMouseMotionListener(new MouseMotionAdapter()
{
@Override
public void mouseMoved(MouseEvent e)
{
if (e.isControlDown())
{
RSyntaxTextArea textArea = (RSyntaxTextArea) e.getSource();
Token token = textArea.viewToToken(e.getPoint());
if (token != null)
{
String lexeme = token.getLexeme();
if (classFileContainer.fieldMembers.containsKey(lexeme) || classFileContainer.methodMembers.containsKey(lexeme)
|| classFileContainer.methodLocalMembers.containsKey(lexeme) || classFileContainer.methodParameterMembers.containsKey(lexeme)
|| classFileContainer.classReferences.containsKey(lexeme))
{
textArea.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
}
} else
{
if (bytecodeViewPanel.textArea.getCursor().getType() != Cursor.TEXT_CURSOR)
{
bytecodeViewPanel.textArea.setCursor(new Cursor(Cursor.TEXT_CURSOR));
}
}
}
});

bytecodeViewPanel.textArea.addMouseListener(new MouseAdapter()
{
@Override
public void mouseClicked(MouseEvent e)
{
if (e.isControlDown())
{
RSyntaxTextArea textArea = (RSyntaxTextArea) e.getSource();
textArea.getActionMap().get("goToAction").actionPerformed(new ActionEvent(textArea, ActionEvent.ACTION_PERFORMED, "goToAction"));
}
}
});

markerCaretListener = new MarkerCaretListener(classContainerName);
bytecodeViewPanel.textArea.addCaretListener(markerCaretListener);
}
Expand Down

0 comments on commit 06e6117

Please sign in to comment.