minimal jedit mode for Isabelle NEWS;
authorwenzelm
Sat Jul 06 21:19:38 2013 +0200 (2013-07-06)
changeset 525397658f8d7b2dc
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
     1.1 --- a/NEWS	Fri Jul 05 23:17:39 2013 +0200
     1.2 +++ b/NEWS	Sat Jul 06 21:19:38 2013 +0200
     1.3 @@ -10536,4 +10536,4 @@
     1.4  * 'subtype' facility in HOL for introducing new types as subsets of existing
     1.5  types;
     1.6  
     1.7 -:mode=text:wrap=hard:maxLineLen=72:
     1.8 +:mode=isabelle-news:wrap=hard:maxLineLen=72:
     2.1 --- a/src/Tools/jEdit/lib/Tools/jedit	Fri Jul 05 23:17:39 2013 +0200
     2.2 +++ b/src/Tools/jEdit/lib/Tools/jedit	Sat Jul 06 21:19:38 2013 +0200
     2.3 @@ -284,6 +284,7 @@
     2.4    perl -i -e 'while (<>) {
     2.5      if (m/NAME="javacc"/) {
     2.6        print qq,<MODE NAME="isabelle" FILE="isabelle.xml" FILE_NAME_GLOB="*.thy"/>\n\n,;
     2.7 +      print qq,<MODE NAME="isabelle-news" FILE="isabelle-news.xml"/>\n\n,;
     2.8        print qq,<MODE NAME="isabelle-options" FILE="isabelle-options.xml"/>\n\n,;
     2.9        print qq,<MODE NAME="isabelle-root" FILE="isabelle-root.xml" FILE_NAME_GLOB="ROOT"/>\n\n,; }
    2.10      print; }' dist/modes/catalog
     3.1 --- a/src/Tools/jEdit/src/Isabelle.props	Fri Jul 05 23:17:39 2013 +0200
     3.2 +++ b/src/Tools/jEdit/src/Isabelle.props	Sat Jul 06 21:19:38 2013 +0200
     3.3 @@ -66,6 +66,8 @@
     3.4  isabelle-timing.title=Timing
     3.5  
     3.6  #SideKick
     3.7 +mode.isabelle-news.folding=none
     3.8 +mode.isabelle-news.sidekick.parser=isabelle-news
     3.9  mode.isabelle-options.folding=sidekick
    3.10  mode.isabelle-options.sidekick.parser=isabelle-options
    3.11  mode.isabelle-root.folding=sidekick
     4.1 --- a/src/Tools/jEdit/src/isabelle_sidekick.scala	Fri Jul 05 23:17:39 2013 +0200
     4.2 +++ b/src/Tools/jEdit/src/isabelle_sidekick.scala	Sat Jul 06 21:19:38 2013 +0200
     4.3 @@ -12,6 +12,7 @@
     4.4  
     4.5  import scala.collection.Set
     4.6  import scala.collection.immutable.TreeSet
     4.7 +import scala.util.matching.Regex
     4.8  
     4.9  import java.awt.Component
    4.10  import javax.swing.tree.DefaultMutableTreeNode
    4.11 @@ -229,3 +230,34 @@
    4.12    }
    4.13  }
    4.14  
    4.15 +
    4.16 +class Isabelle_Sidekick_News extends Isabelle_Sidekick("isabelle-news", Some(Outer_Syntax.empty))
    4.17 +{
    4.18 +  private val Heading1 = new Regex("""^New in (.*)\w*$""")
    4.19 +  private val Heading2 = new Regex("""^\*\*\*\w*(.*)\w*\*\*\*\w*$""")
    4.20 +
    4.21 +  private def make_node(s: String, start: Text.Offset, stop: Text.Offset): DefaultMutableTreeNode =
    4.22 +    new DefaultMutableTreeNode(new Isabelle_Sidekick.Asset(s, start, stop))
    4.23 +
    4.24 +  override def parser(buffer: Buffer, syntax: Outer_Syntax, data: SideKickParsedData): Boolean =
    4.25 +  {
    4.26 +    var offset = 0
    4.27 +
    4.28 +    for (line <- split_lines(JEdit_Lib.buffer_text(buffer)) if !stopped) {
    4.29 +      line match {
    4.30 +        case Heading1(s) =>
    4.31 +          data.root.add(make_node(Library.capitalize(s), offset, offset + line.length))
    4.32 +        case Heading2(s) =>
    4.33 +          data.root.getLastChild.asInstanceOf[DefaultMutableTreeNode]
    4.34 +            .add(make_node(s, offset, offset + line.length))
    4.35 +        case _ =>
    4.36 +      }
    4.37 +      offset += line.length + 1
    4.38 +    }
    4.39 +
    4.40 +    true
    4.41 +  }
    4.42 +
    4.43 +  override def supportsCompletion = false
    4.44 +}
    4.45 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/Tools/jEdit/src/modes/isabelle-news.xml	Sat Jul 06 21:19:38 2013 +0200
     5.3 @@ -0,0 +1,13 @@
     5.4 +<?xml version="1.0"?>
     5.5 +<!DOCTYPE MODE SYSTEM "xmode.dtd">
     5.6 +
     5.7 +<!-- Isabelle NEWS mode -->
     5.8 +<MODE>
     5.9 +  <PROPS>
    5.10 +    <PROPERTY NAME="noWordSep" VALUE="_'.?"/>
    5.11 +    <PROPERTY NAME="unalignedOpenBrackets" VALUE="(" />
    5.12 +    <PROPERTY NAME="unalignedCloseBrackets" VALUE=")" />
    5.13 +    <PROPERTY NAME="tabSize" VALUE="2" />
    5.14 +    <PROPERTY NAME="indentSize" VALUE="2" />
    5.15 +  </PROPS>
    5.16 +</MODE>
     6.1 --- a/src/Tools/jEdit/src/services.xml	Fri Jul 05 23:17:39 2013 +0200
     6.2 +++ b/src/Tools/jEdit/src/services.xml	Sat Jul 06 21:19:38 2013 +0200
     6.3 @@ -8,6 +8,9 @@
     6.4  	<SERVICE NAME="isabelle" CLASS="sidekick.SideKickParser">
     6.5  		new isabelle.jedit.Isabelle_Sidekick_Default();
     6.6  	</SERVICE>
     6.7 +	<SERVICE NAME="isabelle-news" CLASS="sidekick.SideKickParser">
     6.8 +		new isabelle.jedit.Isabelle_Sidekick_News();
     6.9 +	</SERVICE>
    6.10  	<SERVICE NAME="isabelle-options" CLASS="sidekick.SideKickParser">
    6.11  		new isabelle.jedit.Isabelle_Sidekick_Options();
    6.12  	</SERVICE>