Mercurial > octave
diff libinterp/parse-tree/pt-eval.cc @ 26087:7656fcd0ff9f
move whos_line_format to evaluator
* variables.h, variables.cc (Vwhos_line_format): Delete.
(symbol_info_list::parse_whos_line_format, symbol_info_list::display):
Accept format as argument. Change all uses.
* pt-eval.h, pt-eval.cc (tree_evaluator::m_whos_line_format,
tree_evaluator::whos_line_format): New data member and functions.
(Fwhos_line_format): Move here from variables.cc. Adapt to use class
member variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 15 Nov 2018 15:05:36 -0500 |
parents | 2eb71b83d3e2 |
children | 8fb0df0c8772 |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc Thu Nov 15 21:57:03 2018 -0800 +++ b/libinterp/parse-tree/pt-eval.cc Thu Nov 15 15:05:36 2018 -0500 @@ -3335,6 +3335,13 @@ } octave_value + tree_evaluator::whos_line_format (const octave_value_list& args, int nargout) + { + return set_internal_variable (m_whos_line_format, args, nargout, + "whos_line_format"); + } + + octave_value tree_evaluator::silent_functions (const octave_value_list& args, int nargout) { return set_internal_variable (m_silent_functions, args, nargout, @@ -3743,6 +3750,85 @@ %!error (max_recursion_depth (1, 2)) */ +DEFMETHOD (whos_line_format, interp, args, nargout, + doc: /* -*- texinfo -*- +@deftypefn {} {@var{val} =} whos_line_format () +@deftypefnx {} {@var{old_val} =} whos_line_format (@var{new_val}) +@deftypefnx {} {} whos_line_format (@var{new_val}, "local") +Query or set the format string used by the command @code{whos}. + +A full format string is: +@c Set example in small font to prevent overfull line + +@smallexample +%[modifier]<command>[:width[:left-min[:balance]]]; +@end smallexample + +The following command sequences are available: + +@table @code +@item %a +Prints attributes of variables (g=global, p=persistent, f=formal parameter, +a=automatic variable). + +@item %b +Prints number of bytes occupied by variables. + +@item %c +Prints class names of variables. + +@item %e +Prints elements held by variables. + +@item %n +Prints variable names. + +@item %s +Prints dimensions of variables. + +@item %t +Prints type names of variables. +@end table + +Every command may also have an alignment modifier: + +@table @code +@item l +Left alignment. + +@item r +Right alignment (default). + +@item c +Column-aligned (only applicable to command %s). +@end table + +The @code{width} parameter is a positive integer specifying the minimum +number of columns used for printing. No maximum is needed as the field will +auto-expand as required. + +The parameters @code{left-min} and @code{balance} are only available when +the column-aligned modifier is used with the command @samp{%s}. +@code{balance} specifies the column number within the field width which +will be aligned between entries. Numbering starts from 0 which indicates +the leftmost column. @code{left-min} specifies the minimum field width to +the left of the specified balance column. + +The default format is: + +@qcode{" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;@xbackslashchar{}n"} + +When called from inside a function with the @qcode{"local"} option, the +variable is changed locally for the function and any subroutines it calls. +The original variable value is restored when exiting the function. +@seealso{whos} +@end deftypefn */) +{ + octave::tree_evaluator& tw = interp.get_evaluator (); + + return tw.whos_line_format (args, nargout); +} + DEFMETHOD (silent_functions, interp, args, nargout, doc: /* -*- texinfo -*- @deftypefn {} {@var{val} =} silent_functions ()