Mercurial > octave-nkf
diff gui/src/octave-adapter/octave-event.h @ 14804:a565c560e654 gui
Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
* default-settings: New file containing the default settings.
* file-editor-tab: Subclassed event observer and added code to send a run event.
* main-window: Sending workspace events instead of using the terminal.
* octave-event: Added new event types.
* octave-link: Added getter for the current working directory.
* octave-gui: Adjusted code, so the default settings can be loaded.
* resource-manager: Added code to handle the logic with a default settings file.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 26 Jun 2012 15:27:10 +0200 |
parents | c30916f904fb |
children | 61c80e9326a8 |
line wrap: on
line diff
--- a/gui/src/octave-adapter/octave-event.h Tue Jun 26 10:54:39 2012 +0200 +++ b/gui/src/octave-adapter/octave-event.h Tue Jun 26 15:27:10 2012 +0200 @@ -20,6 +20,8 @@ #include <string> #include "octave-event-observer.h" +#include "octave/config.h" +#include "symtab.h" #include "oct-env.h" #include "pt-eval.h" #include "toplev.h" @@ -129,7 +131,30 @@ { clean_up_and_exit (0); return true; } }; -/** Implements a change directory events. */ +/** Implements an octave run file event. */ +class octave_run_file_event : public octave_event +{ + public: + /** Creates a new octave_run_file_event. */ + octave_run_file_event (octave_event_observer& o, + std::string file) + : octave_event (o) + { _file = file; } + + bool perform () + { + octave_value_list args; + args.append (octave_value (_file)); + call_octave_function ("run", args); + finish_readline_event (); + return true; + } + + private: + std::string _file; +}; + +/** Implements a change directory event. */ class octave_change_directory_event : public octave_event { public: @@ -146,6 +171,66 @@ std::string _directory; }; +/** Implements a clear workspace event. */ +class octave_clear_workspace_event : public octave_event +{ + public: + /** Creates a new octave_run_file_event. */ + octave_clear_workspace_event (octave_event_observer& o) + : octave_event (o) + { } + + bool perform () + { + call_octave_function ("clear"); + return true; + } +}; + +/** Implements a load workspace event. */ +class octave_load_workspace_event : public octave_event +{ + public: + /** Creates a new octave_change_directory_event. */ + octave_load_workspace_event (octave_event_observer& o, + std::string file) + : octave_event (o) + { _file = file; } + + bool perform () + { + octave_value_list args; + args.append (octave_value (_file)); + call_octave_function ("load", args); + return true; + } + + private: + std::string _file; +}; + +/** Implements a save workspace event. */ +class octave_save_workspace_event : public octave_event +{ + public: + /** Creates a new octave_change_directory_event. */ + octave_save_workspace_event (octave_event_observer& o, + std::string file) + : octave_event (o) + { _file = file; } + + bool perform () + { + octave_value_list args; + args.append (octave_value (_file)); + call_octave_function ("save", args); + return true; + } + + private: + std::string _file; +}; + class octave_debug_step_into_event : public octave_event { public: