]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Change editor font in UI and update on editor reload. 83/3283/2
authorAlpi Rimppi <alpi.rimppi@semantum.fi>
Thu, 26 Sep 2019 08:26:55 +0000 (11:26 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 26 Sep 2019 12:03:20 +0000 (12:03 +0000)
gitlab #390

Change-Id: Ieae1ceb208a3e401f122725eda5693e1e4aeb5b5

bundles/org.simantics.scl.ui/plugin.xml
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLPresentationReconciler.java

index 85e8aad7adcacf5f1b893a666594eec1788e8c04..bb69f55bfb30f329d98dfa2dce241e9d55fdc3bb 100644 (file)
             The SCL Console font is used by SCL Console and SCL Script Output console views.
          </description>
       </fontDefinition>
+      <fontDefinition
+            categoryId="org.simantics.scl"
+            id="org.simantics.scl.editorfont"
+            label="SCL Editor Font"
+            value="Courier New-regular-11">
+         <description>
+            The SCL editor font is used by SCL module and script editors.
+         </description>
+      </fontDefinition>
    </extension>
    <extension
          point="org.eclipse.search.searchResultViewPages">
index b74e35fb29d2da65ced075b24ff40b0204d0a9c2..7a937f8a31a68053a6db27bee4c24697098469d4 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.scl.ui.editor2;
 
 import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.FontRegistry;
 import org.eclipse.jface.resource.ResourceManager;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.TextAttribute;
@@ -17,11 +18,16 @@ import org.eclipse.jface.text.rules.WordRule;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.PlatformUI;
 import org.simantics.scl.ui.info.SCLInfo;
 
 public class SCLPresentationReconciler extends PresentationReconciler {
-    private static final FontDescriptor FONT_NORMAL = FontDescriptor.createFrom("Consolas", 10, SWT.NORMAL); //$NON-NLS-1$
-    private static final FontDescriptor FONT_BOLD = FontDescriptor.createFrom("Consolas", 10, SWT.BOLD); //$NON-NLS-1$
+    
+    
+    private final FontRegistry fontRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
+    
+    private final FontDescriptor FONT_NORMAL = FontDescriptor.createFrom( fontRegistry.getFontData("org.simantics.scl.editorfont") );
+    private final FontDescriptor FONT_BOLD = FONT_NORMAL.setStyle(SWT.BOLD);
     
     public SCLPresentationReconciler(ResourceManager resourceManager) {
         Font font = resourceManager.createFont(FONT_NORMAL);
@@ -52,8 +58,8 @@ public class SCLPresentationReconciler extends PresentationReconciler {
             setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
         }
     }
-    
-    private static ITokenScanner getSclTokenScanner(ResourceManager resourceManager) {
+
+    private ITokenScanner getSclTokenScanner(ResourceManager resourceManager) {
         RuleBasedScanner scanner = new RuleBasedScanner();
         
         Token defaultToken = new Token(