src/Tools/jEdit/src/plugin.scala
author wenzelm
Sat Jul 09 12:56:51 2011 +0200 (2011-07-09)
changeset 43714 3749d1e6dde9
parent 43697 77ce24aa1770
child 44160 8848867501fb
permissions -rw-r--r--
tuned signature;
wenzelm@43282
     1
/*  Title:      Tools/jEdit/src/plugin.scala
wenzelm@36760
     2
    Author:     Makarius
wenzelm@36760
     3
wenzelm@36760
     4
Main Isabelle/jEdit plugin setup.
wenzelm@36760
     5
*/
wenzelm@34407
     6
wenzelm@34318
     7
package isabelle.jedit
wenzelm@34318
     8
wenzelm@34429
     9
wenzelm@36015
    10
import isabelle._
wenzelm@36015
    11
wenzelm@43520
    12
import java.lang.System
wenzelm@43645
    13
import java.io.{File, FileInputStream, IOException}
wenzelm@34318
    14
import java.awt.Font
wenzelm@34318
    15
wenzelm@34497
    16
import scala.collection.mutable
wenzelm@39517
    17
import scala.swing.ComboBox
immler@34406
    18
wenzelm@39241
    19
import org.gjt.sp.jedit.{jEdit, GUIUtilities, EBMessage, EBPlugin,
wenzelm@43645
    20
  Buffer, EditPane, MiscUtilities, ServiceManager, View}
immler@34406
    21
import org.gjt.sp.jedit.buffer.JEditBuffer
wenzelm@39043
    22
import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea}
wenzelm@43452
    23
import org.gjt.sp.jedit.syntax.{Token => JEditToken, ModeProvider}
wenzelm@39633
    24
import org.gjt.sp.jedit.msg.{EditorStarted, BufferUpdate, EditPaneUpdate, PropertiesChanged}
wenzelm@37068
    25
import org.gjt.sp.jedit.gui.DockableWindowManager
wenzelm@34429
    26
wenzelm@43443
    27
import org.gjt.sp.util.SyntaxUtilities
wenzelm@39241
    28
import org.gjt.sp.util.Log
wenzelm@39241
    29
wenzelm@39630
    30
import scala.actors.Actor
wenzelm@39630
    31
import Actor._
wenzelm@39630
    32
wenzelm@34318
    33
wenzelm@34618
    34
