octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cell-array display in class


From: Colin Macdonald
Subject: Re: cell-array display in class
Date: Wed, 29 Apr 2015 22:38:23 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

On 27/04/15 07:04, Oliver Heimlich wrote:
It is not so easy. First, you have to decide whether “argn” represents
coordinates of a cell-array. You could do this with a regular
expression, but can't be 100% sure.

thanks for this `argn`!

Cannot be 100% sure? Do you have a particular counterexample? This seems to work for me:

if (isempty(inputname(1)) && regexp(argn, '^\[\d+,\d+\]$'))
  % we're in a cell array
  ...
else
  % whatever I did before.
end

If my input was actually `display([1,2])` then it won't be my @class/display that gets called :)

(Ok, needs to be a bit more complicated for all possible shapes of cell array but that regexp gives idea.)

Second, you want to get access to the following variable (in ov-base.cc)
to correctly indent your output. I think there currently is no way to
access this value from within a m-file display method (unless you use an
oct-file kludge).
    int octave_base_value::curr_print_indent_level

Yes, that is unfortunate :( I'm sure I have other things I should be worrying about but perhaps Octave could pass to us the current indent level as 2nd argument of display. Thoughts?

Colin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]