--- src-swt/org/eclipse/swt/custom/StyledText.java.orig 2004-03-03 21:27:59.000000000 +0100 +++ src-swt/org/eclipse/swt/custom/StyledText.java 2004-03-03 22:00:08.000000000 +0100 @@ -6055,6 +6055,10 @@ * @param startY y pixel location to start rendering at * @param renderHeight renderHeight widget area that needs to be filled with lines */ +private Image lineBuffer; +private GC lineGC; +private Point lastLineSize = new Point (0,0); + void performPaint(GC gc,int startLine,int startY, int renderHeight) { Rectangle clientArea = getClientArea(); Color background = getBackground(); @@ -6077,8 +6081,33 @@ startLine = 1; } } - Image lineBuffer = new Image(getDisplay(), clientArea.width, renderHeight); - GC lineGC = new GC(lineBuffer, gcStyle); + //Image lineBuffer = new Image(getDisplay(), clientArea.width, renderHeight); + //GC lineGC = new GC(lineBuffer, gcStyle); + boolean clearBuffer = true; + if (1 == 0 || lineBuffer == null + || lastLineSize.x < clientArea.width + || lastLineSize.y < renderHeight + + ) + { + if (lineGC != null) + lineGC.dispose (); + if (lineBuffer != null) + lineBuffer.dispose (); + lineBuffer = new Image(getDisplay(), clientArea.width, + renderHeight); + lineGC = new GC(lineBuffer, gcStyle); + System.out.println ("Creating new buffer"); + lastLineSize.x = clientArea.width; + lastLineSize.y = renderHeight; + clearBuffer = false; + } + if (clearBuffer) { + lineGC.setBackground(background); + lineGC.setForeground(background); + lineGC.fillRectangle(0, 0, clientArea.width, + renderHeight - paintY); + } lineGC.setFont(getFont()); renderer.setCurrentFontStyle(SWT.NORMAL); @@ -6094,12 +6123,23 @@ lineGC.setForeground(background); lineGC.fillRectangle(0, paintY, clientArea.width, renderHeight - paintY); } - gc.drawImage(lineBuffer, 0, startY); - lineGC.dispose(); - lineBuffer.dispose(); + //gc.drawImage(lineBuffer, 0, startY); + gc.drawImage(lineBuffer, 0, 0, clientArea.width, renderHeight, 0, startY, clientArea.width, renderHeight); + //lineGC.dispose(); + //lineBuffer.dispose(); } clearMargin(gc, background, clientArea, renderHeight); } + +public void dispose () +{ + if (lineGC != null) + lineGC.dispose (); + if (lineBuffer != null) + lineBuffer.dispose (); + super.dispose (); +} + /** * Prints the widget's text to the default printer. *