object Isabelle
wenzelm@34618
    35
{
wenzelm@34784
    36
  /* plugin instance */
wenzelm@34784
    37
wenzelm@43443
    38
  var plugin: Plugin = null
wenzelm@34784
    39
  var session: Session = null
wenzelm@34784
    40
wenzelm@34784
    41
wenzelm@34618
    42
  /* properties */
wenzelm@34618
    43
wenzelm@34618
    44
  val OPTION_PREFIX = "options.isabelle."
wenzelm@34618
    45
wenzelm@34618
    46
  object Property
wenzelm@34618
    47
  {
wenzelm@36814
    48
    def apply(name: String): String =
wenzelm@36814
    49
      jEdit.getProperty(OPTION_PREFIX + name)
wenzelm@36814
    50
    def apply(name: String, default: String): String =
wenzelm@36814
    51
      jEdit.getProperty(OPTION_PREFIX + name, default)
wenzelm@36814
    52
    def update(name: String, value: String) =
wenzelm@36814
    53
      jEdit.setProperty(OPTION_PREFIX + name, value)
wenzelm@34468
    54
  }
wenzelm@34433
    55
wenzelm@34618
    56
  object Boolean_Property
wenzelm@34618
    57
  {
wenzelm@36814
    58
    def apply(name: String): Boolean =
wenzelm@36814
    59
      jEdit.getBooleanProperty(OPTION_PREFIX + name)
wenzelm@36814
    60
    def apply(name: String, default: Boolean): Boolean =
wenzelm@36814
    61
      jEdit.getBooleanProperty(OPTION_PREFIX + name, default)
wenzelm@36814
    62
    def update(name: String, value: Boolean) =
wenzelm@36814
    63
      jEdit.setBooleanProperty(OPTION_PREFIX + name, value)
wenzelm@34618
    64
  }
wenzelm@34618
    65
wenzelm@34618
    66
  object Int_Property
wenzelm@34618
    67
  {
wenzelm@36814
    68
    def apply(name: String): Int =
wenzelm@36814
    69
      jEdit.getIntegerProperty(OPTION_PREFIX + name)
wenzelm@36814
    70
    def apply(name: String, default: Int): Int =
wenzelm@36814
    71
      jEdit.getIntegerProperty(OPTION_PREFIX + name, default)
wenzelm@36814
    72
    def update(name: String, value: Int) =
wenzelm@36814
    73
      jEdit.setIntegerProperty(OPTION_PREFIX + name, value)
wenzelm@34618
    74
  }
wenzelm@34618
    75
wenzelm@40848
    76
  object Double_Property
wenzelm@40848
    77
  {
wenzelm@40848
    78
    def apply(name: String): Double =
wenzelm@40848
    79
      jEdit.getDoubleProperty(OPTION_PREFIX + name, 0.0)
wenzelm@40848
    80
    def apply(name: String, default: Double): Double =
wenzelm@40848
    81
      jEdit.getDoubleProperty(OPTION_PREFIX + name, default)
wenzelm@40848
    82
    def update(name: String, value: Double) =
wenzelm@40848
    83
      jEdit.setDoubleProperty(OPTION_PREFIX + name, value)
wenzelm@40848
    84
  }
wenzelm@40848
    85
wenzelm@40850
    86
  object Time_Property
wenzelm@40850
    87
  {
wenzelm@40850
    88
    def apply(name: String): Time =
wenzelm@40850
    89
      Time.seconds(Double_Property(name))
wenzelm@40850
    90
    def apply(name: String, default: Time): Time =
wenzelm@40850
    91
      Time.seconds(Double_Property(name, default.seconds))
wenzelm@40850
    92
    def update(name: String, value: Time) =
wenzelm@40850
    93
      Double_Property.update(name, value.seconds)
wenzelm@40850
    94
  }
wenzelm@40850
    95
wenzelm@40848
    96
wenzelm@37164
    97
  /* font */
wenzelm@37164
    98
wenzelm@37164
    99
  def font_family(): String = jEdit.getProperty("view.font")
wenzelm@37164
   100
wenzelm@37019
   101
  def font_size(): Float =
wenzelm@37019
   102
    (jEdit.getIntegerProperty("view.fontsize", 16) *
wenzelm@37019
   103
      Int_Property("relative-font-size", 100)).toFloat / 100
wenzelm@36814
   104
wenzelm@34618
   105
wenzelm@39043
   106
  /* text area ranges */
wenzelm@39043
   107
wenzelm@43714
   108
  sealed case class Gfx_Range(val x: Int, val y: Int, val length: Int)
wenzelm@39043
   109
wenzelm@39043
   110
  def gfx_range(text_area: TextArea, range: Text.Range): Option[Gfx_Range] =
wenzelm@39043
   111
  {
wenzelm@39043
   112
    val p = text_area.offsetToXY(range.start)
wenzelm@39043
   113
    val q = text_area.offsetToXY(range.stop)
wenzelm@39043
   114
    if (p != null && q != null && p.y == q.y) Some(new Gfx_Range(p.x, p.y, q.x - p.x))
wenzelm@39043
   115
    else None
wenzelm@39043
   116
  }
wenzelm@39043
   117
wenzelm@39043
   118
wenzelm@37201
   119
  /* tooltip markup */
wenzelm@37201
   120
wenzelm@37201
   121
  def tooltip(text: String): String =
wenzelm@37203
   122
    "<html><pre style=\"font-family: " + font_family() + "; font-size: " +
wenzelm@37203
   123
        Int_Property("tooltip-font-size", 10).toString + "px; \">" +  // FIXME proper scaling (!?)
wenzelm@37203
   124
      HTML.encode(text) + "</pre></html>"
wenzelm@37201
   125
wenzelm@40849
   126
  def tooltip_dismiss_delay(): Time =
wenzelm@40852
   127
    Time_Property("tooltip-dismiss-delay", Time.seconds(8.0)) max Time.seconds(0.5)
wenzelm@38854
   128
wenzelm@38854
   129
  def setup_tooltips()
wenzelm@38854
   130
  {
wenzelm@38854
   131
    Swing_Thread.now {
wenzelm@38854
   132
      val manager = javax.swing.ToolTipManager.sharedInstance
wenzelm@40849
   133
      manager.setDismissDelay(tooltip_dismiss_delay().ms.toInt)
wenzelm@38854
   134
    }
wenzelm@38854
   135
  }
wenzelm@38854
   136
wenzelm@37201
   137
wenzelm@39241
   138
  /* icons */
wenzelm@39241
   139
wenzelm@39241
   140
  def load_icon(name: String): javax.swing.Icon =
wenzelm@39241
   141
  {
wenzelm@39241
   142
    val icon = GUIUtilities.loadIcon(name)
wenzelm@39241
   143
    if (icon.getIconWidth < 0 || icon.getIconHeight < 0)
wenzelm@39630
   144
      Log.log(Log.ERROR, icon, "Bad icon: " + name)
wenzelm@39241
   145
    icon
wenzelm@39241
   146
  }
wenzelm@39241
   147
wenzelm@39241
   148
wenzelm@41382
   149
  /* check JVM */
wenzelm@41382
   150
wenzelm@41382
   151
  def check_jvm()
wenzelm@41382
   152
  {
wenzelm@41382
   153
    if (!Platform.is_hotspot) {
wenzelm@41382
   154
      Library.warning_dialog(jEdit.getActiveView, "Bad Java Virtual Machine",
wenzelm@41382
   155
        "This is " + Platform.jvm_name,
wenzelm@41382
   156
        "Isabelle/jEdit requires Java Hotspot from Sun/Oracle/Apple!")
wenzelm@41382
   157
    }
wenzelm@41382
   158
  }
wenzelm@41382
   159
wenzelm@41382
   160
wenzelm@38221
   161
  /* main jEdit components */
wenzelm@34784
   162
wenzelm@37177
   163
  def jedit_buffers(): Iterator[Buffer] = jEdit.getBuffers().iterator
wenzelm@34784
   164
wenzelm@37177
   165
  def jedit_views(): Iterator[View] = jEdit.getViews().iterator
wenzelm@34784
   166
wenzelm@34784
   167
  def jedit_text_areas(view: View): Iterator[JEditTextArea] =
wenzelm@37177
   168
    view.getEditPanes().iterator.map(_.getTextArea)
wenzelm@34784
   169
wenzelm@34784
   170
  def jedit_text_areas(): Iterator[JEditTextArea] =
wenzelm@34784
   171
    jedit_views().flatMap(jedit_text_areas(_))
wenzelm@34784
   172
wenzelm@34784
   173
  def jedit_text_areas(buffer: JEditBuffer): Iterator[JEditTextArea] =
wenzelm@34784
   174
    jedit_text_areas().filter(_.getBuffer == buffer)
wenzelm@34784
   175
wenzelm@38843
   176
  def buffer_lock[A](buffer: JEditBuffer)(body: => A): A =
wenzelm@38640
   177
  {
wenzelm@38640
   178
    try { buffer.readLock(); body }
wenzelm@38640
   179
    finally { buffer.readUnlock() }
wenzelm@38640
   180
  }
wenzelm@38640
   181
wenzelm@38843
   182
  def swing_buffer_lock[A](buffer: JEditBuffer)(body: => A): A =
wenzelm@38843
   183
    Swing_Thread.now { buffer_lock(buffer) { body } }
wenzelm@38843
   184
wenzelm@40474
   185
  def buffer_text(buffer: JEditBuffer): String =
wenzelm@40474
   186
    buffer_lock(buffer) { buffer.getText(0, buffer.getLength) }
wenzelm@40474
   187
wenzelm@34784
   188
wenzelm@43449
   189
  /* document model and view */
wenzelm@43449
   190
wenzelm@43449
   191
  def document_model(buffer: Buffer): Option[Document_Model] = Document_Model(buffer)
wenzelm@43449
   192
  def document_view(text_area: JEditTextArea): Option[Document_View] = Document_View(text_area)
wenzelm@43449
   193
wenzelm@43510
   194
  def init_model(buffer: Buffer)
wenzelm@43510
   195
  {
wenzelm@43510
   196
    swing_buffer_lock(buffer) {
wenzelm@43510
   197
      val opt_model =
wenzelm@43510
   198
        document_model(buffer) match {
wenzelm@43510
   199
          case Some(model) => Some(model)
wenzelm@43510
   200
          case None =>
wenzelm@43510
   201
            // FIXME strip protocol prefix of URL
wenzelm@43697
   202
            {
wenzelm@43697
   203
              try {
wenzelm@43697
   204
                Some(Thy_Header.split_thy_path(
wenzelm@43697
   205
                  Path.explode(Isabelle_System.posix_path(buffer.getPath))))
wenzelm@43697
   206
              }
wenzelm@43697
   207
              catch { case _ => None }
wenzelm@43697
   208
            } map {
wenzelm@43697
   209
              case (master_dir, thy_name) =>
wenzelm@43697
   210
                Document_Model.init(session, buffer, master_dir, thy_name)
wenzelm@43510
   211
            }
wenzelm@43510
   212
        }
wenzelm@43510
   213
      if (opt_model.isDefined) {
wenzelm@43510
   214
        for (text_area <- jedit_text_areas(buffer)) {
wenzelm@43510
   215
          if (document_view(text_area).map(_.model) != opt_model)
wenzelm@43510
   216
            Document_View.init(opt_model.get, text_area)
wenzelm@43510
   217
        }
wenzelm@43510
   218
      }
wenzelm@43510
   219
    }
wenzelm@43510
   220
  }
wenzelm@43510
   221
wenzelm@43510
   222
  def exit_model(buffer: Buffer)
wenzelm@43510
   223
  {
wenzelm@43510
   224
    swing_buffer_lock(buffer) {
wenzelm@43510
   225
      jedit_text_areas(buffer).foreach(Document_View.exit)
wenzelm@43510
   226
      Document_Model.exit(buffer)
wenzelm@43510
   227
    }
wenzelm@43510
   228
  }
wenzelm@43510
   229
wenzelm@43510
   230
  def init_view(buffer: Buffer, text_area: JEditTextArea)
wenzelm@43510
   231
  {
wenzelm@43510
   232
    swing_buffer_lock(buffer) {
wenzelm@43510
   233
      document_model(buffer) match {
wenzelm@43510
   234
        case Some(model) => Document_View.init(model, text_area)
wenzelm@43510
   235
        case None =>
wenzelm@43510
   236
      }
wenzelm@43510
   237
    }
wenzelm@43510
   238
  }
wenzelm@43510
   239
wenzelm@43510
   240
  def exit_view(buffer: Buffer, text_area: JEditTextArea)
wenzelm@43510
   241
  {
wenzelm@43510
   242
    swing_buffer_lock(buffer) {
wenzelm@43510
   243
      Document_View.exit(text_area)
wenzelm@43510
   244
    }
wenzelm@43510
   245
  }
wenzelm@43510
   246
wenzelm@43449
   247
wenzelm@37068
   248
  /* dockable windows */
wenzelm@37068
   249
wenzelm@37068
   250
  private def wm(view: View): DockableWindowManager = view.getDockableWindowManager
wenzelm@37068
   251
wenzelm@39515
   252
  def docked_session(view: View): Option[Session_Dockable] =
wenzelm@39515
   253
    wm(view).getDockableWindow("isabelle-session") match {
wenzelm@39515
   254
      case dockable: Session_Dockable => Some(dockable)
wenzelm@39515
   255
      case _ => None
wenzelm@39515
   256
    }
wenzelm@39515
   257
wenzelm@37068
   258
  def docked_output(view: View): Option[Output_Dockable] =
wenzelm@37068
   259
    wm(view).getDockableWindow("isabelle-output") match {
wenzelm@37068
   260
      case dockable: Output_Dockable => Some(dockable)
wenzelm@37068
   261
      case _ => None
wenzelm@37068
   262
    }
wenzelm@37068
   263
wenzelm@37068
   264
  def docked_raw_output(view: View): Option[Raw_Output_Dockable] =
wenzelm@37068
   265
    wm(view).getDockableWindow("isabelle-raw-output") match {
wenzelm@37068
   266
      case dockable: Raw_Output_Dockable => Some(dockable)
wenzelm@37068
   267
      case _ => None
wenzelm@37068
   268
    }
wenzelm@37068
   269
wenzelm@37068
   270
  def docked_protocol(view: View): Option[Protocol_Dockable] =
wenzelm@37068
   271
    wm(view).getDockableWindow("isabelle-protocol") match {
wenzelm@37068
   272
      case dockable: Protocol_Dockable => Some(dockable)
wenzelm@37068
   273
      case _ => None
wenzelm@37068
   274
    }
wenzelm@37068
   275
wenzelm@37068
   276
wenzelm@39517
   277
  /* logic image */
wenzelm@39517
   278
wenzelm@39517
   279
  def default_logic(): String =
wenzelm@39517
   280
  {
wenzelm@43661
   281
    val logic = Isabelle_System.getenv("JEDIT_LOGIC")
wenzelm@39517
   282
    if (logic != "") logic
wenzelm@43661
   283
    else Isabelle_System.getenv_strict("ISABELLE_LOGIC")
wenzelm@39517
   284
  }
wenzelm@39517
   285
wenzelm@39517
   286
  class Logic_Entry(val name: String, val description: String)
wenzelm@39517
   287
  {
wenzelm@39517
   288
    override def toString = description
wenzelm@39517
   289
  }
wenzelm@39517
   290
wenzelm@39517
   291
  def logic_selector(logic: String): ComboBox[Logic_Entry] =
wenzelm@39517
   292
  {
wenzelm@39517
   293
    val entries =
wenzelm@39517
   294
      new Logic_Entry("", "default (" + default_logic() + ")") ::
wenzelm@43661
   295
        Isabelle_System.find_logics().map(name => new Logic_Entry(name, name))
wenzelm@39517
   296
    val component = new ComboBox(entries)
wenzelm@39517
   297
    entries.find(_.name == logic) match {
wenzelm@39517
   298
      case None =>
wenzelm@39517
   299
      case Some(entry) => component.selection.item = entry
wenzelm@39517
   300
    }
wenzelm@39702
   301
    component.tooltip = "Isabelle logic image"
wenzelm@39517
   302
    component
wenzelm@39517
   303
  }
wenzelm@39702
   304
wenzelm@39702
   305
  def start_session()
wenzelm@39702
   306
  {
wenzelm@40852
   307
    val timeout = Time_Property("startup-timeout", Time.seconds(10)) max Time.seconds(5)
wenzelm@43670
   308
    val modes = space_explode(',', Isabelle_System.getenv("JEDIT_PRINT_MODE")).map("-m" + _)
wenzelm@39702
   309
    val logic = {
wenzelm@39702
   310
      val logic = Property("logic")
wenzelm@39702
   311
      if (logic != null && logic != "") logic
wenzelm@39702
   312
      else Isabelle.default_logic()
wenzelm@39702
   313
    }
wenzelm@40850
   314
    session.start(timeout, modes ::: List(logic))
wenzelm@39702
   315
  }
wenzelm@34318
   316
}
wenzelm@34318
   317
