|
@@ -27,6 +27,7 @@ import com.dmdirc.ui.messages.LinePosition;
|
27
|
27
|
|
28
|
28
|
import java.awt.Color;
|
29
|
29
|
import java.awt.Graphics2D;
|
|
30
|
+import java.awt.Rectangle;
|
30
|
31
|
import java.awt.Shape;
|
31
|
32
|
import java.awt.font.LineBreakMeasurer;
|
32
|
33
|
import java.awt.font.TextAttribute;
|
|
@@ -132,7 +133,7 @@ public class BasicTextLineRenderer implements LineRenderer {
|
132
|
133
|
final TextLayout layout) {
|
133
|
134
|
graphics.setColor(textPane.getForeground());
|
134
|
135
|
layout.draw(graphics, drawPosX, drawPosY);
|
135
|
|
- doHighlight(line, chars, layout, graphics, drawPosX, drawPosY);
|
|
136
|
+ doHighlight(line, chars, layout, graphics, (int) canvasWidth + DOUBLE_SIDE_PADDING, drawPosX, drawPosY);
|
136
|
137
|
final LineInfo lineInfo = new LineInfo(line, numberOfWraps);
|
137
|
138
|
result.firstVisibleLine = line;
|
138
|
139
|
result.textLayouts.put(lineInfo, layout);
|
|
@@ -154,7 +155,7 @@ public class BasicTextLineRenderer implements LineRenderer {
|
154
|
155
|
* @param drawPosY current y location of the line
|
155
|
156
|
*/
|
156
|
157
|
protected void doHighlight(final int line, final int chars,
|
157
|
|
- final TextLayout layout, final Graphics2D g,
|
|
158
|
+ final TextLayout layout, final Graphics2D g, final int canvasWidth,
|
158
|
159
|
final float drawPosX, final float drawPosY) {
|
159
|
160
|
final LinePosition selectedRange = textPaneCanvas.getSelectedRange();
|
160
|
161
|
final int selectionStartLine = selectedRange.getStartLine();
|
|
@@ -184,14 +185,16 @@ public class BasicTextLineRenderer implements LineRenderer {
|
184
|
185
|
// If the selection includes the chars we're showing
|
185
|
186
|
if (lastChar > 0 && firstChar < layout.getCharacterCount() && lastChar > firstChar) {
|
186
|
187
|
doHighlight(line,
|
187
|
|
- layout.getLogicalHighlightShape(firstChar, lastChar), g,
|
188
|
|
- drawPosY, drawPosX, chars + firstChar, chars + lastChar);
|
|
188
|
+ layout.getLogicalHighlightShape(firstChar, lastChar), g, canvasWidth,
|
|
189
|
+ drawPosY, drawPosX, chars + firstChar, chars + lastChar,
|
|
190
|
+ lastChar == layout.getCharacterCount());
|
189
|
191
|
}
|
190
|
192
|
}
|
191
|
193
|
}
|
192
|
194
|
|
193
|
195
|
private void doHighlight(final int line, final Shape logicalHighlightShape, final Graphics2D g,
|
194
|
|
- final float drawPosY, final float drawPosX, final int firstChar, final int lastChar) {
|
|
196
|
+ final int canvasWidth, final float drawPosY, final float drawPosX,
|
|
197
|
+ final int firstChar, final int lastChar, final boolean isEndOfLine) {
|
195
|
198
|
final AttributedCharacterIterator iterator = document.getStyledLine(line);
|
196
|
199
|
final AttributedString as = new AttributedString(iterator, firstChar, lastChar);
|
197
|
200
|
|
|
@@ -199,7 +202,18 @@ public class BasicTextLineRenderer implements LineRenderer {
|
199
|
202
|
as.addAttribute(TextAttribute.BACKGROUND, highlightBackground);
|
200
|
203
|
final TextLayout newLayout = new TextLayout(as.getIterator(), g.getFontRenderContext());
|
201
|
204
|
|
202
|
|
- newLayout.draw(g, (float) (drawPosX + logicalHighlightShape.getBounds().getX()), drawPosY);
|
|
205
|
+ final Rectangle bounds = logicalHighlightShape.getBounds();
|
|
206
|
+ g.setColor(highlightBackground);
|
|
207
|
+
|
|
208
|
+ if (isEndOfLine) {
|
|
209
|
+ g.fillRect(bounds.x + bounds.width,
|
|
210
|
+ (int) (1 + drawPosY - newLayout.getAscent() - newLayout.getLeading()),
|
|
211
|
+ canvasWidth - bounds.x - bounds.width,
|
|
212
|
+ (int) (1 + newLayout.getAscent() + newLayout.getLeading()
|
|
213
|
+ + newLayout.getDescent()));
|
|
214
|
+ }
|
|
215
|
+
|
|
216
|
+ newLayout.draw(g, (float) (drawPosX + bounds.getX()), drawPosY);
|
203
|
217
|
}
|
204
|
218
|
|
205
|
219
|
}
|