00001 /* 00002 00003 Copyright (C) 1993-2012 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 // Use the GNU readline library for command line editing and hisory. 00024 00025 #if !defined (octave_input_h) 00026 #define octave_input_h 1 00027 00028 #include <cstdio> 00029 00030 #include <string> 00031 00032 #include "oct-time.h" 00033 #include "oct-obj.h" 00034 #include "pager.h" 00035 00036 class octave_value; 00037 00038 extern OCTINTERP_API int octave_read (char *buf, unsigned max_size); 00039 extern OCTINTERP_API FILE *get_input_from_file (const std::string& name, int warn = 1); 00040 extern OCTINTERP_API FILE *get_input_from_stdin (void); 00041 00042 // Global pointer for eval(). 00043 extern std::string current_eval_string; 00044 00045 // TRUE means get input from current_eval_string. 00046 extern bool get_input_from_eval_string; 00047 00048 // TRUE means we haven't been asked for the input from 00049 // current_eval_string yet. 00050 extern bool input_from_eval_string_pending; 00051 00052 // TRUE means that input is coming from a file that was named on 00053 // the command line. 00054 extern bool input_from_command_line_file; 00055 00056 // TRUE means that stdin is a terminal, not a pipe or redirected file. 00057 extern bool stdin_is_tty; 00058 00059 // TRUE means we're parsing a function file. 00060 extern bool reading_fcn_file; 00061 00062 // Simple name of function file we are reading. 00063 extern std::string curr_fcn_file_name; 00064 00065 // Full name of file we are reading. 00066 extern std::string curr_fcn_file_full_name; 00067 00068 // TRUE means we're parsing a script file. 00069 extern bool reading_script_file; 00070 00071 // TRUE means we're parsing a classdef file. 00072 extern bool reading_classdef_file; 00073 00074 // If we are reading from an M-file, this is it. 00075 extern FILE *ff_instream; 00076 00077 // TRUE means this is an interactive shell. 00078 extern bool interactive; 00079 00080 // TRUE means the user forced this shell to be interactive (-i). 00081 extern bool forced_interactive; 00082 00083 // Should we issue a prompt? 00084 extern int promptflag; 00085 00086 // A line of input. 00087 extern std::string current_input_line; 00088 00089 // TRUE after a call to completion_matches. 00090 extern bool octave_completion_matches_called; 00091 00092 // TRUE if the plotting system has requested a call to drawnow at 00093 // the next user prompt. 00094 extern OCTINTERP_API bool Vdrawnow_requested; 00095 00096 // TRUE if we are in debugging mode. 00097 extern OCTINTERP_API bool Vdebugging; 00098 00099 extern std::string gnu_readline (const std::string& s, bool force_readline = false); 00100 00101 extern void initialize_command_input (void); 00102 00103 extern bool octave_yes_or_no (const std::string& prompt); 00104 00105 extern octave_value do_keyboard (const octave_value_list& args = octave_value_list ()); 00106 00107 extern std::string VPS4; 00108 00109 extern char Vfilemarker; 00110 00111 enum echo_state 00112 { 00113 ECHO_OFF = 0, 00114 ECHO_SCRIPTS = 1, 00115 ECHO_FUNCTIONS = 2, 00116 ECHO_CMD_LINE = 4 00117 }; 00118 00119 extern int Vecho_executing_commands; 00120 00121 extern octave_time Vlast_prompt_time; 00122 00123 #endif