comparison src/input.cc @ 2181:138b3c98dc85

[project @ 1996-05-13 18:02:31 by jwe]
author jwe
date Mon, 13 May 1996 18:06:22 +0000
parents a84f9c1fe38b
children bd389b53befa
comparison
equal deleted inserted replaced
2180:b087e5e62bec 2181:138b3c98dc85
61 #include "str-vec.h" 61 #include "str-vec.h"
62 62
63 #include "defun.h" 63 #include "defun.h"
64 #include "dirfns.h" 64 #include "dirfns.h"
65 #include "error.h" 65 #include "error.h"
66 #include "gripes.h"
66 #include "help.h" 67 #include "help.h"
67 #include "input.h" 68 #include "input.h"
68 #include "oct-map.h" 69 #include "oct-map.h"
69 #include "oct-hist.h" 70 #include "oct-hist.h"
70 #include "toplev.h" 71 #include "toplev.h"
78 #include "sysdep.h" 79 #include "sysdep.h"
79 #include "user-prefs.h" 80 #include "user-prefs.h"
80 #include "utils.h" 81 #include "utils.h"
81 #include "variables.h" 82 #include "variables.h"
82 83
84 // Primary prompt string.
85 static string Vps1;
86
87 // Secondary prompt string.
88 static string Vps2;
89
90 // String printed before echoed input (enabled by --echo-input).
91 string Vps4;
92
93 // Character to append after successful command-line completion attempts.
94 static char Vcompletion_append_char;
95
83 // Global pointer for eval(). 96 // Global pointer for eval().
84 string current_eval_string; 97 string current_eval_string;
85 98
86 // Nonzero means get input from current_eval_string. 99 // Nonzero means get input from current_eval_string.
87 int get_input_from_eval_string = 0; 100 int get_input_from_eval_string = 0;
369 if (do_echo) 382 if (do_echo)
370 { 383 {
371 if (forced_interactive) 384 if (forced_interactive)
372 { 385 {
373 if (promptflag > 0) 386 if (promptflag > 0)
374 octave_stdout << decode_prompt_string (user_pref.ps1); 387 octave_stdout << decode_prompt_string (Vps1);
375 else 388 else
376 octave_stdout << decode_prompt_string (user_pref.ps2); 389 octave_stdout << decode_prompt_string (Vps2);
377 } 390 }
378 else 391 else
379 octave_stdout << decode_prompt_string (user_pref.ps4); 392 octave_stdout << decode_prompt_string (Vps4);
380 393
381 if (! input_string.empty ()) 394 if (! input_string.empty ())
382 { 395 {
383 octave_stdout << input_string; 396 octave_stdout << input_string;
384 397
463 char *retval = 0; 476 char *retval = 0;
464 477
465 if ((interactive || forced_interactive) 478 if ((interactive || forced_interactive)
466 && (! (reading_fcn_file || reading_script_file))) 479 && (! (reading_fcn_file || reading_script_file)))
467 { 480 {
468 const char *ps = (promptflag > 0) ? user_pref.ps1.c_str () : 481 const char *ps = (promptflag > 0) ? Vps1.c_str () :
469 user_pref.ps2.c_str (); 482 Vps2.c_str ();
470 483
471 string prompt = decode_prompt_string (ps); 484 string prompt = decode_prompt_string (ps);
472 485
473 if (interactive) 486 if (interactive)
474 { 487 {
853 866
854 if (matches == 1 && looks_like_struct (buf)) 867 if (matches == 1 && looks_like_struct (buf))
855 rl_completion_append_character = '.'; 868 rl_completion_append_character = '.';
856 else 869 else
857 rl_completion_append_character 870 rl_completion_append_character
858 = user_pref.completion_append_char; 871 = Vcompletion_append_char;
859 872
860 return buf; 873 return buf;
861 } 874 }
862 } 875 }
863 } 876 }
1182 } 1195 }
1183 1196
1184 return retval; 1197 return retval;
1185 } 1198 }
1186 1199
1200 static int
1201 ps1 (void)
1202 {
1203 int status = 0;
1204
1205 Vps1 = builtin_string_variable ("PS1");
1206
1207 return status;
1208 }
1209
1210 static int
1211 ps2 (void)
1212 {
1213 int status = 0;
1214
1215 Vps2 = builtin_string_variable ("PS2");
1216
1217 return status;
1218 }
1219
1220 static int
1221 ps4 (void)
1222 {
1223 int status = 0;
1224
1225 Vps4 = builtin_string_variable ("PS4");
1226
1227 return status;
1228 }
1229
1230 static int
1231 completion_append_char (void)
1232 {
1233 int status = 0;
1234
1235 string s = builtin_string_variable ("completion_append_char");
1236
1237 switch (s.length ())
1238 {
1239 case 1:
1240 Vcompletion_append_char = s[0];
1241 break;
1242
1243 case 0:
1244 Vcompletion_append_char = '\0';
1245 break;
1246
1247 default:
1248 warning ("completion_append_char must be a single character");
1249 status = -1;
1250 break;
1251 }
1252
1253 return status;
1254 }
1255
1256 void
1257 symbols_of_input (void)
1258 {
1259 DEFVAR (PS1, "\\s:\\#> ", 0, ps1,
1260 "primary prompt string");
1261
1262 DEFVAR (PS2, "> ", 0, ps2,
1263 "secondary prompt string");
1264
1265 DEFVAR (PS4, "+ ", 0, ps4,
1266 "string printed before echoed input (enabled by --echo-input)");
1267
1268 DEFVAR (completion_append_char, " ", 0, completion_append_char,
1269 "the string to append after successful command-line completion attempts");
1270 }
1271
1187 /* 1272 /*
1188 ;;; Local Variables: *** 1273 ;;; Local Variables: ***
1189 ;;; mode: C++ *** 1274 ;;; mode: C++ ***
1190 ;;; End: *** 1275 ;;; End: ***
1191 */ 1276 */