# Path: debugger/enums.py
# class ProcessState(Enum):
#     """
#     Represents the debugged process' state.
#     """
#     Attaching = 3
#     Connected = 2
#     Crashed = 8
#     Detached = 9
#     Exited = 10
#     Invalid = 0
#     Launching = 4
#     Running = 6
#     Stepping = 7
#     Stopped = 5
#     Suspended = 11
#     Unloaded = 1
# 
# Path: debugger/util.py
# class EventBroadcaster(object):
#     """
#     Object that broadcasts event to it's listeners.
# 
#     Evety broadcaster represents a single event type.
#     """
#     def __init__(self):
#         self.listeners = []
# 
#     def notify(self, *args, **kwargs):
#         """
#         Notifies all listeners that an event has occured.
#         @param args: arbitraty arguments that will be passed to the listeners
#         """
#         map(lambda listener: listener(*args, **kwargs), self.listeners)
# 
#     def subscribe(self, listener):
#         """
#         Subscribes an event listener, who will receive events from the
#         broadcaster.
#         @type listener: function
#         """
#         self.listeners.append(listener)
# 
#     def unsubscribe(self, listener):
#         """
#         Unsubscribes an event listener.
#         It will no longer receive events after he unsubscribes.
#         @param listener: function
#         """
#         self.listeners.remove(listener)
# 
#     def clear(self):
#         """
#         Removes all event listeners.
#         """
#         self.listeners = []
# 
#     def redirect(self, broadcaster):
#         """
#         Redirects this broadcaster to the given broadcaster.
# 
#         All events fired by this broadcaster will be also delivered to the
#         given broadcaster.
#         @type broadcaster: EventBroadcaster
#         """
#         self.subscribe(broadcaster.notify)
# 
#     def __call__(self, *args, **kwargs):
#         self.notify(*args, **kwargs)


from gi.repository import Gtk
from debugger.enums import ProcessState
from debugger.util import EventBroadcaster
from gui_util import require_gui_thread, run_on_gui
import re
#    (at your option) any later version.
#
#    Devi is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Devi.  If not, see <http://www.gnu.org/licenses/>.
#






class RegisterList(Gtk.ListBox):
    def __init__(self, debugger):
        """
        @type debugger: debugger.Debugger
        """
        super(RegisterList, self).__init__()
        self.set_selection_mode(Gtk.SelectionMode.NONE)

        self.debugger = debugger
        self.debugger.on_process_state_changed.subscribe(
            self._handle_process_change)
        self.debugger.on_frame_changed.subscribe(self._handle_frame_change)

    def _handle_process_change(self, state, event_data):

# Path: debugger/enums.py
# class ProcessState(Enum):
#     """
#     Represents the debugged process' state.
#     """
#     Attaching = 3
#     Connected = 2
#     Crashed = 8
#     Detached = 9
#     Exited = 10
#     Invalid = 0
#     Launching = 4
#     Running = 6
#     Stepping = 7
#     Stopped = 5
#     Suspended = 11
#     Unloaded = 1
# 
# Path: debugger/util.py
# class EventBroadcaster(object):
#     """
#     Object that broadcasts event to it's listeners.
# 
#     Evety broadcaster represents a single event type.
#     """
#     def __init__(self):
#         self.listeners = []
# 
#     def notify(self, *args, **kwargs):
#         """
#         Notifies all listeners that an event has occured.
#         @param args: arbitraty arguments that will be passed to the listeners
#         """
#         map(lambda listener: listener(*args, **kwargs), self.listeners)
# 
#     def subscribe(self, listener):
#         """
#         Subscribes an event listener, who will receive events from the
#         broadcaster.
#         @type listener: function
#         """
#         self.listeners.append(listener)
# 
#     def unsubscribe(self, listener):
#         """
#         Unsubscribes an event listener.
#         It will no longer receive events after he unsubscribes.
#         @param listener: function
#         """
#         self.listeners.remove(listener)
# 
#     def clear(self):
#         """
#         Removes all event listeners.
#         """
#         self.listeners = []
# 
#     def redirect(self, broadcaster):
#         """
#         Redirects this broadcaster to the given broadcaster.
# 
#         All events fired by this broadcaster will be also delivered to the
#         given broadcaster.
#         @type broadcaster: EventBroadcaster
#         """
#         self.subscribe(broadcaster.notify)
# 
#     def __call__(self, *args, **kwargs):
#         self.notify(*args, **kwargs)


# Path: gui/memory_view.py
from gi.repository import Gtk
from debugger.enums import ProcessState
from debugger.util import EventBroadcaster
from gui_util import require_gui_thread, run_on_gui
import re

#    (at your option) any later version.
#
#    Devi is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Devi.  If not, see <http://www.gnu.org/licenses/>.
#






class RegisterList(Gtk.ListBox):
    def __init__(self, debugger):
        """
        @type debugger: debugger.Debugger
        """
        super(RegisterList, self).__init__()
        self.set_selection_mode(Gtk.SelectionMode.NONE)

        self.debugger = debugger
        self.debugger.on_process_state_changed.subscribe(
            self._handle_process_change)
        self.debugger.on_frame_changed.subscribe(self._handle_frame_change)

    def _handle_process_change(self, state, event_data):

        if state == ProcessState.Stopped: