changeset 24668:d4dd741b2794

new octave_value functions for formatting output * ov.h, ov.cc, ov-base.h, ov-base.cc, and numeric/matrix-like objects: (get_edit_display_format): New function. (edit_display): Pass float_display_format as argument. * pr-output.h, pr-output.cc: New variants of the octave_print_internal functions that accept display formats. Expose functions for getting display formats. * variable-editor-model.cc: Maintain display format for model.
author John W. Eaton <jwe@octave.org>
date Thu, 01 Feb 2018 06:36:50 -0500
parents 56f889d66b7c
children 15fe766fbaf5
files libgui/src/variable-editor-model.cc libinterp/corefcn/pr-output.cc libinterp/corefcn/pr-output.h libinterp/octave-value/ov-base-diag.cc libinterp/octave-value/ov-base-diag.h libinterp/octave-value/ov-base-mat.cc libinterp/octave-value/ov-base-mat.h libinterp/octave-value/ov-base-scalar.cc libinterp/octave-value/ov-base-scalar.h libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-base.h libinterp/octave-value/ov-cell.cc libinterp/octave-value/ov-perm.cc libinterp/octave-value/ov-perm.h libinterp/octave-value/ov-re-mat.cc libinterp/octave-value/ov-str-mat.cc libinterp/octave-value/ov-str-mat.h libinterp/octave-value/ov-struct.cc libinterp/octave-value/ov-struct.h libinterp/octave-value/ov.cc libinterp/octave-value/ov.h
diffstat 21 files changed, 276 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/variable-editor-model.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libgui/src/variable-editor-model.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -39,6 +39,7 @@
 
 #include "ov.h"
 #include "parse.h"
+#include "pr-flt-fmt.h"
 #include "utils.h"
 #include "variables.h"
 
@@ -124,13 +125,23 @@
     }
 }
 
+static float_display_format
+get_edit_display_format (const octave_value& val)
+{
+  // FIXME: make this limit configurable.
+
+  return (val.numel () > 250000
+          ? float_display_format () : val.get_edit_display_format ());
+}
+
 struct variable_editor_model::impl
 {
   struct cell
   {
     cell (void) : m_defined (false) { }
 
-    cell (const octave_value& val, int r, int c)
+    cell (const float_display_format& fmt, const octave_value& val,
+          int r, int c)
       : m_defined (true), m_data ("no display"), m_status_tip ("status"),
         m_tool_tip ("tip"), m_requires_sub_editor (false),
         m_editor_type (sub_none)
@@ -141,7 +152,7 @@
 
           octave_value ov = cval(r,c);
 
-          init_data_and_sub_editor (val, cval(r,c), r, c);
+          init_data_and_sub_editor (fmt, val, cval(r,c), r, c);
         }
       else if (val.isstruct ())
         {
@@ -152,7 +163,7 @@
 
               octave_scalar_map m = val.scalar_map_value ();
 
-              init_data_and_sub_editor (val, m.contents (r), r, c);
+              init_data_and_sub_editor (fmt, val, m.contents (r), r, c);
             }
           else if (val.rows () == 1 || val.columns () == 1)
             {
@@ -162,7 +173,7 @@
 
               Cell cval = m.contents (c);
 
-              init_data_and_sub_editor (val, cval(r), r, c);
+              init_data_and_sub_editor (fmt, val, cval(r), r, c);
             }
           else
             {
@@ -171,11 +182,11 @@
 
               octave_map m = val.map_value ();
 
-              init_data_and_sub_editor (val, m(r,c), r, c);
+              init_data_and_sub_editor (fmt, val, m(r,c), r, c);
             }
         }
       else
