diff src/input.cc @ 1044:1aa6f2edd975

[project @ 1995-01-18 16:35:01 by jwe]
author jwe
date Wed, 18 Jan 1995 16:35:01 +0000
parents 69e610fb0013
children b326ac82dc9f
line wrap: on
line diff
--- a/src/input.cc	Wed Jan 18 15:56:40 1995 +0000
+++ b/src/input.cc	Wed Jan 18 16:35:01 1995 +0000
@@ -45,6 +45,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <iostream.h>
+#include <strstream.h>
 #include <string.h>
 #include <assert.h>
 #include <signal.h>
@@ -429,6 +430,33 @@
   return result;
 }
 
+static void
+do_input_echo (const char *input_string)
+{
+  if (echo_input)
+    {
+      ostrstream buf;
+
+      if (! forced_interactive)
+	{
+	  char *prefix = decode_prompt_string (user_pref.ps4);
+	  buf << prefix;
+	  delete [] prefix;
+	}
+
+      if (input_string)
+	{
+	  buf << input_string;
+	  int len = strlen (input_string);
+	  if (input_string[len-1] != '\n')
+	    buf << "\n";
+	}
+
+      maybe_page_output (buf);
+    }
+}
+
+
 // Use GNU readline to get an input line and store it in the history
 // list.
 
@@ -469,13 +497,7 @@
 
       maybe_write_to_diary_file (octave_gets_line);
 
-      if (echo_input)
-	{
-	  if (! forced_interactive)
-	    cout << "+ ";
-
-	  cout << octave_gets_line << "\n";
-	}
+      do_input_echo (octave_gets_line);
     }
 
   maybe_write_to_diary_file ("\n");
@@ -562,17 +584,14 @@
 	delete [] stashed_line;
 
       stashed_line = strsave (buf);
+
       current_input_line = stashed_line;
 
-      if (echo_input && current_input_line && *current_input_line)
-	{
-	  if (! forced_interactive)
-	    cout << "+ ";
+      do_input_echo (current_input_line);
+    }
 
-	  cout << current_input_line << "\n";
-	}
-    }
   input_line_number++;
+
   return status;
 }