diff libinterp/interpfcn/input.h @ 16209:e7ff32e7cf82

move global promptflag variable to octave_reader class * input.h, input.cc (promptflag): Declare as member of octave_base_reader and rename to pflag. (octave_base_reader::reset, octave_base_reader::promptflag, octave_base_reader::increment_promptflag, octave_reader::decrement_promptflag, octave_reader::promptflag, octave_reader::increment_promptflag, octave_reader::decrement_promptflag): New functions. * lex.ll (octave_lexer::decrement_promptflag, octave_lexer::promptflag, octave_lexer::increment_promptflag, octave_lexer::decrement_promptflag): New functions. Use them instead of global promptflag variable. (octave_lexer::reset): Call input_reader.reset. * oct-parse.in.yy (input): Don't reset promptflag here.
author John W. Eaton <jwe@octave.org>
date Wed, 06 Mar 2013 20:20:35 -0500
parents ed91ab4d4515
children bf8397caeff1
line wrap: on
line diff
--- a/libinterp/interpfcn/input.h
+++ b/libinterp/interpfcn/input.h
@@ -43,9 +43,6 @@
 // TRUE means the user forced this shell to be interactive (-i).
 extern bool forced_interactive;
 
-// Should we issue a prompt?
-extern int promptflag;
-
 // TRUE after a call to completion_matches.
 extern bool octave_completion_matches_called;
 
@@ -85,7 +82,7 @@
 
   friend class octave_input_reader;
 
-  octave_base_reader (void) : count (1) { }
+  octave_base_reader (void) : count (1), pflag (0) { }
 
   octave_base_reader (const octave_base_reader&) : count (1) { }
 
@@ -95,12 +92,31 @@
 
   virtual std::string input_source (void) const { return in_src; }
 
+  void reset (void) { promptflag (1); }
+
+  void increment_promptflag (void) { pflag++; }
+
+  void decrement_promptflag (void) { pflag--; }
+
+  int promptflag (void) const { return pflag; }
+
+  int promptflag (int n)
+  {
+    int retval = pflag;
+    pflag = n;
+    return retval;
+  }
+
   std::string octave_gets (bool& eof);
 
 private:
 
   int count;
 
+  int pflag;
+
+  void do_input_echo (const std::string&) const;
+
   static const std::string in_src;
 };
 
@@ -198,6 +214,16 @@
       delete rep;
   }
 
+  void reset (void) { return rep->reset (); }
+
+  void increment_promptflag (void) { rep->increment_promptflag (); }
+
+  void decrement_promptflag (void) { rep->decrement_promptflag (); }
+
+  int promptflag (void) const { return rep->promptflag (); }
+
+  int promptflag (int n) { return rep->promptflag (n); }
+
   std::string get_input (bool& eof)
   {
     return rep->get_input (eof);