diff gui/src/octave-adapter/octave-event.h @ 14827:6b90737f69cc gui

Very basic breakpoint setting and removing in the editor works. * file-editor-tab: Instead of toggling breakpoints directly, now sends events. * octave-event: Created new events to add and remove breakpoints.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Mon, 02 Jul 2012 12:35:08 +0200
parents 61c80e9326a8
children e97be88fc478
line wrap: on
line diff
--- a/gui/src/octave-adapter/octave-event.h
+++ b/gui/src/octave-adapter/octave-event.h
@@ -250,6 +250,123 @@
     }
 };
 
+class octave_add_breakpoint_event : public octave_event
+{
+  public:
+    octave_add_breakpoint_event (octave_event_observer& o,
+                                 std::string path,
+                                 std::string function_name,
+                                 int line)
+      : octave_event (o)
+    {
+      _path = path;
+      _function_name = function_name;
+      _line = line;
+    }
+
+    bool perform ()
+    {
+      bp_table::intmap intmap;
+      intmap[0] = _line;
+
+      // TODO: Check success.
+      std::string previous_directory = octave_env::get_current_directory ();
+      octave_env::chdir (_path);
+      bp_table::add_breakpoint (_function_name, intmap);
+      octave_env::chdir (previous_directory);
+      return true;
+    }
+
+    std::string get_path ()
+    {
+      return _path;
+    }
+
+    std::string get_function_name ()
+    {
+      return _function_name;
+    }
+
+    int get_line ()
+    {
+      return _line;
+    }
+
+  private:
+    std::string _path;
+    std::string _function_name;
+    int _line;
+};
+
+class octave_remove_breakpoint_event : public octave_event
+{
+  public:
+    octave_remove_breakpoint_event (octave_event_observer& o,
+                                    std::string path,
+                                    std::string function_name,
+                                    int line)
+      : octave_event (o)
+    {
+      _path = path;
+      _function_name = function_name;
+      _line = line;
+    }
+
+    bool perform ()
+    {
+      bp_table::intmap intmap;
+      intmap[0] = _line;
+
+      // TODO: Check success.
+      std::string previous_directory = octave_env::get_current_directory ();
+      octave_env::chdir (_path);
+      bp_table::remove_breakpoint (_function_name, intmap);
+      octave_env::chdir (previous_directory);
+      return true;
+    }
+
+    std::string get_path ()
+    {
+      return _path;
+    }
+
+    std::string get_function_name ()
+    {
+      return _function_name;
+    }
+
+    int get_line ()
+    {
+      return _line;
+    }
+
+  private:
+    std::string _path;
+    std::string _function_name;
+    int _line;
+};
+
+class octave_remove_all_breakpoints_event : public octave_event
+{
+  public:
+    octave_remove_all_breakpoints_event (octave_event_observer& o,
+                                         std::string file)
+      : octave_event (o)
+    {
+      _file = file;
+    }
+
+    bool perform ()
+    {
+      // TODO: Check success.
+      bp_table::remove_all_breakpoints_in_file (_file, true);
+      return true;
+    }
+
+  private:
+    std::string _file;
+};
+
 class octave_debug_step_into_event : public octave_event
 {
   public: