src/Tools/jEdit/src/plugin.scala
changeset 43443 5d9693c2337e
parent 43390 7ee98a3802af
child 43449 591598bc52bc
     1.1 --- a/src/Tools/jEdit/src/plugin.scala	Sat Jun 18 17:32:13 2011 +0200
     1.2 +++ b/src/Tools/jEdit/src/plugin.scala	Sat Jun 18 17:33:27 2011 +0200
     1.3 @@ -19,9 +19,11 @@
     1.4    Buffer, EditPane, ServiceManager, View}
     1.5  import org.gjt.sp.jedit.buffer.JEditBuffer
     1.6  import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea}
     1.7 +import org.gjt.sp.jedit.syntax.{Token => JEditToken}
     1.8  import org.gjt.sp.jedit.msg.{EditorStarted, BufferUpdate, EditPaneUpdate, PropertiesChanged}
     1.9  import org.gjt.sp.jedit.gui.DockableWindowManager
    1.10  
    1.11 +import org.gjt.sp.util.SyntaxUtilities
    1.12  import org.gjt.sp.util.Log
    1.13  
    1.14  import scala.actors.Actor
    1.15 @@ -32,10 +34,16 @@
    1.16  {
    1.17    /* plugin instance */
    1.18  
    1.19 +  var plugin: Plugin = null
    1.20    var system: Isabelle_System = null
    1.21    var session: Session = null
    1.22  
    1.23  
    1.24 +  /* extended syntax styles */
    1.25 +
    1.26 +  def extended_styles: Boolean = plugin != null && plugin._extended_styles
    1.27 +
    1.28 +
    1.29    /* properties */
    1.30  
    1.31    val OPTION_PREFIX = "options.isabelle."
    1.32 @@ -256,6 +264,19 @@
    1.33  
    1.34  class Plugin extends EBPlugin
    1.35  {
    1.36 +  /* extended syntax styles */
    1.37 +
    1.38 +  @volatile var _extended_styles: Boolean = false
    1.39 +
    1.40 +  private def check_extended_styles()
    1.41 +  {
    1.42 +    val family = jEdit.getProperty("view.font")
    1.43 +    val size = jEdit.getIntegerProperty("view.fontsize", 12)
    1.44 +    val styles = SyntaxUtilities.loadStyles(family, size)
    1.45 +    _extended_styles = (styles.length == JEditToken.ID_COUNT * 3 + 1)
    1.46 +  }
    1.47 +
    1.48 +
    1.49    /* session management */
    1.50  
    1.51    private def init_model(buffer: Buffer)
    1.52 @@ -346,6 +367,7 @@
    1.53      message match {
    1.54        case msg: EditorStarted =>
    1.55        Isabelle.check_jvm()
    1.56 +      check_extended_styles()
    1.57        if (Isabelle.Boolean_Property("auto-start")) Isabelle.start_session()
    1.58  
    1.59        case msg: BufferUpdate
    1.60 @@ -382,6 +404,7 @@
    1.61  
    1.62    override def start()
    1.63    {
    1.64 +    Isabelle.plugin = this
    1.65      Isabelle.setup_tooltips()
    1.66      Isabelle.system = new Isabelle_System
    1.67      Isabelle.system.install_fonts()