25 #if defined (HAVE_CONFIG_H) 44 #include "builtin-defun-decls.h" 126 VPS1 = R
"(octave:\#> )"; 142 if (! eof &&
retval.empty ())
161 catch (
const octave::execution_exception&
e)
167 if (! stack_trace.empty ())
168 std::cerr << stack_trace;
170 if (octave::application::interactive ())
201 if (application::interactive ())
211 bool history_skip_auto_repeated_debugging_command =
false;
231 &&
retval.find_first_not_of (
" \t\n\r") != std::string::npos)
245 history_skip_auto_repeated_debugging_command =
true;
250 if (! history_skip_auto_repeated_debugging_command)
258 if (
retval.back () !=
'\n')
267 if (application::interactive ())
403 static std::string dirfns_commands[] = {
"cd",
"ls"};
404 static const size_t dirfns_commands_length = 2;
410 for (
size_t i = 0;
i < dirfns_commands_length;
i++)
412 int index =
line.find (dirfns_commands[
i] +
' ');
432 static size_t hint_len = 0;
434 static int list_index = 0;
435 static int name_list_len = 0;
436 static int name_list_total_len = 0;
440 static int matches = 0;
453 bool deemed_struct =
false;
461 name_list_len = name_list.
numel ();
470 name_list.
append (file_name_list);
474 name_list_total_len = name_list.
numel ();
476 hint_len = hint.length ();
480 for (
int i = 0;
i < name_list_len;
i++)
481 if (hint == name_list[
i].substr (0, hint_len))
485 if (name_list_total_len > 0 && matches > 0)
487 while (list_index < name_list_total_len)
493 if (hint ==
name.substr (0, hint_len))
497 if (list_index <= name_list_len && ! prefix.empty ())
498 retval = (prefix ==
"." ?
"" : prefix) +
'.' +
name;
541 int pos =
line.length () -
text.length ();
547 while (pos >= 0 && (
line[pos] ==
')' ||
line[pos] ==
'}'))
549 if (
line[pos] ==
')')
551 else if (
line[pos] ==
'}')
554 while (curly_count + paren_count > 0 && --pos >= 0)
556 if (
line[pos] ==
')')
558 else if (
line[pos] ==
'(')
560 else if (
line[pos] ==
'}')
562 else if (
line[pos] ==
'{')
566 while (--pos >= 0 &&
line[pos] ==
' ')
570 while (pos >= 0 && (isalnum (
line[pos]) ||
line[pos] ==
'_'))
574 return (
line.substr (pos, last + 1 - pos));
590 static const char *
s =
"\t\n !\"\'*+-/:;<=>(){}[\\]^`~";
607 execute_in_debugger_handler (
const std::pair<std::string, int>&
arg)
638 std::ostringstream buf;
644 static char ctrl_z =
'Z' & 0x1f;
646 buf << ctrl_z << ctrl_z <<
nm <<
':' << curr_debug_line;
656 buf <<
"stopped in " <<
nm;
658 if (curr_debug_line > 0)
659 buf <<
" at line " << curr_debug_line;
667 std::pair<std::string, int> (
nm, curr_debug_line));
676 if (! line_buf.empty ())
677 buf <<
"\n" << curr_debug_line <<
": " << line_buf;
688 std::cerr << msg << std::endl;
695 octave::application *app = octave::application::app ();
697 if (! app->interactive ())
701 app->interactive ());
704 app->forced_interactive ());
706 app->interactive (
true);
708 app->forced_interactive (
true);
723 curr_parser.
reset ();
742 catch (
const octave::execution_exception&
e)
746 if (! stack_trace.empty ())
747 std::cerr << stack_trace;
814 int read_as_string = 0;
819 std::string prompt = args(0).xstring_value (
"input: unrecognized argument");
832 if (input_buf.empty ())
833 error (
"input: reading user-input failed!");
835 size_t len = input_buf.length ();
839 if (input_buf[len - 1] !=
'\n')
848 if (input_buf.length () == 1 && input_buf[0] ==
'\n')
855 int parse_status = 0;
916 std::string prompt_string = prompt +
"(yes or no) ";
924 if (input_buf ==
"yes")
926 else if (input_buf ==
"no")
929 message (
nullptr,
"Please answer yes or no.");
933 DEFUN (yes_or_no, args, ,
955 prompt = args(0).xstring_value (
"yes_or_no: PROMPT must be a string");
994 prompt = args(0).string_value ();
996 get_debug_input (interp, prompt);
1097 if (!
list.empty ())
1108 int len =
list.numel ();
1110 for (
int i = 0;
i < len;
i++)
1134 DEFUN (readline_read_init_file, args, ,
1164 DEFUN (readline_re_read_init_file, args, ,
1183 internal_input_event_hook_fcn (
void)
1193 DEFUN (add_input_event_hook, args, ,
1221 user_data = args(1);
1230 return ovl (hook_fcn.id ());
1233 DEFUN (remove_input_event_hook, args, ,
1248 std::string hook_fcn_id = args(0).string_value (
"remove_input_event_hook: argument not valid as a hook function name or id");
1250 bool warn = (
nargin < 2);
1258 warning (
"remove_input_event_hook: %s not found in list",
1259 hook_fcn_id.c_str ());
1349 DEFUN (__request_drawnow__, args, ,
1369 DEFUN (__gud_mode__, args, ,
virtual bool reading_fcn_file(void) const
static void enter_debugger_event(const std::string &file, int line)
static void pre_input_event(void)
std::string m_eval_string
static void set_completion_function(completion_fcn f)
std::string get_input(bool &eof)
For example cd octave end example noindent changes the current working directory to file
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
static const std::string s_in_src
interpreter & __get_interpreter__(const std::string &who)
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 OCTAVE_NORETURN void eval_error(const char *msg, const dim_vector &x, const dim_vector &y)
static void recover_from_exception(void)
static void exit_debugger_event(void)
std::string get_input(bool &eof)
std::string octave_fgets(FILE *f)
OCTINTERP_API void print_usage(void)
static void set_filename_quote_characters(const std::string &s)
static void set_input_stream(FILE *f)
bool input_from_eval_string(void) const
bool looks_like_struct(const std::string &text, char prev_char)
tree_statement_list * m_stmt_list
virtual bool reading_script_file(void) const
void add_fcn(void(*fcn)(void))
std::string get_code_line(size_t line)
bool goto_frame_relative(int n, bool verbose=false)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
std::string input_source(void) const
#define SET_INTERNAL_VARIABLE(NM)
std::string input_source(void) const
octave_user_code * caller_user_code(size_t nskip=0) const
static void ignore_entries(bool=true)
int caller_user_code_line(void) const
static std::string get_line_buffer(void)
static bool add(const std::string &)
static const std::string s_in_src
tree_evaluator & get_evaluator(void)
iterator find(const std::string &id)
static void execute_in_debugger_event(const std::string &file, int line)
virtual std::string fcn_file_name(void) const
static void set_default_prompts(std::string &ps1, std::string &ps2, std::string &ps4)
static bool quiet_breakpoint_flag
virtual bool reading_classdef_file(void) const
terminal_reader(base_lexer *lxr=nullptr)
static void re_read_init_file(void)
void insert(const std::string &id, const hook_function &f)
void message(const char *name, const char *fmt,...)
nd deftypefn *std::string name
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
string_vector make_name_list(void)
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)
static const std::string s_in_src
static void post_input_event(void)
static string_vector generate_filename_completions(const std::string &text)
int pipe_handler_error_count
static bool erase_empty_line(bool flag)
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
static void set_completer_quote_characters(const std::string &s)
bool input_from_file(void) const
static char get_prev_char(int)
static size_t current_frame
static void set_workspace(void)
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)
void accept(tree_walker &tw)
void reset_error_handler(void)
string_vector & sort(bool make_uniq=false)
file_reader(FILE *f_arg, base_lexer *lxr=nullptr)
static void set_completer_word_break_characters(const std::string &s)
static FILE * get_input_stream(void)
OCTAVE_EXPORT octave_value_list or cell arrays Arguments are concatenated vertically The returned values are padded with blanks as needed to make each row of the string array have the same length Empty input strings are significant and will concatenated in the output For numerical input
static bool interrupt(bool=true)
load_path & __get_load_path__(const std::string &who)
static uint32_t state[624]
bool m_reading_script_file
static void read_init_file(const std::string &file="")
void warning(const char *fmt,...)
octave::unwind_protect frame
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
charNDArray max(char d, const charNDArray &m)
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
std::string get_input(bool &eof)
static void set_completion_append_character(char c)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
static std::string readline(const std::string &prompt)
int current_line(void) const
eval_string_reader(const std::string &str, base_lexer *lxr=nullptr)
bool m_reading_classdef_file
octave_idx_type length(void) const
call_stack & get_call_stack(void)
static bool ignoring_entries(void)
static const std::string s_in_src
void add_method(T *obj, void(T::*method)(void))
static void add_event_hook(event_hook_fcn f)
void restore_frame(size_t n)
static void set_basic_word_break_characters(const std::string &s)
static void set_basic_quote_characters(const std::string &s)
bool input_from_terminal(void) const
std::string input_source(void) const
octave_idx_type numel(void) const
Number of elements in the array.
std::string name(void) const
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
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)
size_t current_frame(void) const
map_type::iterator iterator
std::string octave_gets(bool &eof)