]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.server/scl/Document/All.scl
Console printing enhancements for documents (Simupedia)
[simantics/platform.git] / bundles / org.simantics.document.server / scl / Document / All.scl
index 23896814224bdeed738e03fb32723c466fc5d367..7781cfdb3ffaa9595eb322be7d01ffc286bf48c0 100644 (file)
@@ -21,6 +21,13 @@ importJava "org.simantics.document.server.io.ITreeTableCell" where
 
 importJava "org.simantics.document.server.io.IFont" where
     data IFont
+    
+    @JavaName getFamily
+    fontFamily :: IFont -> <Proc> Maybe String
+    @JavaName getStyle
+    fontStyle :: IFont -> <Proc> Maybe String
+    @JavaName getHeight
+    fontHeight :: IFont -> <Proc> Integer
 
 importJava "org.simantics.document.server.io.IColor" where
     data IColor
@@ -78,6 +85,9 @@ instance Coercible CommandContextMutable CommandContext where
 cloneCommandContext :: CommandContext -> <Proc> CommandContextMutable
 cloneCommandContext context = merge (commandContext ()) context
 
+instance Show CommandContext where
+    show ctx = printContext ctx
+
 importJava "org.simantics.document.server.io.CommandResult" where
     data CommandResult
 
@@ -136,10 +146,10 @@ displayValue var str = propertyValue (property var str) "HasDisplayValue"
 displayValue0 :: Variable -> <ReadGraph> String
 displayValue0 var = propertyValue var "HasDisplayValue"
 
-consoleLog :: Variable -> String -> <ReadGraph> ()
-consoleLog state message = do
-    console = state#console
-    runProc $ addMessage console message
+consoleLog :: CommandContext -> String -> ()
+consoleLog context message = match possibleValue context "console" with
+  Nothing -> ()
+  Just console -> runProc $ addMessage console message
 
 contextDocument :: CommandContext -> <Proc> IDocument
 contextDocument ctx = justValue ctx "__document__"