-        m_data = QString::fromStdString (val.edit_display (r, c));
+        m_data = QString::fromStdString (val.edit_display (fmt, r, c));
     }
 
     cell (const QString& d, const QString& s, const QString& t,
@@ -184,7 +195,8 @@
         m_requires_sub_editor (rse), m_editor_type (edtype)
     { }
 
-    void init_data_and_sub_editor (const octave_value& val,
+    void init_data_and_sub_editor (const float_display_format& fmt,
+                                   const octave_value& val,
                                    const octave_value& elt,
                                    int r, int c)
     {
@@ -192,12 +204,12 @@
           || (elt.is_string () && (elt.rows () == 1 || elt.isempty ())))
         {
           m_requires_sub_editor = false;
-          m_data = QString::fromStdString (elt.edit_display (0, 0));
+          m_data = QString::fromStdString (elt.edit_display (fmt, 0, 0));
         }
       else
         {
           m_requires_sub_editor = true;
-          m_data = QString::fromStdString (val.edit_display (r, c));
+          m_data = QString::fromStdString (val.edit_display (fmt, r, c));
         }
     }
 
@@ -223,6 +235,7 @@
   impl (const QString& name, const octave_value& val, QLabel *label)
     : m_name (name.toStdString ()), m_value (val),
       m_rows (0), m_cols (0), m_table (), m_label (label),
+      m_display_fmt (get_edit_display_format (m_value)),
       m_validity (true), m_validtext (make_label (m_name, m_value))
   {
     m_label->setText (m_validtext);
@@ -384,7 +397,7 @@
         int r = idx.row ();
         int c = idx.column ();
 
-        cell edit_cell (m_value, r, c);
+        cell edit_cell (m_display_fmt, m_value, r, c);
 
         set (r, c, edit_cell);
       }
@@ -488,6 +501,8 @@
 
     m_value = val;
 
+    m_display_fmt = get_edit_display_format (m_value);
+
     if (m_value.is_defined ())
       {
         m_validity = true;
@@ -548,6 +563,8 @@
 
   QLabel *m_label;
 
+  float_display_format m_display_fmt;
+
   bool m_validity;
 
   QString m_validtext;
--- a/libinterp/corefcn/pr-output.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/corefcn/pr-output.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -1323,7 +1323,7 @@
   while (0)
 
 static void
-pr_any_float (const float_format& fmt, std::ostream& os, double d, int fw = 0)
+pr_any_float (std::ostream& os, const float_format& fmt, double d, int fw = 0)
 {
   // Unless explicitly asked for, always print in big-endian format
   // for hex and bit formats.
@@ -1431,30 +1431,44 @@
 }
 
 static inline void
-pr_float (std::ostream& os, double d, int fw = 0, double scale = 1.0)
+pr_float (std::ostream& os, const float_display_format& fmt, double d,
+          int fw = 0, double scale = 1.0)
 {
   if (Vfixed_point_format && ! print_g && scale != 1.0)
     d /= scale;
 
-  pr_any_float (curr_float_display_fmt.real_format (), os, d, fw);
+  pr_any_float (os, fmt.real_format (), d, fw);
+}
+
+static inline void
+pr_float (std::ostream& os, double d, int fw = 0, double scale = 1.0)
+{
+  pr_float (os, curr_float_display_fmt, d, fw, scale);
+}
+
+static inline void
+pr_imag_float (std::ostream& os, const float_display_format& fmt,
+               double d, int fw = 0)
+{
+  pr_any_float (os, fmt.imag_format (), d, fw);
 }
 
 static inline void
 pr_imag_float (std::ostream& os, double d, int fw = 0)
 {
-  pr_any_float (curr_float_display_fmt.imag_format (), os, d, fw);
+  pr_imag_float (os, curr_float_display_fmt, d, fw);
 }
 
 static void
-pr_complex (std::ostream& os, const Complex& c, int r_fw = 0,
-            int i_fw = 0, double scale = 1.0)
+pr_complex (std::ostream& os, const float_display_format& fmt,
+            const Complex& c, int r_fw = 0, int i_fw = 0, double scale = 1.0)
 {
   Complex tmp
     = (Vfixed_point_format && ! print_g && scale != 1.0) ? c / scale : c;
 
   double r = tmp.real ();
 
-  pr_float (os, r, r_fw);
+  pr_float (os, fmt, r, r_fw);
 
   if (! bank_format)
     {
@@ -1463,7 +1477,7 @@
         {
           os << " - ";
           i = -i;
-          pr_imag_float (os, i, i_fw);
+          pr_imag_float (os, fmt, i, i_fw);
         }
       else
         {
@@ -1472,13 +1486,20 @@
           else
             os << " + ";
 
-          pr_imag_float (os, i, i_fw);
+          pr_imag_float (os, fmt, i, i_fw);
         }
       os << 'i';
     }
 }
 
 static void
+pr_complex (std::ostream& os, const Complex& c, int r_fw = 0, int i_fw = 0,
+            double scale = 1.0)
+{
+  pr_complex (os, curr_float_display_fmt, c, r_fw, i_fw, scale);
+}
+
+static void
 print_empty_matrix (std::ostream& os, octave_idx_type nr, octave_idx_type nc,
                     bool pr_as_read_syntax)
 {
@@ -1579,6 +1600,25 @@
     os << plus_format_chars[2];
 }
 
+template <>
+float_display_format
+make_format (const NDArray& nda)
+{
+  int fw = 0;
+  double scale = 0;
+  return make_format (Matrix (nda), fw, scale);
+}
+
+template <>
+float_display_format
+make_format (const ComplexNDArray& nda)
+{
+  int r_fw = 0;
+  int i_fw = 0;
+  double scale = 0;
+  return make_format (ComplexMatrix (nda), r_fw, i_fw, scale);
+}
+
 void
 octave_print_internal (std::ostream&, char, bool)
 {
@@ -1589,17 +1629,23 @@
 octave_print_internal (std::ostream& os, double d,
                        bool pr_as_read_syntax)
 {
+  octave_print_internal (os, curr_float_display_fmt, d, pr_as_read_syntax);
+}
+
+void
+octave_print_internal (std::ostream& os, const float_display_format& fmt,
+                       double d, bool pr_as_read_syntax)
+{
   if (pr_as_read_syntax)
     os << d;
   else if (plus_format)
     pr_plus_format (os, d);
   else
     {
-      set_format (d);
       if (free_format)
         os << d;
       else
-        pr_float (os, d);
+        pr_float (os, fmt, d);
     }
 }
 
@@ -2005,17 +2051,23 @@
 octave_print_internal (std::ostream& os, const Complex& c,
                        bool pr_as_read_syntax)
 {
+  octave_print_internal (os, curr_float_display_fmt, c, pr_as_read_syntax);
+}
+
+extern void
+octave_print_internal (std::ostream& os, const float_display_format& fmt,
+                       const Complex& c, bool pr_as_read_syntax)
+{
   if (pr_as_read_syntax)
     os << c;
   else if (plus_format)
     pr_plus_format (os, c);
   else
     {
-      set_format (c);
       if (free_format)
         os << c;
       else
-        pr_complex (os, c);
+        pr_complex (os, fmt, c);
     }
 }
 
--- a/libinterp/corefcn/pr-output.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/corefcn/pr-output.h	Thu Feb 01 06:36:50 2018 -0500
@@ -56,22 +56,49 @@
 
 template <typename T> class intNDArray;
 
+// FIXME: templates plus specializations might help here.
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, bool d,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       bool d, bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, d, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, char c,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       char c, bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, c, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, double d,
                        bool pr_as_read_syntax = false);
 
+extern void
+octave_print_internal (std::ostream& os, const float_display_format& fmt,
+                       double d, bool pr_as_read_syntax = false);
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, float d,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       float d, bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, d, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const Matrix& m,
                        bool pr_as_read_syntax = false,
@@ -106,10 +133,21 @@
 octave_print_internal (std::ostream& os, const Complex& c,
                        bool pr_as_read_syntax = false);
 
+extern void
+octave_print_internal (std::ostream& os, const float_display_format& fmt,
+                       const Complex& c, bool pr_as_read_syntax = false);
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const FloatComplex& c,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const FloatComplex& c, bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, c, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const ComplexMatrix& cm,
                        bool pr_as_read_syntax = false,
@@ -226,40 +264,113 @@
 octave_print_internal (std::ostream& os, const octave_int<int8_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<int8_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_int<uint8_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<uint8_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_int<int16_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<int16_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_int<uint16_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<uint16_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_int<int32_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<int32_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_int<uint32_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<uint32_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_int<int64_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<int64_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_int<uint64_t>& sa,
                        bool pr_as_read_syntax = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const octave_int<uint64_t>& sa,
+                       bool pr_as_read_syntax = false)
+{
+  octave_print_internal (os, sa, pr_as_read_syntax);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const Cell& cell,
                        bool pr_as_read_syntax = false,
                        int extra_indent = 0,
                        bool pr_as_string = false);
 
+inline void
+octave_print_internal (std::ostream& os, const float_display_format&,
+                       const Cell& cell, bool pr_as_read_syntax = false,
+                       int extra_indent = 0, bool pr_as_string = false)
+{
+  octave_print_internal (os, cell, pr_as_read_syntax, extra_indent,
+                         pr_as_string);
+}
+
 extern OCTINTERP_API void
 octave_print_internal (std::ostream& os, const octave_value& ov,
                        bool pr_as_read_syntax = false);
@@ -279,6 +390,13 @@
 extern float_display_format
 make_format (const Range& r, int& fw, double& scale);
 
+template <typename MT>
+float_display_format
+make_format (const MT&)
+{
+  return float_display_format ();
+}
+
 class
 pr_engineering_float
 {
--- a/libinterp/octave-value/ov-base-diag.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base-diag.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -615,7 +615,8 @@
 
 template <typename DMT, typename MT>
 std::string
-octave_base_diag<DMT, MT>::edit_display (octave_idx_type i,
+octave_base_diag<DMT, MT>::edit_display (const float_display_format& fmt,
+                                         octave_idx_type i,
                                          octave_idx_type j) const
 {
   std::ostringstream buf;
--- a/libinterp/octave-value/ov-base-diag.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base-diag.h	Thu Feb 01 06:36:50 2018 -0500
@@ -216,7 +216,8 @@
 
   void short_disp (std::ostream& os) const;
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const;
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const;
 
   octave_value fast_elem_extract (octave_idx_type n) const;
 
--- a/libinterp/octave-value/ov-base-mat.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base-mat.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -507,12 +507,20 @@
 }
 
 template <typename MT>
+float_display_format
+octave_base_matrix<MT>::get_edit_display_format (void) const
+{
+  return make_format (matrix);
+}
+
+template <typename MT>
 std::string
-octave_base_matrix<MT>::edit_display (octave_idx_type i,
+octave_base_matrix<MT>::edit_display (const float_display_format& fmt,
+                                      octave_idx_type i,
                                       octave_idx_type j) const
 {
   std::ostringstream buf;
-  octave_print_internal (buf, matrix(i,j));
+  octave_print_internal (buf, fmt, matrix(i,j));
   return buf.str ();
 }
 
--- a/libinterp/octave-value/ov-base-mat.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base-mat.h	Thu Feb 01 06:36:50 2018 -0500
@@ -163,7 +163,10 @@
 
   void short_disp (std::ostream& os) const;
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const;
+  float_display_format get_edit_display_format (void) const;
+
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const;
 
   MT& matrix_ref (void)
   {
--- a/libinterp/octave-value/ov-base-scalar.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base-scalar.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -190,7 +190,8 @@
 
 template <typename ST>
 std::string
-octave_base_scalar<ST>::edit_display (octave_idx_type, octave_idx_type) const
+octave_base_scalar<ST>::edit_display (const float_display_format& fmt,
+                                      octave_idx_type, octave_idx_type) const
 {
   std::ostringstream buf;
   octave_print_internal (buf, scalar);
--- a/libinterp/octave-value/ov-base-scalar.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base-scalar.h	Thu Feb 01 06:36:50 2018 -0500
@@ -138,7 +138,8 @@
 
   void short_disp (std::ostream& os) const;
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const;
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const;
 
   // Unsafe.  This function exists to support the MEX interface.
   // You should not use it anywhere else.
--- a/libinterp/octave-value/ov-base.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -55,6 +55,7 @@
 #include "ov-str-mat.h"
 #include "ovl.h"
 #include "parse.h"
+#include "pr-flt-fmt.h"
 #include "pr-output.h"
 #include "utils.h"
 #include "variables.h"
@@ -442,6 +443,12 @@
     newline (output_buf);
 }
 
+float_display_format
+octave_base_value::get_edit_display_format (void) const
+{
+  return float_display_format ();
+}
+
 void
 octave_base_value::print_info (std::ostream& os,
                                const std::string& /* prefix */) const
--- a/libinterp/octave-value/ov-base.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-base.h	Thu Feb 01 06:36:50 2018 -0500
@@ -53,6 +53,7 @@
 }
 
 class Cell;
+class float_display_format;
 class mxArray;
 class octave_map;
 class octave_scalar_map;
@@ -663,7 +664,10 @@
 
   virtual void short_disp (std::ostream& os) const { os << "..."; }
 
-  virtual std::string edit_display (octave_idx_type, octave_idx_type) const
+  virtual float_display_format get_edit_display_format (void) const;
+
+  virtual std::string edit_display (const float_display_format&,
+                                    octave_idx_type, octave_idx_type) const
   { return "#VAL"; }
 
   virtual void print_info (std::ostream& os, const std::string& prefix) const;
--- a/libinterp/octave-value/ov-cell.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-cell.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -101,7 +101,8 @@
 
 template <>
 std::string
-octave_base_matrix<Cell>::edit_display (octave_idx_type i,
+octave_base_matrix<Cell>::edit_display (const float_display_format& fmt,
+                                        octave_idx_type i,
                                         octave_idx_type j) const
 {
   octave_value val = matrix(i,j);
--- a/libinterp/octave-value/ov-perm.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-perm.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -544,7 +544,8 @@
 }
 
 std::string
-octave_perm_matrix::edit_display (octave_idx_type i, octave_idx_type j) const
+octave_perm_matrix::edit_display (const float_display_format& fmt,
+                                  octave_idx_type i, octave_idx_type j) const
 {
   // FIXME: maybe we should have octave_print_internal functions for
   // standard int types, not just octave_int<T> types.
--- a/libinterp/octave-value/ov-perm.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-perm.h	Thu Feb 01 06:36:50 2018 -0500
@@ -232,7 +232,8 @@
 
   void short_disp (std::ostream& os) const;
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const;
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const;
 
   octave_value map (unary_mapper_t umap) const
   { return to_dense ().map (umap); }
--- a/libinterp/octave-value/ov-re-mat.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-re-mat.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -71,6 +71,7 @@
 #include "ov-cx-diag.h"
 #include "ov-lazy-idx.h"
 #include "ov-perm.h"
+#include "pr-flt-fmt.h"
 #include "pr-output.h"
 #include "variables.h"
 
--- a/libinterp/octave-value/ov-str-mat.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-str-mat.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -278,7 +278,8 @@
 }
 
 std::string
-octave_char_matrix_str::edit_display (octave_idx_type i,
+octave_char_matrix_str::edit_display (const float_display_format& fmt,
+                                      octave_idx_type i,
                                       octave_idx_type) const
 {
   if (i == 0)
--- a/libinterp/octave-value/ov-str-mat.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-str-mat.h	Thu Feb 01 06:36:50 2018 -0500
@@ -146,7 +146,8 @@
 
   void short_disp (std::ostream& os) const;
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const;
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const;
 
   bool save_ascii (std::ostream& os);
 
--- a/libinterp/octave-value/ov-struct.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-struct.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -657,7 +657,8 @@
 }
 
 std::string
-octave_struct::edit_display (octave_idx_type r, octave_idx_type c) const
+octave_struct::edit_display (const float_display_format& fmt,
+                             octave_idx_type r, octave_idx_type c) const
 {
   octave_value val;
   if (map.rows () == 1 || map.columns () == 1)
@@ -1359,7 +1360,8 @@
 }
 
 std::string
-octave_scalar_struct::edit_display (octave_idx_type r, octave_idx_type) const
+octave_scalar_struct::edit_display (const float_display_format& fmt,
+                                    octave_idx_type r, octave_idx_type) const
 {
   // Scalar struct.  Rows are fields, single column for values.
 
--- a/libinterp/octave-value/ov-struct.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov-struct.h	Thu Feb 01 06:36:50 2018 -0500
@@ -131,7 +131,8 @@
 
   bool print_name_tag (std::ostream& os, const std::string& name) const;
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const;
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const;
 
   bool save_ascii (std::ostream& os);
 
@@ -254,7 +255,8 @@
 
   bool print_name_tag (std::ostream& os, const std::string& name) const;
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const;
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const;
 
   bool save_ascii (std::ostream& os);
 
--- a/libinterp/octave-value/ov.cc	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov.cc	Thu Feb 01 06:36:50 2018 -0500
@@ -85,6 +85,7 @@
 #include "interpreter-private.h"
 #include "pager.h"
 #include "parse.h"
+#include "pr-flt-fmt.h"
 #include "pr-output.h"
 #include "symtab.h"
 #include "utils.h"
@@ -2132,6 +2133,12 @@
     maybe_economize ();
 }
 
+float_display_format
+octave_value::get_edit_display_format (void) const
+{
+  return rep->get_edit_display_format ();
+}
+
 int
 octave_value::write (octave::stream& os, int block_size,
                      oct_data_conv::data_type output_type, int skip,
--- a/libinterp/octave-value/ov.h	Wed Jan 31 22:21:51 2018 -0600
+++ b/libinterp/octave-value/ov.h	Thu Feb 01 06:36:50 2018 -0500
@@ -48,6 +48,7 @@
 }
 
 class Cell;
+class float_format;
 class mxArray;
 class octave_map;
 class octave_scalar_map;
@@ -1275,9 +1276,12 @@
 
   void short_disp (std::ostream& os) const { rep->short_disp (os); }
 
-  std::string edit_display (octave_idx_type i, octave_idx_type j) const
+  float_display_format get_edit_display_format (void) const;
+
+  std::string edit_display (const float_display_format& fmt,
+                            octave_idx_type i, octave_idx_type j) const
   {
-    return rep->edit_display (i, j);
+    return rep->edit_display (fmt, i, j);
   }
 
   int type_id (void) const { return rep->type_id (); }