diff libinterp/corefcn/pr-output.cc @ 18735:28eab2d84190

Add callbacks for root properties format and formatspacing (bug #42135). * graphics.in.h (root format and formatspacing properties) define custom get and set methods * graphics.in.h (root format property) replace allowed value "rationale" (not supported by Fformat) by "rat" * pr-output.cc: new static variable format_string * pr-output.cc (set_format_style): store the actual current format in format_string * pr-output.cc (F__compactformat__): new defun to set/get the current Vcompactformat state * pr-output.cc (F__formatstring__): new defun to set/get the current format string
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Mon, 21 Apr 2014 17:17:15 +0200
parents 5bd1ca29c5f0
children 307a67b04253
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc	Tue May 06 19:57:44 2014 -0700
+++ b/libinterp/corefcn/pr-output.cc	Mon Apr 21 17:17:15 2014 +0200
@@ -3612,20 +3612,25 @@
   Voutput_max_field_width = fw;
 }
 
+static std::string format_string ("short");
+
 static void
 set_format_style (int argc, const string_vector& argv)
 {
   int idx = 1;
+  std::string format;
 
   if (--argc > 0)
     {
       std::string arg = argv[idx++];
+      format = arg;
 
       if (arg == "short")
         {
           if (--argc > 0)
             {
               arg = argv[idx++];
+              format.append (arg);
 
               if (arg == "e")
                 {
@@ -3703,6 +3708,7 @@
           if (--argc > 0)
             {
               arg = argv[idx++];
+              format.append (arg);
 
               if (arg == "e")
                 {
@@ -3800,6 +3806,7 @@
           if (--argc > 0)
             {
               arg = argv[idx++];
+              format.append (arg);
 
               if (arg.length () == 3)
                 plus_format_chars = arg;
@@ -3838,21 +3845,30 @@
       else if (arg == "compact")
         {
           Vcompact_format = true;
+          return;
         }
       else if (arg == "loose")
         {
           Vcompact_format = false;
+          return;
         }
       else
-        error ("format: unrecognized format state '%s'", arg.c_str ());
+        {
+          error ("format: unrecognized format state '%s'", arg.c_str ());
+          return;
+        }  
     }
   else
     {
       init_format_state ();
       set_output_prec_and_fw (5, 10);
+      format = std::string ("short");
     }
+
+  format_string = format;
 }
 
+
 DEFUN (format, args, ,
        "-*- texinfo -*-\n\
 @deftypefn  {Command} {} format\n\
@@ -4037,6 +4053,25 @@
   return retval;
 }
 
+DEFUN (__compactformat__, args, nargout,
+       "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{val} =} __compactformat__ ()\n\
+@deftypefnx {Built-in Function} {} __compactformat__ (@var{TRUE|FALSE})\n\
+Undocumented internal function\n\
+@end deftypefn")
+{
+  return SET_INTERNAL_VARIABLE (compact_format);
+}
+
+DEFUN (__formatstring__, args, nargout,
+       "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{val} =} __formatstring__ ()\n\
+Undocumented internal function\n\
+@end deftypefn")
+{
+  return ovl (format_string);
+}
+
 DEFUN (fixed_point_format, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {@var{val} =} fixed_point_format ()\n\