diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index d503d5aa3b9..bf7d66fe267 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -11,7 +11,7 @@ * Helmut Haigermoser and Ted Williams. * * Contributors: - * Michael Scharf (Wind River) - split into core, view and connector plugins + * Michael Scharf (Wind River) - split into core, view and connector plugins * Martin Oberhuber (Wind River) - fixed copyright headers and beautified *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -43,7 +43,7 @@ import org.eclipse.tm.terminal.model.Style; * use of screen-oriented applications, such as vi, Emacs, and any GNU * readline-enabled application (Bash, bc, ncftp, etc.). *
- *
+ *
* @author Fran Litterio
// * These connectors write text to the terminal's buffer through
-// * {@link TerminalControl#writeToTerminal(String)} and then have
-// * this run method executed in the display thread. This method
-// * must not execute at the same time as methods
+// * {@link TerminalControl#writeToTerminal(String)} and then have
+// * this run method executed in the display thread. This method
+// * must not execute at the same time as methods
// * {@link #setNewText(StringBuffer)} and {@link #clearTerminal()}.
// *
// * IMPORTANT: This method must be called in strict alternation with method
@@ -256,7 +256,7 @@ public class VT100Emulator implements ControlListener {
/**
* This method scans the newly received text, processing ANSI control
* characters and escape sequences and displaying normal text.
- * @throws IOException
+ * @throws IOException
*/
private void processNewText() throws IOException {
Logger.log("entered"); //$NON-NLS-1$
@@ -342,7 +342,7 @@ public class VT100Emulator implements ControlListener {
ansiState = ANSISTATE_INITIAL;
moveCursor(savedCursorLine, savedCursorColumn);
break;
-
+
case 'c':
// Reset the terminal
ansiState = ANSISTATE_INITIAL;
@@ -863,7 +863,7 @@ public class VT100Emulator implements ControlListener {
/**
* This method returns one of the numeric ANSI parameters received in the
* most recent escape sequence.
- *
+ *
* @return The parameterIndexth numeric ANSI parameter or -1 if the
* index is out of range.
*/
@@ -913,7 +913,7 @@ public class VT100Emulator implements ControlListener {
* append each non-control character individually to the StyledText widget.
* A non-control character is any character that passes the condition in the
* below while loop.
- * @throws IOException
+ * @throws IOException
*/
private void processNonControlCharacters(char character) throws IOException {
StringBuffer buffer=new StringBuffer();
@@ -942,7 +942,7 @@ public class VT100Emulator implements ControlListener {
* view, wrapping text at the right edge of the screen and overwriting text
* when the cursor is not at the very end of the screen's text.
*
- *
+ *
* There are never any ANSI control characters or escape sequences in the
* text being displayed by this method (this includes newlines, carriage
* returns, and tabs).
@@ -987,7 +987,7 @@ public class VT100Emulator implements ControlListener {
* first column of the next line, as if a carriage return (CR) and a NL were
* written.
*
- *
+ *
* UNIX terminals typically display a NL character as a CR followed by a NL
* because the terminal device typically has the ONLCR attribute bit set
* (see the termios(4) man page for details), which causes the terminal
@@ -1018,7 +1018,7 @@ public class VT100Emulator implements ControlListener {
* the edges of the view window (i.e., the view window does not become
* larger to accommodate its contents becoming larger).
*
- *
+ *
* This method must be called immediately before each time text is written
* to the terminal so that we can properly line wrap text. Because it is
* called so frequently, it must be fast when there is no resizing to be
@@ -1055,7 +1055,7 @@ public class VT100Emulator implements ControlListener {
* This method returns the relative line number of the line containing the
* cursor. The returned line number is relative to the topmost visible line,
* which has relative line number 0.
- *
+ *
* @return The relative line number of the line containing the cursor.
*/
private int relativeCursorLine() {
@@ -1127,7 +1127,7 @@ public class VT100Emulator implements ControlListener {
*/
private int fNextChar=-1;
private char getNextChar() throws IOException {
- int c=-1;
+ int c=-1;
if(fNextChar!=-1) {
c= fNextChar;
fNextChar=-1;
@@ -1154,7 +1154,7 @@ public class VT100Emulator implements ControlListener {
*/
void pushBackChar(char c) {
//assert fNextChar!=-1: "Already a character waiting:"+fNextChar; //$NON-NLS-1$
- fNextChar=c;
+ fNextChar=c;
}
private int getCursorColumn() {
return text.getCursorColumn();
diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
index 087f3595ab0..beb7be9a682 100644
--- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
+++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java
@@ -458,7 +458,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
}
// Tell the TerminalControl singleton that the font has changed.
-
+ fCtlText.onFontChange();
getTerminalText().fontChanged();
}
public Font getFont() {
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 d217186a996..86f9990c810 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,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Michael Scharf (Wind River) - initial API and implementation
*******************************************************************************/
package org.eclipse.tm.internal.terminal.textcanvas;
@@ -19,4 +19,5 @@ public interface ILinelRenderer {
int getCellWidth();
int getCellHeight();
void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast);
+ void onFontChange();
}
diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java
index cb52c8cf529..5a96bc73e94 100644
--- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java
+++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ITextCanvasModelListener.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Michael Scharf (Wind River) - initial API and implementation
*******************************************************************************/
package org.eclipse.tm.internal.terminal.textcanvas;
@@ -13,7 +13,6 @@ package org.eclipse.tm.internal.terminal.textcanvas;
/**
*/
public interface ITextCanvasModelListener {
- void cellSizeChanged();
void rangeChanged(int col, int line, int width, int height);
void dimensionsChanged(int cols, int rows);
/**
diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
index 1311cf3fe89..e4df2d66d3c 100644
--- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
+++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Michael Scharf (Wind River) - initial API and implementation
*******************************************************************************/
package org.eclipse.tm.internal.terminal.textcanvas;
@@ -23,11 +23,12 @@ import org.eclipse.tm.terminal.model.Style;
import org.eclipse.tm.terminal.model.StyleColor;
public class StyleMap {
- String fFontName=JFaceResources.TEXT_FONT;
+ // TODO propagate the name of the fonf in the FontRegistry
+ String fFontName="terminal.views.view.font.definition"; //$NON-NLS-1$
Map fColorMap=new HashMap();
Map fFontMap=new HashMap();
private Point fCharSize;
- private Style fDefaultStyle;
+ private final Style fDefaultStyle;
StyleMap() {
Display display=Display.getCurrent();
fColorMap.put(StyleColor.getStyleColor("white"), new Color(display,255,255,255)); //$NON-NLS-1$
@@ -49,11 +50,7 @@ public class StyleMap {
fColorMap.put(StyleColor.getStyleColor("MAGENTA"), new Color(display,255,255,0)); //$NON-NLS-1$
fColorMap.put(StyleColor.getStyleColor("GRAY"), new Color(display,128,128,128)); //$NON-NLS-1$
fDefaultStyle=Style.getStyle(StyleColor.getStyleColor("black"),StyleColor.getStyleColor("white")); //$NON-NLS-1$ //$NON-NLS-2$
- GC gc = new GC (display);
- gc.setFont(getFont());
- fCharSize = gc.textExtent ("W"); //$NON-NLS-1$
- gc.dispose ();
-
+ updateFont();
}
public Color getColor(StyleColor colorName) {
return (Color) fColorMap.get(colorName);
@@ -89,14 +86,14 @@ public class StyleMap {
return JFaceResources.getFontRegistry().getBold(fFontName);
} else if(style.isUnderline()) {
return JFaceResources.getFontRegistry().getItalic(fFontName);
-
+
}
return JFaceResources.getFontRegistry().get(fFontName);
}
-
+
public Font getFont() {
return JFaceResources.getFontRegistry().get(fFontName);
-
+
}
public int getFontWidth() {
return fCharSize.x;
@@ -104,4 +101,11 @@ public class StyleMap {
public int getFontHeight() {
return fCharSize.y;
}
+ public void updateFont() {
+ Display display=Display.getCurrent();
+ GC gc = new GC (display);
+ gc.setFont(getFont());
+ fCharSize = gc.textExtent ("W"); //$NON-NLS-1$
+ gc.dispose ();
+ }
}
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 50eab90ac4c..2e4e9d3b2fa 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
@@ -52,13 +52,6 @@ public class TextCanvas extends GridCanvas {
setCellHeight(fCellRenderer.getCellHeight());
fCellCanvasModel=model;
fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener(){
- public void cellSizeChanged() {
- setCellWidth(fCellRenderer.getCellWidth());
- setCellHeight(fCellRenderer.getCellHeight());
-
- calculateGrid();
-
- }
public void rangeChanged(int col, int line, int width, int height) {
repaintRange(col,line,width,height);
}
@@ -300,5 +293,12 @@ public class TextCanvas extends GridCanvas {
fResizeListener=listener;
}
+ public void onFontChange() {
+ fCellRenderer.onFontChange();
+ setCellWidth(fCellRenderer.getCellWidth());
+ setCellHeight(fCellRenderer.getCellHeight());
+ calculateGrid();
+ }
+
}
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 3b0ead33250..5f7ec3cbbca 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
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Michael Scharf (Wind River) - initial API and implementation
*******************************************************************************/
package org.eclipse.tm.internal.terminal.textcanvas;
@@ -82,13 +82,13 @@ 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.fillRectangle (x,y,width,height);
gc.setBackground(bg);
-
+
}
private Color getBackgroundColor() {
@@ -98,7 +98,7 @@ public class TextLineRenderer implements ILinelRenderer {
if(!model.isCursorOn())
return;
int cursorLine=model.getCursorLine();
-
+
if(row==cursorLine) {
int cursorColumn=model.getCursorColumn();
if(cursorColumn