changeset 18798:89448a7523b2

Add some more callbacks for root properties (bug #42347). * graphics.in.h (root prop. errormessage): set read-only and declare custom get method * graphics.in.h (root prop. diary, diaryfile, echo, recursionlimit): declare custom get/set methods * graphics.cc (root::properties::get_errormessage, set_diary, get_diary, set_diaryfile, get_diaryfile, set_echo, get_echo, set_recursionlimit, get_recursionlimit): new methods. * pager.cc (F__diaryfile__, F__diarystate__): new functions to retrieve diary info. * pager.cc: set default value "diary" for diary_file static variable. * input.cc (F__echostate__): new function to retrieve echo info.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 13 May 2014 18:51:52 +0200
parents 86818f2c4a92
children 692e16c9e488
files libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h libinterp/corefcn/input.cc libinterp/corefcn/pager.cc
diffstat 4 files changed, 146 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Thu May 15 14:24:21 2014 -0700
+++ b/libinterp/corefcn/graphics.cc	Tue May 13 18:51:52 2014 +0200
@@ -3257,6 +3257,89 @@
 }
 
 std::string
+root_figure::properties::get_diary (void) const
+{
+  bool is_diary_on = F__diarystate__ ()(0).bool_value ();
+  if (is_diary_on)
+    return std::string ("on");
+  else
+    return std::string ("off");
+}
+
+void
+root_figure::properties::set_diary (const octave_value& val)
+{
+  if (! error_state)
+    {
+      // Input checking and abrev. matching
+      diary.set (val, false);
+      
+      if (! error_state)
+        {
+          Fdiary (ovl (diary.current_value ()));
+
+          diary.run_listeners ();
+        }
+    }
+}
+
+std::string
+root_figure::properties::get_diaryfile (void) const
+{
+  return F__diaryfile__ ()(0).string_value ();
+}
+
+void
+root_figure::properties::set_diaryfile (const octave_value& val)
+{
+  if (! error_state)
+    {
+      // Input checking and abrev. matching
+      diaryfile.set (val, false);
+      
+      if (! error_state)
+        {
+          Fdiary (ovl (diaryfile.string_value ()));
+
+          diaryfile.run_listeners ();
+        }
+    }
+}
+
+std::string
+root_figure::properties::get_echo (void) const
+{
+  bool is_echo_on = F__echostate__ ()(0).bool_value ();
+  if (is_echo_on)
+    return std::string ("on");
+  else
+    return std::string ("off");
+}
+
+void
+root_figure::properties::set_echo (const octave_value& val)
+{
+  if (! error_state)
+    {
+      // Input checking and abrev. matching
+      echo.set (val, false);
+      
+      if (! error_state)
+        {
+          Fecho (ovl (echo.current_value ()));
+
+          echo.run_listeners ();
+        }
+    }
+}
+
+std::string
+root_figure::properties::get_errormessage (void) const
+{
+  return Flasterr ()(0).string_value ();
+}
+
+std::string
 root_figure::properties::get_format (void) const
 {
   return F__formatstring__ ()(0).string_value ();
@@ -3311,6 +3394,32 @@
     }
 }
 
