changeset 13259:b6efe55f97c7

Allow gtext() to have multi-line text strings (Bug #33232) * gtext.m: Simplify code to take advantage of cellstr handling already available in text().
author Rik <octave@nomad.inbox5.com>
date Fri, 30 Sep 2011 09:57:10 -0700
parents be74491c20e8
children 28e3e9158d70
files scripts/plot/gtext.m
diffstat 1 files changed, 10 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/gtext.m	Fri Sep 30 09:20:08 2011 -0700
+++ b/scripts/plot/gtext.m	Fri Sep 30 09:57:10 2011 -0700
@@ -29,26 +29,19 @@
 
 function gtext (s, varargin)
 
-  if (nargin > 0)
-    if (iscellstr (s))
-      if (isempty (s))
-        s = "";
-      else
-        s = sprintf ("%s\n", s{:});
-      endif
-    endif
-    if (ischar (s))
-      if (! isempty (s))
-        [x, y] = ginput (1);
-        text (x, y, s, varargin{:});
-      endif
-    else
-      error ("gtext: expecting a string or cell array of strings");
-    endif
-  else
+  if (nargin < 1)
     print_usage ();
   endif
 
+  if (! (ischar (s) || iscellstr (s)))
+    error ("gtext: S must be a string or cell array of strings");
+  endif
+
+  if (! isempty (s))
+    [x, y] = ginput (1);
+    text (x, y, s, varargin{:});
+  endif
+
 endfunction
 
 ## Remove from test statistics.  No real tests possible.