Mercurial > hg > octave-avbm
changeset 1044:1aa6f2edd975
[project @ 1995-01-18 16:35:01 by jwe]
author | jwe |
---|---|
date | Wed, 18 Jan 1995 16:35:01 +0000 |
parents | b8dd808bc61f |
children | cb4eaa324faf |
files | src/input.cc src/user-prefs.cc src/user-prefs.h src/variables.cc |
diffstat | 4 files changed, 59 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/input.cc +++ b/src/input.cc @@ -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; }
--- a/src/user-prefs.cc +++ b/src/user-prefs.cc @@ -77,6 +77,7 @@ user_pref.pager_binary = 0; user_pref.ps1 = 0; user_pref.ps2 = 0; + user_pref.ps4 = 0; user_pref.pwd = 0; } @@ -732,6 +733,26 @@ } int +sv_ps4 (void) +{ + int status = 0; + + char *s = builtin_string_variable ("PS4"); + if (s) + { + delete [] user_pref.ps4; + user_pref.ps4 = s; + } + else + { + warning ("invalid value specified for PS4"); + status = -1; + } + + return status; +} + +int sv_pwd (void) { int status = 0;
--- a/src/user-prefs.h +++ b/src/user-prefs.h @@ -61,6 +61,7 @@ char *pager_binary; char *ps1; char *ps2; + char *ps4; char *pwd; }; @@ -104,6 +105,7 @@ extern int sv_pager_binary (void); extern int sv_ps1 (void); extern int sv_ps2 (void); +extern int sv_ps4 (void); extern int sv_pwd (void); #endif
--- a/src/variables.cc +++ b/src/variables.cc @@ -1461,6 +1461,9 @@ DEFVAR ("PS2", SBV_PS2, "> ", 0, 0, 1, sv_ps2, "secondary prompt string"); + DEFVAR ("PS4", SBV_PS4, "+ ", 0, 0, 1, sv_ps4, + "string printed before echoed input (enabled by --echo-input)"); + DEFVAR ("PWD", SBV_PWD, get_working_directory ("initialize_globals"), 0, 1, 1, sv_pwd, "current working directory");