Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 215190 Details for
Bug 265352
[terminal][api] Terminal widget should allow setting fonts programmatically
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch v1
terminalAddSetFont_v1.diff.txt (text/plain), 12.68 KB, created by
Martin Oberhuber
on 2012-05-07 12:05:36 EDT
(
hide
)
Description:
patch v1
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2012-05-07 12:05:36 EDT
Size:
12.68 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tm.terminal >Index: src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java,v >retrieving revision 1.14 >diff -u -r1.14 ITerminalViewControl.java >--- src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java 7 Jul 2008 20:38:07 -0000 1.14 >+++ src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java 7 May 2012 16:03:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. >+ * Copyright (c) 2006, 2012 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 >@@ -45,7 +45,19 @@ > String getEncoding(); > > boolean isEmpty(); >+ /** >+ * Sets the Terminal font >+ * @deprecated use {@link #setFont(String)} in order to support bold and italic variants of the given font >+ * @param font >+ */ > void setFont(Font font); >+ /** >+ * Sets the font for the Terminal, using a JFace symbolic font name, such >+ * that bold and italic variants can be leveraged. >+ * @since 3.2 >+ * @param fontName >+ */ >+ void setFont(String fontName); > void setInvertedColors(boolean invert); > Font getFont(); > /** >Index: src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java,v >retrieving revision 1.36 >diff -u -r1.36 VT100TerminalControl.java >--- src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java 7 Feb 2012 07:32:42 -0000 1.36 >+++ src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java 7 May 2012 16:03:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2011 Wind River Systems, Inc. and others. >+ * Copyright (c) 2003, 2012 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 >@@ -30,6 +30,7 @@ > * Pawel Piech (Wind River) - [333613] "Job found still running" after shutdown > * Martin Oberhuber (Wind River) - [348700] Terminal unusable after disconnect > * Simon Bernard (Sierra Wireless) - [351424] [terminal] Terminal does not support del and insert key >+ * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically > *******************************************************************************/ > package org.eclipse.tm.internal.terminal.emulator; > >@@ -556,6 +557,21 @@ > setupHelp(fWndParent, TerminalPlugin.HELP_VIEW); > } > >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(java.lang.String) >+ */ >+ public void setFont(String fontName) { >+ Font font=JFaceResources.getFont(fontName); >+ getCtlText().setFont(font); >+ if(fCommandInputField!=null) { >+ fCommandInputField.setFont(font); >+ } >+ // Tell the TerminalControl singleton that the font has changed. >+ fCtlText.updateFont(fontName); >+ getTerminalText().fontChanged(); >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#onFontChanged() > */ >Index: src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java,v >retrieving revision 1.5 >diff -u -r1.5 ILinelRenderer.java >--- src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java 22 May 2010 00:07:35 -0000 1.5 >+++ src/org/eclipse/tm/internal/terminal/textcanvas/ILinelRenderer.java 7 May 2012 16:03:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. >+ * Copyright (c) 2007, 2012 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 >@@ -8,6 +8,7 @@ > * Contributors: > * Michael Scharf (Wind River) - initial API and implementation > * Anton Leherbauer (Wind River) - [294468] Fix scroller and text line rendering >+ * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically > *******************************************************************************/ > package org.eclipse.tm.internal.terminal.textcanvas; > >@@ -21,7 +22,16 @@ > int getCellWidth(); > int getCellHeight(); > void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast); >+ /** >+ * Update for a font change from the global JFace Registry. >+ */ > void onFontChange(); >+ /** >+ * Set a new font >+ * @param fontName Jface name of the new font >+ * @since 3.2 >+ */ >+ void updateFont(String fontName); > void setInvertedColors(boolean invert); > Color getDefaultBackgroundColor(); > } >Index: src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java,v >retrieving revision 1.15 >diff -u -r1.15 StyleMap.java >--- src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java 25 Jan 2011 18:22:39 -0000 1.15 >+++ src/org/eclipse/tm/internal/terminal/textcanvas/StyleMap.java 7 May 2012 16:03:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. >+ * Copyright (c) 2007, 2012 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 >@@ -12,6 +12,7 @@ > * Michael Scharf (Wind River) - [206328] Terminal does not draw correctly with proportional fonts > * Martin Oberhuber (Wind River) - [247700] Terminal uses ugly fonts in JEE package > * Martin Oberhuber (Wind River) - [335358] Fix Terminal color definition >+ * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically > *******************************************************************************/ > package org.eclipse.tm.internal.terminal.textcanvas; > >@@ -26,6 +27,7 @@ > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.tm.internal.terminal.preferences.ITerminalConstants; > import org.eclipse.tm.terminal.model.Style; > import org.eclipse.tm.terminal.model.StyleColor; > >@@ -42,9 +44,7 @@ > private static final String RED = "red"; //$NON-NLS-1$ > > private static final String PREFIX = "org.eclipse.tm.internal."; //$NON-NLS-1$ >- // TODO propagate the name of the font in the FontRegistry >- private static final String fDefaultFontName="terminal.views.view.font.definition"; //$NON-NLS-1$ >- String fFontName=fDefaultFontName; >+ String fFontName=ITerminalConstants.FONT_DEFINITION; > Map fColorMapForeground=new HashMap(); > Map fColorMapBackground=new HashMap(); > Map fColorMapIntense=new HashMap(); >@@ -194,13 +194,19 @@ > return fCharSize.y; > } > public void updateFont() { >+ updateFont(ITerminalConstants.FONT_DEFINITION); >+ } >+ /** >+ * Update the StyleMap for a new font name. >+ * The font name must be a valid name in the Jface font registry. >+ * @param fontName Jface name of the new font to use. >+ * @since 3.2 >+ */ >+ public void updateFont(String fontName) { > Display display=Display.getCurrent(); > GC gc = new GC (display); >- if (JFaceResources.getFontRegistry().hasValueFor(fDefaultFontName)) { >- fFontName = fDefaultFontName; >- } else if (JFaceResources.getFontRegistry().hasValueFor("REMOTE_COMMANDS_VIEW_FONT")) { //$NON-NLS-1$ >- //try RSE Shell View Font >- fFontName = "REMOTE_COMMANDS_VIEW_FONT"; //$NON-NLS-1$ >+ if (JFaceResources.getFontRegistry().hasValueFor(fontName)) { >+ fFontName = fontName; > } else { > //fall back to "basic jface text font" > fFontName = "org.eclipse.jface.textfont"; //$NON-NLS-1$ >Index: src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java,v >retrieving revision 1.23 >diff -u -r1.23 TextCanvas.java >--- src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java 23 May 2011 12:19:47 -0000 1.23 >+++ src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java 7 May 2012 16:03:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. >+ * Copyright (c) 2007, 2012 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 >@@ -15,6 +15,7 @@ > * Anton Leherbauer (Wind River) - [219589] Copy an entire line selection > * Anton Leherbauer (Wind River) - [196465] Resizing Terminal changes Scroller location > * Anton Leherbauer (Wind River) - [324608] Terminal has strange scrolling behaviour >+ * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically > *******************************************************************************/ > package org.eclipse.tm.internal.terminal.textcanvas; > >@@ -373,6 +374,9 @@ > } > } > >+ /** >+ * Notify about a change of the global Font Preference. >+ */ > public void onFontChange() { > fCellRenderer.onFontChange(); > setCellWidth(fCellRenderer.getCellWidth()); >@@ -380,6 +384,13 @@ > calculateGrid(); > } > >+ public void updateFont(String fontName) { >+ fCellRenderer.updateFont(fontName); >+ setCellWidth(fCellRenderer.getCellWidth()); >+ setCellHeight(fCellRenderer.getCellHeight()); >+ calculateGrid(); >+ } >+ > public void setInvertedColors(boolean invert) { > fCellRenderer.setInvertedColors(invert); > redraw(); >Index: src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java,v >retrieving revision 1.10 >diff -u -r1.10 TextLineRenderer.java >--- src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java 22 May 2010 00:07:35 -0000 1.10 >+++ src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java 7 May 2012 16:03:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. >+ * Copyright (c) 2007, 2012 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 >@@ -10,6 +10,7 @@ > * Michael Scharf (Wind River) - [205260] Terminal does not take the font from the preferences > * Michael Scharf (Wind River) - [206328] Terminal does not draw correctly with proportional fonts > * Anton Leherbauer (Wind River) - [294468] Fix scroller and text line rendering >+ * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically > *******************************************************************************/ > package org.eclipse.tm.internal.terminal.textcanvas; > >@@ -157,6 +158,9 @@ > public void onFontChange() { > fStyleMap.updateFont(); > } >+ public void updateFont(String fontName) { >+ fStyleMap.updateFont(fontName); >+ } > public void setInvertedColors(boolean invert) { > fStyleMap.setInvertedColors(invert); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 265352
: 215190