robert-dodier / maxima-jupyter

A Maxima kernel for Jupyter, based on CL-Jupyter (Common Lisp kernel)
Other
187 stars 31 forks source link

Add automatic prompt detection and testing #27

Closed yitzchak closed 6 years ago

yitzchak commented 6 years ago

This PR adds support for a STDIN channel stream that overrides *query-io* and *standard-input*. This makes it possible to detect input requests without overriding the internals of Maxima functions like retrieve. It also adds the beginning of a testing framework for the client side. Some unneeded functions are removed and all Maxima overrides are moved into overrides.lisp.

Mechanism

The class stdin-stream looks for finish-output calls on *query-io* and interprets them as printed prompts which are used in an input_request. The read side of *query-io* then filled with the results. The iopub-stream assists by looking for ANSI SOS and ANSI ST which are used as prompt delimeters. It writes prompts to *query-io* causing an input_request. All read calls from *standard-input*, *debug-io* and iopub-stream are routed to stdin-stream also.

All of this makes retrieve, $read, the dbm-loop prompts and the Lisp functions such as yes-or-no-p work without overriding.