26 #if defined (HAVE_CONFIG_H)
49 static int readline_event_hook ()
65 ee.display (std::cerr);
69 : m_event_queue_mutex (new
mutex ()), m_gui_event_queue (),
70 m_debugging (false), m_link_enabled (true),
72 m_qt_event_handlers ()
106 warning (
"event_manager: must have connected link to enable");
143 std::shared_ptr<event_queue> evq (
new event_queue ());
179 evq->add (std::bind (meth, std::ref (m_interpreter)));
212 if (interp.experimental_terminal_widget ())
228 warning (
"GUI desktop is already running");
231 error (
"desktop function requires new experimental terminal widget");
236 DEFMETHOD (__event_manager_enabled__, interp, , ,
247 DEFMETHOD (__event_manager_have_dialogs__, interp, , ,
258 DEFMETHOD (__event_manager_edit_file__, interp, args, ,
268 if (args.length () == 1)
271 = args(0).xstring_value (
"first argument must be filename");
277 else if (args.length () == 2)
280 = args(0).xstring_value (
"first argument must be filename");
290 DEFMETHOD (__event_manager_question_dialog__, interp, args, ,
298 if (args.length () == 6)
300 std::string msg = args(0).
xstring_value (
"invalid arguments");
301 std::string title = args(1).xstring_value (
"invalid arguments");
302 std::string btn1 = args(2).xstring_value (
"invalid arguments");
303 std::string btn2 = args(3).xstring_value (
"invalid arguments");
304 std::string btn3 = args(4).xstring_value (
"invalid arguments");
305 std::string btndef = args(5).xstring_value (
"invalid arguments");
317 DEFMETHOD (__event_manager_file_dialog__, interp, args, ,
323 if (args.length () != 5)
329 std::string title = args(1).string_value ();
330 std::string filename = args(2).string_value ();
331 std::string multi_on = args(3).string_value ();
332 std::string pathname = args(4).string_value ();
339 filter_lst.push_back (std::make_pair (flist(i, 0),
341 ? flist(i, 1) :
"")));
347 std::list<std::string> items_lst
348 = evmgr.
file_dialog (filter_lst, title, filename, pathname, multi_on);
350 nel = items_lst.size ();
355 if (items_lst.front ().empty ())
360 for (
auto& str : items_lst)
365 retval(idx++) = atoi (str.c_str ());
375 auto it = items_lst.begin ();
377 for (
int idx = 0; idx < nel; idx++, it++)
378 items.
xelem (idx) = *it;
380 retval =
ovl (items, *it++, atoi (it->c_str ()));
386 DEFMETHOD (__event_manager_list_dialog__, interp, args, ,
392 if (args.length () != 8)
395 Cell list = args(0).cell_value ();
398 std::list<std::string> list_lst;
400 list_lst.push_back (tlist(i));
402 std::string mode = args(1).string_value ();
404 Matrix size_matrix = args(2).matrix_value ();
405 int width = size_matrix(0);
406 int height = size_matrix(1);
408 Matrix initial_matrix = args(3).matrix_value ();
409 nel = initial_matrix.
numel ();
410 std::list<int> initial_lst;
412 initial_lst.push_back (initial_matrix(i));
414 std::string name = args(4).string_value ();
415 list = args(5).cell_value ();
417 nel = plist.
numel ();
418 std::list<std::string> prompt_lst;
420 prompt_lst.push_back (plist(i));
421 std::string ok_string = args(6).string_value ();
422 std::string cancel_string = args(7).string_value ();
428 std::pair<std::list<int>,
int> result
429 = evmgr.
list_dialog (list_lst, mode, width, height, initial_lst,
430 name, prompt_lst, ok_string, cancel_string);
432 std::list<int> items_lst = result.first;
433 nel = items_lst.size ();
436 for (
const auto& int_el : items_lst)
437 items.
xelem(i++) = int_el;
439 return ovl (items, result.second);
442 DEFMETHOD (__event_manager_input_dialog__, interp, args, ,
448 if (args.length () != 4)
451 Cell prompt = args(0).cell_value ();
454 std::list<std::string> prompt_lst;
456 prompt_lst.push_back (tmp(i));
458 std::string title = args(1).string_value ();
460 Matrix rc = args(2).matrix_value ();
466 nr.push_back (rc(i, 0));
467 nc.push_back (rc(i, 1));
470 Cell defaults = args(3).cell_value ();
473 std::list<std::string> defaults_lst;
475 defaults_lst.push_back (tmp(i));
481 std::list<std::string> items_lst
482 = evmgr.
input_dialog (prompt_lst, title, nr, nc, defaults_lst);
484 nel = items_lst.size ();
487 for (
const auto& str_el : items_lst)
488 items.
xelem(i++) = str_el;
494 DEFMETHOD (__event_manager_named_icon__, interp, args, ,
502 if (args.length () > 0)
504 std::string icon_name = args(0).xstring_value (
"invalid arguments");
515 DEFMETHOD (__event_manager_show_preferences__, interp, , ,
526 DEFMETHOD (__event_manager_apply_preferences__, interp, , ,
537 DEFMETHOD (__event_manager_gui_preference__, interp, args, ,
545 std::string value =
"";
547 if (args.length () >= 1)
548 key = args(0).string_value();
550 error (
"__event_manager_gui_preference__: "
551 "first argument must be the preference key");
553 if (args.length () >= 2)
554 value = args(1).string_value();
566 DEFMETHOD (__event_manager_file_remove__, interp, args, ,
572 std::string old_name, new_name;
574 if (args.length () == 2)
576 old_name = args(0).string_value();
577 new_name = args(1).string_value();
580 error (
"__event_manager_file_remove__: "
581 "old and new name expected as arguments");
590 DEFMETHOD (__event_manager_file_renamed__, interp, args, ,
598 if (args.length () == 1)
599 load_new = args(0).bool_value();
601 error (
"__event_manager_file_renamed__: "
602 "first argument must be boolean for reload new named file");
617 if (args.length () != 1)
620 if (! args(0).is_string ())
621 error (
"openvar: NAME must be a string");
623 std::string name = args(0).string_value ();
628 error (
"openvar: '%s' is not a variable", name.c_str ());
643 DEFMETHOD (__event_manager_show_terminal_window__, interp, , ,
658 DEFMETHOD (__event_manager_show_documentation__, interp, args, ,
666 if (args.length () >= 1)
667 file = args(0).string_value();
674 DEFMETHOD (__event_manager_register_documentation__, interp, args, ,
682 if (args.length () >= 1)
683 file = args(0).string_value();
690 DEFMETHOD (__event_manager_unregister_documentation__, interp, args, ,
698 if (args.length () >= 1)
699 file = args(0).string_value();
706 DEFMETHOD (__event_manager_show_file_browser__, interp, , ,
719 DEFMETHOD (__event_manager_show_command_history__, interp, , ,
732 DEFMETHOD (__event_manager_show_workspace__, interp, , ,
745 DEFMETHOD (__event_manager_show_community_news__, interp, , ,
758 DEFMETHOD (__event_manager_show_release_notes__, interp, , ,
771 DEFMETHOD (__event_manager_gui_status_update__, interp, args, ,
790 if (args.length () < 2)
791 error (
"__event_manager_gui_status_update__: two parameters required");
792 if (! (args(0).is_string ()))
793 error (
"__event_manager_gui_status_update__: FEATURE must be a string");
794 if (! (args(1).is_string ()))
795 error (
"__event_manager_gui_status_update__: STATUS must be a string");
797 feature = args(0).string_value ();
798 status = args(1).string_value ();
805 DEFMETHOD (__event_manager_update_gui_lexer__, interp, , ,
816 DEFMETHOD (__event_manager_copy_image_to_clipboard__, interp, args, ,
824 if (args.length () >= 1)
825 file = args(0).string_value();
832 DEFMETHOD (commandhistory, interp, args, ,
839 if (args.length () != 0)
847 DEFMETHOD (commandwindow, interp, args, ,
854 if (args.length () != 0)
869 if (args.length () != 0)
884 if (args.length () != 0)
892 OCTAVE_END_NAMESPACE(
octave)
octave_value_list Fisguirunning(const octave_value_list &=octave_value_list(), int=0)
octave_idx_type rows() const
octave_idx_type columns() const
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
Array< std::string > cellstr_value() const
static bool is_gui_running()
static void add_event_hook(event_hook_fcn f)
static string_vector list(int=-1, bool=false)
Vector representing the dimensions (size) of an Array.
Provides threadsafe access to octave.
bool show_documentation(const std::string &file)
void connect_link(const std::shared_ptr< interpreter_events > &obj)
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()
event_manager(interpreter &interp)
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)
bool unregister_documentation(const std::string &file)
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 process_events(bool disable=false)
bool copy_image_to_clipboard(const std::string &file)
bool prompt_new_edit_file(const std::string &file)
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)
mutex * m_event_queue_mutex
void start_gui(bool gui_app=false)
bool gui_status_update(const std::string &feature, const std::string &status)
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 post_event(const fcn_callback &fcn)
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)
bool edit_file(const std::string &file)
virtual void display_exception(const execution_exception &ee, bool beep)
tree_evaluator & get_evaluator()
bool is_undefined() const
std::string xstring_value(const char *fmt,...) const
bool at_top_level() const
symbol_info_list get_symbol_info()
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
void warning(const char *fmt,...)
void() error(const char *fmt,...)
std::function< void(interpreter &)> meth_callback
std::function< void()> fcn_callback
event_manager & __get_event_manager__()
bool is_true(const std::string &s)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.