Navigation

Operators and Keywords

Function List:

C++ API

input.cc File Reference

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include "cmd-edit.h"
#include "file-ops.h"
#include "quit.h"
#include "str-vec.h"
#include "debug.h"
#include "defun.h"
#include "dirfns.h"
#include "error.h"
#include "gripes.h"
#include "help.h"
#include "input.h"
#include "load-path.h"
#include "oct-map.h"
#include "oct-hist.h"
#include "toplev.h"
#include "oct-obj.h"
#include "pager.h"
#include "parse.h"
#include "pathlen.h"
#include "pt.h"
#include "pt-const.h"
#include "pt-eval.h"
#include "pt-stmt.h"
#include "sighandlers.h"
#include "sysdep.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"

Include dependency graph for input.cc:


Typedefs

typedef std::map< std::string,
octave_value
hook_fcn_map_type

Functions

std::string gnu_readline (const std::string &s, bool force_readline)
int octave_read (char *buf, unsigned max_size)
FILE * get_input_from_file (const std::string &name, int warn)
FILE * get_input_from_stdin (void)
void initialize_command_input (void)
 DEFUN (input, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} input (@var{prompt})\n\ @deftypefnx {Built-in Function} {} input (@var{prompt}, \"s\")\n\ Print a prompt and wait for user input. For example,\n\ \n\ @example\n\ input (\"Pick a number, any number! \")\n\ @end example\n\ \n\ @noindent\n\ prints the prompt\n\ \n\ @example\n\ Pick a number, any number!\n\ @end example\n\ \n\ @noindent\n\ and waits for the user to enter a value. The string entered by the user\n\ is evaluated as an expression, so it may be a literal constant, a\n\ variable name, or any other valid expression.\n\ \n\ Currently, @code{input} only returns one value, regardless of the number\n\ of values produced by the evaluation of the expression.\n\ \n\ If you are only interested in getting a literal string value, you can\n\ call @code{input} with the character string @code{\"s\"} as the second\n\ argument. This tells Octave to return the string entered by the user\n\ directly, without evaluating it first.\n\ \n\ Because there may be output waiting to be displayed by the pager, it is\n\ a good idea to always call @code{fflush (stdout)} before calling\n\ @code{input}. This will ensure that all pending output is written to\n\ the screen before your prompt. @xref{Input and Output}.\n\ @end deftypefn")
bool octave_yes_or_no (const std::string &prompt)
 DEFUN (yes_or_no, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} yes_or_no (@var{prompt})\n\ Ask the user a yes-or-no question. Return 1 if the answer is yes.\n\ Takes one argument, which is the string to display to ask the\n\ question. It should end in a space; @samp{yes-or-no-p} adds\n\ @samp{(yes or no) } to it. The user must confirm the answer with\n\ RET and can edit it until it has been confirmed.\n\ @end deftypefn")
octave_value do_keyboard (const octave_value_list &args)
 DEFUN (keyboard, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} keyboard ()\n\ @deftypefnx {Built-in Function} {} keyboard (@var{prompt})\n\ This function is normally used for simple debugging. When the\n\ @code{keyboard} function is executed, Octave prints a prompt and waits\n\ for user input. The input strings are then evaluated and the results\n\ are printed. This makes it possible to examine the values of variables\n\ within a function, and to assign new values if necessary. To leave the\n\ prompt and return to normal execution type @samp{return} or @samp{dbcont}.\n\ The @code{keyboard} function does not return an exit status.\n\ \n\ If @code{keyboard} is invoked without arguments, a default prompt of\n\ @samp{debug> } is used.\n\ @seealso{dbcont, dbquit}\n\ @end deftypefn")
 DEFUN (echo, args,,"-*- texinfo -*-\n\ @deffn {Command} echo options\n\ Control whether commands are displayed as they are executed. Valid\n\ options are:\n\ \n\ @table @code\n\ @item on\n\ Enable echoing of commands as they are executed in script files.\n\ \n\ @item off\n\ Disable echoing of commands as they are executed in script files.\n\ \n\ @item on all\n\ Enable echoing of commands as they are executed in script files and\n\ functions.\n\ \n\ @item off all\n\ Disable echoing of commands as they are executed in script files and\n\ functions.\n\ @end table\n\ \n\ @noindent\n\ With no arguments, @code{echo} toggles the current echo state.\n\ @end deffn")
 DEFUN (completion_matches, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\ Generate possible completions given @var{hint}.\n\ \n\ This function is provided for the benefit of programs like Emacs which\n\ might be controlling Octave and handling user input. The current\n\ command number is not incremented when this function is called. This is\n\ a feature, not a bug.\n\ @end deftypefn")
 DEFUN (read_readline_init_file, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} read_readline_init_file (@var{file})\n\ Read the readline library initialization file @var{file}. If\n\ @var{file} is omitted, read the default initialization file (normally\n\ @file{~/.inputrc}).\n\ \n\ @xref{Readline Init File, , , readline, GNU Readline Library},\n\ for details.\n\ @end deftypefn")
 DEFUN (re_read_readline_init_file, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} re_read_readline_init_file ()\n\ Re-read the last readline library initialization file that was read.\n\ @xref{Readline Init File, , , readline, GNU Readline Library},\n\ for details.\n\ @end deftypefn")
 DEFUN (add_input_event_hook, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} add_input_event_hook (@var{fcn}, @var{data})\n\ Add the named function @var{fcn} to the list of functions to call\n\ periodically when Octave is waiting for input. The function should\n\ have the form\n\ @example\n\ @var{fcn} (@var{data})\n\ @end example\n\ \n\ If @var{data} is omitted, Octave calls the function without any\n\ arguments.\n\ @seealso{remove_input_event_hook}\n\ @end deftypefn")
 DEFUN (remove_input_event_hook, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} remove_input_event_hook (@var{fcn})\n\ Remove the named function @var{fcn} to the list of functions to call\n\ periodically when Octave is waiting for input.\n\ @seealso{add_input_event_hook}\n\ @end deftypefn")
 DEFUN (PS1, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} PS1 ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} PS1 (@var{new_val})\n\ Query or set the primary prompt string. When executing interactively,\n\ Octave displays the primary prompt when it is ready to read a command.\n\ \n\ The default value of the primary prompt string is @code{\"\\s:\\#> \"}.\n\ To change it, use a command like\n\ \n\ @example\n\ octave:13> PS1 (\"\\\\u@@\\\\H> \")\n\ @end example\n\ \n\ @noindent\n\ which will result in the prompt @samp{boris@@kremvax> } for the user\n\ @samp{boris} logged in on the host @samp{kremvax.kgb.su}. Note that two\n\ backslashes are required to enter a backslash into a double-quoted\n\ character string.\n\ @xref{Strings}.\n\ @seealso{PS2, PS4}\n\ @end deftypefn")
 DEFUN (PS2, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} PS2 ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} PS2 (@var{new_val})\n\ Query or set the secondary prompt string. The secondary prompt is\n\ printed when Octave is expecting additional input to complete a\n\ command. For example, if you are typing a @code{for} loop that spans several\n\ lines, Octave will print the secondary prompt at the beginning of\n\ each line after the first. The default value of the secondary prompt\n\ string is @code{\"> \"}.\n\ @seealso{PS1, PS4}\n\ @end deftypefn")
 DEFUN (PS4, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} PS4 ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} PS4 (@var{new_val})\n\ Query or set the character string used to prefix output produced\n\ when echoing commands is enabled.\n\ The default value is @code{\"+ \"}.\n\ @xref{Diary and Echo Commands}, for a description of echoing commands.\n\ @seealso{echo, echo_executing_commands, PS1, PS2}\n\ @end deftypefn")
 DEFUN (completion_append_char, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} completion_append_char ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} completion_append_char (@var{new_val})\n\ Query or set the internal character variable that is appended to\n\ successful command-line completion attempts. The default\n\ value is @code{\" \"} (a single space).\n\ @end deftypefn")
 DEFUN (echo_executing_commands, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} echo_executing_commands ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} echo_executing_commands (@var{new_val})\n\ Query or set the internal variable that controls the echo state.\n\ It may be the sum of the following values:\n\ \n\ @table @asis\n\ @item 1\n\ Echo commands read from script files.\n\ \n\ @item 2\n\ Echo commands from functions.\n\ \n\ @item 4\n\ Echo commands read from command line.\n\ @end table\n\ \n\ More than one state can be active at once. For example, a value of 3 is\n\ equivalent to the command @kbd{echo on all}.\n\ \n\ The value of @code{echo_executing_commands} may be set by the @kbd{echo}\n\ command or the command line option @code{--echo-commands}.\n\ @end deftypefn")
 DEFUN (__request_drawnow__, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} __request_drawnow__ ()\n\ @deftypefnx {Built-in Function} {} __request_drawnow__ (@var{flag})\n\ Undocumented internal function.\n\ @end deftypefn")
 DEFUN (__gud_mode__, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} __gud_mode__ ()\n\ Undocumented internal function.\n\ @end deftypefn")
 DEFUN (filemarker, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} filemarker ()\n\ Returns or sets the character used to separate filename from the\n\ the subfunction names contained within the file. This can be used in\n\ a generic manner to interact with subfunctions. For example\n\ \n\ @example\n\ help ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ @end example\n\ \n\ @noindent\n\ returns the help string associated with the sub-function @code{mysubfunc}\n\ of the function @code{myfunc}. Another use of @code{filemarker} is when\n\ debugging it allows easier placement of breakpoints within sub-functions.\n\ For example\n\ \n\ @example\n\ dbstop ([\"myfunc\", filemarker, \"mysubfunc\"])\n\ @end example\n\ \n\ @noindent\n\ will set a breakpoint at the first line of the subfunction @code{mysubfunc}.\n\ @end deftypefn")

Variables

std::string VPS4 = "+ "
int Vecho_executing_commands = ECHO_OFF
octave_time Vlast_prompt_time = 0.0
std::string current_eval_string
bool get_input_from_eval_string = false
bool input_from_eval_string_pending = false
bool input_from_command_line_file = false
bool reading_fcn_file = false
bool reading_classdef_file = false
std::string curr_fcn_file_name
std::string curr_fcn_file_full_name
bool reading_script_file = false
FILE * ff_instream = 0
bool interactive = false
bool forced_interactive = false
int promptflag = 1
std::string current_input_line
bool octave_completion_matches_called = false
bool Vdrawnow_requested = false
bool Vdebugging = false
char Vfilemarker = '>'

Typedef Documentation


Function Documentation

DEFUN ( filemarker  ,
args  ,
nargout   
)

DEFUN ( __gud_mode__  ,
args   
)

DEFUN ( __request_drawnow__  ,
args   
)

DEFUN ( echo_executing_commands  ,
args  ,
nargout   
)

DEFUN ( completion_append_char  ,
args  ,
nargout   
)

DEFUN ( PS4  ,
args  ,
nargout   
)

DEFUN ( PS2  ,
args  ,
nargout   
)

DEFUN ( PS1  ,
args  ,
nargout   
)

DEFUN ( remove_input_event_hook  ,
args   
)

DEFUN ( add_input_event_hook  ,
args   
)

DEFUN ( re_read_readline_init_file  ,
args   
)

DEFUN ( read_readline_init_file  ,
args   
)

DEFUN ( completion_matches  ,
args  ,
nargout   
)

DEFUN ( echo  ,
args   
)

DEFUN ( keyboard  ,
args   
)

DEFUN ( yes_or_no  ,
args   
)

DEFUN ( input  ,
args  ,
nargout   
)

octave_value do_keyboard ( const octave_value_list args  ) 

FILE* get_input_from_file ( const std::string name,
int  warn 
)

FILE* get_input_from_stdin ( void   ) 

std::string gnu_readline ( const std::string s,
bool  force_readline 
)

void initialize_command_input ( void   ) 

int octave_read ( char *  buf,
unsigned  max_size 
)

bool octave_yes_or_no ( const std::string prompt  ) 


Variable Documentation

FILE* ff_instream = 0

bool interactive = false

bool Vdebugging = false

char Vfilemarker = '>'

std::string VPS4 = "+ "