25 #if defined (HAVE_CONFIG_H) 29 #include "builtin-defun-decls.h" 55 : event_queue_mutex (new
octave::mutex ()), gui_event_queue (),
56 debugging (
false), link_enabled (true)
89 error (
"octave_link is already linked!");
118 DEFUN (__octave_link_enabled__, , ,
127 DEFUN (__octave_link_edit_file__, args, ,
135 if (args.length () == 1)
137 std::string file = args(0).xstring_value (
"first argument must be filename");
143 else if (args.length () == 2)
145 std::string file = args(0).xstring_value (
"first argument must be filename");
155 DEFUN (__octave_link_message_dialog__, args, ,
163 if (args.length () == 3)
165 std::string dlg = args(0).xstring_value (
"invalid arguments");
166 std::string msg = args(1).xstring_value (
"invalid arguments");
167 std::string title = args(2).xstring_value (
"invalid arguments");
177 DEFUN (__octave_link_question_dialog__, args, ,
185 if (args.length () == 6)
187 std::string msg = args(0).xstring_value (
"invalid arguments");
188 std::string title = args(1).xstring_value (
"invalid arguments");
189 std::string btn1 = args(2).xstring_value (
"invalid arguments");
190 std::string btn2 = args(3).xstring_value (
"invalid arguments");
191 std::string btn3 = args(4).xstring_value (
"invalid arguments");
192 std::string btndef = args(5).xstring_value (
"invalid arguments");
203 DEFUN (__octave_link_file_dialog__, args, ,
209 if (args.length () != 6)
217 Matrix pos = args(3).matrix_value ();
225 filter_lst.push_back (std::make_pair (flist(
i,0),
227 ? flist(
i,1) :
"")));
231 std::list<std::string> items_lst
235 nel = items_lst.size ();
240 if (items_lst.front ().empty ())
245 for (
auto&
str : items_lst)
260 std::list<std::string>::iterator it = items_lst.begin ();
262 for (
int idx = 0; idx < nel; idx++, it++)
263 items.
xelem (idx) = *it;
265 retval =
ovl (items, *it++, atoi (it->c_str ()));
271 DEFUN (__octave_link_list_dialog__, args, ,
277 if (args.length () != 8)
283 std::list<std::string> list_lst;
285 list_lst.push_back (tlist(
i));
289 Matrix size_matrix = args(2).matrix_value ();
290 int width = size_matrix(0);
291 int height = size_matrix(1);
293 Matrix initial_matrix = args(3).matrix_value ();
294 nel = initial_matrix.
numel ();
295 std::list<int> initial_lst;
297 initial_lst.push_back (initial_matrix(
i));
300 list = args(5).cell_value ();
302 nel = plist.
numel ();
303 std::list<std::string> prompt_lst;
305 prompt_lst.push_back (plist(
i));
307 std::string cancel_string = args(7).string_value ();
311 std::pair<std::list<int>,
int>
result 313 initial_lst,
name, prompt_lst,
314 ok_string, cancel_string);
316 std::list<int> items_lst =
result.first;
317 nel = items_lst.size ();
320 for (
const auto& int_el : items_lst)
321 items.
xelem(
i++) = int_el;
326 DEFUN (__octave_link_input_dialog__, args, ,
332 if (args.length () != 4)
335 Cell prompt = args(0).cell_value ();
338 std::list<std::string> prompt_lst;
340 prompt_lst.push_back (
tmp(
i));
344 Matrix rc = args(2).matrix_value ();
350 nr.push_back (rc(
i,0));
351 nc.push_back (rc(
i,1));
354 Cell defaults = args(3).cell_value ();
357 std::list<std::string> defaults_lst;
359 defaults_lst.push_back (
tmp(
i));
363 std::list<std::string> items_lst
367 nel = items_lst.size ();
370 for (
const auto& str_el : items_lst)
371 items.
xelem(
i++) = str_el;
376 DEFUN (__octave_link_show_preferences__, , ,
391 if (args.length () != 1)
394 if (! args(0).is_string ())
395 error (
"openvar: NAME must be a string");
400 warning (
"openvar: GUI is not running, can't start Variable Editor");
407 if (
val.is_undefined ())
408 error (
"openvar: '%s' is not a variable",
name.c_str ());
422 DEFUN (__octave_link_show_doc__, args, ,
430 if (args.length () >= 1)
431 file = args(0).string_value();
436 DEFUN (__octave_link_register_doc__, args, ,
444 if (args.length () >= 1)
445 file = args(0).string_value();
450 DEFUN (__octave_link_unregister_doc__, args, ,
458 if (args.length () >= 1)
459 file = args(0).string_value();
octave_idx_type rows(void) const
static int message_dialog(const std::string &dlg, const std::string &msg, const std::string &title)
static 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)
For example cd octave end example noindent changes the current working directory to file
virtual ~octave_link(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Provides threadsafe access to octave.
static void finished_readline_hook(void)
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
static 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)
OCTINTERP_API void print_usage(void)
identity matrix If supplied two scalar respectively For allows like xample val
static bool enabled(void)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
symbol_scope current_scope(void)
static void process_events(bool disable=false)
static bool edit_variable(const std::string &name, const octave_value &val)
octave::event_queue gui_event_queue
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
octave_idx_type columns(void) const
static bool prompt_new_edit_file(const std::string &file)
octave::mutex * event_queue_mutex
static octave_link * instance
static 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)
symbol_table & __get_symbol_table__(const std::string &who)
virtual void do_set_workspace(bool top_level, bool debug, const octave::symbol_scope &scope, bool update_variable_editor)=0
void do_discard_events(void)
nd deftypefn *std::string name
static void entered_readline_hook(void)
static bool register_doc(const std::string &file)
static bool edit_file(const std::string &file)
static void set_workspace(void)
void do_process_events(void)
static bool show_doc(const std::string &file)
static void connect_link(octave_link *)
bool is_true(const std::string &s)
octave_value varval(const std::string &name) const
With real return the complex result
T & xelem(octave_idx_type n)
void warning(const char *fmt,...)
static int octave_readline_hook(void)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
Array< std::string > cellstr_value(void) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
static 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)
static void generate_events(void)
static bool unregister_doc(const std::string &file)
static bool show_preferences()
void do_generate_events(void)
static void add_event_hook(event_hook_fcn f)
OCTAVE_EXPORT octave_value_list Fisguirunning(const octave_value_list &args, int)
octave_idx_type numel(void) const
Number of elements in the array.
Vector representing the dimensions (size) of an Array.
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
std::list< std::pair< std::string, std::string > > filter_list