wenzelm@34429
   318
wenzelm@34618
   319
class Plugin extends EBPlugin
wenzelm@34618
   320
{
wenzelm@43645
   321
  /* editor file store */
wenzelm@43645
   322
wenzelm@43645
   323
  private val file_store = new Session.File_Store
wenzelm@43645
   324
  {
wenzelm@43645
   325
    def read(path: Path): String =
wenzelm@43645
   326
    {
wenzelm@43661
   327
      val platform_path = Isabelle_System.platform_path(path)
wenzelm@43645
   328
      val canonical_path = MiscUtilities.resolveSymlinks(platform_path)
wenzelm@43645
   329
wenzelm@43645
   330
      Isabelle.jedit_buffers().find(buffer =>
wenzelm@43645
   331
          MiscUtilities.resolveSymlinks(buffer.getPath) == canonical_path) match {
wenzelm@43645
   332
        case Some(buffer) => Isabelle.buffer_text(buffer)
wenzelm@43645
   333
        case None => Standard_System.read_file(new File(platform_path))
wenzelm@43645
   334
      }
wenzelm@43645
   335
    }
wenzelm@43645
   336
  }
wenzelm@43645
   337
wenzelm@43645
   338
wenzelm@43645
   339
  /* session manager */
wenzelm@39630
   340
wenzelm@39633
   341
  private val session_manager = actor {
wenzelm@39633
   342
    loop {
wenzelm@39633
   343
      react {
wenzelm@39735
   344
        case phase: Session.Phase =>
wenzelm@39735
   345
          phase match {
wenzelm@39735
   346
            case Session.Failed =>
wenzelm@39735
   347
              Swing_Thread.now {
wenzelm@39735
   348
                val text = new scala.swing.TextArea(Isabelle.session.syslog())
wenzelm@39735
   349
                text.editable = false
wenzelm@39735
   350
                Library.error_dialog(jEdit.getActiveView, "Failed to start Isabelle process", text)
wenzelm@39735
   351
              }
wenzelm@39735
   352
wenzelm@43510
   353
            case Session.Ready => Isabelle.jedit_buffers.foreach(Isabelle.init_model)
wenzelm@43510
   354
            case Session.Shutdown => Isabelle.jedit_buffers.foreach(Isabelle.exit_model)
wenzelm@39735
   355
            case _ =>
wenzelm@39735
   356
          }
wenzelm@39735
   357
        case bad => System.err.println("session_manager: ignoring bad message " + bad)
wenzelm@39630
   358
      }
wenzelm@39630
   359
    }
wenzelm@39630
   360
  }
wenzelm@39630
   361
wenzelm@39630
   362
wenzelm@34618
   363
  /* main plugin plumbing */
wenzelm@34433
   364
wenzelm@34767
   365
  override def handleMessage(message: EBMessage)
wenzelm@34618
   366
  {
wenzelm@43510
   367
    Swing_Thread.assert()
wenzelm@34767
   368
    message match {
wenzelm@41383
   369
      case msg: EditorStarted =>
wenzelm@43510
   370
        Isabelle.check_jvm()
wenzelm@43510
   371
        if (Isabelle.Boolean_Property("auto-start"))
wenzelm@43510
   372
          Isabelle.start_session()
wenzelm@39630
   373
wenzelm@37557
   374
      case msg: BufferUpdate
wenzelm@39735
   375
      if msg.getWhat == BufferUpdate.PROPERTIES_CHANGED =>
wenzelm@39634
   376
wenzelm@39633
   377
        val buffer = msg.getBuffer
wenzelm@43643
   378
        if (buffer != null && Isabelle.session.is_ready)
wenzelm@43510
   379
          Isabelle.init_model(buffer)
wenzelm@37557
   380
wenzelm@39634
   381
      case msg: EditPaneUpdate
wenzelm@39735
   382
      if (msg.getWhat == EditPaneUpdate.BUFFER_CHANGING ||
wenzelm@39637
   383
          msg.getWhat == EditPaneUpdate.BUFFER_CHANGED ||
wenzelm@39634
   384
          msg.getWhat == EditPaneUpdate.CREATED ||
wenzelm@39634
   385
          msg.getWhat == EditPaneUpdate.DESTROYED) =>
wenzelm@39634
   386
wenzelm@34784
   387
        val edit_pane = msg.getEditPane
wenzelm@34784
   388
        val buffer = edit_pane.getBuffer
wenzelm@34784
   389
        val text_area = edit_pane.getTextArea
wenzelm@34784
   390
wenzelm@39637
   391
        if (buffer != null && text_area != null) {
wenzelm@39735
   392
          if (msg.getWhat == EditPaneUpdate.BUFFER_CHANGED ||
wenzelm@43510
   393
              msg.getWhat == EditPaneUpdate.CREATED) {
wenzelm@43643
   394
            if (Isabelle.session.is_ready)
wenzelm@43510
   395
              Isabelle.init_view(buffer, text_area)
wenzelm@43510
   396
          }
wenzelm@43510
   397
          else Isabelle.exit_view(buffer, text_area)
immler@34671
   398
        }
wenzelm@34784
   399
wenzelm@34777
   400
      case msg: PropertiesChanged =>
wenzelm@43390
   401
        Swing_Thread.now { Isabelle.setup_tooltips() }
wenzelm@34791
   402
        Isabelle.session.global_settings.event(Session.Global_Settings)
wenzelm@34784
   403
wenzelm@34318
   404
      case _ =>
wenzelm@34318
   405
    }
wenzelm@34318
   406
  }
wenzelm@34318
   407
wenzelm@34618
   408
  override def start()
wenzelm@34618
   409
  {
wenzelm@43443
   410
    Isabelle.plugin = this
wenzelm@39630
   411
    Isabelle.setup_tooltips()
wenzelm@43661
   412
    Isabelle_System.init()
wenzelm@43661
   413
    Isabelle_System.install_fonts()
wenzelm@43661
   414
    Isabelle.session = new Session(file_store)
wenzelm@43661
   415
    SyntaxUtilities.setStyleExtender(new Token_Markup.Style_Extender)
wenzelm@43513
   416
    if (ModeProvider.instance.isInstanceOf[ModeProvider])
wenzelm@43513
   417
      ModeProvider.instance = new Token_Markup.Mode_Provider(ModeProvider.instance)
wenzelm@39633
   418
    Isabelle.session.phase_changed += session_manager
wenzelm@34318
   419
  }
wenzelm@34618
   420
wenzelm@39628
   421
  override def stop()
wenzelm@34618
   422
  {
wenzelm@43513
   423
    Isabelle.session.phase_changed -= session_manager
wenzelm@43513
   424
    Isabelle.jedit_buffers.foreach(Isabelle.exit_model)
wenzelm@39628
   425
    Isabelle.session.stop()
wenzelm@34318
   426
  }
wenzelm@34318
   427
}