changeset 17825:53f433bae63b

display (possibly truncated) values of strings in workspace view * ov-str-mat.h, ov-str-mat.cc (octave_char_matrix_str::short_disp): New function.
author John W. Eaton <jwe@octave.org>
date Fri, 01 Nov 2013 14:45:35 -0400
parents 86e8dbccf7c7
children 574ab045f70c
files libinterp/octave-value/ov-str-mat.cc libinterp/octave-value/ov-str-mat.h
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-str-mat.cc	Fri Nov 01 14:30:47 2013 -0400
+++ b/libinterp/octave-value/ov-str-mat.cc	Fri Nov 01 14:45:35 2013 -0400
@@ -270,6 +270,25 @@
                          current_print_indent_level (), true);
 }
 
+std::string
+octave_char_matrix_str::short_disp (void) const
+{
+  std::string retval;
+
+  if (matrix.ndims () == 2 && numel () > 0)
+    {
+      retval = string_value ();
+
+      // FIXME -- should this be configurable?
+
+      if (retval.length () > 100)
+        retval = retval.substr (0, 100);
+    }
+
+  return retval;
+}
+
+
 bool
 octave_char_matrix_str::save_ascii (std::ostream& os)
 {
--- a/libinterp/octave-value/ov-str-mat.h	Fri Nov 01 14:30:47 2013 -0400
+++ b/libinterp/octave-value/ov-str-mat.h	Fri Nov 01 14:45:35 2013 -0400
@@ -142,6 +142,8 @@
 
   void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
 
+  std::string short_disp (void) const;
+
   bool save_ascii (std::ostream& os);
 
   bool load_ascii (std::istream& is);