Mercurial > hg > octave-lyh
annotate scripts/miscellaneous/inputname.m @ 16447:e3b33a7530bc
improve encapsulation of history window object
* history-dockwidget.h, history-dockwidget.cc
(history_dock_widget::history_dock_widget): Set status tip here.
Connect history_dock_widget::information signal to
main_window::report_status_message.
Connect history_dock_widget::command_double_clicked signal to
main_window::handle_command_double_clicked.
(history_dock_widget::connect_visibility_changed,
history_dock_widget::focus, history_dock_widget::handle_visibility):
New functions.
* main-window.h, main-window.cc (main_window::history_window): Rename
from _history_dock_widget. Don't use a pointer. Change all uses.
(main_window::main_window): Initialize it here.
(main_window::~main_window): Don't delete _history_dock_widget.
(main_window::focus_history_window_signal): New signal.
(main_window::focus_history_window): Rename from
main_window::focus_command_history. Emit focus_history_window_signal
instead of performing actions here.
(main_window::handle_command_history_visible): Delete.
(main_window::connect_visibility_changed): Call
history_window.connect_visibility_changed instead of performing
actions here.
(main_window::construct): Don't create _history_dock_widget. Adapt
signal/slot connections for new history_window object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 06 Apr 2013 16:46:14 -0400 |
parents | f3d52523cde1 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11558
diff
changeset
|
1 ## Copyright (C) 2004-2012 Paul Kienzle |
5837 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
7016 | 5 ## Octave is free software; you can redistribute it and/or modify it |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 ## | |
19 ## Original version by Paul Kienzle distributed as free software in the | |
20 ## public domain. | |
5837 | 21 |
22 ## -*- texinfo -*- | |
23 ## @deftypefn {Function File} {} inputname (@var{n}) | |
10091
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
24 ## Return the name of the @var{n}-th argument to the calling function. |
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
25 ## If the argument is not a simple variable name, return an empty string. |
5837 | 26 ## @end deftypefn |
27 | |
28 function s = inputname (n) | |
7125 | 29 |
10091
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
30 if (nargin == 1) |
11558
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
31 s = evalin ("caller", sprintf ("__varval__ (\".argn.\"){%d};", n)); |
10091
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
32 ## For compatibility with Matlab, return empty string if argument |
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
33 ## name is not a valid identifier. |
10093
d90736774da2
inputname: use isvarname instead of regexp
John W. Eaton <jwe@octave.org>
parents:
10091
diff
changeset
|
34 if (! isvarname (s)) |
10091
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
35 s = ""; |
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
36 endif |
a115046d462d
inputname: compatibility fix
John W. Eaton <jwe@octave.org>
parents:
7125
diff
changeset
|
37 else |
7125 | 38 print_usage (); |
39 endif | |
40 | |
5837 | 41 endfunction |
42 | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
43 |
5837 | 44 ## Warning: heap big magic in the following tests!!! |
45 ## The test function builds a private context for each | |
46 ## test, with only the specified values shared between | |
47 ## them. It does this using the following template: | |
48 ## | |
49 ## function [<shared>] = testfn(<shared>) | |
50 ## <test> | |
51 ## | |
52 ## To test inputname, I need a function context invoked | |
53 ## with known parameter names. So define a couple of | |
54 ## shared parameters, et voila!, the test is trivial. | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 %!shared hello, worldly |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 %!assert (inputname (1), "hello") |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
58 %!assert (inputname (2), "worldly") |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 |