Hi, this patch fixes the broken up/down movement in JTextArea /w lineWrap=true[0] (which use a WrappedPlainView). The faulty behavior was actually caused by some tiny bugs in the implementation of BoxView.getViewAtPoint and WrappedPlainView.WrappedLine.viewToModel().
The ChangeLog:
2006-04-01 Robert Schuster <[EMAIL PROTECTED]>
* javax/swing/text/WrappedPlainView.java:
(WrappedLine.viewToModel): Change < to <= in if-statement,
removed addition of currLineStart to return value.
* javax/swing/text/BoxView.java:
(getViewAtPoint): Use copy instead of r for method call
which modifies the second argument.
cya
Robert
[0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26843
Index: javax/swing/text/WrappedPlainView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/WrappedPlainView.java,v
retrieving revision 1.11
diff -u -r1.11 WrappedPlainView.java
--- javax/swing/text/WrappedPlainView.java 10 Mar 2006 22:14:53 -0000 1.11
+++ javax/swing/text/WrappedPlainView.java 1 Apr 2006 12:48:41 -0000
@@ -588,14 +588,14 @@
int currLineEnd = calculateBreakPosition(currLineStart, end);
// If we're at the right y-position that means we're on the right
// logical line and we should look for the character
- if (y >= rect.y && y < rect.y + lineHeight)
+ if (y >= rect.y && y <= rect.y + lineHeight)
{
// Check if the x position is to the left or right of the text
if (x < rect.x)
return currLineStart;
if (x > rect.x + rect.width)
return currLineEnd - 1;
-
+
try
{
getDocument().getText(currLineStart, end - currLineStart, s);
@@ -604,11 +604,11 @@
{
// Shouldn't happen
}
- int mark = Utilities.getTabbedTextOffset(s, metrics, rect.x,
- (int) x,
- WrappedPlainView.this,
- currLineStart);
- return currLineStart + mark;
+
+ return Utilities.getTabbedTextOffset(s, metrics, rect.x,
+ (int) x,
+ WrappedPlainView.this,
+ currLineStart);
}
// Increment rect.y so we're checking the next logical line
rect.y += lineHeight;
Index: javax/swing/text/BoxView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/BoxView.java,v
retrieving revision 1.16
diff -u -r1.16 BoxView.java
--- javax/swing/text/BoxView.java 28 Mar 2006 10:58:36 -0000 1.16
+++ javax/swing/text/BoxView.java 1 Apr 2006 12:48:42 -0000
@@ -591,7 +591,8 @@
for (int i = 0; i < count; ++i)
{
copy.setBounds(r);
- childAllocation(i, r);
+ // The next call modifies copy.
+ childAllocation(i, copy);
if (copy.contains(x, y))
{
result = getView(i);
signature.asc
Description: OpenPGP digital signature
