Mercurial > hg > octave-terminal
changeset 1423:2d88758ed94b
[project @ 1995-09-18 16:04:37 by jwe]
author | jwe |
---|---|
date | Mon, 18 Sep 1995 16:04:37 +0000 |
parents | afde7233c4dc |
children | 8b1837bc1eac |
files | src/error.cc src/octave.cc src/user-prefs.cc src/user-prefs.h src/variables.cc |
diffstat | 5 files changed, 31 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/error.cc +++ b/src/error.cc @@ -34,6 +34,7 @@ #include "oct-obj.h" #include "pager.h" #include "tree-const.h" +#include "user-prefs.h" #include "utils.h" // Current error state. @@ -47,6 +48,10 @@ { flush_output_to_pager (); + int to_beep_or_not_to_beep = user_pref.beep_on_error && ! error_state; + + if (to_beep_or_not_to_beep) + cerr << "\a"; if (name) cerr << name << ": "; cerr.vform (fmt, args); @@ -54,6 +59,8 @@ ostrstream output_buf; + if (to_beep_or_not_to_beep) + output_buf << "\a"; if (name) output_buf << name << ": "; output_buf.vform (fmt, args); @@ -75,9 +82,6 @@ { if (error_state != -2) { - if (! error_state) - error_state = 1; - if (! suppress_octave_error_messages) { if (fmt) @@ -87,8 +91,6 @@ int len = strlen (fmt); if (fmt[len - 1] == '\n') { - error_state = -2; - if (len > 1) { char *tmp_fmt = strsave (fmt); @@ -96,6 +98,8 @@ verror (name, tmp_fmt, args); delete [] tmp_fmt; } + + error_state = -2; } else verror (name, fmt, args); @@ -104,6 +108,9 @@ else panic ("error_1: invalid format"); } + + if (! error_state) + error_state = 1; } }
--- a/src/octave.cc +++ b/src/octave.cc @@ -507,6 +507,7 @@ { bind_builtin_variable ("PS1", ">> "); bind_builtin_variable ("PS2", ""); + bind_builtin_variable ("beep_on_error", "true"); bind_builtin_variable ("default_save_format", "mat-binary"); bind_builtin_variable ("define_all_return_values", "true"); bind_builtin_variable ("do_fortran_indexing", "true");
--- a/src/user-prefs.cc +++ b/src/user-prefs.cc @@ -45,6 +45,7 @@ init_user_prefs (void) { user_pref.automatic_replot = 0; + user_pref.beep_on_error = 0; user_pref.define_all_return_values = 0; user_pref.do_fortran_indexing = 0; user_pref.empty_list_elements_ok = 0; @@ -130,6 +131,17 @@ } +// Should we beep obnoxiously before printing error messages? + +int +beep_on_error (void) +{ + user_pref.beep_on_error = check_str_pref ("beep_on_error"); + + return 0; +} + + // Should variables returned from functions have default values if // they are otherwise uninitialized?
--- a/src/user-prefs.h +++ b/src/user-prefs.h @@ -27,6 +27,7 @@ struct user_preferences { int automatic_replot; + int beep_on_error; int define_all_return_values; int do_fortran_indexing; int empty_list_elements_ok; @@ -74,6 +75,7 @@ extern void init_user_prefs (void); extern int automatic_replot (void); +extern int beep_on_error (void); extern int define_all_return_values (void); extern int do_fortran_indexing (void); extern int empty_list_elements_ok (void);
--- a/src/variables.cc +++ b/src/variables.cc @@ -1609,6 +1609,10 @@ 0, automatic_replot, "if true, auto-insert a replot command when a plot changes"); + DEFVAR ("beep_on_error", SBV_beep_on_error, "false", 0, + beep_on_error, + "if true, beep before printing error messages"); + DEFVAR ("default_return_value", SBV_default_return_value, Matrix (), 0, 0, "the default for value for unitialized variables returned from\n\