25 #if defined (HAVE_CONFIG_H)
132 input_event_hook_functions.
clear ();
141 VPS1 =
"octave:\\#> ";
151 bool forced_interactive = octave::application::forced_interactive ();
155 : ((Vecho_executing_commands &
ECHO_CMD_LINE) && ! forced_interactive);
159 if (forced_interactive)
169 if (! input_string.empty ())
173 if (input_string[input_string.length () - 1] !=
'\n')
188 if (! eof && retval.empty ())
197 Vlast_prompt_time.
stamp ();
199 if (Vdrawnow_requested && octave::application::interactive ())
207 catch (
const octave::execution_exception&
e)
213 if (! stack_trace.empty ())
214 std::cerr << stack_trace;
216 if (octave::application::interactive ())
225 Vdrawnow_requested =
false;
246 if (octave::application::interactive ())
256 bool history_skip_auto_repeated_debugging_command =
false;
276 && retval.find_first_not_of (
" \t\n\r") != std::string::npos)
288 history_skip_auto_repeated_debugging_command =
true;
293 if (! history_skip_auto_repeated_debugging_command)
301 if (retval[retval.length () - 1] !=
'\n')
312 if (octave::application::interactive ())
375 static std::string dirfns_commands[] = {
"cd",
"ls"};
376 static const size_t dirfns_commands_length = 2;
382 for (
size_t i = 0;
i < dirfns_commands_length;
i++)
384 int index = line.find (dirfns_commands[
i] +
" ");
404 static size_t hint_len = 0;
406 static int list_index = 0;
407 static int name_list_len = 0;
408 static int name_list_total_len = 0;
412 static int matches = 0;
425 bool deemed_struct =
false;
433 name_list_len = name_list.
numel ();
442 name_list.
append (file_name_list);
446 name_list_total_len = name_list.
numel ();
448 hint_len = hint.length ();
452 for (
int i = 0;
i < name_list_len;
i++)
453 if (hint == name_list[
i].substr (0, hint_len))
457 if (name_list_total_len > 0 && matches > 0)
459 while (list_index < name_list_total_len)
465 if (hint == name.substr (0, hint_len))
469 if (list_index <= name_list_len && ! prefix.empty ())
470 retval = (prefix ==
"." ?
"" : prefix) +
"." +
name;
513 int pos = line.length () - text.length ();
519 while (pos >= 0 && (line[pos] ==
')' || line[pos] ==
'}'))
521 if (line[pos] ==
')')
523 else if (line[pos] ==
'}')
526 while (curly_count + paren_count > 0 && --pos >= 0)
528 if (line[pos] ==
')')
530 else if (line[pos] ==
'(')
532 else if (line[pos] ==
'}')
534 else if (line[pos] ==
'{')
538 while (--pos >= 0 && line[pos] ==
' ')
542 while (pos >= 0 && (isalnum (line[pos]) || line[pos] ==
'_'))
546 return (line.substr (pos, last + 1 - pos));
562 static const char *
s =
"\t\n !\"\'*+-/:;<=>(){}[\\]^`~";
596 bool have_file =
false;
603 nm = caller->
name ();
612 std::ostringstream buf;
618 static char ctrl_z =
'Z' & 0x1f;
620 buf << ctrl_z << ctrl_z << nm <<
":" << curr_debug_line;
630 buf <<
"stopped in " <<
nm;
632 if (curr_debug_line > 0)
633 buf <<
" at line " << curr_debug_line;
643 std::pair<std::string, int> (nm, curr_debug_line));
650 if (! line_buf.empty ())
651 buf <<
"\n" << curr_debug_line <<
": " << line_buf;
663 std::cerr << msg << std::endl;
668 octave::application *app = octave::application::app ();
670 if (! app->interactive ())
673 frame.
add_method (app, &octave::application::interactive,
674 app->interactive ());
676 frame.
add_method (app, &octave::application::forced_interactive,
677 app->forced_interactive ());
679 app->interactive (
true);
681 app->forced_interactive (
true);
690 Vtrack_line_num =
false;
694 curr_parser.
reset ();
702 if (retval == 0 && curr_parser.
stmt_list)
706 if (octave_completion_matches_called)
707 octave_completion_matches_called =
false;
713 catch (
const octave::execution_exception&
e)
717 if (! stack_trace.empty ())
718 std::cerr << stack_trace;
782 int read_as_string = 0;
787 std::string prompt =
args(0).xstring_value (
"input: unrecognized argument");
800 if (input_buf.empty ())
801 error (
"input: reading user-input failed!");
803 size_t len = input_buf.length ();
807 if (input_buf[len - 1] !=
'\n')
816 if (input_buf.length () == 1 && input_buf[0] ==
'\n')
823 int parse_status = 0;
825 retval =
eval_string (input_buf,
true, parse_status, nargout);
827 if (! Vdebugging && retval.
empty ())
875 if (nargin < 1 || nargin > 2)
884 std::string prompt_string = prompt +
"(yes or no) ";
892 if (input_buf ==
"yes")
894 else if (input_buf ==
"no")
897 message (0,
"Please answer yes or no.");
923 prompt =
args(0).xstring_value (
"yes_or_no: PROMPT must be a string");
933 int nargin = args.
length ();
935 assert (nargin == 0 || nargin == 1);
956 Vtrack_line_num =
false;
960 prompt =
args(0).string_value ();
967 DEFUN (keyboard, args, ,
1006 DEFUN (echo, args, ,
1047 Vecho_executing_commands =
ECHO_OFF;
1059 else if (arg ==
"off")
1060 Vecho_executing_commands =
ECHO_OFF;
1070 if (arg ==
"on" && argv[1] ==
"all")
1073 Vecho_executing_commands =
tmp;
1075 else if (arg ==
"off" && argv[1] ==
"all")
1076 Vecho_executing_commands =
ECHO_OFF;
1137 DEFUN (__echostate__, , ,
1193 if (!
list.empty ())
1204 int len =
list.numel ();
1206 for (
int i = 0;
i < len;
i++)
1210 octave_completion_matches_called =
true;
1230 DEFUN (readline_read_init_file, args, ,
1243 int nargin = args.
length ();
1260 DEFUN (readline_re_read_init_file, args, ,
1279 internal_input_event_hook_fcn (
void)
1281 input_event_hook_functions.
run ();
1283 if (input_event_hook_functions.
empty ())
1289 DEFUN (add_input_event_hook, args, ,
1309 int nargin = args.
length ();
1311 if (nargin < 1 || nargin > 2)
1317 user_data =
args(1);
1321 if (input_event_hook_functions.
empty ())
1324 input_event_hook_functions.
insert (hook_fcn.id (), hook_fcn);
1326 return ovl (hook_fcn.id ());
1329 DEFUN (remove_input_event_hook, args, ,
1339 int nargin = args.
length ();
1341 if (nargin < 1 || nargin > 2)
1344 std::string hook_fcn_id =
args(0).string_value (
"remove_input_event_hook: argument not valid as a hook function name or id");
1346 bool warn = (nargin < 2);
1349 = input_event_hook_functions.
find (hook_fcn_id);
1351 if (p != input_event_hook_functions.
end ())
1352 input_event_hook_functions.
erase (p);
1354 warning (
"remove_input_event_hook: %s not found in list",
1355 hook_fcn_id.c_str ());
1357 if (input_event_hook_functions.
empty ())
1501 DEFUN (__request_drawnow__, args, ,
1508 int nargin = args.
length ();
1514 Vdrawnow_requested =
true;
1516 Vdrawnow_requested =
args(0).bool_value ();
1521 DEFUN (__gud_mode__, args, ,
1527 int nargin = args.
length ();
1535 retval =
ovl (Vgud_mode);
1537 Vgud_mode =
args(0).bool_value ();
1585 error (
"filemarker: character can not be a valid character for a function name");
static void enter_debugger_event(const std::string &file, int line)
static void pre_input_event(void)
static void restore_frame(size_t n)
static void set_completion_function(completion_fcn f)
For example cd octave end example noindent changes the current working directory to file
static const std::string in_src
virtual bool reading_fcn_file(void) const
static std::string decode_prompt_string(const std::string &s)
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 void exit_debugger_event(void)
std::string octave_fgets(FILE *f)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
static void set_filename_quote_characters(const std::string &s)
static void set_input_stream(FILE *f)
octave_idx_type length(void) const
void accept(tree_walker &tw)
bool looks_like_struct(const std::string &text, char prev_char)
std::string octave_gets(bool &eof)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
std::string name(void) const
#define SET_INTERNAL_VARIABLE(NM)
static void ignore_entries(bool=true)
static std::string get_line_buffer(void)
static bool add(const std::string &)
iterator find(const std::string &id)
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup calculate Y_a and Y _d item Given calculate Y nd enumerate In either initial values for the given components are input
static void execute_in_debugger_event(const std::string &file, int line)
void add_method(T *obj, void(T::*method)(void))
static void set_default_prompts(std::string &ps1, std::string &ps2, std::string &ps4)
static bool quiet_breakpoint_flag
static void re_read_init_file(void)
tree_evaluator * current_evaluator
static const std::string in_src
void do_input_echo(const std::string &) const
void insert(const std::string &id, const hook_function &f)
void message(const char *name, const char *fmt,...)
static int current_line(void)
static octave_user_code * caller_user_code(size_t nskip=0)
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
void add_fcn(void(*fcn)(void))
static void post_input_event(void)
static size_t current_frame(void)
static string_vector generate_filename_completions(const std::string &text)
string_vector make_argv(const std::string &="") const
int pipe_handler_error_count
static bool erase_empty_line(bool flag)
static void set_completer_quote_characters(const std::string &s)
static char get_prev_char(int)
static size_t current_frame
std::string get_input(bool &eof)
static void set_workspace(void)
std::string get_input(bool &eof)
string_vector generate_struct_completions(const std::string &text, std::string &prefix, std::string &hint)
static void remove_event_hook(event_hook_fcn f)
string_vector & append(const std::string &s)
static OCTAVE_NORETURN void eval_error(const char *msg, const dim_vector &x, const dim_vector &y)
std::string get_input(bool &eof)
void reset_error_handler(void)
string_vector & sort(bool make_uniq=false)
static void set_completer_word_break_characters(const std::string &s)
static FILE * get_input_stream(void)
static bool interrupt(bool=true)
virtual bool reading_script_file(void) const
static uint32_t state[624]
static int caller_user_code_line(void)
static void read_init_file(const std::string &file="")
void warning(const char *fmt,...)
octave::unwind_protect frame
void recover_from_exception(void)
charNDArray max(char d, const charNDArray &m)
virtual std::string fcn_file_name(void) const
static const std::string in_src
virtual bool reading_classdef_file(void) const
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
static const std::string in_src
static void set_completion_append_character(char c)
static std::string readline(const std::string &prompt)
=val(i)}if ode{val(i)}occurs in table i
bool reading_classdef_file
static bool ignoring_entries(void)
string_vector make_name_list(void)
static void add_event_hook(event_hook_fcn f)
static void set_basic_word_break_characters(const std::string &s)
static void set_basic_quote_characters(const std::string &s)
tree_statement_list * stmt_list
std::string get_file_line(const std::string &fname, size_t line)
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
static bool goto_frame_relative(int n, bool verbose=false)
static void append_history(const std::string &hist_entry)
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
octave::base_lexer * lexer
void run(const octave_value_list &initial_args=octave_value_list())
static void set_name(const std::string &n)
static void set_quoting_function(quoting_fcn f)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
map_type::iterator iterator