set view title dynamically;
authorwenzelm
Fri, 04 May 2018 16:22:09 +0200
changeset 68080 17f79ae49401
parent 68078 48e188cb1591
child 68081 3d8f34715013
set view title dynamically;
Admin/lib/Tools/makedist_bundle
NEWS
src/Tools/jEdit/src/jEdit.props
src/Tools/jEdit/src/plugin.scala
--- a/Admin/lib/Tools/makedist_bundle	Fri May 04 15:59:21 2018 +0200
+++ b/Admin/lib/Tools/makedist_bundle	Fri May 04 16:22:09 2018 +0200
@@ -185,9 +185,6 @@
 
 # platform-specific setup (inside archive)
 
-perl -pi -e "s,view.title=Isabelle/jEdit,view.title=${ISABELLE_NAME},g;" \
-  "$ISABELLE_TARGET/src/Tools/jEdit/dist/properties/jEdit.props"
-
 case "$PLATFORM_FAMILY" in
   linux)
     purge_target 'contrib -name "x86*-darwin" -o -name "x86*-cygwin" -o -name "x86*-windows"'
--- a/NEWS	Fri May 04 15:59:21 2018 +0200
+++ b/NEWS	Fri May 04 16:22:09 2018 +0200
@@ -71,6 +71,10 @@
 
 *** Isabelle/jEdit Prover IDE ***
 
+* The view title is set dynamically, according to the Isabelle
+distribution and the logic session name. The user can override this via
+set-view-title (stored persistently in $JEDIT_SETTINGS/perspective.xml).
+
 * System options "spell_checker_include" and "spell_checker_exclude"
 supersede former "spell_checker_elements" to determine regions of text
 that are subject to spell-checking. Minor INCOMPATIBILITY.
--- a/src/Tools/jEdit/src/jEdit.props	Fri May 04 15:59:21 2018 +0200
+++ b/src/Tools/jEdit/src/jEdit.props	Fri May 04 16:22:09 2018 +0200
@@ -310,6 +310,5 @@
 view.middleMousePaste=true
 view.showToolbar=true
 view.thickCaret=true
-view.title=Isabelle/jEdit -\u0020
 view.width=1072
 xml-insert-closing-tag.shortcut=
--- a/src/Tools/jEdit/src/plugin.scala	Fri May 04 15:59:21 2018 +0200
+++ b/src/Tools/jEdit/src/plugin.scala	Fri May 04 16:22:09 2018 +0200
@@ -16,7 +16,8 @@
 import org.gjt.sp.jedit.{jEdit, EBMessage, EBPlugin, Buffer, View, PerspectiveManager}
 import org.gjt.sp.jedit.textarea.JEditTextArea
 import org.gjt.sp.jedit.syntax.ModeProvider
-import org.gjt.sp.jedit.msg.{EditorStarted, BufferUpdate, EditPaneUpdate, PropertiesChanged}
+import org.gjt.sp.jedit.msg.{EditorStarted, BufferUpdate, EditPaneUpdate, PropertiesChanged,
+  ViewUpdate}
 import org.gjt.sp.util.SyntaxUtilities
 import org.gjt.sp.util.Log
 
@@ -292,6 +293,19 @@
     Keymap_Merge.check_dialog(view)
   }
 
+  private def init_title(view: View)
+  {
+    val title =
+      proper_string(Isabelle_System.getenv("ISABELLE_IDENTIFIER")).getOrElse("Isabelle") +
+        "/" + PIDE.resources.session_name
+    val marker = "\u200B"
+
+    val old_title = view.getViewConfig.title
+    if (old_title == null || old_title.startsWith(marker)) {
+      view.setUserTitle(marker + title)
+    }
+  }
+
   override def handleMessage(message: EBMessage)
   {
     GUI_Thread.assert {}
@@ -330,6 +344,10 @@
           PIDE.editor.hyperlink_position(true, Document.Snapshot.init,
             JEdit_Sessions.logic_root(options.value)).foreach(_.follow(view))
 
+        case msg: ViewUpdate
+        if msg.getWhat == ViewUpdate.CREATED && msg.getView != null =>
+          init_title(msg.getView)
+
         case msg: BufferUpdate
         if msg.getWhat == BufferUpdate.LOAD_STARTED || msg.getWhat == BufferUpdate.CLOSING =>
           if (msg.getBuffer != null) {
@@ -436,6 +454,8 @@
       completion_history.load()
       spell_checker.update(options.value)
 
+      JEdit_Lib.jedit_views.foreach(init_title(_))
+
       isabelle.jedit_base.Syntax_Style.set_style_extender(Syntax_Style.Extender)
       init_mode_provider()
       JEdit_Lib.jedit_text_areas.foreach(Completion_Popup.Text_Area.init _)