src/Tools/jEdit/src/jedit_editor.scala
author wenzelm
Fri, 06 Jan 2017 13:27:18 +0100
changeset 64813 7283f41d05ab
parent 64799 c0c648911f1a
child 64817 0bb6b582bb4f
permissions -rw-r--r--
manage buffer models as explicit global state; tuned signature;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     1
/*  Title:      Tools/jEdit/src/jedit_editor.scala
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     3
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     4
PIDE editor operations for jEdit.
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     5
*/
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     6
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     7
package isabelle.jedit
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     8
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
     9
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    10
import isabelle._
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    11
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    12
54706
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
    13
import java.io.{File => JFile}
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
    14
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
    15
import org.gjt.sp.jedit.{jEdit, View, Buffer}
54706
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
    16
import org.gjt.sp.jedit.browser.VFSBrowser
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    17
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    18
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    19
class JEdit_Editor extends Editor[View]
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    20
{
52977
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
    21
  /* session */
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
    22
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
    23
  override def session: Session = PIDE.session
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    24
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
    25
  // owned by GUI thread
57611
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    26
  private var removed_nodes = Set.empty[Document.Node.Name]
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    27
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    28
  def remove_node(name: Document.Node.Name): Unit =
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
    29
    GUI_Thread.require { removed_nodes += name }
57611
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    30
61728
5f5ff1eab407 double flush to ensure persistent "state" output is reset;
wenzelm
parents: 61660
diff changeset
    31
  override def flush(hidden: Boolean = false)
52974
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    32
  {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
    33
    GUI_Thread.require {}
52974
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    34
55783
da0513d95155 more formal Document.Blobs;
wenzelm
parents: 55781
diff changeset
    35
    val doc_blobs = PIDE.document_blobs()
57611
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    36
    val models = PIDE.document_models()
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    37
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    38
    val removed = removed_nodes; removed_nodes = Set.empty
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    39
    val removed_perspective =
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    40
      (removed -- models.iterator.map(_.node_name)).toList.map(
57615
df1b3452d71c more explicit discrimination of empty nodes -- suppress from Theories panel;
wenzelm
parents: 57612
diff changeset
    41
        name => (name, Document.Node.no_perspective_text))
57611
b6256ea3b7c5 proper change of perspective for removed nodes (stemming from closed buffers);
wenzelm
parents: 56770
diff changeset
    42
61728
5f5ff1eab407 double flush to ensure persistent "state" output is reset;
wenzelm
parents: 61660
diff changeset
    43
    val edits = models.flatMap(_.flushed_edits(hidden, doc_blobs)) ::: removed_perspective
61544
19d84de5f534 redundant;
wenzelm
parents: 61011
diff changeset
    44
    session.update(doc_blobs, edits)
52974
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    45
  }
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    46
64524
e6a3c55b929b explicit option editor_generated_input_delay, which is more aggressive by default;
wenzelm
parents: 64521
diff changeset
    47
  private val delay1_flush =
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
    48
    GUI_Thread.delay_last(PIDE.options.seconds("editor_input_delay")) { flush() }
54461
6c360a6ade0e centralized management of pending buffer edits;
wenzelm
parents: 54325
diff changeset
    49
64524
e6a3c55b929b explicit option editor_generated_input_delay, which is more aggressive by default;
wenzelm
parents: 64521
diff changeset
    50
  private val delay2_flush =
e6a3c55b929b explicit option editor_generated_input_delay, which is more aggressive by default;
wenzelm
parents: 64521
diff changeset
    51
    GUI_Thread.delay_first(PIDE.options.seconds("editor_generated_input_delay")) { flush() }
64521
1aef5a0e18d7 delay_first for machine generated editor events: avoid starvation, e.g. when operating on big sessions;
wenzelm
parents: 62248
diff changeset
    52
64524
e6a3c55b929b explicit option editor_generated_input_delay, which is more aggressive by default;
wenzelm
parents: 64521
diff changeset
    53
  def invoke(): Unit = delay1_flush.invoke()
e6a3c55b929b explicit option editor_generated_input_delay, which is more aggressive by default;
wenzelm
parents: 64521
diff changeset
    54
  def invoke_generated(): Unit = { delay1_flush.invoke(); delay2_flush.invoke() }
54461
6c360a6ade0e centralized management of pending buffer edits;
wenzelm
parents: 54325
diff changeset
    55
60933
6d03e05ef041 more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents: 60893
diff changeset
    56
  def stable_tip_version(): Option[Document.Version] =
6d03e05ef041 more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents: 60893
diff changeset
    57
    GUI_Thread.require {
6d03e05ef041 more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents: 60893
diff changeset
    58
      if (removed_nodes.isEmpty && PIDE.document_models().forall(_.is_stable))
6d03e05ef041 more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents: 60893
diff changeset
    59
        session.current_state().stable_tip_version
6d03e05ef041 more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents: 60893
diff changeset
    60
      else None
6d03e05ef041 more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents: 60893
diff changeset
    61
    }
6d03e05ef041 more robust access to stable tip version: take all pending edits into account, don't assume model for current buffer;
wenzelm
parents: 60893
diff changeset
    62
64799
c0c648911f1a misc tuning and clarification;
wenzelm
parents: 64682
diff changeset
    63
  def visible_node(name: Document.Node.Name): Boolean =
c0c648911f1a misc tuning and clarification;
wenzelm
parents: 64682
diff changeset
    64
    JEdit_Lib.jedit_buffer(name) match {
c0c648911f1a misc tuning and clarification;
wenzelm
parents: 64682
diff changeset
    65
      case Some(buffer) => JEdit_Lib.jedit_text_areas(buffer).nonEmpty
c0c648911f1a misc tuning and clarification;
wenzelm
parents: 64682
diff changeset
    66
      case None => false
c0c648911f1a misc tuning and clarification;
wenzelm
parents: 64682
diff changeset
    67
    }
c0c648911f1a misc tuning and clarification;
wenzelm
parents: 64682
diff changeset
    68
52977
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
    69
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
    70
  /* current situation */
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
    71
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
    72
  override def current_context: View =
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
    73
    GUI_Thread.require { jEdit.getActiveView() }
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    74
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
    75
  override def current_node(view: View): Option[Document.Node.Name] =
64813
7283f41d05ab manage buffer models as explicit global state;
wenzelm
parents: 64799
diff changeset
    76
    GUI_Thread.require { Document_Model.get(view.getBuffer).map(_.node_name) }
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    77
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
    78
  override def current_node_snapshot(view: View): Option[Document.Snapshot] =
64813
7283f41d05ab manage buffer models as explicit global state;
wenzelm
parents: 64799
diff changeset
    79
    GUI_Thread.require { Document_Model.get(view.getBuffer).map(_.snapshot()) }
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    80
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
    81
  override def node_snapshot(name: Document.Node.Name): Document.Snapshot =
52974
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    82
  {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
    83
    GUI_Thread.require {}
52974
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    84
56457
eea4bbe15745 tuned signature -- prefer static type Document.Node.Name;
wenzelm
parents: 56413
diff changeset
    85
    JEdit_Lib.jedit_buffer(name) match {
52974
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    86
      case Some(buffer) =>
64813
7283f41d05ab manage buffer models as explicit global state;
wenzelm
parents: 64799
diff changeset
    87
        Document_Model.get(buffer) match {
52974
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    88
          case Some(model) => model.snapshot
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    89
          case None => session.snapshot(name)
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    90
        }
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    91
      case None => session.snapshot(name)
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    92
    }
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    93
  }
908e8a36e975 tuned signature;
wenzelm
parents: 52973
diff changeset
    94
53844
71f103629327 skip ignored commands, similar to former proper_command_at (see d68ea01d5084) -- relevant to Output, Query_Operation etc.;
wenzelm
parents: 52980
diff changeset
    95
  override def current_command(view: View, snapshot: Document.Snapshot): Option[Command] =
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    96
  {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
    97
    GUI_Thread.require {}
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
    98
54325
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
    99
    val text_area = view.getTextArea
54528
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   100
    val buffer = view.getBuffer
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   101
54325
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
   102
    PIDE.document_view(text_area) match {
55432
9c53198dbb1c maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents: 54706
diff changeset
   103
      case Some(doc_view) if doc_view.model.is_theory =>
54325
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
   104
        val node = snapshot.version.nodes(doc_view.model.node_name)
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
   105
        val caret = snapshot.revert(text_area.getCaretPosition)
54528
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   106
        if (caret < buffer.getLength) {
56373
0605d90be6fc tuned signature -- more explicit iterator terminology;
wenzelm
parents: 56314
diff changeset
   107
          val caret_command_iterator = node.command_iterator(caret)
0605d90be6fc tuned signature -- more explicit iterator terminology;
wenzelm
parents: 56314
diff changeset
   108
          if (caret_command_iterator.hasNext) {
0605d90be6fc tuned signature -- more explicit iterator terminology;
wenzelm
parents: 56314
diff changeset
   109
            val (cmd0, _) = caret_command_iterator.next
54325
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
   110
            node.commands.reverse.iterator(cmd0).find(cmd => !cmd.is_ignored)
53844
71f103629327 skip ignored commands, similar to former proper_command_at (see d68ea01d5084) -- relevant to Output, Query_Operation etc.;
wenzelm
parents: 52980
diff changeset
   111
          }
54325
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
   112
          else None
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
   113
        }
2c4155003352 clarified Editor.current_command: allow outdated snapshot;
wenzelm
parents: 53845
diff changeset
   114
        else node.commands.reverse.iterator.find(cmd => !cmd.is_ignored)
55432
9c53198dbb1c maintain multiple command chunks and markup trees: for main chunk and loaded files;
wenzelm
parents: 54706
diff changeset
   115
      case _ =>
64813
7283f41d05ab manage buffer models as explicit global state;
wenzelm
parents: 64799
diff changeset
   116
        Document_Model.get(buffer) match {
54531
8330faaeebd5 restrict node_required status and Theories panel to actual theories;
wenzelm
parents: 54528
diff changeset
   117
          case Some(model) if !model.is_theory =>
64799
c0c648911f1a misc tuning and clarification;
wenzelm
parents: 64682
diff changeset
   118
            snapshot.version.nodes.commands_loading(model.node_name) match {
54528
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   119
              case cmd :: _ => Some(cmd)
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   120
              case Nil => None
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   121
            }
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   122
          case _ => None
842adea880a4 refer to thy_load command of auxiliary file;
wenzelm
parents: 54522
diff changeset
   123
        }
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
   124
    }
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
   125
  }
52977
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
   126
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
   127
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
   128
  /* overlays */
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
   129
57873
ea94d2aa62be clarified synchronized scope;
wenzelm
parents: 57615
diff changeset
   130
  private val overlays = Synchronized(Document.Overlays.empty)
52977
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
   131
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   132
  override def node_overlays(name: Document.Node.Name): Document.Node.Overlays =
57873
ea94d2aa62be clarified synchronized scope;
wenzelm
parents: 57615
diff changeset
   133
    overlays.value(name)
52977
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
   134
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   135
  override def insert_overlay(command: Command, fn: String, args: List[String]): Unit =
57873
ea94d2aa62be clarified synchronized scope;
wenzelm
parents: 57615
diff changeset
   136
    overlays.change(_.insert(command, fn, args))
52977
15254e32d299 central management of Document.Overlays, independent of Document_Model;
wenzelm
parents: 52974
diff changeset
   137
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   138
  override def remove_overlay(command: Command, fn: String, args: List[String]): Unit =
57873
ea94d2aa62be clarified synchronized scope;
wenzelm
parents: 57615
diff changeset
   139
    overlays.change(_.remove(command, fn, args))
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   140
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   141
55877
65c9968286d5 tuned signature;
wenzelm
parents: 55876
diff changeset
   142
  /* navigation */
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   143
56413
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   144
  def push_position(view: View)
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   145
  {
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   146
    val navigator = jEdit.getPlugin("ise.plugin.nav.NavigatorPlugin")
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   147
    if (navigator != null) {
59080
611914621edb added Untyped.method convenience (for *this* class only);
wenzelm
parents: 58545
diff changeset
   148
      try { Untyped.method(navigator.getClass, "pushPosition", view.getClass).invoke(null, view) }
56413
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   149
      catch { case _: NoSuchMethodException => }
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   150
    }
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   151
  }
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   152
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   153
  def goto_buffer(focus: Boolean, view: View, buffer: Buffer, offset: Text.Offset)
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   154
  {
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   155
    GUI_Thread.require {}
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   156
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   157
    push_position(view)
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   158
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   159
    if (focus) view.goToBuffer(buffer) else view.showBuffer(buffer)
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   160
    try { view.getTextArea.moveCaretPosition(offset) }
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   161
    catch {
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   162
      case _: ArrayIndexOutOfBoundsException =>
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   163
      case _: IllegalArgumentException =>
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   164
    }
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   165
  }
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   166
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   167
  def goto_file(focus: Boolean, view: View, name: String): Unit =
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   168
    goto_file(focus, view, Line.Node_Position(name))
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   169
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   170
  def goto_file(focus: Boolean, view: View, pos: Line.Node_Position)
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   171
  {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57611
diff changeset
   172
    GUI_Thread.require {}
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   173
56413
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   174
    push_position(view)
2d4d9a5f68ff support for jEdit Navigator plugin;
wenzelm
parents: 56373
diff changeset
   175
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   176
    val name = pos.name
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   177
    val line = pos.line
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   178
    val column = pos.column
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   179
54706
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
   180
    JEdit_Lib.jedit_buffer(name) match {
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   181
      case Some(buffer) =>
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   182
        if (focus) view.goToBuffer(buffer) else view.showBuffer(buffer)
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   183
        val text_area = view.getTextArea
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   184
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   185
        try {
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   186
          val line_start = text_area.getBuffer.getLineStartOffset(line)
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   187
          text_area.moveCaretPosition(line_start)
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   188
          if (column > 0) text_area.moveCaretPosition(line_start + column)
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   189
        }
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   190
        catch {
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   191
          case _: ArrayIndexOutOfBoundsException =>
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   192
          case _: IllegalArgumentException =>
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   193
        }
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   194
54706
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
   195
      case None if (new JFile(name)).isDirectory =>
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
   196
        VFSBrowser.browseDirectory(view, name)
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
   197
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   198
      case None =>
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   199
        val args =
54706
d3c656f0b7ab browse directory hyperlink as well;
wenzelm
parents: 54702
diff changeset
   200
          if (line <= 0) Array(name)
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   201
          else if (column <= 0) Array(name, "+line:" + (line + 1))
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   202
          else Array(name, "+line:" + (line + 1) + "," + (column + 1))
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   203
        jEdit.openFiles(view, null, args)
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   204
    }
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   205
  }
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   206
61660
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   207
  def goto_doc(view: View, path: Path)
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   208
  {
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   209
    if (path.is_file)
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   210
      goto_file(true, view, File.platform_path(path))
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   211
    else {
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   212
      Standard_Thread.fork("documentation") {
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   213
        try { Doc.view(path) }
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   214
        catch {
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   215
          case exn: Throwable =>
62062
ee610059b0e9 fewer use of GUI_Thread.now to reduce danger of deadlock on shutdown;
wenzelm
parents: 61728
diff changeset
   216
            GUI_Thread.later {
ee610059b0e9 fewer use of GUI_Thread.now to reduce danger of deadlock on shutdown;
wenzelm
parents: 61728
diff changeset
   217
              GUI.error_dialog(view,
ee610059b0e9 fewer use of GUI_Thread.now to reduce danger of deadlock on shutdown;
wenzelm
parents: 61728
diff changeset
   218
                "Documentation error", GUI.scrollable_text(Exn.message(exn)))
ee610059b0e9 fewer use of GUI_Thread.now to reduce danger of deadlock on shutdown;
wenzelm
parents: 61728
diff changeset
   219
            }
61660
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   220
        }
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   221
      }
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   222
    }
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   223
  }
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   224
55877
65c9968286d5 tuned signature;
wenzelm
parents: 55876
diff changeset
   225
65c9968286d5 tuned signature;
wenzelm
parents: 55876
diff changeset
   226
  /* hyperlinks */
65c9968286d5 tuned signature;
wenzelm
parents: 55876
diff changeset
   227
61660
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   228
  def hyperlink_doc(name: String): Option[Hyperlink] =
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   229
    Doc.contents().collectFirst({
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   230
      case doc: Doc.Text_File if doc.name == name => doc.path
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   231
      case doc: Doc.Doc if doc.name == name => doc.path}).map(path =>
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   232
        new Hyperlink {
64663
wenzelm
parents: 64662
diff changeset
   233
          override val external = !path.is_file
61660
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   234
          def follow(view: View): Unit = goto_doc(view, path)
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   235
          override def toString: String = "doc " + quote(name)
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   236
        })
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61557
diff changeset
   237
56461
wenzelm
parents: 56458
diff changeset
   238
  def hyperlink_url(name: String): Hyperlink =
wenzelm
parents: 56458
diff changeset
   239
    new Hyperlink {
64663
wenzelm
parents: 64662
diff changeset
   240
      override val external = true
56729
1da2272a06a4 prefer Isabelle/Scala operations;
wenzelm
parents: 56662
diff changeset
   241
      def follow(view: View): Unit =
61557
f6387515f951 prefer ad-hoc non-worker threads;
wenzelm
parents: 61544
diff changeset
   242
        Standard_Thread.fork("hyperlink_url") {
62248
dca0bac351b2 allow single quote within URL;
wenzelm
parents: 62062
diff changeset
   243
          try { Isabelle_System.open(Url.escape(name)) }
56461
wenzelm
parents: 56458
diff changeset
   244
          catch {
wenzelm
parents: 56458
diff changeset
   245
            case exn: Throwable =>
62062
ee610059b0e9 fewer use of GUI_Thread.now to reduce danger of deadlock on shutdown;
wenzelm
parents: 61728
diff changeset
   246
              GUI_Thread.later {
ee610059b0e9 fewer use of GUI_Thread.now to reduce danger of deadlock on shutdown;
wenzelm
parents: 61728
diff changeset
   247
                GUI.error_dialog(view, "System error", GUI.scrollable_text(Exn.message(exn)))
ee610059b0e9 fewer use of GUI_Thread.now to reduce danger of deadlock on shutdown;
wenzelm
parents: 61728
diff changeset
   248
              }
56729
1da2272a06a4 prefer Isabelle/Scala operations;
wenzelm
parents: 56662
diff changeset
   249
          }
1da2272a06a4 prefer Isabelle/Scala operations;
wenzelm
parents: 56662
diff changeset
   250
        }
56461
wenzelm
parents: 56458
diff changeset
   251
      override def toString: String = "URL " + quote(name)
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52978
diff changeset
   252
    }
55876
142139457653 tuned signature;
wenzelm
parents: 55822
diff changeset
   253
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   254
  def hyperlink_buffer(focus: Boolean, buffer: Buffer, offset: Text.Offset): Hyperlink =
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   255
    new Hyperlink {
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   256
      def follow(view: View): Unit = goto_buffer(focus, view, buffer, offset)
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   257
      override def toString: String = "buffer " + quote(JEdit_Lib.buffer_name(buffer))
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   258
    }
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 57878
diff changeset
   259
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   260
  def hyperlink_file(focus: Boolean, name: String): Hyperlink =
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   261
    hyperlink_file(focus, Line.Node_Position(name))
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   262
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   263
  def hyperlink_file(focus: Boolean, pos: Line.Node_Position): Hyperlink =
56461
wenzelm
parents: 56458
diff changeset
   264
    new Hyperlink {
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   265
      def follow(view: View): Unit = goto_file(focus, view, pos)
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   266
      override def toString: String = "file " + quote(pos.name)
56461
wenzelm
parents: 56458
diff changeset
   267
    }
55876
142139457653 tuned signature;
wenzelm
parents: 55822
diff changeset
   268
64653
89c5bb2a2128 tuned -- use zero-based Line.Position;
wenzelm
parents: 64613
diff changeset
   269
  def hyperlink_source_file(focus: Boolean, source_name: String, line1: Int, offset: Symbol.Offset)
55878
6d092a5166f1 more precise navigation within open files;
wenzelm
parents: 55877
diff changeset
   270
    : Option[Hyperlink] =
6d092a5166f1 more precise navigation within open files;
wenzelm
parents: 55877
diff changeset
   271
  {
64657
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   272
    for (name <- PIDE.resources.source_file(source_name)) yield {
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   273
      JEdit_Lib.jedit_buffer(name) match {
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   274
        case Some(buffer) if offset > 0 =>
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   275
          val pos =
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   276
            JEdit_Lib.buffer_lock(buffer) {
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   277
              (Line.Position.zero /:
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   278
                (Symbol.iterator(JEdit_Lib.buffer_text(buffer)).
64682
7e119f32276a clarified modules;
wenzelm
parents: 64681
diff changeset
   279
                  zipWithIndex.takeWhile(p => p._2 < offset - 1).
7e119f32276a clarified modules;
wenzelm
parents: 64681
diff changeset
   280
                  map(_._1)))(_.advance(_, Text.Length))
64657
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   281
            }
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   282
          hyperlink_file(focus, Line.Node_Position(name, pos))
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   283
        case _ =>
6209e0f7a4e8 clarified modules;
wenzelm
parents: 64653
diff changeset
   284
          hyperlink_file(focus, Line.Node_Position(name, Line.Position((line1 - 1) max 0)))
55878
6d092a5166f1 more precise navigation within open files;
wenzelm
parents: 55877
diff changeset
   285
      }
6d092a5166f1 more precise navigation within open files;
wenzelm
parents: 55877
diff changeset
   286
    }
6d092a5166f1 more precise navigation within open files;
wenzelm
parents: 55877
diff changeset
   287
  }
55876
142139457653 tuned signature;
wenzelm
parents: 55822
diff changeset
   288
56461
wenzelm
parents: 56458
diff changeset
   289
  override def hyperlink_command(
64664
wenzelm
parents: 64663
diff changeset
   290
    focus: Boolean, snapshot: Document.Snapshot, id: Document_ID.Generic, offset: Symbol.Offset = 0)
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   291
      : Option[Hyperlink] =
56461
wenzelm
parents: 56458
diff changeset
   292
  {
wenzelm
parents: 56458
diff changeset
   293
    if (snapshot.is_outdated) None
64665
wenzelm
parents: 64664
diff changeset
   294
    else snapshot.find_command_position(id, offset).map(hyperlink_file(focus, _))
56461
wenzelm
parents: 56458
diff changeset
   295
  }
wenzelm
parents: 56458
diff changeset
   296
61011
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   297
  def is_hyperlink_position(snapshot: Document.Snapshot,
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   298
    text_offset: Text.Offset, pos: Position.T): Boolean =
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   299
  {
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   300
    pos match {
64667
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   301
      case Position.Item_Id(id, range) if range.start > 0 =>
64665
wenzelm
parents: 64664
diff changeset
   302
        snapshot.find_command(id) match {
61011
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   303
          case Some((node, command)) if snapshot.version.nodes(command.node_name) eq node =>
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   304
            node.command_start(command) match {
64667
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   305
              case Some(start) => text_offset == start + command.chunk.decode(range.start)
61011
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   306
              case None => false
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   307
            }
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   308
          case _ => false
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   309
        }
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   310
      case _ => false
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   311
    }
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   312
  }
018b0c996b54 more explicit debugger caret rendering;
wenzelm
parents: 60988
diff changeset
   313
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   314
  def hyperlink_position(focus: Boolean, snapshot: Document.Snapshot, pos: Position.T)
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   315
      : Option[Hyperlink] =
60874
7865e03a7fc1 tuned signature;
wenzelm
parents: 59319
diff changeset
   316
    pos match {
64667
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   317
      case Position.Item_File(name, line, range) =>
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   318
        hyperlink_source_file(focus, name, line, range.start)
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   319
      case Position.Item_Id(id, range) =>
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   320
        hyperlink_command(focus, snapshot, id, range.start)
60874
7865e03a7fc1 tuned signature;
wenzelm
parents: 59319
diff changeset
   321
      case _ => None
7865e03a7fc1 tuned signature;
wenzelm
parents: 59319
diff changeset
   322
    }
7865e03a7fc1 tuned signature;
wenzelm
parents: 59319
diff changeset
   323
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   324
  def hyperlink_def_position(focus: Boolean, snapshot: Document.Snapshot, pos: Position.T)
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60874
diff changeset
   325
      : Option[Hyperlink] =
60874
7865e03a7fc1 tuned signature;
wenzelm
parents: 59319
diff changeset
   326
    pos match {
64667
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   327
      case Position.Item_Def_File(name, line, range) =>
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   328
        hyperlink_source_file(focus, name, line, range.start)
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   329
      case Position.Item_Def_Id(id, range) =>
cdb0d559a24b full range for Position.Item;
wenzelm
parents: 64665
diff changeset
   330
        hyperlink_command(focus, snapshot, id, range.start)
60874
7865e03a7fc1 tuned signature;
wenzelm
parents: 59319
diff changeset
   331
      case _ => None
7865e03a7fc1 tuned signature;
wenzelm
parents: 59319
diff changeset
   332
    }
52971
31926d2c04ee tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff changeset
   333
}