buffer_line_context via untyped access;
authorwenzelm
Tue, 14 Oct 2014 19:39:29 +0200
changeset 58683 c9b7a00d5a10
parent 58682 542fa5093ebf
child 58684 56b9eab818ca
buffer_line_context via untyped access;
src/Tools/jEdit/src/token_markup.scala
--- a/src/Tools/jEdit/src/token_markup.scala	Tue Oct 14 19:38:41 2014 +0200
+++ b/src/Tools/jEdit/src/token_markup.scala	Tue Oct 14 19:39:29 2014 +0200
@@ -18,7 +18,7 @@
 import org.gjt.sp.jedit.syntax.{Token => JEditToken, TokenMarker, TokenHandler, ParserRuleSet,
   ModeProvider, XModeHandler, SyntaxStyle}
 import org.gjt.sp.jedit.textarea.{TextArea, Selection}
-import org.gjt.sp.jedit.buffer.JEditBuffer
+import org.gjt.sp.jedit.buffer.{JEditBuffer, LineManager}
 
 import javax.swing.text.Segment
 
@@ -186,6 +186,17 @@
       }
   }
 
+  def buffer_line_context[C](buffer: JEditBuffer, line: Int): Option[Generic_Line_Context[C]] =
+    Untyped.get(buffer, "lineMgr") match {
+      case line_mgr: LineManager =>
+        line_mgr.getLineContext(line) match {
+          case ctxt: Generic_Line_Context[C] => Some(ctxt)
+          case _ => None
+        }
+      case _ => None
+    }
+
+
   private val context_rules = new ParserRuleSet("isabelle", "MAIN")
 
   private class Line_Context(context: Option[Scan.Line_Context])