+
+double
+root_figure::properties::get_recursionlimit (void) const
+{
+  return Fmax_recursion_depth ()(0).double_value ();
+}
+
+void
+root_figure::properties::set_recursionlimit (const octave_value& val)
+{
+  if (! error_state)
+    {
+      // Input checking and abrev. matching
+      recursionlimit.set (val, false);
+      
+      if (! error_state)
+        {
+          double dval = recursionlimit.double_value ();
+
+          Fmax_recursion_depth (ovl (dval));
+
+          recursionlimit.run_listeners ();
+        }
+    }
+}
+
 void
 figure::properties::set_integerhandle (const octave_value& val)
 {
--- a/libinterp/corefcn/graphics.in.h	Thu May 15 14:24:21 2014 -0700
+++ b/libinterp/corefcn/graphics.in.h	Tue May 13 18:51:52 2014 +0200
@@ -3107,16 +3107,10 @@
     // See the genprops.awk script for an explanation of the
     // properties declarations.
 
-    // FIXME: Matlab defines some root properties and uses them in
-    // the same way that Octave uses an internal static variable to
-    // keep track of state.  set (0, "echo", "on") is equivalent
-    // to Octave's echo ("on"). Properties that still dont have callbacks
-    // are : diary, diaryfileecho, errormessage, language, and recursionlimit.
-    // Note that these properties (and the monitorpositions,
-    // pointerlocation, and pointerwindow properties) are not yet used
-    // by Octave, so setting them will have no effect, and changes
-    // made elswhere (say, the diary or format functions) will not
-    // cause these properties to be updated.
+    // FIXME: Properties that still dont have callbacks are:
+    // language, monitorpositions, pointerlocation, pointerwindow.
+    // Note that these properties are not yet used by Octave, so setting
+    // them will have no effect.
 
     // Programming note: Keep property list sorted if new ones are added.
 
@@ -3124,10 +3118,10 @@
       handle_property callbackobject Sr , graphics_handle ()
       array_property commandwindowsize r , Matrix (1, 2, 0)
       handle_property currentfigure S , graphics_handle ()
-      bool_property diary , "off"
-      string_property diaryfile , "diary"
-      bool_property echo , "off"
-      string_property errormessage , ""
+      bool_property diary GS , "off"
+      string_property diaryfile GS , "diary"
+      bool_property echo GS , "off"
+      string_property errormessage Gr , ""
       string_property fixedwidthfontname , "Courier"
       radio_property format GS , "+|bank|bit|hex|long|longe|longeng|longg|native-bit|native-hex|none|rat|{short}|shorte|shorteng|shortg"
       radio_property formatspacing GS , "compact|{loose}"
@@ -3135,7 +3129,7 @@
       array_property monitorpositions , Matrix (1, 4, 0)
       array_property pointerlocation , Matrix (1, 2, 0)
       double_property pointerwindow r , 0.0
-      double_property recursionlimit , 256.0
+      double_property recursionlimit GS , 256.0
       double_property screendepth r , default_screendepth ()
       double_property screenpixelsperinch r , default_screenpixelsperinch ()
       array_property screensize r , default_screensize ()
--- a/libinterp/corefcn/input.cc	Thu May 15 14:24:21 2014 -0700
+++ b/libinterp/corefcn/input.cc	Tue May 13 18:51:52 2014 +0200
@@ -1005,6 +1005,15 @@
   return retval;
 }
 
+DEFUN (__echostate__, args, nargout,
+       "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{state} =} __echostate__ ()\n\
+Undocumented internal function\n\
+@end deftypefn")
+{
+  return ovl (Vecho_executing_commands == ECHO_SCRIPTS);
+}
+
 DEFUN (completion_matches, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} completion_matches (@var{hint})\n\
--- a/libinterp/corefcn/pager.cc	Thu May 15 14:24:21 2014 -0700
+++ b/libinterp/corefcn/pager.cc	Tue May 13 18:51:52 2014 +0200
@@ -52,7 +52,7 @@
 static bool write_to_diary_file = false;
 
 // The name of the current diary file.
-static std::string diary_file;
+static std::string diary_file ("diary");
 
 // The diary file.
 static std::ofstream external_diary_file;
@@ -589,6 +589,24 @@
   return retval;
 }
 
+DEFUN (__diaryfile__, args, nargout,
+       "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{fname} =} __diaryfile__ ()\n\
+Undocumented internal function\n\
+@end deftypefn")
+{
+  return ovl (diary_file);
+}
+
+DEFUN (__diarystate__, args, nargout,
+       "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{state} =} __diarystate__ ()\n\
+Undocumented internal function\n\
+@end deftypefn")
+{
+  return ovl (write_to_diary_file);
+}
+
 DEFUN (more, args, ,
        "-*- texinfo -*-\n\
 @deftypefn  {Command} {} more\n\