Closed tdy closed 8 years ago
Same as #12. Not sure what happened there. I must've messed up some commits accidentally.
Thanks, this is definitely a very nice feature to add. The raw code being echoed probably has to do with send
simulating actual keyboard input, and that causing the matlab console to print them out as if those keys were being pressed.
I will accept the pull request. I think there might be a way to use pexpect.spawn.interact()
's output_filter
to filter out any strings that match the ones sent to pexpect.spawn.send()
. I guess that can be addressed in a different patch. (I'll try to update if I find a way).
0f8a799 was my attempt. Hopefully this works, but there might be edge cases that I haven't checked.
Ah nice, it works for the most part.
Something weird happens with certain code though. I haven't had a chance to debug the cause, but one example is this dummy cell:
%%
magic(5)
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
2987.293487298 + 84.7928748123 + 234 + 234.293847293 + 39847 - 29384798 - 234.1239871;
It not only prints the raw code, but also truncates it:
>> NMITNNQHQSXI=tic;magic(5),2987.293487298 + 84.7928748123 + 234 + 234.293847293 +
39847 - 29384798 - 234.1239871;,2987.293487298 + 84.7928748123 + 234 + 234.293847293 +
39847 - 29384798 - 234.1239871;,2987.293487298 + 84.7928748123 + 234 + 234.293847293 +
39847 - 29384798 - 234.1239871;,2987.293487298 + 84.7928748123 + 234 + 234.293847293 +
39847 - 29384798 - 234.1239871;,2987.293487298 + 84.7928748123 + 234 + 234.293847293 +
39847 - 29384798 - 23
ans =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Elapsed time is 0.003924 seconds.
Good catch, I think there was a race condition. I'm not seeing this anymore after e7ca8a44f. Let me know if you see other issues, thanks 👍 👍 looking forward to using this feature
Now calls
pexpect.spawn.interact()
for full command window functionality (properly handles arrow keys, tab completion, backspace,clc
, etc.). Falls back to the originalsys.stdin
code ifpexpect
isn't available.Note a couple side effects before deciding whether to merge:
print
causes flushing issues withpexpect.spawn.interact()
, so now there'sprint_flush()
as a workaround.pexpect.spawn.send()
.