GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
event-manager.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <iostream>
31 
32 #include "builtin-defun-decls.h"
33 #include "cmd-edit.h"
34 #include "cmd-hist.h"
35 #include "defun.h"
36 #include "event-manager.h"
37 #include "interpreter.h"
38 #include "interpreter-private.h"
39 #include "oct-env.h"
40 #include "oct-mutex.h"
41 #include "ovl.h"
42 #include "pager.h"
43 #include "syminfo.h"
44 
45 #include "quit.h"
46 
48 
49 static int readline_event_hook ()
50 {
52 
53  evmgr.process_events ();
54 
55  return 0;
56 }
57 
58 void
60  bool beep)
61 {
62  if (beep)
63  std::cerr << "\a";
64 
65  ee.display (std::cerr);
66 }
67 
69  : m_event_queue_mutex (new mutex ()), m_gui_event_queue (),
70  m_debugging (false), m_link_enabled (true),
71  m_interpreter (interp), m_instance (new interpreter_events ()),
72  m_qt_event_handlers ()
73 {
75  command_editor::add_event_hook (readline_event_hook);
76 }
77 
79 {
80  delete m_event_queue_mutex;
81 }
82 
83 // Programming Note: It is possible to disable the link without deleting
84 // the connection. This allows it to be temporarily disabled. But if
85 // the link is removed, we also set the link_enabled flag to false
86 // because if there is no link, it can't be enabled. Also, access to
87 // instance is only protected by a check on the link_enabled flag.
88 
89 void
90 event_manager::connect_link (const std::shared_ptr<interpreter_events>& obj)
91 {
92  if (! obj)
93  disable ();
94 
95  m_instance = obj;
96 }
97 
98 bool
100 {
101  bool retval = m_link_enabled;
102 
103  if (m_instance)
104  m_link_enabled = true;
105  else
106  warning ("event_manager: must have connected link to enable");
107 
108  return retval;
109 }
110 
111 void
112 event_manager::process_events (bool disable_flag)
113 {
114  if (enabled ())
115  {
116  if (disable_flag)
117  disable ();
118 
120  std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
122 
123  evq->run ();
124  }
125 }
126 
127 void
129 {
130  if (enabled ())
131  {
133  std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
135 
136  evq->discard ();
137  }
138 }
139 
140 void
142 {
143  std::shared_ptr<event_queue> evq (new event_queue ());
144  m_gui_event_queue.push (evq);
145 }
146 
147 void
149 {
150  // FIXME: Should we worry about the possibility of events remaining
151  // in the queue when we pop back to the previous queue? If so, then
152  // we will probably want to push them on to the front of the
153  // previous queue so they will be executed before any other events
154  // that were in the previous queue. This case could happen if
155  // graphics callback functions were added to the event queue during a
156  // debug session just after a dbcont command was added but before it
157  // executed and brought us here, for example.
158 
159  std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
160  m_gui_event_queue.pop ();
161 }
162 
163 void
165 {
166  if (enabled ())
167  {
168  std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
169  evq->add (fcn);
170  }
171 }
172 
173 void
175 {
176  if (enabled ())
177  {
178  std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
179  evq->add (std::bind (meth, std::ref (m_interpreter)));
180  }
181 }
182 
183 void
185 {
186  if (enabled ())
187  {
188  tree_evaluator& tw = m_interpreter.get_evaluator ();
189 
190  m_instance->set_workspace (tw.at_top_level (), m_debugging,
191  tw.get_symbol_info (), true);
192  }
193 }
194 
195 void
197 {
198  if (enabled ())
199  m_instance->set_history (command_history::list ());
200 }
201 
202 // FIXME: Should the following function be __event_manager_desktop__
203 // with the desktop function implemented in a .m file, similar to the
204 // way the UI* functions work?
205 
206 DEFMETHOD (desktop, interp, , ,
207  doc: /* -*- texinfo -*-
208 @deftypefn {} {} desktop ()
209 If running in command-line mode, start the GUI desktop.
210 @end deftypefn */)
211 {
212  if (interp.experimental_terminal_widget ())
213  {
215  {
216  // FIXME: Currently, the following action is queued and
217  // executed in a Qt event loop and we return immediately to
218  // the command prompt where additional commands may be
219  // executed. Is that what should happen? Or should we be
220  // waiting until the GUI exits to return to the command
221  // prompt, similar to the way the UI* functions work?
222 
223  event_manager& evmgr = interp.get_event_manager ();
224 
225  evmgr.start_gui ();
226  }
227  else
228  warning ("GUI desktop is already running");
229  }
230  else
231  error ("desktop function requires new experimental terminal widget");
232 
233  return ovl ();
234 }
235 
236 DEFMETHOD (__event_manager_enabled__, interp, , ,
237  doc: /* -*- texinfo -*-
238 @deftypefn {} {@var{tf} =} __event_manager_enabled__ ()
239 Undocumented internal function.
240 @end deftypefn */)
241 {
242  event_manager& evmgr = interp.get_event_manager ();
243 
244  return ovl (evmgr.enabled ());
245 }
246 
247 DEFMETHOD (__event_manager_have_dialogs__, interp, , ,
248  doc: /* -*- texinfo -*-
249 @deftypefn {} {@var{tf} =} __event_manager_have_dialogs__ ()
250 Undocumented internal function.
251 @end deftypefn */)
252 {
253  event_manager& evmgr = interp.get_event_manager ();
254 
255  return ovl (evmgr.have_dialogs ());
256 }
257 
258 DEFMETHOD (__event_manager_edit_file__, interp, args, ,
259  doc: /* -*- texinfo -*-
260 @deftypefn {} {@var{status} =} __event_manager_edit_file__ (@var{file})
261 Undocumented internal function.
262 @end deftypefn */)
263 {
264  octave_value retval;
265 
266  event_manager& evmgr = interp.get_event_manager ();
267 
268  if (args.length () == 1)
269  {
270  std::string file
271  = args(0).xstring_value ("first argument must be filename");
272 
273  flush_stdout ();
274 
275  retval = evmgr.edit_file (file);
276  }
277  else if (args.length () == 2)
278  {
279  std::string file
280  = args(0).xstring_value ("first argument must be filename");
281 
282  flush_stdout ();
283 
284  retval = evmgr.prompt_new_edit_file (file);
285  }
286 
287  return retval;
288 }
289 
290 DEFMETHOD (__event_manager_question_dialog__, interp, args, ,
291  doc: /* -*- texinfo -*-
292 @deftypefn {} {@var{btn_val} =} __event_manager_question_dialog__ (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{btn3}, @var{default})
293 Undocumented internal function.
294 @end deftypefn */)
295 {
296  octave_value retval;
297 
298  if (args.length () == 6)
299  {
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");
306 
307  flush_stdout ();
308 
309  event_manager& evmgr = interp.get_event_manager ();
310 
311  retval = evmgr.question_dialog (msg, title, btn1, btn2, btn3, btndef);
312  }
313 
314  return retval;
315 }
316 
317 DEFMETHOD (__event_manager_file_dialog__, interp, args, ,
318  doc: /* -*- texinfo -*-
319 @deftypefn {} {[@var{fname}, @var{fpath}, @var{fltidx}] =} __event_manager_file_dialog__ (@var{filterlist}, @var{title}, @var{filename}, @var{multiselect}, @var{pathname})
320 Undocumented internal function.
321 @end deftypefn */)
322 {
323  if (args.length () != 5)
324  return ovl ();
325 
326  octave_value_list retval (3);
327 
328  const Array<std::string> flist = args(0).cellstr_value ();
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 (); // on, off, create
332  std::string pathname = args(4).string_value ();
333 
334  octave_idx_type nel;
335 
336  event_manager::filter_list filter_lst;
337 
338  for (octave_idx_type i = 0; i < flist.rows (); i++)
339  filter_lst.push_back (std::make_pair (flist(i, 0),
340  (flist.columns () > 1
341  ? flist(i, 1) : "")));
342 
343  flush_stdout ();
344 
345  event_manager& evmgr = interp.get_event_manager ();
346 
347  std::list<std::string> items_lst
348  = evmgr.file_dialog (filter_lst, title, filename, pathname, multi_on);
349 
350  nel = items_lst.size ();
351 
352  // If 3, then retval is filename, directory, and selected index.
353  if (nel <= 3)
354  {
355  if (items_lst.front ().empty ())
356  retval = ovl (octave_value (0.), octave_value (0.), octave_value (0.));
357  else
358  {
359  int idx = 0;
360  for (auto& str : items_lst)
361  {
362  if (idx != 2)
363  retval(idx++) = str;
364  else
365  retval(idx++) = atoi (str.c_str ());
366  }
367  }
368  }
369  else
370  {
371  // Multiple files.
372  nel -= 2;
373  Cell items (dim_vector (1, nel));
374 
375  auto it = items_lst.begin ();
376 
377  for (int idx = 0; idx < nel; idx++, it++)
378  items.xelem (idx) = *it;
379 
380  retval = ovl (items, *it++, atoi (it->c_str ()));
381  }
382 
383  return retval;
384 }
385 
386 DEFMETHOD (__event_manager_list_dialog__, interp, args, ,
387  doc: /* -*- texinfo -*-
388 @deftypefn {} {[@var{sel}, @var{ok}] =} __event_manager_list_dialog__ (@var{list}, @var{mode}, @var{size}, @var{initial}, @var{name}, @var{prompt}, @var{ok_string}, @var{cancel_string})
389 Undocumented internal function.
390 @end deftypefn */)
391 {
392  if (args.length () != 8)
393  return ovl ();
394 
395  Cell list = args(0).cell_value ();
396  const Array<std::string> tlist = list.cellstr_value ();
397  octave_idx_type nel = tlist.numel ();
398  std::list<std::string> list_lst;
399  for (octave_idx_type i = 0; i < nel; i++)
400  list_lst.push_back (tlist(i));
401 
402  std::string mode = args(1).string_value ();
403 
404  Matrix size_matrix = args(2).matrix_value ();
405  int width = size_matrix(0);
406  int height = size_matrix(1);
407 
408  Matrix initial_matrix = args(3).matrix_value ();
409  nel = initial_matrix.numel ();
410  std::list<int> initial_lst;
411  for (octave_idx_type i = 0; i < nel; i++)
412  initial_lst.push_back (initial_matrix(i));
413 
414  std::string name = args(4).string_value ();
415  list = args(5).cell_value ();
416  const Array<std::string> plist = list.cellstr_value ();
417  nel = plist.numel ();
418  std::list<std::string> prompt_lst;
419  for (octave_idx_type i = 0; i < nel; i++)
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 ();
423 
424  flush_stdout ();
425 
426  event_manager& evmgr = interp.get_event_manager ();
427 
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);
431 
432  std::list<int> items_lst = result.first;
433  nel = items_lst.size ();
434  Matrix items (dim_vector (1, nel));
435  octave_idx_type i = 0;
436  for (const auto& int_el : items_lst)
437  items.xelem(i++) = int_el;
438 
439  return ovl (items, result.second);
440 }
441 
442 DEFMETHOD (__event_manager_input_dialog__, interp, args, ,
443  doc: /* -*- texinfo -*-
444 @deftypefn {} {@var{cstr} =} __event_manager_input_dialog__ (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults})
445 Undocumented internal function.
446 @end deftypefn */)
447 {
448  if (args.length () != 4)
449  return ovl ();
450 
451  Cell prompt = args(0).cell_value ();
452  Array<std::string> tmp = prompt.cellstr_value ();
453  octave_idx_type nel = tmp.numel ();
454  std::list<std::string> prompt_lst;
455  for (octave_idx_type i = 0; i < nel; i++)
456  prompt_lst.push_back (tmp(i));
457 
458  std::string title = args(1).string_value ();
459 
460  Matrix rc = args(2).matrix_value ();
461  nel = rc.rows ();
462  std::list<float> nr;
463  std::list<float> nc;
464  for (octave_idx_type i = 0; i < nel; i++)
465  {
466  nr.push_back (rc(i, 0));
467  nc.push_back (rc(i, 1));
468  }
469 
470  Cell defaults = args(3).cell_value ();
471  tmp = defaults.cellstr_value ();
472  nel = tmp.numel ();
473  std::list<std::string> defaults_lst;
474  for (octave_idx_type i = 0; i < nel; i++)
475  defaults_lst.push_back (tmp(i));
476 
477  flush_stdout ();
478 
479  event_manager& evmgr = interp.get_event_manager ();
480 
481  std::list<std::string> items_lst
482  = evmgr.input_dialog (prompt_lst, title, nr, nc, defaults_lst);
483 
484  nel = items_lst.size ();
485  Cell items (dim_vector (nel, 1));
486  octave_idx_type i = 0;
487  for (const auto& str_el : items_lst)
488  items.xelem(i++) = str_el;
489 
490  return ovl (items);
491 }
492 
493 
494 DEFMETHOD (__event_manager_named_icon__, interp, args, ,
495  doc: /* -*- texinfo -*-
496 @deftypefn {} {@var{icon} =} __event_manager_dialog_icons__ (@var{icon_name})
497 Undocumented internal function.
498 @end deftypefn */)
499 {
500  uint8NDArray retval;
501 
502  if (args.length () > 0)
503  {
504  std::string icon_name = args(0).xstring_value ("invalid arguments");
505 
506  event_manager& evmgr = interp.get_event_manager ();
507 
508  retval = evmgr.get_named_icon (icon_name);
509  }
510 
511  return ovl (retval);
512 }
513 
514 // FIXME: Why does this function return any value at all?
515 DEFMETHOD (__event_manager_show_preferences__, interp, , ,
516  doc: /* -*- texinfo -*-
517 @deftypefn {} {@var{status} =} __event_manager_show_preferences__ ()
518 Undocumented internal function.
519 @end deftypefn */)
520 {
521  event_manager& evmgr = interp.get_event_manager ();
522 
523  return ovl (evmgr.show_preferences ());
524 }
525 
526 DEFMETHOD (__event_manager_apply_preferences__, interp, , ,
527  doc: /* -*- texinfo -*-
528 @deftypefn {} {@var{status} =} __event_manager_apply_preferences__ ()
529 Undocumented internal function.
530 @end deftypefn */)
531 {
532  event_manager& evmgr = interp.get_event_manager ();
533 
534  return ovl (evmgr.apply_preferences ());
535 }
536 
537 DEFMETHOD (__event_manager_gui_preference__, interp, args, ,
538  doc: /* -*- texinfo -*-
539 @deftypefn {} {@var{prefval} =} __event_manager_gui_preference__ (@var{key})
540 @deftypefnx {} {@var{prefval} =} __event_manager_gui_preference__ (@var{key}, @var{value})
541 Undocumented internal function.
542 @end deftypefn */)
543 {
544  std::string key;
545  std::string value = "";
546 
547  if (args.length () >= 1)
548  key = args(0).string_value();
549  else
550  error ("__event_manager_gui_preference__: "
551  "first argument must be the preference key");
552 
553  if (args.length () >= 2)
554  value = args(1).string_value();
555 
557  {
558  event_manager& evmgr = interp.get_event_manager ();
559 
560  return ovl (evmgr.gui_preference (key, value));
561  }
562  else
563  return ovl (value);
564 }
565 
566 DEFMETHOD (__event_manager_file_remove__, interp, args, ,
567  doc: /* -*- texinfo -*-
568 @deftypefn {} {} __event_manager_file_remove__ ()
569 Undocumented internal function.
570 @end deftypefn */)
571 {
572  std::string old_name, new_name;
573 
574  if (args.length () == 2)
575  {
576  old_name = args(0).string_value();
577  new_name = args(1).string_value();
578  }
579  else
580  error ("__event_manager_file_remove__: "
581  "old and new name expected as arguments");
582 
583  event_manager& evmgr = interp.get_event_manager ();
584 
585  evmgr.file_remove (old_name, new_name);
586 
587  return ovl ();
588 }
589 
590 DEFMETHOD (__event_manager_file_renamed__, interp, args, ,
591  doc: /* -*- texinfo -*-
592 @deftypefn {} {} __event_manager_file_renamed__ ()
593 Undocumented internal function.
594 @end deftypefn */)
595 {
596  bool load_new;
597 
598  if (args.length () == 1)
599  load_new = args(0).bool_value();
600  else
601  error ("__event_manager_file_renamed__: "
602  "first argument must be boolean for reload new named file");
603 
604  event_manager& evmgr = interp.get_event_manager ();
605 
606  evmgr.file_renamed (load_new);
607 
608  return ovl ();
609 }
610 
611 DEFMETHOD (openvar, interp, args, ,
612  doc: /* -*- texinfo -*-
613 @deftypefn {} {} openvar (@var{name})
614 Open the variable @var{name} in the graphical Variable Editor.
615 @end deftypefn */)
616 {
617  if (args.length () != 1)
618  print_usage ();
619 
620  if (! args(0).is_string ())
621  error ("openvar: NAME must be a string");
622 
623  std::string name = args(0).string_value ();
624 
625  octave_value val = interp.varval (name);
626 
627  if (val.is_undefined ())
628  error ("openvar: '%s' is not a variable", name.c_str ());
629 
630  event_manager& evmgr = interp.get_event_manager ();
631 
632  evmgr.edit_variable (name, val);
633 
634  return ovl ();
635 }
636 
637 /*
638 %!error openvar ()
639 %!error openvar ("a", "b")
640 %!error <NAME must be a string> openvar (1:10)
641 */
642 
643 DEFMETHOD (__event_manager_show_terminal_window__, interp, , ,
644  doc: /* -*- texinfo -*-
645 @deftypefn {} {} __event_manager_show_terminal_window__ ()
646 Undocumented internal function.
647 @end deftypefn */)
648 {
649  std::string file;
650 
651  event_manager& evmgr = interp.get_event_manager ();
652 
653  evmgr.show_terminal_window ();
654 
655  return ovl ();
656 }
657 
658 DEFMETHOD (__event_manager_show_documentation__, interp, args, ,
659  doc: /* -*- texinfo -*-
660 @deftypefn {} {@var{status} =} __event_manager_show_documentation__ (@var{filename})
661 Undocumented internal function.
662 @end deftypefn */)
663 {
664  std::string file;
665 
666  if (args.length () >= 1)
667  file = args(0).string_value();
668 
669  event_manager& evmgr = interp.get_event_manager ();
670 
671  return ovl (evmgr.show_documentation (file));
672 }
673 
674 DEFMETHOD (__event_manager_register_documentation__, interp, args, ,
675  doc: /* -*- texinfo -*-
676 @deftypefn {} {@var{status} =} __event_manager_register_documentation__ (@var{filename})
677 Undocumented internal function.
678 @end deftypefn */)
679 {
680  std::string file;
681 
682  if (args.length () >= 1)
683  file = args(0).string_value();
684 
685  event_manager& evmgr = interp.get_event_manager ();
686 
687  return ovl (evmgr.register_documentation (file));
688 }
689 
690 DEFMETHOD (__event_manager_unregister_documentation__, interp, args, ,
691  doc: /* -*- texinfo -*-
692 @deftypefn {} {@var{status} =} __event_manager_unregister_documentation__ (@var{filename})
693 Undocumented internal function.
694 @end deftypefn */)
695 {
696  std::string file;
697 
698  if (args.length () >= 1)
699  file = args(0).string_value();
700 
701  event_manager& evmgr = interp.get_event_manager ();
702 
703  return ovl (evmgr.unregister_documentation (file));
704 }
705 
706 DEFMETHOD (__event_manager_show_file_browser__, interp, , ,
707  doc: /* -*- texinfo -*-
708 @deftypefn {} {} __event_manager_show_file_browser__ ()
709 Undocumented internal function.
710 @end deftypefn */)
711 {
712  event_manager& evmgr = interp.get_event_manager ();
713 
714  evmgr.show_file_browser ();
715 
716  return ovl ();
717 }
718 
719 DEFMETHOD (__event_manager_show_command_history__, interp, , ,
720  doc: /* -*- texinfo -*-
721 @deftypefn {} {} __event_manager_show_command_history__ ()
722 Undocumented internal function.
723 @end deftypefn */)
724 {
725  event_manager& evmgr = interp.get_event_manager ();
726 
727  evmgr.show_command_history ();
728 
729  return ovl ();
730 }
731 
732 DEFMETHOD (__event_manager_show_workspace__, interp, , ,
733  doc: /* -*- texinfo -*-
734 @deftypefn {} {} __event_manager_show_workspace__ ()
735 Undocumented internal function.
736 @end deftypefn */)
737 {
738  event_manager& evmgr = interp.get_event_manager ();
739 
740  evmgr.show_workspace ();
741 
742  return ovl ();
743 }
744 
745 DEFMETHOD (__event_manager_show_community_news__, interp, , ,
746  doc: /* -*- texinfo -*-
747 @deftypefn {} {} __event_manager_show_community_news__ ()
748 Undocumented internal function.
749 @end deftypefn */)
750 {
751  event_manager& evmgr = interp.get_event_manager ();
752 
753  evmgr.show_community_news ();
754 
755  return ovl ();
756 }
757 
758 DEFMETHOD (__event_manager_show_release_notes__, interp, , ,
759  doc: /* -*- texinfo -*-
760 @deftypefn {} {} __event_manager_show_release_notes__ ()
761 Undocumented internal function.
762 @end deftypefn */)
763 {
764  event_manager& evmgr = interp.get_event_manager ();
765 
766  evmgr.show_release_notes ();
767 
768  return ovl ();
769 }
770 
771 DEFMETHOD (__event_manager_gui_status_update__, interp, args, ,
772  doc: /* -*- texinfo -*-
773 @deftypefn {} {@var{status} =} __event_manager_gui_status_update__ (@var{feature}, @var{status})
774 Internal function for updating the status of some features in the GUI.
775 @end deftypefn */)
776 {
777  // This is currently a stub and should only be activated some
778  // interpreter action only implemented in m-files requires to update
779  // a status indicator in the gui. BUT: This internal function can
780  // be activated by the user leading to gui indicators not reflecting
781  // the real state of the related feature.
782  return ovl ();
783 
784  std::string feature;
785  std::string status;
786 
787  if (! (Fisguirunning ())(0).is_true ())
788  return ovl ();
789 
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");
796 
797  feature = args(0).string_value ();
798  status = args(1).string_value ();
799 
800  event_manager& evmgr = interp.get_event_manager ();
801 
802  return ovl (evmgr.gui_status_update (feature, status));
803 }
804 
805 DEFMETHOD (__event_manager_update_gui_lexer__, interp, , ,
806  doc: /* -*- texinfo -*-
807 @deftypefn {} {@var{status} =} __event_manager_update_gui_lexer__ ()
808 Undocumented internal function.
809 @end deftypefn */)
810 {
811  event_manager& evmgr = interp.get_event_manager ();
812 
813  return ovl (evmgr.update_gui_lexer ());
814 }
815 
816 DEFMETHOD (__event_manager_copy_image_to_clipboard__, interp, args, ,
817  doc: /* -*- texinfo -*-
818 @deftypefn {} {} __event_manager_copy_image_to_clipboard__ (@var{filename})
819 Undocumented internal function.
820 @end deftypefn */)
821 {
822  std::string file;
823 
824  if (args.length () >= 1)
825  file = args(0).string_value();
826 
827  event_manager& evmgr = interp.get_event_manager ();
828  evmgr.copy_image_to_clipboard (file);
829  return ovl ();
830 }
831 
832 DEFMETHOD (commandhistory, interp, args, ,
833  doc: /* -*- texinfo -*-
834 @deftypefn {} {} commandhistory ()
835 Show the GUI command history window and give it the keyboard focus.
836 @seealso{commandwindow, filebrowser, workspace}
837 @end deftypefn */)
838 {
839  if (args.length () != 0)
840  print_usage ();
841 
842  event_manager& evmgr = interp.get_event_manager ();
843  evmgr.focus_window ("history");
844  return ovl ();
845 }
846 
847 DEFMETHOD (commandwindow, interp, args, ,
848  doc: /* -*- texinfo -*-
849 @deftypefn {} {} commandwindow ()
850 Show the GUI command window and give it the keyboard focus.
851 @seealso{commandhistory, filebrowser, workspace}
852 @end deftypefn */)
853 {
854  if (args.length () != 0)
855  print_usage ();
856 
857  event_manager& evmgr = interp.get_event_manager ();
858  evmgr.focus_window ("command");
859  return ovl ();
860 }
861 
862 DEFMETHOD (filebrowser, interp, args, ,
863  doc: /* -*- texinfo -*-
864 @deftypefn {} {} filebrowser ()
865 Show the GUI file browser window and give it the keyboard focus.
866 @seealso{commandwindow, commandhistory, workspace}
867 @end deftypefn */)
868 {
869  if (args.length () != 0)
870  print_usage ();
871 
872  event_manager& evmgr = interp.get_event_manager ();
873  evmgr.focus_window ("filebrowser");
874  return ovl ();
875 }
876 
877 DEFMETHOD (workspace, interp, args, ,
878  doc: /* -*- texinfo -*-
879 @deftypefn {} {} workspace ()
880 Show the GUI workspace window and give it the keyboard focus.
881 @seealso{commandwindow, commandhistory, filebrowser}
882 @end deftypefn */)
883 {
884  if (args.length () != 0)
885  print_usage ();
886 
887  event_manager& evmgr = interp.get_event_manager ();
888  evmgr.focus_window ("workspace");
889  return ovl ();
890 }
891 
892 OCTAVE_END_NAMESPACE(octave)
octave_value_list Fisguirunning(const octave_value_list &=octave_value_list(), int=0)
octave_idx_type rows() const
Definition: Array.h:459
octave_idx_type columns() const
Definition: Array.h:471
T & xelem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:524
octave_idx_type numel() const
Number of elements in the array.
Definition: Array.h:414
Definition: Cell.h:43
Array< std::string > cellstr_value() const
Definition: Cell.cc:145
Definition: dMatrix.h:42
static bool is_gui_running()
Definition: octave.h:318
static void add_event_hook(event_hook_fcn f)
Definition: cmd-edit.cc:1558
static string_vector list(int=-1, bool=false)
Definition: cmd-hist.cc:749
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
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 show_preferences()
bool apply_preferences()
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)
bool update_gui_lexer()
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)
void discard_events()
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)
virtual ~event_manager()
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 enabled() const
void show_file_browser()
void pop_event_queue()
bool edit_file(const std::string &file)
void push_event_queue()
void show_workspace()
void set_workspace()
virtual void display_exception(const execution_exception &ee, bool beep)
tree_evaluator & get_evaluator()
void unlock()
Definition: oct-mutex.h:69
void lock()
Definition: oct-mutex.h:64
bool is_undefined() const
Definition: ov.h:595
std::string xstring_value(const char *fmt,...) const
bool at_top_level() const
Definition: pt-eval.cc:538
symbol_info_list get_symbol_info()
Definition: pt-eval.cc:4618
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void print_usage(void)
Definition: defun-int.h:72
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:111
void warning(const char *fmt,...)
Definition: error.cc:1063
void() error(const char *fmt,...)
Definition: error.cc:988
std::function< void(interpreter &)> meth_callback
Definition: event-manager.h:48
std::function< void()> fcn_callback
Definition: event-manager.h:43
event_manager & __get_event_manager__()
bool is_true(const std::string &s)
Definition: mkoctfile.cc:604
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:219
void flush_stdout()