minimal jedit mode for Isabelle NEWS;
authorwenzelm
Sat, 06 Jul 2013 21:19:38 +0200
changeset 52539 7658f8d7b2dc
parent 52538 64206b5b243c
child 52540 c1ddd91ba515
minimal jedit mode for Isabelle NEWS;
NEWS
src/Tools/jEdit/lib/Tools/jedit
src/Tools/jEdit/src/Isabelle.props
src/Tools/jEdit/src/isabelle_sidekick.scala
src/Tools/jEdit/src/modes/isabelle-news.xml
src/Tools/jEdit/src/services.xml
--- a/NEWS	Fri Jul 05 23:17:39 2013 +0200
+++ b/NEWS	Sat Jul 06 21:19:38 2013 +0200
@@ -10536,4 +10536,4 @@
 * 'subtype' facility in HOL for introducing new types as subsets of existing
 types;
 
-:mode=text:wrap=hard:maxLineLen=72:
+:mode=isabelle-news:wrap=hard:maxLineLen=72:
--- a/src/Tools/jEdit/lib/Tools/jedit	Fri Jul 05 23:17:39 2013 +0200
+++ b/src/Tools/jEdit/lib/Tools/jedit	Sat Jul 06 21:19:38 2013 +0200
@@ -284,6 +284,7 @@
   perl -i -e 'while (<>) {
     if (m/NAME="javacc"/) {
       print qq,<MODE NAME="isabelle" FILE="isabelle.xml" FILE_NAME_GLOB="*.thy"/>\n\n,;
+      print qq,<MODE NAME="isabelle-news" FILE="isabelle-news.xml"/>\n\n,;
       print qq,<MODE NAME="isabelle-options" FILE="isabelle-options.xml"/>\n\n,;
       print qq,<MODE NAME="isabelle-root" FILE="isabelle-root.xml" FILE_NAME_GLOB="ROOT"/>\n\n,; }
     print; }' dist/modes/catalog
--- a/src/Tools/jEdit/src/Isabelle.props	Fri Jul 05 23:17:39 2013 +0200
+++ b/src/Tools/jEdit/src/Isabelle.props	Sat Jul 06 21:19:38 2013 +0200
@@ -66,6 +66,8 @@
 isabelle-timing.title=Timing
 
 #SideKick
+mode.isabelle-news.folding=none
+mode.isabelle-news.sidekick.parser=isabelle-news
 mode.isabelle-options.folding=sidekick
 mode.isabelle-options.sidekick.parser=isabelle-options
 mode.isabelle-root.folding=sidekick
--- a/src/Tools/jEdit/src/isabelle_sidekick.scala	Fri Jul 05 23:17:39 2013 +0200
+++ b/src/Tools/jEdit/src/isabelle_sidekick.scala	Sat Jul 06 21:19:38 2013 +0200
@@ -12,6 +12,7 @@
 
 import scala.collection.Set
 import scala.collection.immutable.TreeSet
+import scala.util.matching.Regex
 
 import java.awt.Component
 import javax.swing.tree.DefaultMutableTreeNode
@@ -229,3 +230,34 @@
   }
 }
 
+
+class Isabelle_Sidekick_News extends Isabelle_Sidekick("isabelle-news", Some(Outer_Syntax.empty))
+{
+  private val Heading1 = new Regex("""^New in (.*)\w*$""")
+  private val Heading2 = new Regex("""^\*\*\*\w*(.*)\w*\*\*\*\w*$""")
+
+  private def make_node(s: String, start: Text.Offset, stop: Text.Offset): DefaultMutableTreeNode =
+    new DefaultMutableTreeNode(new Isabelle_Sidekick.Asset(s, start, stop))
+
+  override def parser(buffer: Buffer, syntax: Outer_Syntax, data: SideKickParsedData): Boolean =
+  {
+    var offset = 0
+
+    for (line <- split_lines(JEdit_Lib.buffer_text(buffer)) if !stopped) {
+      line match {
+        case Heading1(s) =>
+          data.root.add(make_node(Library.capitalize(s), offset, offset + line.length))
+        case Heading2(s) =>
+          data.root.getLastChild.asInstanceOf[DefaultMutableTreeNode]
+            .add(make_node(s, offset, offset + line.length))
+        case _ =>
+      }
+      offset += line.length + 1
+    }
+
+    true
+  }
+
+  override def supportsCompletion = false
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Tools/jEdit/src/modes/isabelle-news.xml	Sat Jul 06 21:19:38 2013 +0200
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE MODE SYSTEM "xmode.dtd">
+
+<!-- Isabelle NEWS mode -->
+<MODE>
+  <PROPS>
+    <PROPERTY NAME="noWordSep" VALUE="_'.?"/>
+    <PROPERTY NAME="unalignedOpenBrackets" VALUE="(" />
+    <PROPERTY NAME="unalignedCloseBrackets" VALUE=")" />
+    <PROPERTY NAME="tabSize" VALUE="2" />
+    <PROPERTY NAME="indentSize" VALUE="2" />
+  </PROPS>
+</MODE>
--- a/src/Tools/jEdit/src/services.xml	Fri Jul 05 23:17:39 2013 +0200
+++ b/src/Tools/jEdit/src/services.xml	Sat Jul 06 21:19:38 2013 +0200
@@ -8,6 +8,9 @@
 	<SERVICE NAME="isabelle" CLASS="sidekick.SideKickParser">
 		new isabelle.jedit.Isabelle_Sidekick_Default();
 	</SERVICE>
+	<SERVICE NAME="isabelle-news" CLASS="sidekick.SideKickParser">
+		new isabelle.jedit.Isabelle_Sidekick_News();
+	</SERVICE>
 	<SERVICE NAME="isabelle-options" CLASS="sidekick.SideKickParser">
 		new isabelle.jedit.Isabelle_Sidekick_Options();
 	</SERVICE>