src/Tools/jEdit/src/debugger_dockable.scala
author wenzelm
Sat, 15 Aug 2015 17:38:20 +0200
changeset 60932 13ee73f57c85
parent 60910 79abcf48c377
child 60936 2751f7f31be2
permissions -rw-r--r--
allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
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}
60901
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
    13
import java.awt.event.{ComponentEvent, ComponentAdapter, KeyEvent, FocusAdapter, FocusEvent}
60883
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
    14
import javax.swing.{JTree, JMenuItem}
60850
d5d776c8a7e2 proper dynamic update;
wenzelm
parents: 60849
diff changeset
    15
import javax.swing.tree.{DefaultMutableTreeNode, DefaultTreeModel, TreeSelectionModel}
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    16
import javax.swing.event.{TreeSelectionEvent, TreeSelectionListener}
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
    17
60883
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
    18
import scala.swing.{Button, Label, Component, ScrollPane, SplitPane, Orientation,
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
    19
  CheckBox, BorderPanel}
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
    20
import scala.swing.event.ButtonClicked
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    21
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
    22
import org.gjt.sp.jedit.{jEdit, View}
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    23
import org.gjt.sp.jedit.menu.EnhancedMenuItem
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    24
import org.gjt.sp.jedit.textarea.JEditTextArea
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    25
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    26
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    27
object Debugger_Dockable
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    28
{
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    29
  /* state entries */
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    30
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    31
  sealed case class Thread_Entry(thread_name: String, debug_states: List[Debugger.Debug_State])
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    32
  {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    33
    override def toString: String = thread_name
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    34
  }
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    35
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    36
  sealed case class Stack_Entry(debug_state: Debugger.Debug_State, index: Int)
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    37
  {
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    38
    override def toString: String = debug_state.function
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
    39
  }
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    40
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
  /* breakpoints */
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    43
60880
fa958e24ff24 set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents: 60878
diff changeset
    44
  def toggle_breakpoint(command: Command, breakpoint: Long)
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    45
  {
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    46
    GUI_Thread.require {}
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    47
60880
fa958e24ff24 set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents: 60878
diff changeset
    48
    Debugger.toggle_breakpoint(command, breakpoint)
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    49
    jEdit.propertiesChanged()
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    50
  }
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    51
60880
fa958e24ff24 set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents: 60878
diff changeset
    52
  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
    53
  {
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    54
    GUI_Thread.require {}
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    55
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    56
    PIDE.document_view(text_area) match {
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    57
      case Some(doc_view) =>
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    58
        val rendering = doc_view.get_rendering()
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    59
        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
    60
        rendering.breakpoint(range)
60878
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    61
      case None => None
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    62
    }
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
  /* context menu */
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    67
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    68
  def context_menu(text_area: JEditTextArea, offset: Text.Offset): List[JMenuItem] =
60890
e2aeaa397e93 GUI actions depend on active debugger;
wenzelm
parents: 60889
diff changeset
    69
    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
    70
      val context = jEdit.getActionContext()
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    71
      val name = "isabelle.toggle-breakpoint"
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    72
      List(new EnhancedMenuItem(context.getAction(name).getLabel, name, context))
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    73
    }
1f0d2bbcf38b added action to toggle breakpoints (on editor side);
wenzelm
parents: 60876
diff changeset
    74
    else Nil
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    75
}
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    76
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    77
class Debugger_Dockable(view: View, position: String) extends Dockable(view, position)
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    78
{
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    79
  GUI_Thread.require {}
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    80
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    81
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    82
  /* component state -- owned by GUI thread */
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    83
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    84
  private var current_snapshot = Document.Snapshot.init
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    85
  private var current_threads: Map[String, List[Debugger.Debug_State]] = Map.empty
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    86
  private var current_output: List[XML.Tree] = Nil
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    87
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
    88
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    89
  /* pretty text area */
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    90
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    91
  val pretty_text_area = new Pretty_Text_Area(view)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    92
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    93
  override def detach_operation = pretty_text_area.detach_operation
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    94
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    95
  private def handle_resize()
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    96
  {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    97
    GUI_Thread.require {}
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    98
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
    99
    pretty_text_area.resize(
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   100
      Font_Info.main(PIDE.options.real("jedit_font_scale") * zoom.factor / 100))
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   101
  }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   102
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   103
  private def handle_update()
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   104
  {
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   105
    GUI_Thread.require {}
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   106
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   107
    val new_snapshot = PIDE.editor.current_node_snapshot(view).getOrElse(current_snapshot)
60898
a3fcde62df10 misc tuning and clarification;
wenzelm
parents: 60897
diff changeset
   108
    val new_threads = Debugger.threads()
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   109
    val new_output =
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   110
    {
60898
a3fcde62df10 misc tuning and clarification;
wenzelm
parents: 60897
diff changeset
   111
      val output = Debugger.output()
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   112
      val current_thread_selection = thread_selection()
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   113
      (for {
60898
a3fcde62df10 misc tuning and clarification;
wenzelm
parents: 60897
diff changeset
   114
        (thread_name, results) <- output
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   115
        if current_thread_selection.isEmpty || current_thread_selection.get == thread_name
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   116
        (_, tree) <- results.iterator
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   117
      } yield tree).toList
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   118
    }
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   119
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   120
    if (new_threads != current_threads) {
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   121
      val thread_entries =
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   122
        (for ((a, b) <- new_threads.iterator)
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   123
          yield Debugger_Dockable.Thread_Entry(a, b)).toList.sortBy(_.thread_name)
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   124
      update_tree(thread_entries)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   125
    }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   126
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   127
    if (new_output != current_output)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   128
      pretty_text_area.update(new_snapshot, Command.Results.empty, Pretty.separate(new_output))
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   129
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   130
    current_snapshot = new_snapshot
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   131
    current_threads = new_threads
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   132
    current_output = new_output
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   133
  }
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
  /* tree view */
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   137
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   138
  private val root = new DefaultMutableTreeNode("Threads")
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   139
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   140
  val tree = new JTree(root)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   141
  tree.setRowHeight(0)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   142
  tree.getSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION)
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   143
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   144
  def tree_selection(): Option[(Debugger_Dockable.Thread_Entry, Option[Int])] =
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   145
    tree.getSelectionPath match {
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   146
      case null => None
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   147
      case path =>
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   148
        path.getPath.toList.map(n => n.asInstanceOf[DefaultMutableTreeNode].getUserObject) match {
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   149
          case List(_, t: Debugger_Dockable.Thread_Entry) =>
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   150
            Some((t, None))
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   151
          case List(_, t: Debugger_Dockable.Thread_Entry, s: Debugger_Dockable.Stack_Entry) =>
60854
8f45dd297357 more controls;
wenzelm
parents: 60851
diff changeset
   152
            Some((t, Some(s.index)))
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   153
          case _ => None
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   154
        }
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   155
    }
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   156
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   157
  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
   158
