fixing things up after #194

This commit is contained in:
Ben Fry
2022-01-29 12:55:30 -05:00
parent 3e566e8fe7
commit c85f2f3d14
2 changed files with 25 additions and 44 deletions

View File

@@ -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);

View File

@@ -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
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .