diff gui/src/m-editor/file-editor-tab.cc @ 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 ed0f820c7ce0
children e97be88fc478
line wrap: on
line diff
--- a/gui/src/m-editor/file-editor-tab.cc	Mon Jul 02 10:51:47 2012 +0200
+++ b/gui/src/m-editor/file-editor-tab.cc	Mon Jul 02 12:35:08 2012 +0200
@@ -107,6 +107,28 @@
     {
       // File was run successfully.
     }
+
+  if (octave_add_breakpoint_event *abe
+      = dynamic_cast<octave_add_breakpoint_event*> (e))
+    {
+      // TODO: Check file.
+      _edit_area->markerAdd (abe->get_line (), breakpoint);
+    }
+
+  if (octave_remove_breakpoint_event *rbe
+      = dynamic_cast<octave_remove_breakpoint_event*> (e))
+    {
+      // TODO: Check file.
+      _edit_area->markerDelete (rbe->get_line (), breakpoint);
+    }
+
+  if (octave_remove_all_breakpoints_event *rabe
+      = dynamic_cast<octave_remove_all_breakpoints_event*> (e))
+    {
+      Q_UNUSED (rabe);
+      _edit_area->markerDeleteAll (breakpoint);
+    }
+
   delete e;
 }
 
@@ -168,14 +190,52 @@
       else
         {
           if (mask && (1 << breakpoint))
-            _edit_area->markerDelete(line,breakpoint);
+            {
+              request_remove_breakpoint (line);
+            }
           else
-            _edit_area->markerAdd(line,breakpoint);
+            {
+              request_add_breakpoint (line);
+            }
         }
     }
 }
 
 void
+file_editor_tab::request_add_breakpoint (int line)
+{
+  QFileInfo file_info (_file_name);
+  QString path = file_info.absolutePath ();
+  QString function_name = file_info.fileName ();
+
+  // We have to cut off the suffix, because octave appends it.
+  function_name.chop (file_info.suffix ().length () + 1);
+
+  octave_link::instance ()->post_event
+      (new octave_add_breakpoint_event (*this,
+                                        path.toStdString (),
+                                        function_name.toStdString (),
+                                        line));
+}
+
+void
+file_editor_tab::request_remove_breakpoint (int line)
+{
+  QFileInfo file_info (_file_name);
+  QString path = file_info.absolutePath ();
+  QString function_name = file_info.fileName ();
+
+  // We have to cut off the suffix, because octave appends it.
+  function_name.chop (file_info.suffix ().length () + 1);
+
+  octave_link::instance ()->post_event
+      (new octave_remove_breakpoint_event (*this,
+                                           path.toStdString (),
+                                           function_name.toStdString (),
+                                           line));
+}
+
+void
 file_editor_tab::comment_selected_text ()
 {
   do_comment_selected_text (true);
@@ -332,11 +392,11 @@
 file_editor_tab::toggle_breakpoint ()
 {
   int line, cur;
-  _edit_area->getCursorPosition (&line,&cur);
+  _edit_area->getCursorPosition (&line, &cur);
   if ( _edit_area->markersAtLine (line) && (1 << breakpoint) )
-    _edit_area->markerDelete (line, breakpoint);
+    request_remove_breakpoint (line);
   else
-    _edit_area->markerAdd (line, breakpoint);
+    request_add_breakpoint (line);
 }
 
 void