From ec57b279a1ad10a47a228fe0d2cfe9643b8c167f Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Sat, 22 May 2010 00:07:35 +0000 Subject: [PATCH] Bug 294468 - [terminal] When a horizontal scrollbar is visible, terminal size is missing 1 line --- .../internal/terminal/textcanvas/ILinelRenderer.java | 5 ++++- .../tm/internal/terminal/textcanvas/TextCanvas.java | 6 ++++-- .../internal/terminal/textcanvas/TextLineRenderer.java | 10 +++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java index c957d98a18a..8595b0ae234 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,9 +7,11 @@ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation + * Anton Leherbauer (Wind River) - [294468] Fix scroller and text line rendering *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; /** @@ -21,4 +23,5 @@ public interface ILinelRenderer { void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast); void onFontChange(); void setInvertedColors(boolean invert); + Color getDefaultBackgroundColor(); } diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 48f9eae2f79..7c314a57036 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -24,6 +24,7 @@ import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; @@ -278,7 +279,6 @@ public class TextCanvas extends GridCanvas { } /** * If set then if the size changes - * @param scrollLock */ public void setScrollLock(boolean scrollLock) { fScrollLock=scrollLock; @@ -290,7 +290,9 @@ public class TextCanvas extends GridCanvas { } protected void drawLine(GC gc, int line, int x, int y, int colFirst, int colLast) { fCellRenderer.drawLine(fCellCanvasModel, gc,line,x,y,colFirst, colLast); - + } + protected Color getTerminalBackgroundColor() { + return fCellRenderer.getDefaultBackgroundColor(); } protected void visibleCellRectangleChanged(int x, int y, int width, int height) { fCellCanvasModel.setVisibleRectangle(y,x,height,width); diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index da6adb7bbaf..e36be513f6c 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -29,10 +29,8 @@ import org.eclipse.tm.terminal.model.Style; public class TextLineRenderer implements ILinelRenderer { private final ITextCanvasModel fModel; StyleMap fStyleMap=new StyleMap(); - Color fBackgroundColor; public TextLineRenderer(TextCanvas c, ITextCanvasModel model) { fModel=model; - fBackgroundColor=Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND); } /* (non-Javadoc) * @see com.imagicus.thumbs.view.ICellRenderer#getCellWidth() @@ -88,15 +86,17 @@ public class TextLineRenderer implements ILinelRenderer { private void fillBackground(GC gc, int x, int y, int width, int height) { Color bg=gc.getBackground(); - gc.setBackground(getBackgroundColor()); + gc.setBackground(getDefaultBackgroundColor()); gc.fillRectangle (x,y,width,height); gc.setBackground(bg); } - private Color getBackgroundColor() { - return fBackgroundColor; + public Color getDefaultBackgroundColor() { + // null == default style + return fStyleMap.getBackgroundColor(null); } + private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) { if(!model.isCursorOn()) return;