src/Tools/jEdit/src/debugger_dockable.scala
author wenzelm
Tue, 11 Aug 2015 20:21:13 +0200
changeset 60898 a3fcde62df10
parent 60897 7aad4be8a48e
child 60899 84569dbe1e30
permissions -rw-r--r--
misc tuning and clarification;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     1
/*  Title:      Tools/jEdit/src/debugger_dockable.scala
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     3
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     4
Dockable window for Isabelle/ML debugger.
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     5
*/
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     6
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     7
package isabelle.jedit
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     8
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
     9
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    10
import isabelle._
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    11
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    12
import java.awt.{BorderLayout, Dimension}
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
    13
import java.awt.event.{ComponentEvent, ComponentAdapter, KeyEvent, MouseEvent, MouseAdapter,
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
    14
  FocusAdapter, FocusEvent}
60883
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
    15
import javax.swing.{JTree, JMenuItem}
60850
d5d776c8a7e2 proper dynamic update;
wenzelm
parents: 60849
diff changeset
    16
import javax.swing.tree.{DefaultMutableTreeNode, DefaultTreeModel, TreeSelectionModel}
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    17
import javax.swing.event.{TreeSelectionEvent, TreeSelectionListener}
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
    18
60883
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
    19
import scala.swing.{Button, Label, Component, ScrollPane, SplitPane, Orientation,
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
    20
  CheckBox, BorderPanel}
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
    21
import scala.swing.event.ButtonClicked
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    22
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
    23
