GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
event-manager.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2011-2025 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
49static int readline_event_hook ()
50{
52
53 evmgr.process_events ();
54
55 return 0;
56}
57
58void
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
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
89void
90event_manager::connect_link (const std::shared_ptr<interpreter_events>& obj)
91{
92 if (! obj)
93 disable ();
94
95 m_instance = obj;
96}
97
98bool
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
111void
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
127void
129{
130 if (enabled ())
131 {
133 std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
135
136 evq->discard ();
137 }
138}
139
140void
142{
143 std::shared_ptr<event_queue> evq (new event_queue ());
144 m_gui_event_queue.push (evq);
145}
146
147void
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
163void
165{
166 if (enabled ())
167 {
168 std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
169 evq->add (fcn);
170 }
171}
172
173void
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
183void
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
195void
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
206DEFMETHOD (desktop, interp, , ,
207 doc: /* -*- texinfo -*-
208@deftypefn {} {} desktop ()
209If 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
236DEFMETHOD (__event_manager_enabled__, interp, , ,
237 doc: /* -*- texinfo -*-
238@deftypefn {} {@var{tf} =} __event_manager_enabled__ ()
239Undocumented internal function.
240@end deftypefn */)
241{
242 event_manager& evmgr = interp.get_event_manager ();
243
244 return ovl (evmgr.enabled ());
245}
246
247DEFMETHOD (__event_manager_have_dialogs__, interp, , ,
248 doc: /* -*- texinfo -*-
249@deftypefn {} {@var{tf} =} __event_manager_have_dialogs__ ()
250Undocumented internal function.
251@end deftypefn */)
252{
253 event_manager& evmgr = interp.get_event_manager ();
254
255 return ovl (evmgr.have_dialogs ());
256}
257
258DEFMETHOD (__event_manager_edit_file__, interp, args, ,
259 doc: /* -*- texinfo -*-
260@deftypefn {} {@var{status} =} __event_manager_edit_file__ (@var{file})
261Undocumented 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
290DEFMETHOD (__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})
293Undocumented 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
317DEFMETHOD (__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})
320Undocumented 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
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 {
366 // FIXME: Should we warn or error on invalid or out of
367 // range values in STR? When atoi was used for
368 // conversion instead of std::stoi we did not. Was
369 // that intentional?
370
371 try
372 {
373 retval(idx++) = std::stoi (str);
374 }
375 catch (const std::invalid_argument&) { }
376 catch (const std::out_of_range&) { }
377 }
378 }
379 }
380 }
381 else
382 {
383 // Multiple files.
384 nel -= 2;
385 Cell items (dim_vector (1, nel));
386
387 auto it = items_lst.begin ();
388
389 for (int idx = 0; idx < nel; idx++, it++)
390 items.xelem (idx) = *it;
391
392 auto fpath = *it++;
393
394 int idx = 0;
395
396 // FIXME: Should we warn or error on invalid or out of range
397 // values in *IT? When atoi was used for conversion instead of
398 // std::stoi we did not. Was that intentional?
399
400 try
401 {
402 idx = std::stoi (*it);
403 }
404 catch (const std::invalid_argument&) { }
405 catch (const std::out_of_range&) { }
406
407 retval = ovl (items, fpath, idx);
408 }
409
410 return retval;
411}
412
413DEFMETHOD (__event_manager_list_dialog__, interp, args, ,
414 doc: /* -*- texinfo -*-
415@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})
416Undocumented internal function.
417@end deftypefn */)
418{
419 if (args.length () != 8)
420 return ovl ();
421
422 Cell list = args(0).cell_value ();
423 const Array<std::string> tlist = list.cellstr_value ();
424 octave_idx_type nel = tlist.numel ();
425 std::list<std::string> list_lst;
426 for (octave_idx_type i = 0; i < nel; i++)
427 list_lst.push_back (tlist(i));
428
429 std::string mode = args(1).string_value ();
430
431 Matrix size_matrix = args(2).matrix_value ();
432 int width = size_matrix(0);
433 int height = size_matrix(1);
434
435 Matrix initial_matrix = args(3).matrix_value ();
436 nel = initial_matrix.numel ();
437 std::list<int> initial_lst;
438 for (octave_idx_type i = 0; i < nel; i++)
439 initial_lst.push_back (initial_matrix(i));
440
441 std::string name = args(4).string_value ();
442 list = args(5).cell_value ();
443 const Array<std::string> plist = list.cellstr_value ();
444 nel = plist.numel ();
445 std::list<std::string> prompt_lst;
446 for (octave_idx_type i = 0; i < nel; i++)
447 prompt_lst.push_back (plist(i));
448 std::string ok_string = args(6).string_value ();
449 std::string cancel_string = args(7).string_value ();
450
451 flush_stdout ();
452
453 event_manager& evmgr = interp.get_event_manager ();
454
455 std::pair<std::list<int>, int> result
456 = evmgr.list_dialog (list_lst, mode, width, height, initial_lst,
457 name, prompt_lst, ok_string, cancel_string);
458
459 std::list<int> items_lst = result.first;
460 nel = items_lst.size ();
461 Matrix items (dim_vector (1, nel));
462 octave_idx_type i = 0;
463 for (const auto& int_el : items_lst)
464 items.xelem(i++) = int_el;
465
466 return ovl (items, result.second);
467}
468
469DEFMETHOD (__event_manager_input_dialog__, interp, args, ,
470 doc: /* -*- texinfo -*-
471@deftypefn {} {@var{cstr} =} __event_manager_input_dialog__ (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults})
472Undocumented internal function.
473@end deftypefn */)
474{
475 if (args.length () != 4)
476 return ovl ();
477
478 Cell prompt = args(0).cell_value ();
479 Array<std::string> tmp = prompt.cellstr_value ();
480 octave_idx_type nel = tmp.numel ();
481 std::list<std::string> prompt_lst;
482 for (octave_idx_type i = 0; i < nel; i++)
483 prompt_lst.push_back (tmp(i));
484
485 std::string title = args(1).string_value ();
486
487 Matrix rc = args(2).matrix_value ();
488 nel = rc.rows ();
489 std::list<float> nr;
490 std::list<float> nc;
491 for (octave_idx_type i = 0; i < nel; i++)
492 {
493 nr.push_back (rc(i, 0));
494 nc.push_back (rc(i, 1));
495 }
496
497 Cell defaults = args(3).cell_value ();
498 tmp = defaults.cellstr_value ();
499 nel = tmp.numel ();
500 std::list<std::string> defaults_lst;
501 for (octave_idx_type i = 0; i < nel; i++)
502 defaults_lst.push_back (tmp(i));
503
504 flush_stdout ();
505
506 event_manager& evmgr = interp.get_event_manager ();
507
508 std::list<std::string> items_lst
509 = evmgr.input_dialog (prompt_lst, title, nr, nc, defaults_lst);
510
511 nel = items_lst.size ();
512 Cell items (dim_vector (nel, 1));
513 octave_idx_type i = 0;
514 for (const auto& str_el : items_lst)
515 items.xelem(i++) = str_el;
516
517 return ovl (items);
518}
519
520
521DEFMETHOD (__event_manager_named_icon__, interp, args, ,
522 doc: /* -*- texinfo -*-
523@deftypefn {} {@var{icon} =} __event_manager_dialog_icons__ (@var{icon_name})
524Undocumented internal function.
525@end deftypefn */)
526{
527 uint8NDArray retval;
528
529 if (args.length () > 0)
530 {
531 std::string icon_name = args(0).xstring_value ("invalid arguments");
532
533 event_manager& evmgr = interp.get_event_manager ();
534
535 retval = evmgr.get_named_icon (icon_name);
536 }
537
538 return ovl (retval);
539}
540
541// FIXME: Why does this function return any value at all?
542DEFMETHOD (__event_manager_show_preferences__, interp, , ,
543 doc: /* -*- texinfo -*-
544@deftypefn {} {@var{status} =} __event_manager_show_preferences__ ()
545Undocumented internal function.
546@end deftypefn */)
547{
548 event_manager& evmgr = interp.get_event_manager ();
549
550 return ovl (evmgr.show_preferences ());
551}
552
553DEFMETHOD (__event_manager_apply_preferences__, interp, , ,
554 doc: /* -*- texinfo -*-
555@deftypefn {} {@var{status} =} __event_manager_apply_preferences__ ()
556Undocumented internal function.
557@end deftypefn */)
558{
559 event_manager& evmgr = interp.get_event_manager ();
560
561 return ovl (evmgr.apply_preferences ());
562}
563
564DEFMETHOD (__event_manager_gui_preference__, interp, args, ,
565 doc: /* -*- texinfo -*-
566@deftypefn {} {@var{prefval} =} __event_manager_gui_preference__ (@var{key})
567@deftypefnx {} {@var{prefval} =} __event_manager_gui_preference__ (@var{key}, @var{value})
568Undocumented internal function.
569@end deftypefn */)
570{
571 std::string key;
572 std::string value = "";
573
574 if (args.length () >= 1)
575 key = args(0).string_value();
576 else
577 error ("__event_manager_gui_preference__: "
578 "first argument must be the preference key");
579
580 if (args.length () >= 2)
581 value = args(1).string_value();
582
584 {
585 event_manager& evmgr = interp.get_event_manager ();
586
587 return ovl (evmgr.gui_preference (key, value));
588 }
589 else
590 return ovl (value);
591}
592
593DEFMETHOD (__event_manager_file_remove__, interp, args, ,
594 doc: /* -*- texinfo -*-
595@deftypefn {} {} __event_manager_file_remove__ ()
596Undocumented internal function.
597@end deftypefn */)
598{
599 std::string old_name, new_name;
600
601 if (args.length () == 2)
602 {
603 old_name = args(0).string_value();
604 new_name = args(1).string_value();
605 }
606 else
607 error ("__event_manager_file_remove__: "
608 "old and new name expected as arguments");
609
610 event_manager& evmgr = interp.get_event_manager ();
611
612 evmgr.file_remove (old_name, new_name);
613
614 return ovl ();
615}
616
617DEFMETHOD (__event_manager_file_renamed__, interp, args, ,
618 doc: /* -*- texinfo -*-
619@deftypefn {} {} __event_manager_file_renamed__ ()
620Undocumented internal function.
621@end deftypefn */)
622{
623 bool load_new;
624
625 if (args.length () == 1)
626 load_new = args(0).bool_value();
627 else
628 error ("__event_manager_file_renamed__: "
629 "first argument must be boolean for reload new named file");
630
631 event_manager& evmgr = interp.get_event_manager ();
632
633 evmgr.file_renamed (load_new);
634
635 return ovl ();
636}
637
638DEFMETHOD (openvar, interp, args, ,
639 doc: /* -*- texinfo -*-
640@deftypefn {} {} openvar (@var{name})
641Open the variable @var{name} in the graphical Variable Editor.
642@end deftypefn */)
643{
644 if (args.length () != 1)
645 print_usage ();
646
647 if (! args(0).is_string ())
648 error ("openvar: NAME must be a string");
649
650 std::string name = args(0).string_value ();
651
652 octave_value val = interp.varval (name);
653
654 if (val.is_undefined ())
655 error ("openvar: '%s' is not a variable", name.c_str ());
656
657 event_manager& evmgr = interp.get_event_manager ();
658
659 evmgr.edit_variable (name, val);
660
661 return ovl ();
662}
663
664/*
665%!error openvar ()
666%!error openvar ("a", "b")
667%!error <NAME must be a string> openvar (1:10)
668*/
669
670DEFMETHOD (__event_manager_show_terminal_window__, interp, , ,
671 doc: /* -*- texinfo -*-
672@deftypefn {} {} __event_manager_show_terminal_window__ ()
673Undocumented internal function.
674@end deftypefn */)
675{
676 std::string file;
677
678 event_manager& evmgr = interp.get_event_manager ();
679
680 evmgr.show_terminal_window ();
681
682 return ovl ();
683}
684
685DEFMETHOD (__event_manager_show_documentation__, interp, args, ,
686 doc: /* -*- texinfo -*-
687@deftypefn {} {@var{status} =} __event_manager_show_documentation__ (@var{filename})
688Undocumented internal function.
689@end deftypefn */)
690{
691 std::string file;
692
693 if (args.length () >= 1)
694 file = args(0).string_value();
695
696 event_manager& evmgr = interp.get_event_manager ();
697
698 return ovl (evmgr.show_documentation (file));
699}
700
701DEFMETHOD (__event_manager_register_documentation__, interp, args, ,
702 doc: /* -*- texinfo -*-
703@deftypefn {} {@var{status} =} __event_manager_register_documentation__ (@var{filename})
704Undocumented internal function.
705@end deftypefn */)
706{
707 std::string file;
708
709 if (args.length () >= 1)
710 file = args(0).string_value();
711
712 event_manager& evmgr = interp.get_event_manager ();
713
714 return ovl (evmgr.register_documentation (file));
715}
716
717DEFMETHOD (__event_manager_unregister_documentation__, interp, args, ,
718 doc: /* -*- texinfo -*-
719@deftypefn {} {@var{status} =} __event_manager_unregister_documentation__ (@var{filename})
720Undocumented internal function.
721@end deftypefn */)
722{
723 std::string file;
724
725 if (args.length () >= 1)
726 file = args(0).string_value();
727
728 event_manager& evmgr = interp.get_event_manager ();
729
730 return ovl (evmgr.unregister_documentation (file));
731}
732
733DEFMETHOD (__event_manager_show_file_browser__, interp, , ,
734 doc: /* -*- texinfo -*-
735@deftypefn {} {} __event_manager_show_file_browser__ ()
736Undocumented internal function.
737@end deftypefn */)
738{
739 event_manager& evmgr = interp.get_event_manager ();
740
741 evmgr.show_file_browser ();
742
743 return ovl ();
744}
745
746DEFMETHOD (__event_manager_show_command_history__, interp, , ,
747 doc: /* -*- texinfo -*-
748@deftypefn {} {} __event_manager_show_command_history__ ()
749Undocumented internal function.
750@end deftypefn */)
751{
752 event_manager& evmgr = interp.get_event_manager ();
753
754 evmgr.show_command_history ();
755
756 return ovl ();
757}
758
759DEFMETHOD (__event_manager_show_workspace__, interp, , ,
760 doc: /* -*- texinfo -*-
761@deftypefn {} {} __event_manager_show_workspace__ ()
762Undocumented internal function.
763@end deftypefn */)
764{
765 event_manager& evmgr = interp.get_event_manager ();
766
767 evmgr.show_workspace ();
768
769 return ovl ();
770}
771
772DEFMETHOD (__event_manager_show_community_news__, interp, , ,
773 doc: /* -*- texinfo -*-
774@deftypefn {} {} __event_manager_show_community_news__ ()
775Undocumented internal function.
776@end deftypefn */)
777{
778 event_manager& evmgr = interp.get_event_manager ();
779
780 evmgr.show_community_news ();
781
782 return ovl ();
783}
784
785DEFMETHOD (__event_manager_show_release_notes__, interp, , ,
786 doc: /* -*- texinfo -*-
787@deftypefn {} {} __event_manager_show_release_notes__ ()
788Undocumented internal function.
789@end deftypefn */)
790{
791 event_manager& evmgr = interp.get_event_manager ();
792
793 evmgr.show_release_notes ();
794
795 return ovl ();
796}
797
798DEFMETHOD (__event_manager_gui_status_update__, interp, args, ,
799 doc: /* -*- texinfo -*-
800@deftypefn {} {@var{status} =} __event_manager_gui_status_update__ (@var{feature}, @var{status})
801Internal function for updating the status of some features in the GUI.
802@end deftypefn */)
803{
804 // This is currently a stub and should only be activated some
805 // interpreter action only implemented in m-files requires to update
806 // a status indicator in the gui. BUT: This internal function can
807 // be activated by the user leading to gui indicators not reflecting
808 // the real state of the related feature.
809 return ovl ();
810
811 std::string feature;
812 std::string status;
813
814 if (! (Fisguirunning ())(0).is_true ())
815 return ovl ();
816
817 if (args.length () < 2)
818 error ("__event_manager_gui_status_update__: two parameters required");
819 if (! (args(0).is_string ()))
820 error ("__event_manager_gui_status_update__: FEATURE must be a string");
821 if (! (args(1).is_string ()))
822 error ("__event_manager_gui_status_update__: STATUS must be a string");
823
824 feature = args(0).string_value ();
825 status = args(1).string_value ();
826
827 event_manager& evmgr = interp.get_event_manager ();
828
829 return ovl (evmgr.gui_status_update (feature, status));
830}
831
832DEFMETHOD (__event_manager_update_gui_lexer__, interp, , ,
833 doc: /* -*- texinfo -*-
834@deftypefn {} {@var{status} =} __event_manager_update_gui_lexer__ ()
835Undocumented internal function.
836@end deftypefn */)
837{
838 event_manager& evmgr = interp.get_event_manager ();
839
840 return ovl (evmgr.update_gui_lexer ());
841}
842
843DEFMETHOD (__event_manager_copy_image_to_clipboard__, interp, args, ,
844 doc: /* -*- texinfo -*-
845@deftypefn {} {} __event_manager_copy_image_to_clipboard__ (@var{filename})
846Undocumented internal function.
847@end deftypefn */)
848{
849 std::string file;
850
851 if (args.length () >= 1)
852 file = args(0).string_value();
853
854 event_manager& evmgr = interp.get_event_manager ();
855 evmgr.copy_image_to_clipboard (file);
856 return ovl ();
857}
858
859DEFMETHOD (commandhistory, interp, args, ,
860 doc: /* -*- texinfo -*-
861@deftypefn {} {} commandhistory ()
862Show the GUI command history window and give it the keyboard focus.
863@seealso{commandwindow, filebrowser, workspace}
864@end deftypefn */)
865{
866 if (args.length () != 0)
867 print_usage ();
868
869 event_manager& evmgr = interp.get_event_manager ();
870 evmgr.focus_window ("history");
871 return ovl ();
872}
873
874DEFMETHOD (commandwindow, interp, args, ,
875 doc: /* -*- texinfo -*-
876@deftypefn {} {} commandwindow ()
877Show the GUI command window and give it the keyboard focus.
878@seealso{commandhistory, filebrowser, workspace}
879@end deftypefn */)
880{
881 if (args.length () != 0)
882 print_usage ();
883
884 event_manager& evmgr = interp.get_event_manager ();
885 evmgr.focus_window ("command");
886 return ovl ();
887}
888
889DEFMETHOD (filebrowser, interp, args, ,
890 doc: /* -*- texinfo -*-
891@deftypefn {} {} filebrowser ()
892Show the GUI file browser window and give it the keyboard focus.
893@seealso{commandwindow, commandhistory, workspace}
894@end deftypefn */)
895{
896 if (args.length () != 0)
897 print_usage ();
898
899 event_manager& evmgr = interp.get_event_manager ();
900 evmgr.focus_window ("filebrowser");
901 return ovl ();
902}
903
904DEFMETHOD (workspace, interp, args, ,
905 doc: /* -*- texinfo -*-
906@deftypefn {} {} workspace ()
907Show the GUI workspace window and give it the keyboard focus.
908@seealso{commandwindow, commandhistory, filebrowser}
909@end deftypefn */)
910{
911 if (args.length () != 0)
912 print_usage ();
913
914 event_manager& evmgr = interp.get_event_manager ();
915 evmgr.focus_window ("workspace");
916 return ovl ();
917}
918
919OCTAVE_END_NAMESPACE(octave)
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
T & xelem(octave_idx_type n)
Size of the specified dimension.
Definition Array.h:525
octave_idx_type rows() const
Definition Array.h:463
octave_idx_type columns() const
Definition Array.h:475
octave_idx_type numel() const
Number of elements in the array.
Definition Array.h:418
Definition Cell.h:41
Array< std::string > cellstr_value() const
Definition Cell.cc:145
static bool is_gui_running()
Definition octave.h:333
static void add_event_hook(event_hook_fcn f)
Definition cmd-edit.cc:1556
static string_vector list(int=-1, bool=false)
Definition cmd-hist.cc:748
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
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()
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)
virtual ~event_manager()
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 copy_image_to_clipboard(const std::string &file)
bool prompt_new_edit_file(const std::string &file)
mutex * m_event_queue_mutex
void start_gui(bool gui_app=false)
bool gui_status_update(const std::string &feature, const std::string &status)
void post_event(const fcn_callback &fcn)
std::string gui_preference(const std::string &key, const std::string &value)
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)
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()
bool edit_file(const std::string &file)
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 push_event_queue()
void show_workspace()
virtual void display_exception(const execution_exception &ee, bool beep)
tree_evaluator & get_evaluator()
void unlock()
Definition oct-mutex.h:65
void lock()
Definition oct-mutex.h:60
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:544
symbol_info_list get_symbol_info()
Definition pt-eval.cc:4705
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void print_usage()
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:1078
void error(const char *fmt,...)
Definition error.cc:1003
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 Fisguirunning(const octave_value_list &args, int)
Definition octave.cc:453
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition ovl.h:217
void flush_stdout()
Definition pager.cc:268