60901
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   159
  def focus_selection(): Option[Position.T] =
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   160
    tree_selection() match {
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   161
      case Some((t, opt_index)) =>
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   162
        val i = opt_index getOrElse 0
60901
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   163
        if (i < t.debug_states.length) Some(t.debug_states(i).pos) else None
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   164
      case _ => None
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   165
    }
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   166
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   167
  private def update_tree(thread_entries: List[Debugger_Dockable.Thread_Entry])
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   168
  {
60906
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   169
    val new_thread_selection =
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   170
      thread_selection() match {
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   171
        case Some(thread_name) if thread_entries.exists(t => t.thread_name == thread_name) =>
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   172
          Some(thread_name)
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   173
        case _ => thread_entries.headOption.map(_.thread_name)
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   174
      }
60860
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   175
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   176
    tree.clearSelection
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   177
    root.removeAllChildren
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   178
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   179
    for (thread_entry <- thread_entries) {
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   180
      val thread_node = new DefaultMutableTreeNode(thread_entry)
60851
35932863b114 support for tree selection;
wenzelm
parents: 60850
diff changeset
   181
      for ((debug_state, i) <- thread_entry.debug_states.zipWithIndex) {
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   182
        val stack_node =
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   183
          new DefaultMutableTreeNode(Debugger_Dockable.Stack_Entry(debug_state, i))
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   184
        thread_node.add(stack_node)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   185
      }
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   186
      root.add(thread_node)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   187
    }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   188
60859
933737bacac7 expand all rows for robustness and simplicity;
wenzelm
parents: 60857
diff changeset
   189
    tree.getModel.asInstanceOf[DefaultTreeModel].reload(root)
60860
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   190
60905
eba3acb72b55 clarified tree row handling;
wenzelm
parents: 60901
diff changeset
   191
    tree.expandRow(0)
eba3acb72b55 clarified tree row handling;
wenzelm
parents: 60901
diff changeset
   192
    for (i <- Range.inclusive(tree.getRowCount - 1, 1, -1)) tree.expandRow(i)
eba3acb72b55 clarified tree row handling;
wenzelm
parents: 60901
diff changeset
   193
60906
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   194
    new_thread_selection match {
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   195
      case Some(thread_name) =>
60860
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   196
        val i =
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   197
          (for (t <- thread_entries.iterator.takeWhile(t => t.thread_name != thread_name))
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   198
            yield 1 + t.debug_states.length).sum
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   199
        tree.addSelectionRow(i + 1)
60906
6032429da70d clarified thread re-selection;
wenzelm
parents: 60905
diff changeset
   200
      case None =>
60860
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   201
    }
e78bdf06d33c approximate old selection after update;
wenzelm
parents: 60859
diff changeset
   202
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   203
    tree.revalidate()
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   204
  }
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   205
60901
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   206
  def update_vals()
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   207
  {
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   208
    tree_selection() match {
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   209
      case Some((t, None)) =>
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   210
        Debugger.clear_output(t.thread_name)
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   211
      case Some((t, Some(i))) if i < t.debug_states.length =>
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   212
        Debugger.print_vals(t.thread_name, i, sml_button.selected, context_field.getText)
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   213
      case _ =>
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   214
    }
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   215
  }
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   216
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   217
  tree.addTreeSelectionListener(
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   218
    new TreeSelectionListener {
60901
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   219
      override def valueChanged(e: TreeSelectionEvent) {
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   220
        update_focus(focus_selection())
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   221
        update_vals()
ce8abd005c5d clarified GUI event handling;
wenzelm
parents: 60900
diff changeset
   222
      }
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   223
    })
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   224
60883
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   225
  private val tree_pane = new ScrollPane(Component.wrap(tree))
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   226
  tree_pane.horizontalScrollBarPolicy = ScrollPane.BarPolicy.Always
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   227
  tree_pane.verticalScrollBarPolicy = ScrollPane.BarPolicy.Always
8eb8640d7300 more uniform ScrollPane, like graphview;
wenzelm
parents: 60880
diff changeset
   228
  tree_pane.minimumSize = new Dimension(200, 100)
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   229
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   230
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   231
  /* controls */
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   232
60932
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   233
  private val break_button = new CheckBox("Break") {
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   234
    tooltip = "Break running threads at next possible breakpoint"
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   235
    selected = Debugger.is_break()
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   236
    reactions += { case ButtonClicked(_) => Debugger.set_break(selected) }
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   237
  }
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   238
60907
wenzelm
parents: 60906
diff changeset
   239
  private val continue_button = new Button("Continue") {
wenzelm
parents: 60906
diff changeset
   240
    tooltip = "Continue program on current thread, until next breakpoint"
wenzelm
parents: 60906
diff changeset
   241
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.continue(_)) }
wenzelm
parents: 60906
diff changeset
   242
  }
wenzelm
parents: 60906
diff changeset
   243
wenzelm
parents: 60906
diff changeset
   244
  private val step_button = new Button("Step") {
wenzelm
parents: 60906
diff changeset
   245
    tooltip = "Single-step in depth-first order"
wenzelm
parents: 60906
diff changeset
   246
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.step(_)) }
wenzelm
parents: 60906
diff changeset
   247
  }
