[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
more missing core functions
From: |
David Bateman |
Subject: |
more missing core functions |
Date: |
Tue, 23 Oct 2007 02:25:54 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Do we want the attached that adds 4 new missing core functions. Do we
want it for 3.0?
D.
*** ./scripts/miscellaneous/what.m.orig10 2007-10-22 17:42:25.333407321
+0200
--- ./scripts/miscellaneous/what.m 2007-10-22 17:42:04.328430905 +0200
***************
*** 0 ****
--- 1,116 ----
+ ## Copyright (C) 2007 David Bateman
+ ##
+ ## This file is part of Octave.
+ ##
+ ## Octave is free software; you can redistribute it and/or modify it
+ ## under the terms of the GNU General Public License as published by
+ ## the Free Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version.
+ ##
+ ## Octave is distributed in the hope that it will be useful, but
+ ## WITHOUT ANY WARRANTY; without even the implied warranty of
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ## General Public License for more details.
+ ##
+ ## You should have received a copy of the GNU General Public License
+ ## along with Octave; see the file COPYING. If not, see
+ ## <http://www.gnu.org/licenses/>.
+
+ ## -*- texinfo -*-
+ ## @deftypefn {Command} {} what
+ ## @deftypefnx {Command} {} what @var{dir}
+ ## @deftypefnx {Function File} {w =} what (@var{dir})
+ ## List the Octave specific files in a directory. If the variable @var{dir}
+ ## is given then check that directory rather than the current directory. If
+ ## a return argument is requested, the files found are returned in the
+ ## structure @var{w}.
+ ## @seealso{which}
+ ## @end deftypefn
+
+ ## PKG_ADD: mark_as_command what
+
+ function ret = what (d)
+
+ if (nargin == 0)
+ d = pwd ();
+ elseif (isempty (strfind (d, filesep ())))
+ ## Find the appropriate directory on the path
+ p = split (path (), pathsep());
+ p = cellfun (@(x) deblank (x), mat2cell (p, ones (1, size (p, 1)), ...
+ size (p, 2)), "UniformOutput", false);
+ d = p{find (cellfun (@(x) ! isempty (strfind (x, d)), p))(end)};
+ else
+ [status, msg, msgid] = fileattrib (d);
+ if (status != 1)
+ error ("could not find the file or path %s", d);
+ else
+ d = msg.Name;
+ endif
+ endif
+
+ files = dir (d);
+ w.path = d;
+ w.m = cell (0, 1);
+ w.mex = cell (0, 1);
+ w.oct = cell (0, 1);
+ w.mat = cell (0, 1);
+ w.mdl = cell (0, 1);
+ w.p = cell (0, 1);
+ w.classes = cell (0, 1);
+
+ for i = 1 : length (files)
+ n = files(i).name;
+ ## Ignore . and ..
+ if (strcmp (n, ".") || strcmp (n, ".."))
+ continue;
+ else
+ ## Ignore mdl and p files
+ [dummy, f, e] = fileparts (n);
+ if (strcmp (e, ".m"))
+ w.m {end+1} = n;
+ elseif (strcmp (e, mexext ()))
+ w.mex {end + 1} = n;
+ elseif (strcmp (e, ".oct"))
+ w.oct {end + 1} = n;
+ elseif (strcmp (e, ".mat"))
+ w.mat {end + 1} = n;
+ elseif(strcmp (n(1), "@"))
+ w.classes {end + 1} = n;
+ endif
+ endif
+ endfor
+
+ if (nargout == 0)
+ __display_filenames__ ("M-files in directory", w.path, w.m);
+ __display_filenames__ ("\nMEX-files in directory", w.path, w.mex);
+ __display_filenames__ ("\nOCT-files in directory", w.path, w.oct);
+ __display_filenames__ ("\nMAT-files in directory", w.path, w.mat);
+ __display_filenames__ ("\nClasses in directory", w.path, w.classes);
+ else
+ ret = w;
+ endif
+ endfunction
+
+ function __display_filenames__ (msg, p, f)
+ if (length (f) > 0)
+ printf ("%s %s:\n\n", msg, p)
+
+ maxlen = max (cellfun (@(x) length (x), f));
+ ncols = max (1, floor (terminal_size()(2) / (maxlen + 3)));
+ fmt = "";
+ for i = 1: ncols
+ fmt = sprintf ("%s %%-%ds", fmt, maxlen);
+ endfor
+ fmt = [fmt, "\n"];
+
+ nrows = ceil (length (f) / ncols);
+ for i = 1 : nrows
+ args = f(i:nrows:end);
+ if (length (args) < ncols)
+ n = ncols - length (args);
+ args{end : end + n} = "";
+ endif
+ printf (fmt, args{:});
+ endfor
+ endif
+ endfunction
*** ./scripts/miscellaneous/Makefile.in.orig10 2007-10-22 17:42:20.916622521
+0200
--- ./scripts/miscellaneous/Makefile.in 2007-10-22 18:12:42.369779570 +0200
***************
*** 42,48 ****
news.m orderfields.m pack.m paren.m parseparams.m \
run.m semicolon.m setfield.m single.m substruct.m swapbytes.m tar.m \
tempdir.m tempname.m texas_lotto.m unix.m unpack.m untar.m \
! unzip.m ver.m version.m warning_ids.m xor.m zip.m
DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES))
--- 42,48 ----
news.m orderfields.m pack.m paren.m parseparams.m \
run.m semicolon.m setfield.m single.m substruct.m swapbytes.m tar.m \
tempdir.m tempname.m texas_lotto.m unix.m unpack.m untar.m \
! unzip.m ver.m version.m warning_ids.m what.m xor.m zip.m
DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES))
*** ./scripts/plot/xlim.m.orig10 2007-10-22 17:40:56.983715290 +0200
--- ./scripts/plot/xlim.m 2007-10-22 17:37:24.096124922 +0200
***************
*** 0 ****
--- 1,46 ----
+ ## Copyright (C) 2007 David Bateman
+ ##
+ ## This file is part of Octave.
+ ##
+ ## Octave is free software; you can redistribute it and/or modify it
+ ## under the terms of the GNU General Public License as published by
+ ## the Free Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version.
+ ##
+ ## Octave is distributed in the hope that it will be useful, but
+ ## WITHOUT ANY WARRANTY; without even the implied warranty of
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ## General Public License for more details.
+ ##
+ ## You should have received a copy of the GNU General Public License
+ ## along with Octave; see the file COPYING. If not, see
+ ## <http://www.gnu.org/licenses/>.
+
+ ## -*- texinfo -*-
+ ## @deftypefn {Function File} address@hidden =} xlim ()
+ ## @deftypefnx {Function File} {} xlim (@var{xl})
+ ## @deftypefnx {Function File} address@hidden =} xlim ('mode')
+ ## @deftypefnx {Function File} {} xlim (@var{m})
+ ## @deftypefnx {Function File} {} xlim (@var{h}, @dots{})
+ ## Get or set the limits of the x axis of the current plot. Called without
+ ## argumenst @code{xlim] returns the x axis limits of the current plot.
+ ## If passed a two element vector @var{xl}, the limits of the x axis are set
+ ## to this value.
+ ##
+ ## The current mode for calculation of the x axis can be returned with a
+ ## call @code{xlim ('mode')}, and can be either 'auto' or 'manual'. The
+ ## current plotting mode can be set by passing either 'auto' or 'manual'
+ ## as the argument.
+ ##
+ ## If passed an handle as the first argument, then operate on this handle
+ ## rather than the current axes handle.
+ ## @seealso{ylim, zlim, set, get, gca}
+ ## @end deftypefn
+
+ function retval = xlim (varargin)
+ ret = __axes_limits__ ("xlim", varargin {:});
+
+ if (! isempty (ret))
+ retval = ret;
+ endif
+ endfunction
*** ./scripts/plot/Makefile.in.orig10 2007-10-22 17:40:52.222947625 +0200
--- ./scripts/plot/Makefile.in 2007-10-23 02:23:52.215455030 +0200
***************
*** 34,39 ****
--- 34,40 ----
INSTALL_DATA = @INSTALL_DATA@
SOURCES = \
+ __axes_limits__.m \
__axis_label__.m \
__bar__.m \
__default_plot_options__.m \
***************
*** 114,121 ****
title.m \
view.m \
xlabel.m \
ylabel.m \
! zlabel.m
DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES))
--- 115,125 ----
title.m \
view.m \
xlabel.m \
+ xlim.m \
ylabel.m \
! ylim.m \
! zlabel.m \
! zlim.m
DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES))
*** ./scripts/plot/ylim.m.orig10 2007-10-22 17:40:58.831625113 +0200
--- ./scripts/plot/ylim.m 2007-10-22 17:38:10.053874151 +0200
***************
*** 0 ****
--- 1,46 ----
+ ## Copyright (C) 2007 David Bateman
+ ##
+ ## This file is part of Octave.
+ ##
+ ## Octave is free software; you can redistribute it and/or modify it
+ ## under the terms of the GNU General Public License as published by
+ ## the Free Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version.
+ ##
+ ## Octave is distributed in the hope that it will be useful, but
+ ## WITHOUT ANY WARRANTY; without even the implied warranty of
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ## General Public License for more details.
+ ##
+ ## You should have received a copy of the GNU General Public License
+ ## along with Octave; see the file COPYING. If not, see
+ ## <http://www.gnu.org/licenses/>.
+
+ ## -*- texinfo -*-
+ ## @deftypefn {Function File} address@hidden =} ylim ()
+ ## @deftypefnx {Function File} {} ylim (@var{xl})
+ ## @deftypefnx {Function File} address@hidden =} ylim ('mode')
+ ## @deftypefnx {Function File} {} ylim (@var{m})
+ ## @deftypefnx {Function File} {} ylim (@var{h}, @dots{})
+ ## Get or set the limits of the y axis of the current plot. Called without
+ ## argumenst @code{ylim] returns the y axis limits of the current plot.
+ ## If passed a two element vector @var{xl}, the limits of the y axis are set
+ ## to this value.
+ ##
+ ## The current mode for calculation of the y axis can be returned with a
+ ## call @code{ylim ('mode')}, and can be either 'auto' or 'manual'. The
+ ## current plotting mode can be set by passing either 'auto' or 'manual'
+ ## as the argument.
+ ##
+ ## If passed an handle as the first argument, then operate on this handle
+ ## rather than the current axes handle.
+ ## @seealso{xlim, zlim, set, get, gca}
+ ## @end deftypefn
+
+ function retval = ylim (varargin)
+ ret = __axes_limits__ ("ylim", varargin {:});
+
+ if (! isempty (ret))
+ retval = ret;
+ endif
+ endfunction
*** ./scripts/plot/zlim.m.orig10 2007-10-22 17:41:00.640536843 +0200
--- ./scripts/plot/zlim.m 2007-10-22 17:38:01.941271320 +0200
***************
*** 0 ****
--- 1,46 ----
+ ## Copyright (C) 2007 David Bateman
+ ##
+ ## This file is part of Octave.
+ ##
+ ## Octave is free software; you can redistribute it and/or modify it
+ ## under the terms of the GNU General Public License as published by
+ ## the Free Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version.
+ ##
+ ## Octave is distributed in the hope that it will be useful, but
+ ## WITHOUT ANY WARRANTY; without even the implied warranty of
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ## General Public License for more details.
+ ##
+ ## You should have received a copy of the GNU General Public License
+ ## along with Octave; see the file COPYING. If not, see
+ ## <http://www.gnu.org/licenses/>.
+
+ ## -*- texinfo -*-
+ ## @deftypefn {Function File} address@hidden =} zlim ()
+ ## @deftypefnx {Function File} {} zlim (@var{xl})
+ ## @deftypefnx {Function File} address@hidden =} zlim ('mode')
+ ## @deftypefnx {Function File} {} zlim (@var{m})
+ ## @deftypefnx {Function File} {} zlim (@var{h}, @dots{})
+ ## Get or set the limits of the z axis of the current plot. Called without
+ ## argumenst @code{zlim] returns the z axis limits of the current plot.
+ ## If passed a two element vector @var{xl}, the limits of the z axis are set
+ ## to this value.
+ ##
+ ## The current mode for calculation of the z axis can be returned with a
+ ## call @code{zlim ('mode')}, and can be either 'auto' or 'manual'. The
+ ## current plotting mode can be set by passing either 'auto' or 'manual'
+ ## as the argument.
+ ##
+ ## If passed an handle as the first argument, then operate on this handle
+ ## rather than the current axes handle.
+ ## @seealso{xlim, ylim, set, get, gca}
+ ## @end deftypefn
+
+ function retval = zlim (varargin)
+ ret = __axes_limits__ ("zlim", varargin {:});
+
+ if (! isempty (ret))
+ retval = ret;
+ endif
+ endfunction
*** ./scripts/plot/__axes_limits__.m.orig10 2007-10-23 02:23:17.111040371
+0200
--- ./scripts/plot/__axes_limits__.m 2007-10-22 17:36:21.655186163 +0200
***************
*** 0 ****
--- 1,57 ----
+ ## Copyright (C) 2007 David Bateman
+ ##
+ ## This file is part of Octave.
+ ##
+ ## Octave is free software; you can redistribute it and/or modify it
+ ## under the terms of the GNU General Public License as published by
+ ## the Free Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version.
+ ##
+ ## Octave is distributed in the hope that it will be useful, but
+ ## WITHOUT ANY WARRANTY; without even the implied warranty of
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ## General Public License for more details.
+ ##
+ ## You should have received a copy of the GNU General Public License
+ ## along with Octave; see the file COPYING. If not, see
+ ## <http://www.gnu.org/licenses/>.
+
+ ## Undocumented internal function.
+
+ function retval = __axes_limits__ (fcn, varargin)
+ retval = [];
+ fcnmode = sprintf("%smode", fcn);
+
+ if (nargin > 1 && isscalar (varargin{1}) && ishandle (varargin{1}))
+ h = varargin {1};
+ off = 1;
+ if (! strcmp (get (h, "type"), "axes"))
+ error ("%s: expecting first argument to be an axes object", fcn);
+ endif
+ else
+ off = 0;
+ h = gca ();
+ endif
+
+ if (nargin == off + 1)
+ retval = get (h, fcn);
+ else
+ arg = varargin {off + 1};
+
+ if (ischar (arg))
+ arg = tolower (arg);
+ if (strcmp ("mode", arg))
+
+ retval = get (h, fcnmode);
+ elseif (strcmp ("auto", arg) || strcmp ("manual", arg))
+ set (h, fcnmode, arg);
+ endif
+ else
+ if (!isnumeric (arg) && any (size(arg(:)) != [2, 1]))
+ error ("%s: argument must be a 2 element vector", fcn);
+ else
+ set (h, fcn, arg (:));
+ endif
+ endif
+ endif
+ endfunction
- more missing core functions,
David Bateman <=