changeset 16528:9bc1f8278966

allow GUI to customize prompts at startup * octave-link.h (octave_link::set_default_prompts, octave_link::do_set_default_prompts): New functions. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::do_set_default_prompts): New function. * input.h, input.cc (set_default_prompts): New function. * defaults.cc (install_defaults): Call set_default_prompts. * octave.cc (traditional): New static variable. (octave_process_command_line): Set it and defer calling maximum_braindamage until after defaults have been set. (octave_initialize_interpreter): Call sysdep_init and install_defaults here. (octave_main): Not here. * main-cli.cc (main): Or here. * main.cc (main): Or here.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Apr 2013 00:17:21 -0400
parents 8701792e16ec
children faccc20d5f39
files libgui/src/octave-qt-link.cc libgui/src/octave-qt-link.h libinterp/interpfcn/defaults.cc libinterp/interpfcn/input.cc libinterp/interpfcn/input.h libinterp/interpfcn/octave-link.h libinterp/octave.cc src/main-cli.cc src/main.cc
diffstat 9 files changed, 51 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/octave-qt-link.cc
+++ b/libgui/src/octave-qt-link.cc
@@ -251,6 +251,16 @@
 }
 
 void
+octave_qt_link::do_set_default_prompts (std::string& ps1, std::string& ps2,
+                                        std::string& ps4)
+{
+  ps1 = ">> ";
+  ps2 = "";
+  ps4 = "";
+}
+
+
+void
 octave_qt_link::do_insert_debugger_pointer (const std::string& file, int line)
 {
   emit insert_debugger_pointer_signal (QString::fromStdString (file), line);
--- a/libgui/src/octave-qt-link.h
+++ b/libgui/src/octave-qt-link.h
@@ -99,6 +99,9 @@
 
   void do_update_breakpoint (bool insert, const std::string& file, int line);
 
+  void do_set_default_prompts (std::string& ps1, std::string& ps2,
+                               std::string& ps4);
+
 private:
 
   // No copying!
--- a/libinterp/interpfcn/defaults.cc
+++ b/libinterp/interpfcn/defaults.cc
@@ -463,6 +463,8 @@
   set_site_defaults_file ();
 
   set_built_in_docstrings_file ();
+
+  set_default_prompts ();
 }
 
 DEFUN (EDITOR, args, nargout,
--- a/libinterp/interpfcn/input.cc
+++ b/libinterp/interpfcn/input.cc
@@ -57,6 +57,7 @@
 #include "oct-map.h"
 #include "oct-hist.h"
 #include "toplev.h"
+#include "octave-link.h"
 #include "oct-obj.h"
 #include "ov-fcn-handle.h"
 #include "pager.h"
@@ -75,10 +76,10 @@
 #include "variables.h"
 
 // Primary prompt string.
-static std::string VPS1 = "\\s:\\#> ";
+static std::string VPS1;
 
 // Secondary prompt string.
-static std::string VPS2 = "> ";
+static std::string VPS2;
 
 // String printed before echoed input (enabled by --echo-input).
 std::string VPS4 = "+ ";
@@ -134,6 +135,16 @@
 }
 
 void
+set_default_prompts (void)
+{
+  VPS1 = "\\s:\\#> ";
+  VPS2 = "> ";
+  VPS4 = "+ ";
+
+  octave_link::set_default_prompts (VPS1, VPS2, VPS4);
+}
+
+void
 octave_base_reader::do_input_echo (const std::string& input_string) const
 {
   int do_echo = LEXER->reading_script_file ?
--- a/libinterp/interpfcn/input.h
+++ b/libinterp/interpfcn/input.h
@@ -61,6 +61,8 @@
 
 extern void remove_input_event_hook_functions (void);
 
+extern void set_default_prompts (void);
+
 extern std::string VPS4;
 
 extern char Vfilemarker;
--- a/libinterp/interpfcn/octave-link.h
+++ b/libinterp/interpfcn/octave-link.h
@@ -256,6 +256,13 @@
 
   static void connect_link (octave_link *);
 
+  static void set_default_prompts (std::string& ps1, std::string& ps2,
+                                   std::string& ps4)
+  {
+    if (enabled ())
+      instance->do_set_default_prompts (ps1, ps2, ps4);
+  }
+
 private:
 
   static octave_link *instance;
@@ -359,6 +366,9 @@
 
   virtual void do_update_breakpoint (bool insert,
                                      const std::string& file, int line) = 0;
+
+  virtual void do_set_default_prompts (std::string& ps1, std::string& ps2,
+                                       std::string& ps4) = 0;
 };
 
 #endif // OCTAVELINK_H
--- a/libinterp/octave.cc
+++ b/libinterp/octave.cc
@@ -178,6 +178,9 @@
 // If TRUE, the GUI should be started.
 static bool start_gui = false;
 
+// If TRUE use traditional settings (--traditional)
+static bool traditional = false;
+
 // Long options.  See the comments in getopt.h for the meanings of the
 // fields in this structure.
 #define BUILT_IN_DOCSTRINGS_FILE_OPTION 1
@@ -644,10 +647,6 @@
 {
   octave_process_command_line (argc, argv);
 
-  sysdep_init ();
-
-  install_defaults ();
-
   octave_initialize_interpreter (argc, argv, embedded);
 
   return octave_execute_interpreter ();
@@ -814,7 +813,7 @@
           break;
 
         case TRADITIONAL_OPTION:
-          maximum_braindamage ();
+          traditional = true;
           break;
 
         default:
@@ -849,6 +848,13 @@
 
   octave_thread::init ();
 
+  sysdep_init ();
+
+  install_defaults ();
+
+  if (traditional)
+    maximum_braindamage ();
+
   init_signals ();
 
   octave_ieee_init ();
--- a/src/main-cli.cc
+++ b/src/main-cli.cc
@@ -33,10 +33,6 @@
 {
   octave_process_command_line (argc, argv);
 
-  sysdep_init ();
-
-  install_defaults ();
-
   octave_initialize_interpreter (argc, argv, 0);
 
   return octave_execute_interpreter ();
--- a/src/main.cc
+++ b/src/main.cc
@@ -36,10 +36,6 @@
 
   octave_process_command_line (argc, argv);
 
-  sysdep_init ();
-
-  install_defaults ();
-
   if (octave_starting_gui ())
     retval = octave_start_gui (argc, argv);
   else