From c85f2f3d14a3095b00d51185262d5f08a03bb3a2 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 29 Jan 2022 12:55:30 -0500 Subject: [PATCH] fixing things up after #194 --- .../app/syntax/TextAreaPainter.java | 49 ++++++------------- todo.txt | 20 ++++---- 2 files changed, 25 insertions(+), 44 deletions(-) diff --git a/app/src/processing/app/syntax/TextAreaPainter.java b/app/src/processing/app/syntax/TextAreaPainter.java index 58094ef8d..c3fc76923 100644 --- a/app/src/processing/app/syntax/TextAreaPainter.java +++ b/app/src/processing/app/syntax/TextAreaPainter.java @@ -55,10 +55,6 @@ public class TextAreaPainter extends JComponent implements TabExpander { Token currentLineTokens; Segment currentLine; - // Debugging mono font handling and fractional screen resolutions - // https://github.com/processing/processing4/issues/342 - private final boolean THROWBACK = false; - /** * Creates a new repaint manager. This should be not be called directly. @@ -377,20 +373,12 @@ public class TextAreaPainter extends JComponent implements TabExpander { gfx.setFont(plainFont); y += fontMetrics.getHeight(); - // doesn't respect fixed width like it should - if (THROWBACK) { - // deprecated version - //x = Utilities.drawTabbedText(currentLine, x, y, gfx, this, 0); - // this wants returns floats for x, which requires more changes - x = (int) Utilities.drawTabbedText(currentLine, (float) x, (float) y, (Graphics2D) gfx, this, 0); - } else { - for (int i = 0; i < currentLine.count; i++) { - gfx.drawChars(currentLine.array, currentLine.offset + i, 1, x, y); - x = currentLine.array[currentLine.offset + i] == '\t' ? - x0 + (int) nextTabStop(x - x0, i) : - x + fontMetrics.charWidth(currentLine.array[currentLine.offset + i]); // TODO why this char? - //textArea.offsetToX(line, currentLine.offset + i); - } + for (int i = 0; i < currentLine.count; i++) { + gfx.drawChars(currentLine.array, currentLine.offset + i, 1, x, y); + x = currentLine.array[currentLine.offset + i] == '\t' ? + x0 + (int) nextTabStop(x - x0, i) : + x + fontMetrics.charWidth(currentLine.array[currentLine.offset + i]); // TODO why this char? + //textArea.offsetToX(line, currentLine.offset + i); } // Draw characters via input method. @@ -477,20 +465,13 @@ public class TextAreaPainter extends JComponent implements TabExpander { gfx.setFont(ss.isBold() ? boldFont : plainFont); } line.count = length; // huh? suspicious - // doesn't respect mono metrics, insists on spacing w/ fractional or something - if (THROWBACK) { - // Attempting with non-deprecated version. Rounding x isn't a problem - // because it's just the placement of eolmarkers after returning. - x = (int) Utilities.drawTabbedText(line, (float) x, (float) y, (Graphics2D) gfx, this, 0); - } else { - for (int i = 0; i < line.count; i++) { - gfx.drawChars(line.array, line.offset + i, 1, x, y); - x = line.array[line.offset + i] == '\t' ? - x0 + (int) nextTabStop(x - x0, i) : - x + fontMetrics.charWidth(line.array[line.offset + i]); - } - line.offset += length; + for (int i = 0; i < line.count; i++) { + gfx.drawChars(line.array, line.offset + i, 1, x, y); + x = line.array[line.offset + i] == '\t' ? + x0 + (int) nextTabStop(x - x0, i) : + x + fontMetrics.charWidth(line.array[line.offset + i]); } + line.offset += length; tokens = tokens.next; } @@ -541,10 +522,12 @@ public class TextAreaPainter extends JComponent implements TabExpander { if (selectionStartLine == selectionEndLine) { x1 = textArea._offsetToX(line, selectionStart - lineStart); x2 = textArea._offsetToX(line, selectionEnd - lineStart); - } else if(line == selectionStartLine) { + + } else if (line == selectionStartLine) { x1 = textArea._offsetToX(line, selectionStart - lineStart); x2 = getWidth(); - } else if(line == selectionEndLine) { + + } else if (line == selectionEndLine) { //x1 = 0; // hack from Stendahl to avoid doing weird side selection thing x1 = textArea._offsetToX(line, 0); diff --git a/todo.txt b/todo.txt index 1591a2604..92af16475 100755 --- a/todo.txt +++ b/todo.txt @@ -8,18 +8,16 @@ X when building on macOS, can't share folder b/c jdk zip is wrong arch X but also requires checkout of processing-docs, so an unnecessary headache X update themes with new token colors - scaling, text, again -_ Editor cursor position is offset to the right when display scaling >100% -_ https://github.com/processing/processing4/issues/226 -_ Remove the need for “Disable HiDPI Scaling” on Windows -_ https://github.com/processing/processing4/issues/342 -_ IDE cursor position is wrong if font size is changed in preferences on macOS -_ though at least one report that restarting the PDE doesn't fix the problem -_ probably related to second displays, need to hook one up and test -_ https://github.com/processing/processing4/issues/194 -_ seems like the Windows workaround may be making this worse? -_ users confirms the correctly working display swapped between beta 3 and 4 +X IDE cursor position is wrong if font size is changed in preferences on macOS +X though at least one report that restarting the PDE doesn't fix the problem +X probably related to second displays, need to hook one up and test +X https://github.com/processing/processing4/issues/194 +X seems like the Windows workaround may be making this worse? +X users confirms the correctly working display swapped between beta 3 and 4 +X also updated the two older bugs +X https://github.com/processing/processing4/issues/226 +X https://github.com/processing/processing4/issues/342 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .