GNU Octave 7.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-2022 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
47OCTAVE_NAMESPACE_BEGIN
48
49 static int readline_event_hook (void)
50 {
51 event_manager& evmgr = __get_event_manager__ ("octave_readline_hook");
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 {
74 command_editor::add_event_hook (readline_event_hook);
75 }
76
78 {
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
116 m_event_queue_mutex->lock ();
117 std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
118 m_event_queue_mutex->unlock ();
119
120 evq->run ();
121 }
122 }
123
125 {
126 if (enabled ())
127 {
128 m_event_queue_mutex->lock ();
129 std::shared_ptr<event_queue> evq = m_gui_event_queue.top ();
130 m_event_queue_mutex->unlock ();
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
196DEFMETHOD (desktop, interp, , ,
197 doc: /* -*- texinfo -*-
198@deftypefn {} {} desktop ()
199If 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
226DEFMETHOD (__event_manager_enabled__, interp, , ,
227 doc: /* -*- texinfo -*-
228@deftypefn {} {} __event_manager_enabled__ ()
229Undocumented internal function.
230@end deftypefn */)
231{
232 event_manager& evmgr = interp.get_event_manager ();
233
234 return ovl (evmgr.enabled ());
235}
236
237DEFMETHOD (__event_manager_have_dialogs__, interp, , ,
238 doc: /* -*- texinfo -*-
239@deftypefn {} {} __event_manager_have_dialogs__ ()
240Undocumented internal function.
241@end deftypefn */)
242{
243 event_manager& evmgr = interp.get_event_manager ();
244
245 return ovl (evmgr.have_dialogs ());
246}
247
248DEFMETHOD (__event_manager_edit_file__, interp, args, ,
249 doc: /* -*- texinfo -*-
250@deftypefn {} {} __event_manager_edit_file__ (@var{file})
251Undocumented 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
280DEFMETHOD (__event_manager_question_dialog__, interp, args, ,
281 doc: /* -*- texinfo -*-
282@deftypefn {} {} __event_manager_question_dialog__ (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{btn3}, @var{default})
283Undocumented 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
307DEFMETHOD (__event_manager_file_dialog__, interp, args, ,
308 doc: /* -*- texinfo -*-
309@deftypefn {} {} __event_manager_file_dialog__ (@var{filterlist}, @var{title}, @var{filename}, @var{multiselect}, @var{pathname})
310Undocumented 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
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
376DEFMETHOD (__event_manager_list_dialog__, interp, args, ,
377 doc: /* -*- texinfo -*-
378@deftypefn {} {} __event_manager_list_dialog__ (@var{list}, @var{mode}, @var{size}, @var{initial}, @var{name}, @var{prompt}, @var{ok_string}, @var{cancel_string})
379Undocumented 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
432DEFMETHOD (__event_manager_input_dialog__, interp, args, ,
433 doc: /* -*- texinfo -*-
434@deftypefn {} {} __event_manager_input_dialog__ (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults})
435Undocumented 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
484DEFMETHOD (__event_manager_named_icon__, interp, args, ,
485 doc: /* -*- texinfo -*-
486@deftypefn {} {} __event_manager_dialog_icons__ (@var{icon_name})
487Undocumented 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
504DEFMETHOD (__event_manager_show_preferences__, interp, , ,
505 doc: /* -*- texinfo -*-
506@deftypefn {} {} __event_manager_show_preferences__ ()
507Undocumented internal function.
508@end deftypefn */)
509{
510 event_manager& evmgr = interp.get_event_manager ();
511
512 return ovl (evmgr.show_preferences ());
513}
514
515DEFMETHOD (__event_manager_apply_preferences__, interp, , ,
516 doc: /* -*- texinfo -*-
517@deftypefn {} {} __event_manager_apply_preferences__ ()
518Undocumented internal function.
519@end deftypefn */)
520{
521 event_manager& evmgr = interp.get_event_manager ();
522
523 return ovl (evmgr.apply_preferences ());
524}
525
526DEFMETHOD (__event_manager_gui_preference__, interp, args, ,
527 doc: /* -*- texinfo -*-
528@deftypefn {} {} __event_manager_gui_preference__ ()
529Undocumented internal function.
530@end deftypefn */)
531{
532 std::string key;
533 std::string value = "";
534
535 if (args.length () >= 1)
536 key = args(0).string_value();
537 else
538 error ("__event_manager_gui_preference__: "
539 "first argument must be the preference key");
540
541 if (args.length () >= 2)
542 value = args(1).string_value();
543
545 {
546 event_manager& evmgr = interp.get_event_manager ();
547
548 return ovl (evmgr.gui_preference (key, value));
549 }
550 else
551 return ovl (value);
552}
553
554DEFMETHOD (__event_manager_file_remove__, interp, args, ,
555 doc: /* -*- texinfo -*-
556@deftypefn {} {} __event_manager_file_remove__ ()
557Undocumented internal function.
558@end deftypefn */)
559{
560 std::string old_name, new_name;
561
562 if (args.length () == 2)
563 {
564 old_name = args(0).string_value();
565 new_name = args(1).string_value();
566 }
567 else
568 error ("__event_manager_file_remove__: "
569 "old and new name expected as arguments");
570
571 event_manager& evmgr = interp.get_event_manager ();
572
573 evmgr.file_remove (old_name, new_name);
574
575 return ovl ();
576}
577
578DEFMETHOD (__event_manager_file_renamed__, interp, args, ,
579 doc: /* -*- texinfo -*-
580@deftypefn {} {} __event_manager_file_renamed__ ()
581Undocumented internal function.
582@end deftypefn */)
583{
584 bool load_new;
585
586 if (args.length () == 1)
587 load_new = args(0).bool_value();
588 else
589 error ("__event_manager_file_renamed__: "
590 "first argument must be boolean for reload new named file");
591
592 event_manager& evmgr = interp.get_event_manager ();
593
594 evmgr.file_renamed (load_new);
595
596 return ovl ();
597}
598
599DEFMETHOD (openvar, interp, args, ,
600 doc: /* -*- texinfo -*-
601@deftypefn {} {} openvar (@var{name})
602Open the variable @var{name} in the graphical Variable Editor.
603@end deftypefn */)
604{
605 if (args.length () != 1)
606 print_usage ();
607
608 if (! args(0).is_string ())
609 error ("openvar: NAME must be a string");
610
611 std::string name = args(0).string_value ();
612
613 octave_value val = interp.varval (name);
614
615 if (val.is_undefined ())
616 error ("openvar: '%s' is not a variable", name.c_str ());
617
618 event_manager& evmgr = interp.get_event_manager ();
619
620 evmgr.edit_variable (name, val);
621
622 return ovl ();
623}
624
625/*
626%!error openvar ()
627%!error openvar ("a", "b")
628%!error <NAME must be a string> openvar (1:10)
629*/
630
631DEFMETHOD (__event_manager_show_terminal_window__, interp, , ,
632 doc: /* -*- texinfo -*-
633@deftypefn {} {} __event_manager_show_terminal_window__ ()
634Undocumented internal function.
635@end deftypefn */)
636{
637 std::string file;
638
639 event_manager& evmgr = interp.get_event_manager ();
640
641 evmgr.show_terminal_window ();
642
643 return ovl ();
644}
645
646DEFMETHOD (__event_manager_show_documentation__, interp, args, ,
647 doc: /* -*- texinfo -*-
648@deftypefn {} {} __event_manager_show_documentation__ (@var{filename})
649Undocumented internal function.
650@end deftypefn */)
651{
652 std::string file;
653
654 if (args.length () >= 1)
655 file = args(0).string_value();
656
657 event_manager& evmgr = interp.get_event_manager ();
658
659 return ovl (evmgr.show_documentation (file));
660}
661
662DEFMETHOD (__event_manager_register_documentation__, interp, args, ,
663 doc: /* -*- texinfo -*-
664@deftypefn {} {} __event_manager_register_documentation__ (@var{filename})
665Undocumented internal function.
666@end deftypefn */)
667{
668 std::string file;
669
670 if (args.length () >= 1)
671 file = args(0).string_value();
672
673 event_manager& evmgr = interp.get_event_manager ();
674
675 return ovl (evmgr.register_documentation (file));
676}
677
678DEFMETHOD (__event_manager_unregister_documentation__, interp, args, ,
679 doc: /* -*- texinfo -*-
680@deftypefn {} {} __event_manager_unregister_documentation__ (@var{filename})
681Undocumented internal function.
682@end deftypefn */)
683{
684 std::string file;
685
686 if (args.length () >= 1)
687 file = args(0).string_value();
688
689 event_manager& evmgr = interp.get_event_manager ();
690
691 return ovl (evmgr.unregister_documentation (file));
692}
693
694DEFMETHOD (__event_manager_show_file_browser__, interp, , ,
695 doc: /* -*- texinfo -*-
696@deftypefn {} {} __event_manager_show_file_browser__ ()
697Undocumented internal function.
698@end deftypefn */)
699{
700 event_manager& evmgr = interp.get_event_manager ();
701
702 evmgr.show_file_browser ();
703
704 return ovl ();
705}
706
707DEFMETHOD (__event_manager_show_command_history__, interp, , ,
708 doc: /* -*- texinfo -*-
709@deftypefn {} {} __event_manager_show_command_history__ ()
710Undocumented internal function.
711@end deftypefn */)
712{
713 event_manager& evmgr = interp.get_event_manager ();
714
715 evmgr.show_command_history ();
716
717 return ovl ();
718}
719
720DEFMETHOD (__event_manager_show_workspace__, interp, , ,
721 doc: /* -*- texinfo -*-
722@deftypefn {} {} __event_manager_show_workspace__ ()
723Undocumented internal function.
724@end deftypefn */)
725{
726 event_manager& evmgr = interp.get_event_manager ();
727
728 evmgr.show_workspace ();
729
730 return ovl ();
731}
732
733DEFMETHOD (__event_manager_show_community_news__, interp, , ,
734 doc: /* -*- texinfo -*-
735@deftypefn {} {} __event_manager_show_community_news__ ()
736Undocumented internal function.
737@end deftypefn */)
738{
739 event_manager& evmgr = interp.get_event_manager ();
740
741 evmgr.show_community_news ();
742
743 return ovl ();
744}
745
746DEFMETHOD (__event_manager_show_release_notes__, interp, , ,
747 doc: /* -*- texinfo -*-
748@deftypefn {} {} __event_manager_show_release_notes__ ()
749Undocumented internal function.
750@end deftypefn */)
751{
752 event_manager& evmgr = interp.get_event_manager ();
753
754 evmgr.show_release_notes ();
755
756 return ovl ();
757}
758
759DEFMETHOD (__event_manager_gui_status_update__, interp, args, ,
760 doc: /* -*- texinfo -*-
761@deftypefn {} {} __event_manager_gui_status_update__ (@var{feature}, @var{status})
762Internal function for updating the status of some features in the GUI.
763@end deftypefn */)
764{
765 // This is currently a stub and should only be activated some
766 // interpreter action only implemented in m-files requires to update
767 // a status indicator in the gui. BUT: This internal function can
768 // be activated by the user leading to gui indicators not reflecting
769 // the real state of the related feature.
770 return ovl ();
771
772 std::string feature;
773 std::string status;
774
775 if (! (Fisguirunning ())(0).is_true ())
776 return ovl ();
777
778 if (args.length () < 2)
779 error ("__event_manager_gui_status_update__: two parameters required");
780 if (! (args(0).is_string ()))
781 error ("__event_manager_gui_status_update__: FEATURE must be a string");
782 if (! (args(1).is_string ()))
783 error ("__event_manager_gui_status_update__: STATUS must be a string");
784
785 feature = args(0).string_value ();
786 status = args(1).string_value ();
787
788 event_manager& evmgr = interp.get_event_manager ();
789
790 return ovl (evmgr.gui_status_update (feature, status));
791}
792
793DEFMETHOD (__event_manager_update_gui_lexer__, interp, , ,
794 doc: /* -*- texinfo -*-
795@deftypefn {} {} __event_manager_update_gui_lexer__ ()
796Undocumented internal function.
797@end deftypefn */)
798{
799 event_manager& evmgr = interp.get_event_manager ();
800
801 return ovl (evmgr.update_gui_lexer ());
802}
803
804DEFMETHOD (__event_manager_copy_image_to_clipboard__, interp, args, ,
805 doc: /* -*- texinfo -*-
806@deftypefn {} {} __event_manager_copy_image_to_clipboard__ (@var{filename})
807Undocumented internal function.
808@end deftypefn */)
809{
810 std::string file;
811
812 if (args.length () >= 1)
813 file = args(0).string_value();
814
815 event_manager& evmgr = interp.get_event_manager ();
816 evmgr.copy_image_to_clipboard (file);
817 return ovl ();
818}
819
820DEFMETHOD (commandhistory, interp, args, ,
821 doc: /* -*- texinfo -*-
822@deftypefn {} {} commandhistory ()
823Show the GUI command history window and give it the keyboard focus.
824@seealso{commandwindow, filebrowser, workspace}
825@end deftypefn */)
826{
827 if (args.length () != 0)
828 print_usage ();
829
830 event_manager& evmgr = interp.get_event_manager ();
831 evmgr.focus_window ("history");
832 return ovl ();
833}
834
835DEFMETHOD (commandwindow, interp, args, ,
836 doc: /* -*- texinfo -*-
837@deftypefn {} {} commandwindow ()
838Show the GUI command window and give it the keyboard focus.
839@seealso{commandhistory, filebrowser, workspace}
840@end deftypefn */)
841{
842 if (args.length () != 0)
843 print_usage ();
844
845 event_manager& evmgr = interp.get_event_manager ();
846 evmgr.focus_window ("command");
847 return ovl ();
848}
849
850DEFMETHOD (filebrowser, interp, args, ,
851 doc: /* -*- texinfo -*-
852@deftypefn {} {} filebrowser ()
853Show the GUI file browser window and give it the keyboard focus.
854@seealso{commandwindow, commandhistory, workspace}
855@end deftypefn */)
856{
857 if (args.length () != 0)
858 print_usage ();
859
860 event_manager& evmgr = interp.get_event_manager ();
861 evmgr.focus_window ("filebrowser");
862 return ovl ();
863}
864
865DEFMETHOD (workspace, interp, args, ,
866 doc: /* -*- texinfo -*-
867@deftypefn {} {} workspace ()
868Show the GUI workspace window and give it the keyboard focus.
869@seealso{commandwindow, commandhistory, filebrowser}
870@end deftypefn */)
871{
872 if (args.length () != 0)
873 print_usage ();
874
875 event_manager& evmgr = interp.get_event_manager ();
876 evmgr.focus_window ("workspace");
877 return ovl ();
878}
879
880OCTAVE_NAMESPACE_END
T & xelem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:504
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:411
octave_idx_type rows(void) const
Definition: Array.h:449
octave_idx_type columns(void) const
Definition: Array.h:458
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:312
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)
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)
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)
OCTINTERP_API void discard_events(void)
OCTINTERP_API bool enable(void)
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
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::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
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)
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 show_file_browser(void)
virtual void display_exception(const execution_exception &ee, bool beep)
tree_evaluator & get_evaluator(void)
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:4411
bool at_top_level(void) const
Definition: pt-eval.cc:533
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:1055
void error(const char *fmt,...)
Definition: error.cc:980
static OCTAVE_NAMESPACE_BEGIN int readline_event_hook(void)
OCTAVE_NAMESPACE_BEGIN typedef std::function< void(void)> fcn_callback
Definition: event-manager.h:47
std::function< void(interpreter &)> meth_callback
Definition: event-manager.h:48
QString name
bool is_true(const std::string &s)
event_manager & __get_event_manager__(const std::string &who)
OCTAVE_EXPORT octave_value_list Fisguirunning(const octave_value_list &args, int)
Definition: octave.cc:435
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