-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input() not supported #59
Comments
input() should be doable, I think. We'd just have to have a way of identify an input prompt for pexpect, and then hooking that up to ask the interface (notebook or console) for the input. That already exists for non-pexpect-based metakernel notebooks. |
Thanks. Looks as if emacs octave mode is doing an expect type of approach. So this might help. https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/octave.el |
Thanks @DrXyzzy, this line looks promising: https://github.com/emacs-mirror/emacs/blob/d40073f017ffb3dee2266f356c127ef587c40b71/lisp/progmodes/octave.el#L616. Worst case, we can override the |
Cool. I looked for a hook for terminal input in Octave sources with idea of adding a marker, but didn't see one, e.g. http://octave.org/doxygen/4.0/de/d4c/input_8cc_source.html#l00746. I wasn't sure you could override (aka "monkey patch") a built-in method in Octave without losing access to the original one. |
AFAIK only a raw |
@blink1073 looks as if Regarding replacement, there is advice to use |
Where there's a will there's a way 😉 |
Thanks for looking into that! |
Confirmed, this totally works: ## -*- texinfo -*-
## @deftypefn {Function File} {} input ()
## @deftypefnx {Function File} {} input (@var{PROMPT})
## @deftypefnx {Function File} {} input (@var{PROMPT}, 's')
## Print PROMPT and wait for user input
##
## @end deftypefn
function ANS = input (varargin)
% let the builtin handle the nargin error
if (nargin == 0)
builtin('input')
end
varargin{1} = sprintf('%s__stdin_prompt>', varargin{1});
ANS = builtin('input', varargin{:});
endfunction |
Updated the above to actually do what we want. By Jove, this is going to work! |
Notes:
|
Actually, menu uses |
Sweet. The builtin |
Note: My comment about |
WIP in #60. |
could anyone check if this works in 0.24.5? i.e.
gives 5 for input 2 |
hmm, our notebook server is a bit older, maybe that's the problem. |
You haven't rolled out the new kernel on SMC, correct? |
well, I did, for about 10 minutes, but the above just hangs at "x =" and that's it. So I rolled back to 0.21.0 (what it was before the update, and there There are also a couple of other libraries involved, maybe it's a bad combination of them. |
Below is what pip installed in python2 when it broke. After that, I just changed octave-kernel back to 0.21.0 and it works. Maybe there are also other libs involved not in that list. My primary suspect is of course metakernel :-)
|
The difference between this version and 0.21.0 is 0.21.0 used the |
Which OS and version of Octave are you running? |
a slightly outdated Ubuntu 15.10, Octave is 4.0.0 I don't remember, do you have an account on SMC and a dev project? You could check those details there, and I could even see to set it up in a way that it is broken. |
Drat, I just confirmed the behavior in Ubuntu 14.04. I do have a SMC and a test project. I'll get this working on Ubuntu 14.04 and report back (might not be until this weekend). |
I am not sure Add the named function or function handle @var{fcn} to the list of functions I sometimes see hundreds of calls to the input hook function for a single call to octave |
Yep, another reason I stopped using that function. |
Also I wonder if |
That is the behavior of |
But it still relies on the function override working... |
LOL. Ok, I will wait. As @haraldschilly noted above, there are problems installing the most recent kernels on SMC. When I install octave_kernel as non-root using |
That would do it! |
Wow, this is definitely a case of "works on my machine". I was not including any of those files in the wheel or the tar releases. Nice catch, @DrXyzzy! |
The tarball has them, but not the wheel. |
I just tried 0.24.6 on Ubuntu 14.04 and all is right in the world ;). |
Works in jupyter notebook with user install on SMC, including friendly |
This kernel is using the |
GNU Octave
input()
function appears not to be supported. Note that IPython kernels support pythoninput()
andraw_input()
.Other terminal input functions,
menu()
,yes_or_no()
, andkbhit()
, are also unsupported. Butinput()
is probably the one that adds most value.The text was updated successfully, but these errors were encountered: