src/Tools/jEdit/src/plugin.scala
changeset 65249 c3ee88b9c3cb
parent 65248 fef7b7a9e5b0
child 65256 c3d6dd17d626
equal deleted inserted replaced
65248:fef7b7a9e5b0 65249:c3ee88b9c3cb
    84 
    84 
    85   /* global changes */
    85   /* global changes */
    86 
    86 
    87   def options_changed()
    87   def options_changed()
    88   {
    88   {
    89     PIDE.session.global_options.post(Session.Global_Options(PIDE.options.value))
    89     PIDE.session.global_options.post(Session.Global_Options(options.value))
    90     delay_load.invoke()
    90     delay_load.invoke()
    91   }
    91   }
    92 
    92 
    93   def deps_changed()
    93   def deps_changed()
    94   {
    94   {
    97 
    97 
    98 
    98 
    99   /* theory files */
    99   /* theory files */
   100 
   100 
   101   lazy val delay_init =
   101   lazy val delay_init =
   102     GUI_Thread.delay_last(PIDE.options.seconds("editor_load_delay"))
   102     GUI_Thread.delay_last(options.seconds("editor_load_delay"))
   103     {
   103     {
   104       init_models()
   104       init_models()
   105     }
   105     }
   106 
   106 
   107   private val delay_load_active = Synchronized(false)
   107   private val delay_load_active = Synchronized(false)
   122             (for ((node_name, model) <- models.iterator if model.is_theory)
   122             (for ((node_name, model) <- models.iterator if model.is_theory)
   123               yield (node_name, Position.none)).toList
   123               yield (node_name, Position.none)).toList
   124           val thy_files = PIDE.resources.thy_info.dependencies("", thys).deps.map(_.name)
   124           val thy_files = PIDE.resources.thy_info.dependencies("", thys).deps.map(_.name)
   125 
   125 
   126           val aux_files =
   126           val aux_files =
   127             if (PIDE.options.bool("jedit_auto_resolve")) {
   127             if (options.bool("jedit_auto_resolve")) {
   128               val stable_tip_version =
   128               val stable_tip_version =
   129                 if (models.forall(p => p._2.is_stable))
   129                 if (models.forall(p => p._2.is_stable))
   130                   PIDE.session.current_state().stable_tip_version
   130                   PIDE.session.current_state().stable_tip_version
   131                 else None
   131                 else None
   132               stable_tip_version match {
   132               stable_tip_version match {
   162       }
   162       }
   163     }
   163     }
   164   }
   164   }
   165 
   165 
   166   private lazy val delay_load =
   166   private lazy val delay_load =
   167     GUI_Thread.delay_last(PIDE.options.seconds("editor_load_delay")) { delay_load_action() }
   167     GUI_Thread.delay_last(options.seconds("editor_load_delay")) { delay_load_action() }
   168 
   168 
   169   private def file_watcher_action(changed: Set[JFile]): Unit =
   169   private def file_watcher_action(changed: Set[JFile]): Unit =
   170     if (Document_Model.sync_files(changed)) JEdit_Editor.invoke_generated()
   170     if (Document_Model.sync_files(changed)) JEdit_Editor.invoke_generated()
   171 
   171 
   172   lazy val file_watcher: File_Watcher =
   172   lazy val file_watcher: File_Watcher =
   173     File_Watcher(file_watcher_action _, PIDE.options.seconds("editor_load_delay"))
   173     File_Watcher(file_watcher_action _, options.seconds("editor_load_delay"))
   174 
   174 
   175 
   175 
   176   /* session phase */
   176   /* session phase */
   177 
   177 
   178   val session_phase_changed: Session.Phase => Unit =
   178   val session_phase_changed: Session.Phase => Unit =
   182         GUI.error_dialog(jEdit.getActiveView, "Prover process terminated",
   182         GUI.error_dialog(jEdit.getActiveView, "Prover process terminated",
   183           "Isabelle Syslog", GUI.scrollable_text(PIDE.session.syslog_content()))
   183           "Isabelle Syslog", GUI.scrollable_text(PIDE.session.syslog_content()))
   184       }
   184       }
   185 
   185 
   186     case Session.Ready =>
   186     case Session.Ready =>
   187       PIDE.session.update_options(PIDE.options.value)
   187       PIDE.session.update_options(options.value)
   188       init_models()
   188       init_models()
   189 
   189 
   190       if (!Isabelle.continuous_checking) {
   190       if (!Isabelle.continuous_checking) {
   191         GUI_Thread.later {
   191         GUI_Thread.later {
   192           val answer =
   192           val answer =
   358             val buffer = edit_pane.getBuffer
   358             val buffer = edit_pane.getBuffer
   359             val text_area = edit_pane.getTextArea
   359             val text_area = edit_pane.getTextArea
   360             if (buffer != null && text_area != null) init_view(buffer, text_area)
   360             if (buffer != null && text_area != null) init_view(buffer, text_area)
   361           }
   361           }
   362 
   362 
   363           spell_checker.update(PIDE.options.value)
   363           spell_checker.update(options.value)
   364           PIDE.session.update_options(PIDE.options.value)
   364           PIDE.session.update_options(options.value)
   365 
   365 
   366         case _ =>
   366         case _ =>
   367       }
   367       }
   368     }
   368     }
   369   }
   369   }
   372   {
   372   {
   373     try {
   373     try {
   374       Debug.DISABLE_SEARCH_DIALOG_POOL = true
   374       Debug.DISABLE_SEARCH_DIALOG_POOL = true
   375 
   375 
   376       completion_history.load()
   376       completion_history.load()
   377       spell_checker.update(PIDE.options.value)
   377       spell_checker.update(options.value)
   378 
   378 
   379       SyntaxUtilities.setStyleExtender(new Token_Markup.Style_Extender)
   379       SyntaxUtilities.setStyleExtender(new Token_Markup.Style_Extender)
   380       if (ModeProvider.instance.isInstanceOf[ModeProvider])
   380       if (ModeProvider.instance.isInstanceOf[ModeProvider])
   381         ModeProvider.instance = new Token_Markup.Mode_Provider(ModeProvider.instance)
   381         ModeProvider.instance = new Token_Markup.Mode_Provider(ModeProvider.instance)
   382 
   382 
   384 
   384 
   385       val resources = new JEdit_Resources(JEdit_Sessions.session_base())
   385       val resources = new JEdit_Resources(JEdit_Sessions.session_base())
   386 
   386 
   387       PIDE.session.stop()
   387       PIDE.session.stop()
   388       PIDE.session = new Session(resources) {
   388       PIDE.session = new Session(resources) {
   389         override def output_delay = PIDE.options.seconds("editor_output_delay")
   389         override def output_delay = options.seconds("editor_output_delay")
   390         override def prune_delay = PIDE.options.seconds("editor_prune_delay")
   390         override def prune_delay = options.seconds("editor_prune_delay")
   391         override def syslog_limit = PIDE.options.int("editor_syslog_limit")
   391         override def syslog_limit = options.int("editor_syslog_limit")
   392         override def reparse_limit = PIDE.options.int("editor_reparse_limit")
   392         override def reparse_limit = options.int("editor_reparse_limit")
   393       }
   393       }
   394 
   394 
   395       startup_failure = None
   395       startup_failure = None
   396     }
   396     }
   397     catch {
   397     catch {
   405   override def stop()
   405   override def stop()
   406   {
   406   {
   407     JEdit_Lib.jedit_text_areas.foreach(Completion_Popup.Text_Area.exit _)
   407     JEdit_Lib.jedit_text_areas.foreach(Completion_Popup.Text_Area.exit _)
   408 
   408 
   409     if (startup_failure.isEmpty) {
   409     if (startup_failure.isEmpty) {
   410       PIDE.options.value.save_prefs()
   410       options.value.save_prefs()
   411       completion_history.value.save()
   411       completion_history.value.save()
   412     }
   412     }
   413 
   413 
   414     exit_models(JEdit_Lib.jedit_buffers().toList)
   414     exit_models(JEdit_Lib.jedit_buffers().toList)
   415     PIDE.session.stop()
   415     PIDE.session.stop()