avoid confusion about pointless cursor movement with external links;
authorwenzelm
Wed, 09 Apr 2014 13:32:34 +0200
changeset 56494 1b74abf064e1
parent 56493 1f660d858a75
child 56495 0b9334adcf05
avoid confusion about pointless cursor movement with external links;
src/Pure/PIDE/editor.scala
src/Tools/jEdit/src/jedit_editor.scala
src/Tools/jEdit/src/rich_text_area.scala
--- a/src/Pure/PIDE/editor.scala	Wed Apr 09 12:33:02 2014 +0200
+++ b/src/Pure/PIDE/editor.scala	Wed Apr 09 13:32:34 2014 +0200
@@ -22,7 +22,10 @@
   def insert_overlay(command: Command, fn: String, args: List[String]): Unit
   def remove_overlay(command: Command, fn: String, args: List[String]): Unit
 
-  abstract class Hyperlink { def follow(context: Context): Unit }
+  abstract class Hyperlink {
+    def external: Boolean
+    def follow(context: Context): Unit
+  }
   def hyperlink_command(
     snapshot: Document.Snapshot, command: Command, offset: Symbol.Offset = 0): Option[Hyperlink]
 }
--- a/src/Tools/jEdit/src/jedit_editor.scala	Wed Apr 09 12:33:02 2014 +0200
+++ b/src/Tools/jEdit/src/jedit_editor.scala	Wed Apr 09 13:32:34 2014 +0200
@@ -161,6 +161,7 @@
 
   def hyperlink_url(name: String): Hyperlink =
     new Hyperlink {
+      val external = true
       def follow(view: View) =
         default_thread_pool.submit(() =>
           try { Isabelle_System.open(name) }
@@ -173,6 +174,7 @@
 
   def hyperlink_file(name: String, line: Int = 0, column: Int = 0): Hyperlink =
     new Hyperlink {
+      val external = false
       def follow(view: View) = goto_file(view, name, line, column)
       override def toString: String = "file " + quote(name)
     }
--- a/src/Tools/jEdit/src/rich_text_area.scala	Wed Apr 09 12:33:02 2014 +0200
+++ b/src/Tools/jEdit/src/rich_text_area.scala	Wed Apr 09 13:32:34 2014 +0200
@@ -168,12 +168,14 @@
       robust_body(()) {
         hyperlink_area.info match {
           case Some(Text.Info(range, link)) =>
-            try { text_area.moveCaretPosition(range.start) }
-            catch {
-              case _: ArrayIndexOutOfBoundsException =>
-              case _: IllegalArgumentException =>
+            if (!link.external) {
+              try { text_area.moveCaretPosition(range.start) }
+              catch {
+                case _: ArrayIndexOutOfBoundsException =>
+                case _: IllegalArgumentException =>
+              }
+              text_area.requestFocus
             }
-            text_area.requestFocus
             link.follow(view)
           case None =>
         }