Commit 3a2228d2 authored by Sumit Sahrawat's avatar Sumit Sahrawat

Comment on console input issue

Explain reasons for widget's inability to use stdin.
parent 73446ed7
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
> Largely based on: https://github.com/ipython/ipython/wiki/IPEP-23:-Backbone.js-Widgets > Largely based on: https://github.com/ipython/ipython/wiki/IPEP-23:-Backbone.js-Widgets
> The messaging specification as detailed is riddled with assumptions IHaskell's widget > The messaging specification as detailed is riddled with assumptions the IHaskell widget
> implementation makes. It works for us, so it should work for everyone. > implementation makes. It works for us, so it should work for everyone.
## Creating widgets ## Creating widgets
...@@ -101,6 +101,18 @@ two possible formats: ...@@ -101,6 +101,18 @@ two possible formats:
This form is generally used to notify the kernel about events. For example, the `TextWidget` sends a This form is generally used to notify the kernel about events. For example, the `TextWidget` sends a
custom message when the text is submitted by hitting the 'Enter' key. custom message when the text is submitted by hitting the 'Enter' key.
## The issue with console input
Whenever the kernel needs to fetch input from the stdin, an `input_request` message is sent to the
frontend. The format for this message requires that this message be sent in response to an
`execute_request`, which is sent by the frontend whenever a cell is executed.
If this were not so, the frontend would not be able to determine under which cell to place the text
input widget, when an `input_request` is received.
Now, widgets cannot send `execute_request` messages. They can only send `comm_data` messages, which
means that it's not possible to fetch input through widget events.
--- ---
*NOTE*: It's important that the messages sent on the comm are in response to an execution message *NOTE*: It's important that the messages sent on the comm are in response to an execution message
......
...@@ -51,7 +51,9 @@ module IHaskell.Display.Widgets.Types where ...@@ -51,7 +51,9 @@ module IHaskell.Display.Widgets.Types where
-- --
-- To know more about the IPython messaging specification (as implemented in this package) take a look -- To know more about the IPython messaging specification (as implemented in this package) take a look
-- at the supplied MsgSpec.md. -- at the supplied MsgSpec.md.
--
-- Widgets are not able to do console input, the reason for that can also be found in the messaging
-- specification
import Control.Monad (unless, join, when, void) import Control.Monad (unless, join, when, void)
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
import qualified Control.Exception as Ex import qualified Control.Exception as Ex
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment