mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 12:05:21 +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:
parent
839cf0e907
commit
0114f92c25
7 changed files with 78 additions and 71 deletions
|
@ -79,7 +79,7 @@ public class VT100Emulator implements ControlListener {
|
|||
* This field holds a reference to the {@link TerminalControl} object that
|
||||
* instantiates this class.
|
||||
*/
|
||||
private ITerminalControlForText terminal;
|
||||
private final ITerminalControlForText terminal;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* "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
|
||||
* 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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
@ -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 ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -136,4 +136,7 @@ public class TextLineRenderer implements ILinelRenderer {
|
|||
ITerminalTextDataReadOnly getTerminalText() {
|
||||
return fModel.getTerminalText();
|
||||
}
|
||||
public void onFontChange() {
|
||||
fStyleMap.updateFont();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue