mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 12:11:16 +00:00
BreakPoints UI enhancements - line icons
Breakpoints handling fixes
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package jsyntaxpane.components;
|
||||
|
||||
import java.awt.Graphics;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface LineMarkerPainter {
|
||||
|
||||
public void installLineMarker(LineNumbersBreakpointsRuler ruler);
|
||||
|
||||
public void paintLineMarker(Graphics g, int line, int x, int lineY, int textY, int lineHeight, boolean currentLine, int maxLines);
|
||||
}
|
||||
+43
@@ -13,11 +13,17 @@
|
||||
*/
|
||||
package jsyntaxpane.components;
|
||||
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import jsyntaxpane.SyntaxView;
|
||||
import jsyntaxpane.actions.ActionUtils;
|
||||
|
||||
/**
|
||||
@@ -29,6 +35,9 @@ public class LineNumbersBreakpointsRuler extends LineNumbersRuler {
|
||||
@Override
|
||||
public void install(final JEditorPane editor) {
|
||||
super.install(editor);
|
||||
if (editor instanceof LineMarkerPainter) {
|
||||
((LineMarkerPainter) editor).installLineMarker(this);
|
||||
}
|
||||
removeMouseListener(mouseListener);
|
||||
mouseListener = new MouseAdapter() {
|
||||
|
||||
@@ -54,4 +63,38 @@ public class LineNumbersBreakpointsRuler extends LineNumbersRuler {
|
||||
addMouseListener(mouseListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
if (editor instanceof LineMarkerPainter) {
|
||||
FontMetrics fontMetrics = editor.getFontMetrics(editor.getFont());
|
||||
int lh = fontMetrics.getHeight();
|
||||
Rectangle bounds = g.getClipBounds();
|
||||
int minY = bounds.y;
|
||||
int maxY = minY + bounds.height;
|
||||
int maxLines = ActionUtils.getLineCount(editor);
|
||||
Insets insets = getInsets();
|
||||
|
||||
int currentLine = -1;
|
||||
try {
|
||||
// get current line, and add one as we start from 1 for the display
|
||||
currentLine = ActionUtils.getLineNumber(editor, editor.getCaretPosition()) + 1;
|
||||
} catch (BadLocationException ex) {
|
||||
// this wont happen, even if it does, we can ignore it and we will not have
|
||||
// a current line to worry about...
|
||||
}
|
||||
|
||||
for (int line = 1; line <= maxLines; line++) {
|
||||
int y = line * lh;
|
||||
if (y < minY) {
|
||||
continue;
|
||||
}
|
||||
if (y - lh > maxY) {
|
||||
break;
|
||||
}
|
||||
((LineMarkerPainter) editor).paintLineMarker(g, line, insets.left, y - lh + fontMetrics.getDescent() - 1, y, lh, currentLine == line, maxLines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public class LineNumbersRuler extends JPanel
|
||||
private Status status;
|
||||
private final static int HEIGHT = Integer.MAX_VALUE - 1000000;
|
||||
// Text component this TextTextLineNumber component is in sync with
|
||||
private JEditorPane editor;
|
||||
protected JEditorPane editor; //JPEXS: changed to protected
|
||||
private int minimumDisplayDigits = 2;
|
||||
// Keep history information to reduce the number of times the component
|
||||
// needs to be repainted
|
||||
|
||||
Reference in New Issue
Block a user