From 871d2953950fcb401e9331d85b73e7d00f72f6eb Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Fri, 11 Sep 2026 11:01:42 +0200 Subject: [PATCH] Draw squiggles and folding dots in points on scaled displays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SquigglesStrategy draws with line width 0 and the collapsed region marker draws its dots with drawPoint. On Windows both stay one device pixel while the geometry around them scales with the zoom. Use a 1 point antialiased line and 1 point squares, which matches what GTK already renders. Assisted-by: multiple AI agents and layers of automated tooling 🤖 --- .../jface/text/source/projection/ProjectionSupport.java | 8 ++++++-- .../org/eclipse/jface/text/source/AnnotationPainter.java | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java b/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java index beb5bb57fe1..b51cf1d133b 100644 --- a/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java +++ b/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java @@ -98,7 +98,9 @@ public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset Point p= textWidget.getLocationAtOffset(lineEnd); Color c= gc.getForeground(); + Color bg= gc.getBackground(); gc.setForeground(color); + gc.setBackground(color); FontMetrics metrics= gc.getFontMetrics(); @@ -117,10 +119,12 @@ public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset gc.drawRectangle(p.x, p.y + leading, (int) width, height); int third= (int) (width / 3); int dotsVertical= p.y + baseline - 1; - gc.drawPoint(p.x + third, dotsVertical); - gc.drawPoint((int) (p.x + width - third), dotsVertical); + // drawPoint stays one device pixel on Windows + gc.fillRectangle(p.x + third, dotsVertical, 1, 1); + gc.fillRectangle((int) (p.x + width - third), dotsVertical, 1, 1); gc.setForeground(c); + gc.setBackground(bg); } else { textWidget.redrawRange(offset, length, true); diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java index 959f92777b0..05fb1761228 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java @@ -130,10 +130,16 @@ public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset int[] polyline= computePolyline(left, right, textWidget.getBaseline(offset), textWidget.getLineHeight(offset)); - gc.setLineWidth(0); // NOTE: 0 means width is 1 but with optimized performance + // width 0 stays one device pixel on Windows while the zigzag scales + int lineWidth= gc.getLineWidth(); + gc.setLineWidth(1); gc.setLineStyle(SWT.LINE_SOLID); gc.setForeground(color); + int antialias= gc.getAntialias(); + gc.setAntialias(SWT.ON); gc.drawPolyline(polyline); + gc.setAntialias(antialias); + gc.setLineWidth(lineWidth); } else { textWidget.redrawRange(offset, length, true);