changeset 14800:564cc673bcc5 gui

Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly * main-window.cc: Added connects and menus/actions. * main-window.h: Added new slots, made debug menu a member variable. * octave-event.h: Removed magic readline code.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sat, 09 Jun 2012 01:10:51 +0200
parents c6135951bc18
children c30916f904fb
files gui/src/main-window.cc gui/src/main-window.h gui/src/octave-adapter/octave-event.h
diffstat 3 files changed, 72 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/gui/src/main-window.cc
+++ b/gui/src/main-window.cc
@@ -208,12 +208,49 @@
 main_window::handle_entered_debug_mode ()
 {
   setWindowTitle ("Octave (Debugging)");
+  _debug_menu->setEnabled (true);
 }
 
 void
 main_window::handle_quit_debug_mode ()
 {
   setWindowTitle ("Octave");
+  _debug_menu->setEnabled (false);
+}
+
+void
+main_window::debug_continue ()
+{
+  octave_link::instance ()
+      ->post_event (new octave_debug_continue_event (*this));
+}
+
+void
+main_window::debug_step_into ()
+{
+  octave_link::instance ()
+      ->post_event (new octave_debug_step_into_event (*this));
+}
+
+void
+main_window::debug_step_over ()
+{
+  octave_link::instance ()
+      ->post_event (new octave_debug_step_over_event (*this));
+}
+
+void
+main_window::debug_step_out ()
+{
+  octave_link::instance ()
+      ->post_event (new octave_debug_step_out_event (*this));
+}
+
+void
+main_window::debug_quit ()
+{
+  octave_link::instance ()
+      ->post_event (new octave_debug_quit_event (*this));
 }
 
 void
@@ -269,8 +306,6 @@
 void
 main_window::construct ()
 {
-  QStyle *style = QApplication::style ();
-  // TODO: Check this.
   _closing = false;   // flag for editor files when closed
   setWindowIcon (resource_manager::instance ()->get_icon (resource_manager::octave));
 
@@ -342,7 +377,21 @@
       = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo"));
   redo_action->setShortcut (QKeySequence::Redo);
 
-  //QMenu *debugMenu = menuBar ()->addMenu (tr ("De&bug"));
+  _debug_menu = menuBar ()->addMenu (tr ("De&bug"));
+  QAction * debug_continue = _debug_menu->addAction (tr ("Continue"));
+  debug_continue->setShortcut (Qt::Key_F5);
+  QAction * debug_step_into = _debug_menu->addAction (tr ("Step into"));
+  debug_step_into->setShortcut (Qt::Key_F9);
+  QAction * debug_step_over = _debug_menu->addAction (tr ("Next"));
+  debug_step_over->setShortcut (Qt::Key_F10);
+  QAction * debug_step_out = _debug_menu->addAction (tr ("Step out"));
+  debug_step_out->setShortcut (Qt::Key_F11);
+  _debug_menu->addSeparator ();
+  QAction * debug_quit = _debug_menu->addAction (tr ("Quit"));
+  debug_quit->setShortcut (Qt::Key_Escape);
+  _debug_menu->setEnabled (false);
+
+
   //QMenu *parallelMenu = menuBar ()->addMenu (tr ("&Parallel"));
 
   QMenu *   desktop_menu = menuBar ()->addMenu (tr ("&Desktop"));
@@ -455,6 +504,16 @@
            _terminal,                   SLOT   (pasteClipboard ()));
   connect (_current_directory_combo_box, SIGNAL (activated (QString)),
            this,                        SLOT (change_current_working_directory (QString)));
+  connect (debug_continue,              SIGNAL (triggered ()),
+           this,                        SLOT (debug_continue ()));
+  connect (debug_step_into,             SIGNAL (triggered ()),
+           this,                        SLOT (debug_step_into ()));
+  connect (debug_step_over,             SIGNAL (triggered ()),
+           this,                        SLOT (debug_step_over ()));
+  connect (debug_step_out,              SIGNAL (triggered ()),
+           this,                        SLOT (debug_step_out ()));
+  connect (debug_quit,                  SIGNAL (triggered ()),
+           this,                        SLOT (debug_quit ()));
 
   setWindowTitle ("Octave");
   setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
--- a/gui/src/main-window.h
+++ b/gui/src/main-window.h
@@ -93,6 +93,11 @@
 
   void handle_entered_debug_mode ();
   void handle_quit_debug_mode ();
+  void debug_continue ();
+  void debug_step_into ();
+  void debug_step_over ();
+  void debug_step_out ();
+  void debug_quit ();
 
 protected:
   void closeEvent (QCloseEvent * closeEvent);
@@ -105,6 +110,7 @@
 
   QTerminal *               _terminal;
   file_editor_interface *   _file_editor;
+  QMenu *                   _debug_menu;
 
   // Dock widgets.
   workspace_view *          _workspace_view;
@@ -114,7 +120,6 @@
 
   // Toolbars.
   QStatusBar *              _status_bar;
-
   QComboBox *               _current_directory_combo_box;
   QToolButton *             _current_directory_tool_button;
   QToolButton *             _current_directory_up_tool_button;
--- a/gui/src/octave-adapter/octave-event.h
+++ b/gui/src/octave-adapter/octave-event.h
@@ -135,10 +135,6 @@
     bool perform () const
     {
       tree_evaluator::dbstep_flag = -1;
-      rl_line_buffer[0] = '\0';
-      rl_point = rl_end = 0;
-      rl_done = 1;
-      rl_forced_update_display ();
       return true;
     }
 };
@@ -153,10 +149,6 @@
     bool perform () const
     {
       tree_evaluator::dbstep_flag = 1;
-      rl_line_buffer[0] = '\0';
-      rl_point = rl_end = 0;
-      rl_done = 1;
-      rl_forced_update_display ();
       return true;
     }
 };
@@ -171,46 +163,34 @@
     bool perform () const
     {
       tree_evaluator::dbstep_flag = -2;
-      rl_line_buffer[0] = '\0';
-      rl_point = rl_end = 0;
-      rl_done = 1;
-      rl_forced_update_display ();
       return true;
     }
 };
 
-class octave_debug_step_continue_event : public octave_event
+class octave_debug_continue_event : public octave_event
 {
   public:
     /** Creates a new octave_debug_step_out_event. */
-    octave_debug_step_continue_event (octave_event_observer& o)
+    octave_debug_continue_event (octave_event_observer& o)
       : octave_event (o) { }
 
     bool perform () const
     {
       tree_evaluator::dbstep_flag = 0;
-      rl_line_buffer[0] = '\0';
-      rl_point = rl_end = 0;
-      rl_done = 1;
-      rl_forced_update_display ();
       return true;
     }
 };
 
-class octave_debug_step_break_event : public octave_event
+class octave_debug_quit_event : public octave_event
 {
   public:
     /** Creates a new octave_debug_step_out_event. */
-    octave_debug_step_break_event (octave_event_observer& o)
+    octave_debug_quit_event (octave_event_observer& o)
       : octave_event (o) { }
 
     bool perform () const
     {
       tree_evaluator::dbstep_flag = 0;
-      rl_line_buffer[0] = '\0';
-      rl_point = rl_end = 0;
-      rl_done = 1;
-      rl_forced_update_display ();
       return true;
     }
 };