Mercurial > hg > octave-lyh
changeset 14726:e94a54ee0f46 gui
Added debug events, debug mode detection and fixed compiling error.
* main-window: Added new slots reacting on debug mode changes.
* octave-event-listener: Extended interface to transmit debug mode changes.
* octave-event: Added a lot of debug events.
* octave-link: Added code to detect the change of the debug mode flag.
* octave-qt-event-listener: Implemented new interface methods.
* workspace-view.h: Added missing #include.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 05 Jun 2012 14:41:22 +0200 |
parents | 7784625acf66 |
children | f34984656658 |
files | gui/src/main-window.cc gui/src/main-window.h gui/src/octave-adapter/octave-event-listener.h gui/src/octave-adapter/octave-event.h gui/src/octave-adapter/octave-link.cc gui/src/octave-adapter/octave-link.h gui/src/octave-qt-event-listener.cc gui/src/octave-qt-event-listener.h gui/src/workspace-view.h |
diffstat | 9 files changed, 162 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/main-window.cc +++ b/gui/src/main-window.cc @@ -35,13 +35,6 @@ { // We have to set up all our windows, before we finally launch octave. construct (); - _octave_qt_event_listener = new octave_qt_event_listener (); - octave_link::instance ()->register_event_listener (_octave_qt_event_listener); - - connect (_octave_qt_event_listener, - SIGNAL (current_directory_changed(QString)), - this, - SLOT (update_current_working_directory(QString))); octave_link::instance ()->launch_octave(); } @@ -210,6 +203,19 @@ _terminal->setFocus (); } + +void +main_window::handle_entered_debug_mode () +{ + setWindowTitle ("Octave (Debugging)"); +} + +void +main_window::handle_quit_debug_mode () +{ + setWindowTitle ("Octave"); +} + void main_window::show_about_octave () { @@ -467,5 +473,23 @@ addDockWidget (Qt::BottomDockWidgetArea, _terminal_dock_widget); setStatusBar (_status_bar); read_settings (); + + _octave_qt_event_listener = new octave_qt_event_listener (); + octave_link::instance ()->register_event_listener (_octave_qt_event_listener); + + connect (_octave_qt_event_listener, + SIGNAL (current_directory_has_changed_signal (QString)), + this, + SLOT (update_current_working_directory (QString))); + + connect (_octave_qt_event_listener, + SIGNAL (entered_debug_mode_signal ()), + this, + SLOT(handle_entered_debug_mode ())); + + connect (_octave_qt_event_listener, + SIGNAL (quit_debug_mode_signal ()), + this, + SLOT (handle_quit_debug_mode ())); }
--- a/gui/src/main-window.h +++ b/gui/src/main-window.h @@ -91,6 +91,9 @@ void change_current_working_directory (QString directory); void current_working_directory_up (); + void handle_entered_debug_mode (); + void handle_quit_debug_mode (); + protected: void closeEvent (QCloseEvent * closeEvent); void read_settings ();
--- a/gui/src/octave-adapter/octave-event-listener.h +++ b/gui/src/octave-adapter/octave-event-listener.h @@ -28,6 +28,9 @@ virtual void current_directory_has_changed (std::string directory) = 0; virtual void about_to_exit () = 0; + + virtual void entered_debug_mode () = 0; + virtual void quit_debug_mode () = 0; }; #endif // OCTAVEEVENTLISTENER_H
--- a/gui/src/octave-adapter/octave-event.h +++ b/gui/src/octave-adapter/octave-event.h @@ -21,8 +21,11 @@ #include <string> #include "octave-event-observer.h" #include "oct-env.h" +#include "pt-eval.h" #include "toplev.h" +#include <readline/readline.h> + /** * \class octave_event * \brief Base class for an octave event. @@ -122,4 +125,94 @@ std::string _directory; }; +class octave_debug_step_into_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_into_event. */ + octave_debug_step_into_event (octave_event_observer& o) + : octave_event (o) { } + + 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; + } +}; + +class octave_debug_step_over_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_over_event. */ + octave_debug_step_over_event (octave_event_observer& o) + : octave_event (o) { } + + 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; + } +}; + +class octave_debug_step_out_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_out_event. */ + octave_debug_step_out_event (octave_event_observer& o) + : octave_event (o) { } + + 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 +{ + public: + /** Creates a new octave_debug_step_out_event. */ + octave_debug_step_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 +{ + public: + /** Creates a new octave_debug_step_out_event. */ + octave_debug_step_break_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; + } +}; + #endif // OCTAVEEVENT_H
--- a/gui/src/octave-adapter/octave-link.cc +++ b/gui/src/octave-adapter/octave-link.cc @@ -70,6 +70,18 @@ _octave_event_listener ->current_directory_has_changed (_last_working_directory); } + + if (_debugging_mode_active != tree_evaluator::debug_mode) + { + _debugging_mode_active = tree_evaluator::debug_mode; + if (_octave_event_listener) + { + if (_debugging_mode_active) + _octave_event_listener->entered_debug_mode (); + else + _octave_event_listener->quit_debug_mode (); + } + } } void
--- a/gui/src/octave-adapter/octave-link.h +++ b/gui/src/octave-adapter/octave-link.h @@ -110,6 +110,7 @@ /** Stores the last known current working directory of octave. */ std::string _last_working_directory; + bool _debugging_mode_active; /** Unique instance. Singelton! */ static octave_link _singleton;
--- a/gui/src/octave-qt-event-listener.cc +++ b/gui/src/octave-qt-event-listener.cc @@ -25,10 +25,21 @@ void octave_qt_event_listener::current_directory_has_changed (std::string directory) -{ emit current_directory_changed (QString::fromStdString (directory)); } +{ + emit current_directory_has_changed_signal + (QString::fromStdString (directory)); +} void octave_qt_event_listener::about_to_exit () { qApp->quit (); } + +void +octave_qt_event_listener::entered_debug_mode () +{ emit entered_debug_mode_signal (); } + +void +octave_qt_event_listener::quit_debug_mode () +{ emit quit_debug_mode_signal (); }
--- a/gui/src/octave-qt-event-listener.h +++ b/gui/src/octave-qt-event-listener.h @@ -32,8 +32,13 @@ void current_directory_has_changed (std::string directory); void about_to_exit (); + void entered_debug_mode (); + void quit_debug_mode (); + signals: - void current_directory_changed (QString directory); + void current_directory_has_changed_signal (QString directory); + void entered_debug_mode_signal (); + void quit_debug_mode_signal (); }; #endif // OCTAVEQTEVENTLISTENER_H