src/Pure/Tools/debugger.scala
changeset 60876 52edced9cce5
parent 60875 ee23c1d21ac3
child 60878 1f0d2bbcf38b
     1.1 --- a/src/Pure/Tools/debugger.scala	Mon Aug 10 14:14:49 2015 +0200
     1.2 +++ b/src/Pure/Tools/debugger.scala	Mon Aug 10 16:05:41 2015 +0200
     1.3 @@ -17,6 +17,8 @@
     1.4  
     1.5    sealed case class State(
     1.6      session: Session = new Session(Resources.empty),
     1.7 +    active: Int = 0,
     1.8 +    active_breakpoints: Set[Long] = Set.empty,
     1.9      focus: Option[Position.T] = None,  // position of active GUI component
    1.10      threads: Map[String, List[Debug_State]] = Map.empty,  // thread name ~> stack of debug states
    1.11      output: Map[String, Command.Results] = Map.empty)  // thread name ~> output messages
    1.12 @@ -24,6 +26,17 @@
    1.13      def set_session(new_session: Session): State =
    1.14        copy(session = new_session)
    1.15  
    1.16 +    def inc_active: State = copy(active = active + 1)
    1.17 +    def dec_active: State = copy(active = active - 1)
    1.18 +
    1.19 +    def toggle_breakpoint(serial: Long): State =
    1.20 +    {
    1.21 +      val active_breakpoints1 =
    1.22 +        if (active_breakpoints(serial)) active_breakpoints - serial
    1.23 +      else active_breakpoints + serial
    1.24 +      copy(active_breakpoints = active_breakpoints1)
    1.25 +    }
    1.26 +
    1.27      def set_focus(new_focus: Option[Position.T]): State =
    1.28        copy(focus = new_focus)
    1.29  
    1.30 @@ -124,6 +137,19 @@
    1.31      current_state().session.protocol_command("Debugger.init")
    1.32    }
    1.33  
    1.34 +  def is_active(): Boolean = current_state().active > 0
    1.35 +  def inc_active(): Unit = global_state.change(_.inc_active)
    1.36 +  def dec_active(): Unit = global_state.change(_.dec_active)
    1.37 +
    1.38 +  def breakpoint_active(serial: Long): Option[Boolean] =
    1.39 +  {
    1.40 +    val state = current_state()
    1.41 +    if (state.active > 0) Some(state.active_breakpoints(serial)) else None
    1.42 +  }
    1.43 +
    1.44 +  def toggle_breakpoint(serial: Long): Unit =
    1.45 +    global_state.change(_.toggle_breakpoint(serial))
    1.46 +
    1.47    def focus(new_focus: Option[Position.T]): Boolean =
    1.48      global_state.change_result(state => (state.focus != new_focus, state.set_focus(new_focus)))
    1.49