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& )
308 connect_link (
const std::shared_ptr<interpreter_events>& obj);
310 OCTINTERP_API
bool enable ();
314 bool retval = m_link_enabled;
315 m_link_enabled =
false;
321 return m_link_enabled;
331 m_qt_event_handlers = obj;
334 std::shared_ptr<interpreter_events>
340 OCTINTERP_API
void process_events (
bool disable =
false);
342 OCTINTERP_API
void discard_events ();
349 void push_event_queue ();
350 void pop_event_queue ();
352 OCTINTERP_API
void post_event (
const fcn_callback& fcn);
371 m_instance->start_gui (gui_app);
377 m_instance->close_gui ();
384 return m_qt_event_handlers && m_qt_event_handlers->have_dialogs ();
387 typedef std::list<std::pair<std::string, std::string>>
filter_list;
389 std::list<std::string>
391 const std::string& filename,
const std::string&
dirname,
392 const std::string& multimode)
394 return (enabled () && have_dialogs ()
397 : std::list<std::string> ());
400 std::list<std::string>
402 const std::string& title,
403 const std::list<float>& nr,
404 const std::list<float>& nc,
405 const std::list<std::string>& defaults)
407 return (enabled () && have_dialogs ()
408 ? m_instance->input_dialog (prompt, title, nr, nc, defaults)
409 : std::list<std::string> ());
412 std::pair<std::list<int>,
int>
414 const std::string& mode,
415 int width,
int height,
416 const std::list<int>& initial_value,
417 const std::string& name,
418 const std::list<std::string>& prompt,
419 const std::string& ok_string,
420 const std::string& cancel_string)
422 return (enabled () && have_dialogs ()
423 ? m_instance->list_dialog (list, mode, width, height,
424 initial_value, name, prompt,
425 ok_string, cancel_string)
426 : std::pair<std::list<int>,
int> ());
431 const std::string& btn1,
const std::string& btn2,
432 const std::string& btn3,
const std::string& btndef)
434 return (enabled () && have_dialogs ()
435 ? m_instance->question_dialog (msg, title, btn1,
443 m_instance->update_path_dialog ();
450 m_instance->show_preferences ();
461 m_instance->apply_preferences ();
471 m_instance->show_terminal_window ();
476 return enabled () ? m_instance->show_documentation (file) :
false;
482 m_instance->show_file_browser ();
488 m_instance->show_command_history ();
494 m_instance->show_workspace ();
500 m_instance->show_community_news (serial);
506 m_instance->show_release_notes ();
511 return enabled () ? m_instance->edit_file (file) :
false;
518 m_instance->edit_variable (name, val);
530 retval = m_instance->confirm_shutdown ();
537 return enabled () ? m_instance->prompt_new_edit_file (file) :
false;
541 const std::string& dir,
bool addpath_option)
544 ? m_instance->debug_cd_or_addpath_error (file, dir,
552 ? m_instance->get_named_icon (icon_name) :
uint8NDArray ());
556 const std::string& value)
558 return enabled () ? m_instance->gui_preference (key, value) :
"";
563 return enabled () ? m_instance->copy_image_to_clipboard (file) :
false;
569 m_instance->focus_window (win_name);
576 m_instance->execute_command_in_terminal (command);
583 m_instance->register_documentation (file);
594 m_instance->unregister_documentation (file);
605 m_instance->interpreter_output (msg);
616 m_instance->display_exception (ee, beep);
624 const std::string& status)
628 m_instance->gui_status_update (feature, status);
639 m_instance->update_gui_lexer ();
649 m_instance->directory_changed (dir);
653 void file_remove (
const std::string& old_name,
const std::string& new_name)
656 m_instance->file_remove (old_name, new_name);
662 m_instance->file_renamed (load_new);
665 OCTINTERP_API
void set_workspace ();
668 bool update_variable_editor =
true)
671 m_instance->set_workspace (top_level, m_debugging, syminfo,
672 update_variable_editor);
678 m_instance->clear_workspace ();
684 m_instance->update_prompt (prompt);
687 OCTINTERP_API
void set_history ();
692 m_instance->set_history (hist);
698 m_instance->append_history (hist_entry);
704 m_instance->clear_history ();
710 m_instance->pre_input_event ();
716 m_instance->post_input_event ();
720 const std::string& fcn_file_name,
int line)
726 m_instance->enter_debugger_event (fcn_name, fcn_file_name,
line);
733 m_instance->execute_in_debugger_event (file,
line);
738 if (enabled () && m_debugging)
742 m_instance->exit_debugger_event ();
747 int line,
const std::string& cond =
"")
750 m_instance->update_breakpoint (insert, file,
line, cond);
756 m_instance->interpreter_interrupted ();
786 std::shared_ptr<interpreter_events> m_instance;
788 std::shared_ptr<interpreter_events> m_qt_event_handlers;
792 OCTAVE_END_NAMESPACE(
octave)
static bool is_gui_running()
Provides threadsafe access to octave.
void append_history(const std::string &hist_entry)
bool show_documentation(const std::string &file)
void show_terminal_window()
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 register_documentation(const std::string &file)
void show_command_history()
void show_release_notes()
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)
void install_qt_event_handlers(const std::shared_ptr< interpreter_events > &obj)
void execute_command_in_terminal(const std::string &command)
uint8NDArray get_named_icon(const std::string &icon_name)
std::list< std::pair< std::string, std::string > > filter_list
void file_remove(const std::string &old_name, const std::string &new_name)
void update_path_dialog()
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)
std::shared_ptr< interpreter_events > qt_event_handlers() const
void interpreter_interrupted()
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 exit_debugger_event()
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 start_gui(bool gui_app=false)
bool interpreter_output(const std::string &msg)
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)
std::string gui_preference(const std::string &key, const std::string &value)
std::stack< std::shared_ptr< event_queue > > m_gui_event_queue
bool have_dialogs() const
void show_community_news(int serial=-1)
int debug_cd_or_addpath_error(const std::string &file, const std::string &dir, bool addpath_option)
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)
virtual void show_preferences()
interpreter_events()=default
virtual void register_documentation(const std::string &)
virtual void show_command_history()
std::list< std::pair< std::string, std::string > > filter_list
virtual void enter_debugger_event(const std::string &, const std::string &, int)
virtual void show_file_browser()
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 update_gui_lexer()
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 bool edit_file(const std::string &)
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 &)
interpreter_events(const interpreter_events &)=default
virtual bool prompt_new_edit_file(const std::string &)
virtual int debug_cd_or_addpath_error(const std::string &, const std::string &, bool)
virtual ~interpreter_events()=default
virtual void update_breakpoint(bool, const std::string &, int, const std::string &)
virtual void clear_workspace()
virtual void update_path_dialog()
virtual void apply_preferences()
virtual void clear_history()
virtual void execute_command_in_terminal(const std::string &)
virtual uint8NDArray get_named_icon(const std::string &)
virtual void interpreter_interrupted()
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_workspace()
virtual void start_gui(bool=false)
virtual void edit_variable(const std::string &, const octave_value &)
virtual void execute_in_debugger_event(const std::string &, int)
virtual std::string question_dialog(const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &)
virtual void show_terminal_window()
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 bool show_documentation(const std::string &)
virtual void post_input_event()
virtual void exit_debugger_event()
virtual void show_release_notes()
virtual bool confirm_shutdown()
virtual void pre_input_event()
virtual void gui_status_update(const std::string &, const std::string &)
virtual bool have_dialogs() const
virtual void focus_window(const std::string)
virtual void set_history(const string_vector &)
virtual void unregister_documentation(const std::string &)
string_vector & operator=(const string_vector &)=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(interpreter &)> meth_callback
std::function< void()> fcn_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