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