diff --git a/terminal/features/org.eclipse.tm.terminal.control.feature/feature.xml b/terminal/features/org.eclipse.tm.terminal.control.feature/feature.xml index c1966c85670..53af7622cb9 100644 --- a/terminal/features/org.eclipse.tm.terminal.control.feature/feature.xml +++ b/terminal/features/org.eclipse.tm.terminal.control.feature/feature.xml @@ -16,7 +16,7 @@ = getTerminalText().getHeight() || colFirst >= getTerminalText().getWidth() || colFirst - colLast == 0) { - fillBackground(gc, x, y, getCellWidth() * (colLast - colFirst), getCellHeight()); + fillBackground(doubleBufferGC, 0, 0, width, height); } else { colLast = Math.min(colLast, getTerminalText().getWidth()); LineSegment[] segments = getTerminalText().getLineSegments(line, colFirst, colLast - colFirst); for (int i = 0; i < segments.length; i++) { LineSegment segment = segments[i]; Style style = segment.getStyle(); - setupGC(gc, style); + setupGC(doubleBufferGC, style); String text = segment.getText(); - drawText(gc, x, y, colFirst, segment.getColumn(), text); - drawCursor(model, gc, line, x, y, colFirst); + drawText(doubleBufferGC, 0, 0, colFirst, segment.getColumn(), text); + drawCursor(model, doubleBufferGC, line, 0, 0, colFirst); } if (fModel.hasLineSelection(line)) { - gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); - gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); + doubleBufferGC.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); + doubleBufferGC.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); Point start = model.getSelectionStart(); Point end = model.getSelectionEnd(); char[] chars = model.getTerminalText().getChars(line); - if (chars == null) - return; - int offset = 0; - if (start.y == line) - offset = start.x; - offset = Math.max(offset, colFirst); - int len; - if (end.y == line) - len = end.x - offset + 1; - else - len = chars.length - offset + 1; - len = Math.min(len, chars.length - offset); - if (len > 0) { - String text = new String(chars, offset, len); - drawText(gc, x, y, colFirst, offset, text); + if (chars != null) { + int offset = 0; + if (start.y == line) + offset = start.x; + offset = Math.max(offset, colFirst); + int len; + if (end.y == line) + len = end.x - offset + 1; + else + len = chars.length - offset + 1; + len = Math.min(len, chars.length - offset); + if (len > 0) { + String text = new String(chars, offset, len); + drawText(doubleBufferGC, 0, 0, colFirst, offset, text); + } } } } + gc.drawImage(buffer, x, y); + doubleBufferGC.dispose(); + buffer.dispose(); } private void fillBackground(GC gc, int x, int y, int width, int height) {