1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 20:15:22 +02:00

bug 205260: [terminal] The terminal does not take the font from the preferences

https://bugs.eclipse.org/bugs/show_bug.cgi?id=205260
This commit is contained in:
Michael Scharf 2007-10-13 01:36:50 +00:00
parent 839cf0e907
commit 0114f92c25
7 changed files with 78 additions and 71 deletions

View file

@ -79,7 +79,7 @@ public class VT100Emulator implements ControlListener {
* This field holds a reference to the {@link TerminalControl} object that * This field holds a reference to the {@link TerminalControl} object that
* instantiates this class. * instantiates this class.
*/ */
private ITerminalControlForText terminal; private final ITerminalControlForText terminal;
/** /**
* This field holds a reference to the StyledText widget that is used to * This field holds a reference to the StyledText widget that is used to
@ -104,13 +104,13 @@ public class VT100Emulator implements ControlListener {
* parsing the escape sequence "\e[20;10H", this array holds the strings * parsing the escape sequence "\e[20;10H", this array holds the strings
* "20" and "10". * "20" and "10".
*/ */
private StringBuffer[] ansiParameters = new StringBuffer[16]; private final StringBuffer[] ansiParameters = new StringBuffer[16];
/** /**
* This field holds the OS-specific command found in an escape sequence of * This field holds the OS-specific command found in an escape sequence of
* the form "\e]...\u0007". * the form "\e]...\u0007".
*/ */
private StringBuffer ansiOsCommand = new StringBuffer(128); private final StringBuffer ansiOsCommand = new StringBuffer(128);
/** /**
* This field holds the index of the next unused element of the array stored * This field holds the index of the next unused element of the array stored

View file

@ -458,7 +458,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
} }
// Tell the TerminalControl singleton that the font has changed. // Tell the TerminalControl singleton that the font has changed.
fCtlText.onFontChange();
getTerminalText().fontChanged(); getTerminalText().fontChanged();
} }
public Font getFont() { public Font getFont() {

View file

@ -19,4 +19,5 @@ public interface ILinelRenderer {
int getCellWidth(); int getCellWidth();
int getCellHeight(); int getCellHeight();
void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast); void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast);
void onFontChange();
} }

View file

@ -13,7 +13,6 @@ package org.eclipse.tm.internal.terminal.textcanvas;
/** /**
*/ */
public interface ITextCanvasModelListener { public interface ITextCanvasModelListener {
void cellSizeChanged();
void rangeChanged(int col, int line, int width, int height); void rangeChanged(int col, int line, int width, int height);
void dimensionsChanged(int cols, int rows); void dimensionsChanged(int cols, int rows);
/** /**

View file

@ -23,11 +23,12 @@ import org.eclipse.tm.terminal.model.Style;
import org.eclipse.tm.terminal.model.StyleColor; import org.eclipse.tm.terminal.model.StyleColor;
public class StyleMap { 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 fColorMap=new HashMap();
Map fFontMap=new HashMap(); Map fFontMap=new HashMap();
private Point fCharSize; private Point fCharSize;
private Style fDefaultStyle; private final Style fDefaultStyle;
StyleMap() { StyleMap() {
Display display=Display.getCurrent(); Display display=Display.getCurrent();
fColorMap.put(StyleColor.getStyleColor("white"), new Color(display,255,255,255)); //$NON-NLS-1$ 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("MAGENTA"), new Color(display,255,255,0)); //$NON-NLS-1$
fColorMap.put(StyleColor.getStyleColor("GRAY"), new Color(display,128,128,128)); //$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$ fDefaultStyle=Style.getStyle(StyleColor.getStyleColor("black"),StyleColor.getStyleColor("white")); //$NON-NLS-1$ //$NON-NLS-2$
GC gc = new GC (display); updateFont();
gc.setFont(getFont());
fCharSize = gc.textExtent ("W"); //$NON-NLS-1$
gc.dispose ();
} }
public Color getColor(StyleColor colorName) { public Color getColor(StyleColor colorName) {
return (Color) fColorMap.get(colorName); return (Color) fColorMap.get(colorName);
@ -104,4 +101,11 @@ public class StyleMap {
public int getFontHeight() { public int getFontHeight() {
return fCharSize.y; 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 ();
}
} }

View file

@ -52,13 +52,6 @@ public class TextCanvas extends GridCanvas {
setCellHeight(fCellRenderer.getCellHeight()); setCellHeight(fCellRenderer.getCellHeight());
fCellCanvasModel=model; fCellCanvasModel=model;
fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener(){ 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) { public void rangeChanged(int col, int line, int width, int height) {
repaintRange(col,line,width,height); repaintRange(col,line,width,height);
} }
@ -300,5 +293,12 @@ public class TextCanvas extends GridCanvas {
fResizeListener=listener; fResizeListener=listener;
} }
public void onFontChange() {
fCellRenderer.onFontChange();
setCellWidth(fCellRenderer.getCellWidth());
setCellHeight(fCellRenderer.getCellHeight());
calculateGrid();
}
} }

View file

@ -136,4 +136,7 @@ public class TextLineRenderer implements ILinelRenderer {
ITerminalTextDataReadOnly getTerminalText() { ITerminalTextDataReadOnly getTerminalText() {
return fModel.getTerminalText(); return fModel.getTerminalText();
} }
public void onFontChange() {
fStyleMap.updateFont();
}
} }