wenzelm
parents: 60906
diff changeset
   248
wenzelm
parents: 60906
diff changeset
   249
  private val step_over_button = new Button("Step over") {
wenzelm
parents: 60906
diff changeset
   250
    tooltip = "Single-step within this function"
wenzelm
parents: 60906
diff changeset
   251
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.step_over(_)) }
wenzelm
parents: 60906
diff changeset
   252
  }
wenzelm
parents: 60906
diff changeset
   253
wenzelm
parents: 60906
diff changeset
   254
  private val step_out_button = new Button("Step out") {
wenzelm
parents: 60906
diff changeset
   255
    tooltip = "Single-step outside this function"
wenzelm
parents: 60906
diff changeset
   256
    reactions += { case ButtonClicked(_) => thread_selection().map(Debugger.step_out(_)) }
wenzelm
parents: 60906
diff changeset
   257
  }
wenzelm
parents: 60906
diff changeset
   258
60862
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   259
  private val context_label = new Label("Context:") {
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   260
    tooltip = "Isabelle/ML context: type theory, Proof.context, Context.generic"
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   261
  }
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   262
  private val context_field =
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   263
    new Completion_Popup.History_Text_Field("isabelle-debugger-context")
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   264
    {
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   265
      setColumns(20)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   266
      setToolTipText(context_label.tooltip)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   267
      setFont(GUI.imitate_font(getFont, Font_Info.main_family(), 1.2))
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   268
    }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   269
60862
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   270
  private val expression_label = new Label("ML:") {
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   271
    tooltip = "Isabelle/ML or Standard ML expression"
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   272
  }
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   273
  private val expression_field =
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   274
    new Completion_Popup.History_Text_Field("isabelle-debugger-expression")
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   275
    {
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   276
      override def processKeyEvent(evt: KeyEvent)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   277
      {
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   278
        if (evt.getID == KeyEvent.KEY_PRESSED && evt.getKeyCode == KeyEvent.VK_ENTER)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   279
          eval_expression()
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   280
        super.processKeyEvent(evt)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   281
      }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   282
      { val max = getPreferredSize; max.width = Integer.MAX_VALUE; setMaximumSize(max) }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   283
      setColumns(40)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   284
      setToolTipText(expression_label.tooltip)
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   285
      setFont(GUI.imitate_font(getFont, Font_Info.main_family(), 1.2))
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   286
    }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   287
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   288
  private val eval_button = new Button("<html><b>Eval</b></html>") {
60862
097afdd8a2fd eval ML context;
wenzelm
parents: 60861
diff changeset
   289
      tooltip = "Evaluate ML expression within optional context"
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   290
      reactions += { case ButtonClicked(_) => eval_expression() }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   291
    }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   292
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   293
  private def eval_expression()
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   294
  {
60861
fa77faa87d5f maintain history more often;
wenzelm
parents: 60860
diff changeset
   295
    context_field.addCurrentToHistory()
fa77faa87d5f maintain history more often;
wenzelm
parents: 60860
diff changeset
   296
    expression_field.addCurrentToHistory()
60856
eb21ae05ec43 clarified thread state;
wenzelm
parents: 60854
diff changeset
   297
    tree_selection() match {
60857
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   298
      case Some((t, opt_index)) if t.debug_states.nonEmpty =>
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   299
        Debugger.eval(t.thread_name, opt_index getOrElse 0,
4c18d8e4fe14 clarified debugger loop;
wenzelm
parents: 60856
diff changeset
   300
          sml_button.selected, context_field.getText, expression_field.getText)
60856
eb21ae05ec43 clarified thread state;
wenzelm
parents: 60854
diff changeset
   301
      case _ =>
eb21ae05ec43 clarified thread state;
wenzelm
parents: 60854
diff changeset
   302
    }
60832
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   303
  }
