26 #if ! defined (octave_event_manager_h)
27 #define octave_event_manager_h 1
29 #include "octave-config.h"
105 typedef std::list<std::pair<std::string, std::string>>
filter_list;
107 virtual std::list<std::string>
114 return std::list<std::string> ();
117 virtual std::list<std::string>
120 const std::list<float>& ,
121 const std::list<float>& ,
122 const std::list<std::string>& )
124 return std::list<std::string> ();
127 virtual std::pair<std::list<int>,
int>
129 const std::string& ,
int ,
int ,
130 const std::list<int>& ,
132 const std::list<std::string>& ,
136 return std::pair<std::list<int>,
int> ();
141 const std::string& ,
const std::string& ,
142 const std::string& ,
const std::string& )
169 virtual bool edit_file (
const std::string& ) {
return false; }
232 const std::string& ) { }
280 int ,
const std::string& )
313 connect_link (
const std::shared_ptr<interpreter_events>& obj);
315 OCTINTERP_API
bool enable (
void);
319 bool retval = m_link_enabled;
320 m_link_enabled =
false;
326 return m_link_enabled;
336 m_qt_event_handlers = obj;
339 std::shared_ptr<interpreter_events>
345 OCTINTERP_API
void process_events (
bool disable =
false);
347 OCTINTERP_API
void discard_events (
void);
354 void push_event_queue (
void);
355 void pop_event_queue (
void);
357 OCTINTERP_API
void post_event (
const fcn_callback& fcn);
376 m_instance->start_gui (gui_app);
382 m_instance->close_gui ();
389 return m_qt_event_handlers && m_qt_event_handlers->have_dialogs ();
392 typedef std::list<std::pair<std::string, std::string>>
filter_list;
394 std::list<std::string>
396 const std::string& filename,
const std::string&
dirname,
397 const std::string& multimode)
399 return (enabled () && have_dialogs ()
402 : std::list<std::string> ());
405 std::list<std::string>
407 const std::string& title,
408 const std::list<float>& nr,
409 const std::list<float>& nc,
410 const std::list<std::string>& defaults)
412 return (enabled () && have_dialogs ()
413 ? m_instance->input_dialog (prompt, title, nr, nc, defaults)
414 : std::list<std::string> ());
417 std::pair<std::list<int>,
int>
419 const std::string& mode,
420 int width,
int height,
421 const std::list<int>& initial_value,
422 const std::string& name,
423 const std::list<std::string>& prompt,
424 const std::string& ok_string,
425 const std::string& cancel_string)
427 return (enabled () && have_dialogs ()
428 ? m_instance->list_dialog (list, mode, width, height,
429 initial_value, name, prompt,
430 ok_string, cancel_string)
431 : std::pair<std::list<int>,
int> ());
436 const std::string& btn1,
const std::string& btn2,
437 const std::string& btn3,
const std::string& btndef)
439 return (enabled () && have_dialogs ()
440 ? m_instance->question_dialog (msg, title, btn1,
448 m_instance->update_path_dialog ();
455 m_instance->show_preferences ();
466 m_instance->apply_preferences ();
476 m_instance->show_terminal_window ();
481 return enabled () ? m_instance->show_documentation (file) :
false;
487 m_instance->show_file_browser ();
493 m_instance->show_command_history ();
499 m_instance->show_workspace ();
505 m_instance->show_community_news (serial);
511 m_instance->show_release_notes ();
516 return enabled () ? m_instance->edit_file (file) :
false;
523 m_instance->edit_variable (name, val);
535 retval = m_instance->confirm_shutdown ();
542 return enabled () ? m_instance->prompt_new_edit_file (file) :
false;
546 const std::string& dir,
bool addpath_option)
549 ? m_instance->debug_cd_or_addpath_error (file, dir,
557 ? m_instance->get_named_icon (icon_name) :
uint8NDArray ());
561 const std::string& value)
563 return enabled () ? m_instance->gui_preference (key, value) :
"";
568 return enabled () ? m_instance->copy_image_to_clipboard (file) :
false;
574 m_instance->focus_window (win_name);
581 m_instance->execute_command_in_terminal (command);
588 m_instance->register_documentation (file);
599 m_instance->unregister_documentation (file);
610 m_instance->interpreter_output (msg);
621 m_instance->display_exception (ee, beep);
629 const std::string& status)
633 m_instance->gui_status_update (feature, status);
644 m_instance->update_gui_lexer ();
654 m_instance->directory_changed (dir);
658 void file_remove (
const std::string& old_name,
const std::string& new_name)
661 m_instance->file_remove (old_name, new_name);
667 m_instance->file_renamed (load_new);
670 OCTINTERP_API
void set_workspace (
void);
673 bool update_variable_editor =
true)
676 m_instance->set_workspace (top_level, m_debugging, syminfo,
677 update_variable_editor);
683 m_instance->clear_workspace ();
689 m_instance->update_prompt (prompt);
692 OCTINTERP_API
void set_history (
void);
697 m_instance->set_history (hist);
703 m_instance->append_history (hist_entry);
709 m_instance->clear_history ();
715 m_instance->pre_input_event ();
721 m_instance->post_input_event ();
725 const std::string& fcn_file_name,
int line)
731 m_instance->enter_debugger_event (fcn_name, fcn_file_name, line);
738 m_instance->execute_in_debugger_event (file, line);
743 if (enabled () && m_debugging)
747 m_instance->exit_debugger_event ();
752 int line,
const std::string& cond =
"")
755 m_instance->update_breakpoint (insert, file, line, cond);
761 m_instance->interpreter_interrupted ();
static bool is_gui_running(void)
Provides threadsafe access to octave.
void append_history(const std::string &hist_entry)
void show_workspace(void)
bool show_documentation(const std::string &file)
void update_path_dialog(void)
bool edit_variable(const std::string &name, const octave_value &val)
void file_renamed(bool load_new)
virtual void focus_window(const std::string win_name)
std::list< std::string > input_dialog(const std::list< std::string > &prompt, const std::string &title, const std::list< float > &nr, const std::list< float > &nc, const std::list< std::string > &defaults)
bool show_preferences(void)
bool register_documentation(const std::string &file)
bool confirm_shutdown(void)
bool have_dialogs(void) const
std::string question_dialog(const std::string &msg, const std::string &title, const std::string &btn1, const std::string &btn2, const std::string &btn3, const std::string &btndef)
void enter_debugger_event(const std::string &fcn_name, const std::string &fcn_file_name, int line)
bool unregister_documentation(const std::string &file)
std::shared_ptr< interpreter_events > m_instance
void install_qt_event_handlers(const std::shared_ptr< interpreter_events > &obj)
void execute_command_in_terminal(const std::string &command)
bool update_gui_lexer(void)
uint8NDArray get_named_icon(const std::string &icon_name)
void clear_workspace(void)
std::list< std::pair< std::string, std::string > > filter_list
void file_remove(const std::string &old_name, const std::string &new_name)
void post_input_event(void)
void set_history(const string_vector &hist)
bool copy_image_to_clipboard(const std::string &file)
bool prompt_new_edit_file(const std::string &file)
event_manager(const event_manager &)=delete
std::pair< std::list< int >, int > list_dialog(const std::list< std::string > &list, const std::string &mode, int width, int height, const std::list< int > &initial_value, const std::string &name, const std::list< std::string > &prompt, const std::string &ok_string, const std::string &cancel_string)
void directory_changed(const std::string &dir)
mutex * m_event_queue_mutex
void set_workspace(bool top_level, const symbol_info_list &syminfo, bool update_variable_editor=true)
void show_command_history(void)
void start_gui(bool gui_app=false)
bool interpreter_output(const std::string &msg)
void exit_debugger_event(void)
bool gui_status_update(const std::string &feature, const std::string &status)
bool display_exception(const execution_exception &ee, bool beep=false)
std::list< std::string > file_dialog(const filter_list &filter, const std::string &title, const std::string &filename, const std::string &dirname, const std::string &multimode)
void interpreter_interrupted(void)
std::string gui_preference(const std::string &key, const std::string &value)
void show_release_notes(void)
interpreter & m_interpreter
std::stack< std::shared_ptr< event_queue > > m_gui_event_queue
void show_community_news(int serial=-1)
std::shared_ptr< interpreter_events > m_qt_event_handlers
int debug_cd_or_addpath_error(const std::string &file, const std::string &dir, bool addpath_option)
void show_terminal_window(void)
bool apply_preferences(void)
std::shared_ptr< interpreter_events > qt_event_handlers(void) const
bool edit_file(const std::string &file)
void update_breakpoint(bool insert, const std::string &file, int line, const std::string &cond="")
void update_prompt(const std::string &prompt)
void execute_in_debugger_event(const std::string &file, int line)
void pre_input_event(void)
void show_file_browser(void)
virtual void register_documentation(const std::string &)
virtual void clear_history(void)
virtual bool have_dialogs(void) const
virtual void apply_preferences(void)
std::list< std::pair< std::string, std::string > > filter_list
virtual void enter_debugger_event(const std::string &, const std::string &, int)
virtual void set_workspace(bool, bool, const symbol_info_list &, bool)
virtual void interpreter_output(const std::string &)
virtual std::list< std::string > file_dialog(const filter_list &, const std::string &, const std::string &, const std::string &, const std::string &)
virtual std::string gui_preference(const std::string &, const std::string &)
virtual void show_community_news(int)
virtual bool copy_image_to_clipboard(const std::string &)
virtual void append_history(const std::string &)
virtual void directory_changed(const std::string &)
virtual void show_workspace(void)
virtual bool edit_file(const std::string &)
virtual ~interpreter_events(void)=default
virtual std::pair< std::list< int >, int > list_dialog(const std::list< std::string > &, const std::string &, int, int, const std::list< int > &, const std::string &, const std::list< std::string > &, const std::string &, const std::string &)
virtual void update_path_dialog(void)
interpreter_events(const interpreter_events &)=default
virtual bool confirm_shutdown(void)
virtual void interpreter_interrupted(void)
virtual void update_gui_lexer(void)
virtual bool prompt_new_edit_file(const std::string &)
virtual int debug_cd_or_addpath_error(const std::string &, const std::string &, bool)
interpreter_events(void)=default
virtual void show_command_history(void)
virtual void update_breakpoint(bool, const std::string &, int, const std::string &)
virtual void execute_command_in_terminal(const std::string &)
virtual void close_gui(void)
virtual uint8NDArray get_named_icon(const std::string &)
virtual void show_release_notes(void)
virtual void file_remove(const std::string &, const std::string &)
virtual void file_renamed(bool)
virtual void update_prompt(const std::string &)
virtual void show_preferences(void)
virtual void start_gui(bool=false)
virtual void show_terminal_window(void)
virtual void edit_variable(const std::string &, const octave_value &)
virtual void show_file_browser(void)
virtual void execute_in_debugger_event(const std::string &, int)
virtual void exit_debugger_event(void)
virtual std::string question_dialog(const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &)
virtual std::list< std::string > input_dialog(const std::list< std::string > &, const std::string &, const std::list< float > &, const std::list< float > &, const std::list< std::string > &)
virtual void clear_workspace(void)
virtual bool show_documentation(const std::string &)
virtual void post_input_event(void)
virtual void gui_status_update(const std::string &, const std::string &)
virtual void focus_window(const std::string)
virtual void set_history(const string_vector &)
virtual void unregister_documentation(const std::string &)
virtual void pre_input_event(void)
string_vector & operator=(const string_vector &)=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(void)> fcn_callback
std::function< void(interpreter &)> meth_callback
std::string dirname(const std::string &path)
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
intNDArray< octave_uint8 > uint8NDArray