Mercurial > octave
view libinterp/corefcn/input.h @ 29654:d13d090cb03a stable
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
Files affected: make_int.cc, file-editor-tab.cc, octave-qscintilla.cc,
Cell.cc, Cell.h, call-stack.cc, call-stack.h, cellfun.cc, data.cc,
debug.cc, dlmread.cc, error.cc, event-queue.h, fcn-info.cc,
fcn-info.h, file-io.cc, ft-text-renderer.cc, gl2ps-print.cc,
graphics.cc, graphics.in.h, help.cc, hex2num.cc, input.cc,
latex-text-renderer.cc, load-path.cc, load-save.cc, load-save.h,
ls-hdf5.cc, ls-mat-ascii.cc, ls-mat5.cc, ls-oct-text.cc, mex.cc,
mexproto.h, mxarray.h, oct-map.cc, oct-stream.cc, oct-stream.h,
pager.cc, pager.h, pr-output.cc, regexp.cc, settings.h,
stack-frame.cc, stack-frame.h, strfns.cc, syminfo.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, sysdep.cc, toplev.cc, utils.cc,
utils.h, variables.cc, __fltk_uigetfile__.cc, __init_fltk__.cc,
audioread.cc, gzip.cc, cdef-class.cc, cdef-manager.cc, cdef-method.cc,
cdef-object.cc, cdef-object.h, ov-base-diag.cc, ov-base-diag.h,
ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h,
ov-base-sparse.h, ov-base.cc, ov-base.h, ov-cell.cc, ov-cell.h,
ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-fcn-handle.cc, ov-java.cc, ov-lazy-idx.h, ov-perm.cc, ov-perm.h,
ov-range.h, ov-str-mat.cc, ov-struct.cc, ov-struct.h, ov-usr-fcn.cc,
ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, octave.cc, bp-table.cc, jit-ir.cc,
jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.h, lex.h, lex.ll,
oct-lvalue.cc, oct-parse.yy, parse.h, profiler.h, pt-eval.cc,
pt-eval.h, pt-jit.cc, pt-jit.h, pt-pr-code.cc, pt-tm-const.cc,
pt-tm-const.h, Array.h, CMatrix.cc, DiagArray2.h, PermMatrix.h,
Sparse.h, dMatrix.cc, fCMatrix.cc, fMatrix.cc, bsxfun-defs.cc,
oct-fftw.cc, oct-fftw.h, randpoisson.cc, sparse-chol.cc,
mx-inlines.cc, file-ops.cc, lo-sysdep.cc, oct-env.cc, oct-time.cc,
action-container.cc, action-container.h, base-list.h, caseless-str.h,
cmd-edit.cc, cmd-hist.cc, data-conv.cc, data-conv.h, f77-fcn.h,
file-info.cc, file-info.h, kpse.cc, kpse.h, lo-cutils.h, lo-hash.h,
lo-regexp.cc, oct-base64.cc, oct-base64.h, oct-binmap.h, oct-glob.cc,
oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sparse.h, oct-string.cc,
quit.cc, unwind-prot.h, url-transfer.cc, main.in.cc, mkoctfile.in.cc,
and shared-fcns.h.
(grafted from aef11bb4e6d1f303ad9de5688fcb7244ef48867e)
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 28 Apr 2021 22:57:42 -0400 |
parents | 0a5b15007766 |
children | 7854d5752dd2 |
line wrap: on
line source
//////////////////////////////////////////////////////////////////////// // // Copyright (C) 1993-2021 The Octave Project Developers // // See the file COPYRIGHT.md in the top-level directory of this // distribution or <https://octave.org/copyright/>. // // This file is part of Octave. // // Octave is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Octave is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Octave; see the file COPYING. If not, see // <https://www.gnu.org/licenses/>. // //////////////////////////////////////////////////////////////////////// // Use the GNU readline library for command line editing and history. #if ! defined (octave_input_h) #define octave_input_h 1 #include "octave-config.h" #include <cstdio> #include <memory> #include <string> #include "hook-fcn.h" #include "oct-time.h" #include "ovl.h" #include "pager.h" // TRUE after a call to completion_matches. extern bool octave_completion_matches_called; // TRUE if the plotting system has requested a call to drawnow at // the next user prompt. extern OCTINTERP_API bool Vdrawnow_requested; OCTAVE_DEPRECATED (6, "'Vtrack_line_num' is an obsolete internal variable; any uses should be removed") extern OCTINTERP_API bool Vtrack_line_num; extern octave::sys::time Vlast_prompt_time; class octave_value; namespace octave { class interpreter; class input_system { public: input_system (interpreter& interp); void initialize (bool line_editing); octave_value PS1 (const octave_value_list& args, int nargout); std::string PS1 (void) const { return m_PS1; } std::string PS1 (const std::string& s) { std::string val = m_PS1; m_PS1 = s; return val; } void set_PS1 (const std::string& s) { m_PS1 = s; } octave_value PS2 (const octave_value_list& args, int nargout); std::string PS2 (void) const { return m_PS2; } std::string PS2 (const std::string& s) { std::string val = m_PS2; m_PS2 = s; return val; } void set_PS2 (const std::string& s) { m_PS2 = s; } std::string last_debugging_command (void) const { return m_last_debugging_command; } std::string last_debugging_command (const std::string& s) { std::string val = m_last_debugging_command; m_last_debugging_command = s; return val; } octave_value completion_append_char (const octave_value_list& args, int nargout); char completion_append_char (void) const { return m_completion_append_char; } char completion_append_char (char c) { char val = m_completion_append_char; m_completion_append_char = c; return val; } void set_completion_append_char (char c) { m_completion_append_char = c; } octave_value gud_mode (const octave_value_list& args, int nargout); bool gud_mode (void) const { return m_gud_mode; } bool gud_mode (bool flag) { bool val = m_gud_mode; m_gud_mode = flag; return val; } void set_gud_mode (bool flag) { m_gud_mode = flag; } octave_value mfile_encoding (const octave_value_list& args, int nargout); std::string mfile_encoding (void) const { return m_mfile_encoding; } std::string mfile_encoding (const std::string& s) { std::string val = m_mfile_encoding; m_mfile_encoding = s; return val; } void set_mfile_encoding (const std::string& s) { m_mfile_encoding = s; } octave_value auto_repeat_debug_command (const octave_value_list& args, int nargout); bool auto_repeat_debug_command (void) const { return m_auto_repeat_debug_command; } bool auto_repeat_debug_command (bool val) { bool old_val = m_auto_repeat_debug_command; m_auto_repeat_debug_command = val; return old_val; } bool yes_or_no (const std::string& prompt); std::string interactive_input (const std::string& s, bool& eof); octave_value_list get_user_input (const octave_value_list& args, int nargout); bool have_input_event_hooks (void) const; void add_input_event_hook (const hook_function& hook_fcn); bool remove_input_event_hook (const std::string& hook_fcn_id); void clear_input_event_hooks (void); void run_input_event_hooks (void); private: interpreter& m_interpreter; // Primary prompt string. std::string m_PS1; // Secondary prompt string. std::string m_PS2; // Character to append after successful command-line completion // attempts. char m_completion_append_char; // TRUE if we are running in the Emacs GUD mode. bool m_gud_mode; // Codepage which is used to read .m files std::string m_mfile_encoding; // TRUE means repeat last debug command if the user just types RET. bool m_auto_repeat_debug_command; // If we are in debugging mode, this is the last command entered, // so that we can repeat the previous command if the user just // types RET. std::string m_last_debugging_command; hook_function_list m_input_event_hook_functions; bool m_initialized; std::string gnu_readline (const std::string& s, bool& eof) const; }; class base_reader { public: friend class input_reader; base_reader (interpreter& interp) : m_interpreter (interp) { } base_reader (const base_reader& x) : m_interpreter (x.m_interpreter) { } virtual ~base_reader (void) = default; virtual std::string get_input (const std::string& prompt, bool& eof) = 0; virtual std::string input_source (void) const { return s_in_src; } std::string octave_gets (const std::string& prompt, bool& eof); virtual bool input_from_terminal (void) const { return false; } virtual bool input_from_file (void) const { return false; } virtual bool input_from_eval_string (void) const { return false; } protected: interpreter& m_interpreter; private: static const std::string s_in_src; }; class input_reader { public: input_reader (interpreter& interp); input_reader (interpreter& interp, FILE *file); input_reader (interpreter& interp, const std::string& str); input_reader (const input_reader& ir) = default; input_reader& operator = (const input_reader& ir) = default; ~input_reader (void) = default; std::string get_input (const std::string& prompt, bool& eof) { return m_rep->get_input (prompt, eof); } std::string input_source (void) const { return m_rep->input_source (); } bool input_from_terminal (void) const { return m_rep->input_from_terminal (); } bool input_from_file (void) const { return m_rep->input_from_file (); } bool input_from_eval_string (void) const { return m_rep->input_from_eval_string (); } private: std::shared_ptr<base_reader> m_rep; }; } #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) OCTAVE_DEPRECATED (5, "use 'octave::input_system::yes_or_no' instead") extern bool octave_yes_or_no (const std::string& prompt); OCTAVE_DEPRECATED (5, "use 'octave::input_system::clear_input_event_hooks' instead") extern void remove_input_event_hook_functions (void); OCTAVE_DEPRECATED (5, "this function will be removed in a future version of Octave") extern OCTINTERP_API FILE * get_input_from_stdin (void); #endif #endif