Skip to content
Browse files

apply theming to both terminal view and editor...

  • Loading branch information...
1 parent f18b9a2 commit 30d3c8e8c1fb49e3da1e640953511f292743a220 sgtcoolguy committed
View
25 plugins/com.aptana.terminal/src/com/aptana/terminal/editor/TerminalEditor.java
@@ -6,8 +6,6 @@
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
@@ -26,11 +24,10 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.EditorPart;
-import com.aptana.editor.common.CommonEditorPlugin;
-import com.aptana.editor.common.theme.Theme;
import com.aptana.terminal.Activator;
import com.aptana.terminal.Closeable;
import com.aptana.terminal.connector.LocalTerminalConnector;
+import com.aptana.terminal.internal.TerminalThemer;
@SuppressWarnings("restriction")
public class TerminalEditor extends EditorPart implements Closeable, ITerminalListener
@@ -63,19 +60,8 @@ public void run()
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
- public void createPartControl(Composite parent)
- {
- Theme theme = CommonEditorPlugin.getDefault().getThemeManager().getCurrentTheme();
- setColor(0, 0, 0, theme.getForeground()); // black
- setColor(255, 255, 255, theme.getBackground()); // white
- setColor(229, 229, 229, theme.getBackground()); // white fg
-// setColor(255, 128, 128); // RED
-// setColor(128, 255, 128); // GREEN
-// setColor(128, 128, 255); // BLUE
-// setColor(255, 255, 0); // YELLOW
-// setColor(0, 255, 255); // CYAN
-// setColor(255, 255, 0); // MAGENTA
-// setColor(128, 128, 128); // GRAY
+ public void createPartControl(Composite parent) {
+ TerminalThemer.apply();
fCtlTerminal = TerminalViewControlFactory.makeControl(this, parent, getTerminalConnectors());
fCtlTerminal.setConnector(fCtlTerminal.getConnectors()[0]);
@@ -97,11 +83,6 @@ public void createPartControl(Composite parent)
saveInputState();
}
- private void setColor(int r, int g, int b, RGB rgb)
- {
- JFaceResources.getColorRegistry().put("org.eclipse.tm.internal." + r+ "-" + g + "-" + b, rgb);
- }
-
private ITerminalConnector[] getTerminalConnectors() {
return new ITerminalConnector[] { TerminalConnectorExtension.makeTerminalConnector(LocalTerminalConnector.ID) };
}
View
43 plugins/com.aptana.terminal/src/com/aptana/terminal/internal/TerminalThemer.java
@@ -0,0 +1,43 @@
+package com.aptana.terminal.internal;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.RGB;
+
+import com.aptana.editor.common.CommonEditorPlugin;
+import com.aptana.editor.common.theme.Theme;
+
+@SuppressWarnings("nls")
+public class TerminalThemer
+{
+
+ public static void apply()
+ {
+ Theme theme = CommonEditorPlugin.getDefault().getThemeManager().getCurrentTheme();
+ setColor(0, 0, 0, theme.getForeground()); // black
+ setColor(255, 255, 255, theme.getBackground()); // white
+ setColor(229, 229, 229, "ansi.white"); // white fg
+ setColor(255, 128, 128, "ansi.red"); // RED
+ setColor(128, 255, 128, "ansi.green"); // GREEN
+ setColor(128, 128, 255, "ansi.blue"); // BLUE
+ setColor(255, 255, 0, "ansi.yellow"); // YELLOW
+ setColor(0, 255, 255, "ansi.cyan"); // CYAN
+ setColor(255, 255, 0, "ansi.magenta"); // MAGENTA
+ }
+
+ private static void setColor(int r, int g, int b, String tokenName)
+ {
+ Theme theme = CommonEditorPlugin.getDefault().getThemeManager().getCurrentTheme();
+ RGB rgb = new RGB(r, g, b);
+ if (theme.hasEntry(tokenName))
+ {
+ rgb = theme.getForegroundAsRGB(tokenName);
+ }
+ setColor(r, g, b, rgb);
+ }
+
+ private static void setColor(int r, int g, int b, RGB rgb)
+ {
+ JFaceResources.getColorRegistry().put("org.eclipse.tm.internal." + r + "-" + g + "-" + b, rgb);
+ }
+
+}
View
3 plugins/com.aptana.terminal/src/com/aptana/terminal/views/TerminalView.java
@@ -56,6 +56,7 @@
import com.aptana.terminal.Utils;
import com.aptana.terminal.connector.LocalTerminalConnector;
import com.aptana.terminal.editor.TerminalEditor;
+import com.aptana.terminal.internal.TerminalThemer;
/**
* @author Max Stepanov
@@ -110,6 +111,8 @@ public void init(IViewSite site, IMemento memento) throws PartInitException {
*/
@Override
public void createPartControl(Composite parent) {
+ TerminalThemer.apply();
+
fCtlTerminal = TerminalViewControlFactory.makeControl(this, parent, getTerminalConnectors());
fCtlTerminal.setConnector(fCtlTerminal.getConnectors()[0]);
if (getViewSite().getSecondaryId() == null || savedState != null) {

0 comments on commit 30d3c8e

Please sign in to comment.
Something went wrong with that request. Please try again.