src/Tools/jEdit/src/jedit_editor.scala
changeset 55876 142139457653
parent 55822 ccf2d784be97
child 55877 65c9968286d5
equal deleted inserted replaced
55850:7f229b0212fe 55876:142139457653
   140           else Array(name, "+line:" + line.toInt + "," + column.toInt)
   140           else Array(name, "+line:" + line.toInt + "," + column.toInt)
   141         jEdit.openFiles(view, null, args)
   141         jEdit.openFiles(view, null, args)
   142     }
   142     }
   143   }
   143   }
   144 
   144 
   145   override def hyperlink_url(name: String): Hyperlink =
       
   146     new Hyperlink {
       
   147       def follow(view: View) =
       
   148         default_thread_pool.submit(() =>
       
   149           try { Isabelle_System.open(name) }
       
   150           catch {
       
   151             case exn: Throwable =>
       
   152               GUI.error_dialog(view, "System error", GUI.scrollable_text(Exn.message(exn)))
       
   153           })
       
   154     }
       
   155 
       
   156   override def hyperlink_file(name: String, line: Int = 0, column: Int = 0): Hyperlink =
       
   157     new Hyperlink { def follow(view: View) = goto(view, name, line, column) }
       
   158 
       
   159   override def hyperlink_command(snapshot: Document.Snapshot, command: Command, raw_offset: Int = 0)
   145   override def hyperlink_command(snapshot: Document.Snapshot, command: Command, raw_offset: Int = 0)
   160     : Option[Hyperlink] =
   146     : Option[Hyperlink] =
   161   {
   147   {
   162     if (snapshot.is_outdated) None
   148     if (snapshot.is_outdated) None
   163     else {
   149     else {
   172           val (line, column) = ((1, 1) /: sources)(Symbol.advance_line_column)
   158           val (line, column) = ((1, 1) /: sources)(Symbol.advance_line_column)
   173           Some(new Hyperlink { def follow(view: View) { goto(view, file_name, line, column) } })
   159           Some(new Hyperlink { def follow(view: View) { goto(view, file_name, line, column) } })
   174       }
   160       }
   175     }
   161     }
   176   }
   162   }
       
   163 
       
   164   def hyperlink_command_id(
       
   165     snapshot: Document.Snapshot,
       
   166     id: Document_ID.Generic,
       
   167     raw_offset: Text.Offset): Option[Hyperlink] =
       
   168   {
       
   169     snapshot.state.find_command(snapshot.version, id) match {
       
   170       case Some((node, command)) => hyperlink_command(snapshot, command, raw_offset)
       
   171       case None => None
       
   172     }
       
   173   }
       
   174 
       
   175   def hyperlink_file(name: String, line: Int = 0, column: Int = 0): Hyperlink =
       
   176     new Hyperlink { def follow(view: View) = goto(view, name, line, column) }
       
   177 
       
   178   def hyperlink_source_file(name: String, line: Int): Option[Hyperlink] =
       
   179     if (Path.is_ok(name))
       
   180       Isabelle_System.source_file(Path.explode(name)).map(path =>
       
   181         hyperlink_file(Isabelle_System.platform_path(path), line))
       
   182     else None
       
   183 
       
   184   def hyperlink_url(name: String): Hyperlink =
       
   185     new Hyperlink {
       
   186       def follow(view: View) =
       
   187         default_thread_pool.submit(() =>
       
   188           try { Isabelle_System.open(name) }
       
   189           catch {
       
   190             case exn: Throwable =>
       
   191               GUI.error_dialog(view, "System error", GUI.scrollable_text(Exn.message(exn)))
       
   192           })
       
   193     }
   177 }
   194 }