1cdc63224ed3 more GUI components;
wenzelm
parents: 60750
diff changeset
   304
60907
wenzelm
parents: 60906
diff changeset
   305
  private val sml_button = new CheckBox("SML") {
wenzelm
parents: 60906
diff changeset
   306
    tooltip = "Official Standard ML instead of Isabelle/ML"
wenzelm
parents: 60906
diff changeset
   307
    selected = false
60869
878e32cf3131 more single stepping;
wenzelm
parents: 60862
diff changeset
   308
  }
878e32cf3131 more single stepping;
wenzelm
parents: 60862
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)(
60932
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   314
      break_button, continue_button, step_button, step_over_button, step_out_button,
60848
7ec20b1c8dc9 more GUI components;
wenzelm
parents: 60845
diff changeset
   315
      context_label, Component.wrap(context_field),
60907
wenzelm
parents: 60906
diff changeset
   316
      expression_label, Component.wrap(expression_field), eval_button, sml_button,
60889
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
        GUI_Thread.later { handle_resize() }
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   353
60900
11a0f333de6f tuned signature;
wenzelm
parents: 60899
diff changeset
   354
      case Debugger.Update =>
60932
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   355
        GUI_Thread.later {
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   356
          break_button.selected = Debugger.is_break()
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   357
          handle_update()
13ee73f57c85 allow to break running threads at next possible breakpoint (simplified version of former option, see f3039309702e);
wenzelm
parents: 60910
diff changeset
   358
        }
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   359
    }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   360
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   361
  override def init()
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   362
  {
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   363
    PIDE.session.global_options += main
60835
6512bb0b1ff4 clarified management of (single) session;
wenzelm
parents: 60834
diff changeset
   364
    PIDE.session.debugger_updates += main
60910
79abcf48c377 clarified init/exit vs. session phase;
wenzelm
parents: 60907
diff changeset
   365
    Debugger.init()
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   366
    handle_update()
60876
52edced9cce5 rendering for debugger/breakpoint active state;
wenzelm
parents: 60875
diff changeset
   367
    jEdit.propertiesChanged()
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   368
  }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   369
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   370
  override def exit()
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   371
  {
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   372
    PIDE.session.global_options -= main
60835
6512bb0b1ff4 clarified management of (single) session;
wenzelm
parents: 60834
diff changeset
   373
    PIDE.session.debugger_updates -= main
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   374
    delay_resize.revoke()
60875
ee23c1d21ac3 follow debugger focus;
wenzelm
parents: 60869
diff changeset
   375
    update_focus(None)
60910
79abcf48c377 clarified init/exit vs. session phase;
wenzelm
parents: 60907
diff changeset
   376
    Debugger.exit()
60876
52edced9cce5 rendering for debugger/breakpoint active state;
wenzelm
parents: 60875
diff changeset
   377
    jEdit.propertiesChanged()
60749
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
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   381
  /* resize */
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   382
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   383
  private val delay_resize =
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   384
    GUI_Thread.delay_first(PIDE.options.seconds("editor_update_delay")) { handle_resize() }
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   385
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   386
  addComponentListener(new ComponentAdapter {
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   387
    override def componentResized(e: ComponentEvent) { delay_resize.invoke() }
60750
7694aa52ad56 more uniform ComponentAdapter;
wenzelm
parents: 60749
diff changeset
   388
    override def componentShown(e: ComponentEvent) { delay_resize.invoke() }
60749
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   389
  })
f727b99faaf7 skeleton for interactive debugger;
wenzelm
parents:
diff changeset
   390
}