import org.gjt.sp.jedit.{jEdit, View}
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    24
import org.gjt.sp.jedit.menu.EnhancedMenuItem
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    25
import org.gjt.sp.jedit.textarea.JEditTextArea
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    26
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    27
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    28
object Debugger_Dockable
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    29
{
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    30
  /* state entries */
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    31
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    32
  sealed case class Thread_Entry(thread_name: String, debug_states: List[Debugger.Debug_State])
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    33
  {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    34
    override def toString: String = thread_name
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    35
  }
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    36
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    37
  sealed case class Stack_Entry(debug_state: Debugger.Debug_State, index: Int)
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    38
  {
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    39
    override def toString: String = debug_state.function
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    40
  }
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    41
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    42
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    43
  /* breakpoints */
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    44
60880
fa958e24ff24 set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents: 60878
diff changeset
    45
  def toggle_breakpoint(command: Command, breakpoint: Long)
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    46
  {
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    47
    GUI_Thread.require {}
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    48
60880
fa958e24ff24 set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents: 60878
diff changeset
    49
    Debugger.toggle_breakpoint(command, breakpoint)
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    50
    jEdit.propertiesChanged()
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    51
  }
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    52
60880
fa958e24ff24 set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents: 60878
diff changeset
    53
  def get_breakpoint(text_area: JEditTextArea, offset: Text.Offset): Option[(Command, Long)] =
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    54
  {
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    55
    GUI_Thread.require {}
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    56
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    57
    PIDE.document_view(text_area) match {
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    58
      case Some(doc_view) =>
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    59
        val rendering = doc_view.get_rendering()
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    60
        val range = JEdit_Lib.point_range(text_area.getBuffer, offset)
60880
fa958e24ff24 set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents: 60878
diff changeset
    61
        rendering.breakpoint(range)
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    62
      case None => None
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    63
    }
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    64
  }
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    65
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    66
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    67
  /* context menu */
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    68
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    69
  def context_menu(text_area: JEditTextArea, offset: Text.Offset): List[JMenuItem] =
60890
e2aeaa397e93 GUI actions depend on active debugger;
wenzelm
parents: 60889
diff changeset
    70
    if (Debugger.is_active() && get_breakpoint(text_area, offset).isDefined) {
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    71
      val context = jEdit.getActionContext()
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    72
      val name = "isabelle.toggle-breakpoint"
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    73
      List(new EnhancedMenuItem(context.getAction(name).getLabel, name, context))
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    74
    }
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    75
    else Nil
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    76
}
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    77
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    78
class Debugger_Dockable(view: View, position: String) extends Dockable(view, position)
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    79
{
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    80
  GUI_Thread.require {}
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    81
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    82
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    83
  /* component state -- owned by GUI thread */
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    84
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    85
  private var current_snapshot = Document.Snapshot.init
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    86
  private var current_threads: Map[String, List[Debugger.Debug_State]] = Map.empty
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    87
  private var current_output: List[XML.Tree] = Nil
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    88
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    89
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    90
  /* pretty text area */
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    91
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    92
  val pretty_text_area = new Pretty_Text_Area(view)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    93
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    94
  override def detach_operation = pretty_text_area.detach_operation
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    95
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    96
  private def handle_resize()
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    97
  {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    98
    GUI_Thread.require {}
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    99
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   100
    pretty_text_area.resize(
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   101
      Font_Info.main(PIDE.options.real("jedit_font_scale") * zoom.factor / 100))
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   102
  }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   103
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   104
  private def handle_update()
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   105
  {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   106
    GUI_Thread.require {}
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   107
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   108
    val new_snapshot = PIDE.editor.current_node_snapshot(view).getOrElse(current_snapshot)
60898
a3fcde62df10 misc tuning and clarification;
wenzelm
parents: 60897
diff changeset
   109
    val new_threads = Debugger.threads()
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   110
    val new_output =
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   111
    {
60898
a3fcde62df10 misc tuning and clarification;
wenzelm
parents: 60897
diff changeset
   112
      val output = Debugger.output()
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   113
      val current_thread_selection = thread_selection()
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   114
      (for {
60898
a3fcde62df10 misc tuning and clarification;
wenzelm
parents: 60897
diff changeset
   115
        (thread_name, results) <- output
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   116
        if current_thread_selection.isEmpty || current_thread_selection.get == thread_name
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   117
        (_, tree) <- results.iterator
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   118
      } yield tree).toList
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   119
    }
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   120
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   121
    if (new_threads != current_threads) {
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   122
      val thread_entries =
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   123
        (for ((a, b) <- new_threads.iterator)
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   124
          yield Debugger_Dockable.Thread_Entry(a, b)).toList.sortBy(_.thread_name)
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   125
      update_tree(thread_entries)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   126
    }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   127
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   128
    if (new_output != current_output)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   129
      pretty_text_area.update(new_snapshot, Command.Results.empty, Pretty.separate(new_output))
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   130
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   131
    current_snapshot = new_snapshot
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   132
    current_threads = new_threads
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   133
    current_output = new_output
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   134
  }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   135
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   136
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   137
  /* tree view */
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   138
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   139
  private val root = new DefaultMutableTreeNode("Threads")
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   140
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   141
  val tree = new JTree(root)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   142
  tree.setRowHeight(0)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   143
  tree.getSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   144
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   145
  def tree_selection(): Option[(Debugger_Dockable.Thread_Entry, Option[Int])] =
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   146
    tree.getSelectionPath match {
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   147
      case null => None
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   148
      case path =>
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   149
        path.getPath.toList.map(n => n.asInstanceOf[DefaultMutableTreeNode].getUserObject) match {
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   150
          case List(_, t: Debugger_Dockable.Thread_Entry) =>
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   151
            Some((t, None))
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   152
          case List(_, t: Debugger_Dockable.Thread_Entry, s: Debugger_Dockable.Stack_Entry) =>
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   153
            Some((t, Some(s.index)))
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   154
          case _ => None
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   155
        }
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   156
    }
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   157
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   158
  def thread_selection(): Option[String] = tree_selection().map(sel => sel._1.thread_name)
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   159
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   160
  def index_selection(): Option[(Debugger_Dockable.Thread_Entry, Int)] =
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   161
    tree_selection() match {
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   162
      case Some((t, opt_index)) =>
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   163
        val i = opt_index getOrElse 0
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   164
        if (i < t.debug_states.length) Some((t, i)) else None
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   165
      case _ => None
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   166
    }
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   167
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   168
  def focus_selection(): Option[Position.T] =
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   169
    index_selection() match {
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   170
      case Some((t, i)) => Some(t.debug_states(i).pos)
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   171
      case None => None
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   172
    }
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   173
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   174
  private def update_tree(thread_entries: List[Debugger_Dockable.Thread_Entry])
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   175
  {
60886
0165aac83cdb clarified default selection;
wenzelm
parents: 60884
diff changeset
   176
    val old_thread_selection =
0165aac83cdb clarified default selection;
wenzelm
parents: 60884
diff changeset
   177
      thread_selection() orElse
0165aac83cdb clarified default selection;
wenzelm
parents: 60884
diff changeset
   178
      thread_entries.collectFirst { case t if t.debug_states.nonEmpty => t.thread_name }
60860
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   179
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   180
    tree.clearSelection
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   181
    root.removeAllChildren
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   182
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   183
    for (thread_entry <- thread_entries) {
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   184
      val thread_node = new DefaultMutableTreeNode(thread_entry)
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   185
      for ((debug_state, i) <- thread_entry.debug_states.zipWithIndex) {
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   186
        val stack_node =
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   187
          new DefaultMutableTreeNode(Debugger_Dockable.Stack_Entry(debug_state, i))
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   188
        thread_node.add(stack_node)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   189
      }
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   190
      root.add(thread_node)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   191
    }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   192
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   193
    tree.getModel.asInstanceOf[DefaultTreeModel].reload(root)
60860
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   194
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   195
    old_thread_selection match {
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   196
      case Some(thread_name) if thread_entries.exists(t => t.thread_name == thread_name) =>
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   197
        val i =
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   198
          (for (t <- thread_entries.iterator.takeWhile(t => t.thread_name != thread_name))
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   199
            yield 1 + t.debug_states.length).sum
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   200
        tree.addSelectionRow(i + 1)
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   201
      case _ =>
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   202
    }
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   203
    for (i <- 0 until tree.getRowCount) tree.expandRow(i)
60860
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   204
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   205
    tree.revalidate()
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   206
  }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   207
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   208
  tree.addTreeSelectionListener(
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   209
    new TreeSelectionListener {
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   210
      override def valueChanged(e: TreeSelectionEvent) { update_focus(focus_selection()) }
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   211
    })
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   212
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   213
  tree.addMouseListener(new MouseAdapter {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   214
    override def mouseClicked(e: MouseEvent)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   215
    {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   216
      val click = tree.getPathForLocation(e.getX, e.getY)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   217
      if (click != null && e.getClickCount == 1) {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   218
        (click.getLastPathComponent, tree.getLastSelectedPathComponent) match {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   219
          case (node: DefaultMutableTreeNode, node1: DefaultMutableTreeNode) if node == node1 =>
60897
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   220
            index_selection() match {
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   221
              case Some((t, i)) =>
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   222
                Debugger.print_vals(t.thread_name, i, sml_button.selected, context_field.getText)
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   223
              case None =>
7aad4be8a48e print values for stack entry;
wenzelm
parents: 60893
diff changeset
   224
            }
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   225
          case _ =>
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   226
        }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   227
      }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   228
    }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   229
  })
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   230
60883
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   231
  private val tree_pane = new ScrollPane(Component.wrap(tree))
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   232
  tree_pane.horizontalScrollBarPolicy = ScrollPane.BarPolicy.Always
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   233
  tree_pane.verticalScrollBarPolicy = ScrollPane.BarPolicy.Always
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   234
  tree_pane.minimumSize = new Dimension(200, 100)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   235
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   236
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   237
  /* controls */
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   238
60862
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   239
  private val context_label = new Label("Context:") {
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   240
    tooltip = "Isabelle/ML context: type theory, Proof.context, Context.generic"
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   241
  }
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   242
  private val context_field =
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   243
    new Completion_Popup.History_Text_Field("isabelle-debugger-context")
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   244
    {
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   245
      setColumns(20)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   246
      setToolTipText(context_label.tooltip)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   247
      setFont(GUI.imitate_font(getFont, Font_Info.main_family(), 1.2))
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   248
    }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   249
60862
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   250
  private val expression_label = new Label("ML:") {
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   251
    tooltip = "Isabelle/ML or Standard ML expression"
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   252
  }
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   253
  private val expression_field =
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   254
    new Completion_Popup.History_Text_Field("isabelle-debugger-expression")
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   255
    {
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   256
      override def processKeyEvent(evt: KeyEvent)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   257
      {
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   258
        if (evt.getID == KeyEvent.KEY_PRESSED && evt.getKeyCode == KeyEvent.VK_ENTER)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   259
          eval_expression()
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   260
        super.processKeyEvent(evt)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   261
      }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   262
      { val max = getPreferredSize; max.width = Integer.MAX_VALUE; setMaximumSize(max) }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   263
      setColumns(40)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   264
      setToolTipText(expression_label.tooltip)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   265
      setFont(GUI.imitate_font(getFont, Font_Info.main_family(), 1.2))
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   266
    }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   267
60857
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   268
  private val sml_button = new CheckBox("SML") {
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   269
    tooltip = "Official Standard ML instead of Isabelle/ML"
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   270
    selected = false
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   271
  }
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   272
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   273
  private val eval_button = new Button("<html><b>Eval</b></html>") {
60862
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   274
      tooltip = "Evaluate ML expression within optional context"
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   275
      reactions += { case ButtonClicked(_) => eval_expression() }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   276
    }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   277
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   278
  private def eval_expression()
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   279
  {
60861
fa77faa87d5f maintain history more often;
wenzelm
parents: 60860
diff changeset
   280
    context_field.addCurrentToHistory()
fa77faa87d5f maintain history more often;
wenzelm
parents: 60860
diff changeset
   281
    expression_field.addCurrentToHistory()
60856
eb21ae05ec43 clarified thread state;
wenzelm
parents: 60854
diff changeset
   282
    tree_selection() match {
60857
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   283
      case Some((t, opt_index)) if t.debug_states.nonEmpty =>
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   284
        Debugger.eval(t.thread_name, opt_index getOrElse 0,
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   285
          sml_button.selected, context_field.getText, expression_field.getText)
60856
eb21ae05ec43 clarified thread state;
wenzelm
parents: 60854
diff changeset
   286
      case _ =>
eb21ae05ec43 clarified thread state;
wenzelm
parents: 60854
diff changeset
   287
    }
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   288
  }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   289
60869
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   290
  private val step_button = new Button("Step") {
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   291
    tooltip = "Single-step in depth-first order"
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   292
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.step(_)) }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   293
  }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   294
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   295
  private val step_over_button = new Button("Step over") {
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   296
    tooltip = "Single-step within this function"
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   297
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.step_over(_)) }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   298
  }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   299
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   300
  private val step_out_button = new Button("Step out") {
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   301
    tooltip = "Single-step outside this function"
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   302
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.step_out(_)) }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   303
  }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   304
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   305
  private val continue_button = new Button("Continue") {
60869
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   306
    tooltip = "Continue program on current thread, until next breakpoint"
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   307
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.continue(_)) }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   308
  }
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   309
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   310
  private val zoom = new Font_Info.Zoom_Box { def changed = handle_resize() }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   311
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   312
  private val controls =
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   313
    new Wrap_Panel(Wrap_Panel.Alignment.Right)(
60888
35d85fd89fc1 eliminated cancel operation: disrupts normal evaluation of thread;
wenzelm
parents: 60886
diff changeset
   314
      step_button, step_over_button, step_out_button, continue_button,
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   315
      context_label, Component.wrap(context_field),
60889
7f210887cc4e init/exit depending on active debugger panels;
wenzelm
parents: 60888
diff changeset
   316
      expression_label, Component.wrap(expression_field), sml_button, eval_button,
7f210887cc4e init/exit depending on active debugger panels;
wenzelm
parents: 60888
diff changeset
   317
      pretty_text_area.search_label, pretty_text_area.search_field, zoom)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   318
  add(controls.peer, BorderLayout.NORTH)
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   319
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   320
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   321
  /* focus */
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   322
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   323
  override def focusOnDefaultComponent { eval_button.requestFocus }
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   324
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   325
  addFocusListener(new FocusAdapter {
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   326
    override def focusGained(e: FocusEvent) { update_focus(focus_selection()) }
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   327
    override def focusLost(e: FocusEvent) { update_focus(None) }
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   328
  })
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   329
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   330
  private def update_focus(focus: Option[Position.T])
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   331
  {
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   332
    if (Debugger.focus(focus) && focus.isDefined)
60893
3c8b9b4b577c support hyperlinks with optional focus change;
wenzelm
parents: 60890
diff changeset
   333
      PIDE.editor.hyperlink_position(false, current_snapshot, focus.get).foreach(_.follow(view))
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   334
  }
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   335
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   336
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   337
  /* main panel */
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   338
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   339
  val main_panel = new SplitPane(Orientation.Vertical) {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   340
    oneTouchExpandable = true
60883
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   341
    leftComponent = tree_pane
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   342
    rightComponent = Component.wrap(pretty_text_area)
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   343
  }
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   344
  set_content(main_panel)
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   345
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   346
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   347
  /* main */
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   348
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   349
  private val main =
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   350
    Session.Consumer[Any](getClass.getName) {
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   351
      case _: Session.Global_Options =>
60889
7f210887cc4e init/exit depending on active debugger panels;
wenzelm
parents: 60888
diff changeset
   352
        Debugger.set_session(PIDE.session)
7f210887cc4e init/exit depending on active debugger panels;
wenzelm
parents: 60888
diff changeset
   353
        GUI_Thread.later { handle_resize() }
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   354
60835
6512bb0b1ff4 clarified management of (single) session;
wenzelm
parents: 60834
diff changeset
   355
      case _: Debugger.Update =>
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   356
        GUI_Thread.later { handle_update() }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   357
    }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   358
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   359
  override def init()
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   360
  {
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   361
    PIDE.session.global_options += main
60835
6512bb0b1ff4 clarified management of (single) session;
wenzelm
parents: 60834
diff changeset
   362
    PIDE.session.debugger_updates += main
60889
7f210887cc4e init/exit depending on active debugger panels;
wenzelm
parents: 60888
diff changeset
   363
    Debugger.set_session(PIDE.session)
60876
52edced9cce5 rendering for debugger/breakpoint active state;
wenzelm
parents: 60875
diff changeset
   364
    Debugger.inc_active()
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   365
    handle_update()
60876
52edced9cce5 rendering for debugger/breakpoint active state;
wenzelm
parents: 60875
diff changeset
   366
    jEdit.propertiesChanged()
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   367
  }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   368
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   369
  override def exit()
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   370
  {
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   371
    PIDE.session.global_options -= main
60835
6512bb0b1ff4 clarified management of (single) session;
wenzelm
parents: 60834
diff changeset
   372
    PIDE.session.debugger_updates -= main
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   373
    delay_resize.revoke()
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   374
    update_focus(None)
60876
52edced9cce5 rendering for debugger/breakpoint active state;
wenzelm
parents: 60875
diff changeset
   375
    Debugger.dec_active()
52edced9cce5 rendering for debugger/breakpoint active state;
wenzelm
parents: 60875
diff changeset
   376
    jEdit.propertiesChanged()
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   377
  }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   378
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   379
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   380
  /* resize */
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   381
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   382
  private val delay_resize =
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   383
    GUI_Thread.delay_first(PIDE.options.seconds("editor_update_delay")) { handle_resize() }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   384
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   385
  addComponentListener(new ComponentAdapter {
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   386
    override def componentResized(e: ComponentEvent) { delay_resize.invoke() }
60750
7694aa52ad56 more uniform ComponentAdapter;
wenzelm
parents: 60749
diff changeset
   387
    override def componentShown(e: ComponentEvent) { delay_resize.invoke() }
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   388
  })
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   389
}