Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
aed969c2
Commit
aed969c2
authored
Jun 25, 2015
by
Sumit Sahrawat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finalize Output Widget
- Add support for `clear_output` - Rename `setOutput` to `appendOutput`
parent
d7565d15
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
22 deletions
+65
-22
Output.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
+26
-5
Types.hs
ipython-kernel/src/IHaskell/IPython/Types.hs
+3
-2
Widgets.hs
src/IHaskell/Eval/Widgets.hs
+32
-14
Types.hs
src/IHaskell/Types.hs
+4
-1
No files found.
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
View file @
aed969c2
...
@@ -12,7 +12,10 @@ module IHaskell.Display.Widgets.Output (
...
@@ -12,7 +12,10 @@ module IHaskell.Display.Widgets.Output (
modifyOutputWidth
,
modifyOutputWidth
,
modifyOutputWidth_
,
modifyOutputWidth_
,
-- * Output to widget
-- * Output to widget
setOutput
,
appendOutput
,
clearOutput
,
clearOutput_
,
replaceOutput
,
)
where
)
where
-- To keep `cabal repl` happy when running from the ihaskell repo
-- To keep `cabal repl` happy when running from the ihaskell repo
...
@@ -72,13 +75,31 @@ modifyOutputWidth widget modifier = getOutputWidth widget >>= modifier >>= setOu
...
@@ -72,13 +75,31 @@ modifyOutputWidth widget modifier = getOutputWidth widget >>= modifier >>= setOu
-- | Modify the output widget width (with pure modifier)
-- | Modify the output widget width (with pure modifier)
modifyOutputWidth_
::
OutputWidget
->
(
Int
->
Int
)
->
IO
()
modifyOutputWidth_
::
OutputWidget
->
(
Int
->
Int
)
->
IO
()
modifyOutputWidth_
widget
modifier
=
getOutputWidth
widget
>>=
setOutputWidth
widget
.
modifier
modifyOutputWidth_
widget
modifier
=
do
w
<-
getOutputWidth
widget
setOutput
::
IHaskellDisplay
a
=>
OutputWidget
->
a
->
IO
()
let
newWidth
=
modifier
w
setOutput
widget
out
=
do
setOutputWidth
widget
newWidth
-- | Append to the output widget
appendOutput
::
IHaskellDisplay
a
=>
OutputWidget
->
a
->
IO
()
appendOutput
widget
out
=
do
disp
<-
display
out
disp
<-
display
out
widgetPublishDisplay
widget
disp
widgetPublishDisplay
widget
disp
-- | Clear the output widget immediately
clearOutput
::
OutputWidget
->
IO
()
clearOutput
widget
=
widgetClearOutput
widget
False
-- | Clear the output widget on next append
clearOutput_
::
OutputWidget
->
IO
()
clearOutput_
widget
=
widgetClearOutput
widget
True
-- | Replace the currently displayed output for output widget
replaceOutput
::
IHaskellDisplay
a
=>
OutputWidget
->
a
->
IO
()
replaceOutput
widget
d
=
do
clearOutput_
widget
appendOutput
widget
d
instance
ToJSON
OutputWidget
where
instance
ToJSON
OutputWidget
where
toJSON
b
=
object
toJSON
b
=
object
[
"_view_module"
.=
str
""
[
"_view_module"
.=
str
""
...
...
ipython-kernel/src/IHaskell/IPython/Types.hs
View file @
aed969c2
...
@@ -25,6 +25,7 @@ module IHaskell.IPython.Types (
...
@@ -25,6 +25,7 @@ module IHaskell.IPython.Types (
HistoryAccessType
(
..
),
HistoryAccessType
(
..
),
HistoryReplyElement
(
..
),
HistoryReplyElement
(
..
),
replyType
,
replyType
,
showMessageType
,
-- ** IPython display data message
-- ** IPython display data message
DisplayData
(
..
),
DisplayData
(
..
),
...
@@ -63,7 +64,7 @@ data Profile =
...
@@ -63,7 +64,7 @@ data Profile =
Profile
Profile
{
ip
::
IP
-- ^ The IP on which to listen.
{
ip
::
IP
-- ^ The IP on which to listen.
,
transport
::
Transport
-- ^ The transport mechanism.
,
transport
::
Transport
-- ^ The transport mechanism.
,
stdinPort
::
Port
-- ^ The stdin channel port.
,
stdinPort
::
Port
-- ^ The stdin channel port.
,
controlPort
::
Port
-- ^ The control channel port.
,
controlPort
::
Port
-- ^ The control channel port.
,
hbPort
::
Port
-- ^ The heartbeat channel port.
,
hbPort
::
Port
-- ^ The heartbeat channel port.
,
shellPort
::
Port
-- ^ The shell command port.
,
shellPort
::
Port
-- ^ The shell command port.
...
@@ -114,7 +115,7 @@ instance ToJSON Transport where
...
@@ -114,7 +115,7 @@ instance ToJSON Transport where
-------------------- IPython Kernelspec Types ----------------------
-------------------- IPython Kernelspec Types ----------------------
data
KernelSpec
=
data
KernelSpec
=
KernelSpec
KernelSpec
{
{
-- | Name shown to users to describe this kernel (e.g. "Haskell")
-- | Name shown to users to describe this kernel (e.g. "Haskell")
kernelDisplayName
::
String
kernelDisplayName
::
String
-- | Name for the kernel; unique kernel identifier (e.g. "haskell")
-- | Name for the kernel; unique kernel identifier (e.g. "haskell")
...
...
src/IHaskell/Eval/Widgets.hs
View file @
aed969c2
...
@@ -6,6 +6,7 @@ module IHaskell.Eval.Widgets (
...
@@ -6,6 +6,7 @@ module IHaskell.Eval.Widgets (
widgetSendClose
,
widgetSendClose
,
widgetSendValue
,
widgetSendValue
,
widgetPublishDisplay
,
widgetPublishDisplay
,
widgetClearOutput
,
relayWidgetMessages
,
relayWidgetMessages
,
widgetHandler
,
widgetHandler
,
)
where
)
where
...
@@ -22,6 +23,7 @@ import System.IO.Unsafe (unsafePerformIO)
...
@@ -22,6 +23,7 @@ import System.IO.Unsafe (unsafePerformIO)
import
IHaskell.Display
import
IHaskell.Display
import
IHaskell.Eval.Util
(
unfoldM
)
import
IHaskell.Eval.Util
(
unfoldM
)
import
IHaskell.IPython.Types
(
showMessageType
)
import
IHaskell.IPython.Message.UUID
import
IHaskell.IPython.Message.UUID
import
IHaskell.IPython.Message.Writer
import
IHaskell.IPython.Message.Writer
import
IHaskell.Types
import
IHaskell.Types
...
@@ -78,6 +80,10 @@ widgetSendValue widget = queue . JSONValue (Widget widget)
...
@@ -78,6 +80,10 @@ widgetSendValue widget = queue . JSONValue (Widget widget)
widgetPublishDisplay
::
(
IHaskellWidget
a
,
IHaskellDisplay
b
)
=>
a
->
b
->
IO
()
widgetPublishDisplay
::
(
IHaskellWidget
a
,
IHaskellDisplay
b
)
=>
a
->
b
->
IO
()
widgetPublishDisplay
widget
disp
=
display
disp
>>=
queue
.
DispMsg
(
Widget
widget
)
widgetPublishDisplay
widget
disp
=
display
disp
>>=
queue
.
DispMsg
(
Widget
widget
)
-- | Send a `clear_output` message as a [method .= custom] message
widgetClearOutput
::
IHaskellWidget
a
=>
a
->
Bool
->
IO
()
widgetClearOutput
widget
wait
=
queue
$
ClrOutput
(
Widget
widget
)
wait
-- | Handle a single widget message. Takes necessary actions according to the message type, such as
-- | Handle a single widget message. Takes necessary actions according to the message type, such as
-- opening comms, storing and updating widget representation in the kernel state etc.
-- opening comms, storing and updating widget representation in the kernel state etc.
handleMessage
::
(
Message
->
IO
()
)
handleMessage
::
(
Message
->
IO
()
)
...
@@ -142,16 +148,13 @@ handleMessage send replyHeader state msg = do
...
@@ -142,16 +148,13 @@ handleMessage send replyHeader state msg = do
DispMsg
widget
disp
->
do
DispMsg
widget
disp
->
do
dispHeader
<-
dupHeader
replyHeader
DisplayDataMessage
dispHeader
<-
dupHeader
replyHeader
DisplayDataMessage
let
dmsg
=
WidgetDisplay
dispHeader
"haskell"
$
unwrap
disp
let
dmsg
=
WidgetDisplay
dispHeader
"haskell"
$
unwrap
disp
uuid
=
getCommUUID
widget
sendMessage
widget
(
toJSON
$
CustomContent
$
toJSON
dmsg
)
present
=
isJust
$
Map
.
lookup
uuid
oldComms
-- If the widget is present, we send an update message on its comm.
ClrOutput
widget
wait
->
do
when
present
$
do
header
<-
dupHeader
replyHeader
ClearOutputMessage
header
<-
dupHeader
replyHeader
CommDataMessage
let
cmsg
=
WidgetClear
header
wait
send
$
CommData
header
uuid
$
toJSON
$
CustomContent
$
toJSON
dmsg
sendMessage
widget
(
toJSON
$
CustomContent
$
toJSON
cmsg
)
return
state
where
where
oldComms
=
openComms
state
oldComms
=
openComms
state
...
@@ -175,12 +178,27 @@ data WidgetDisplay = WidgetDisplay MessageHeader String [DisplayData]
...
@@ -175,12 +178,27 @@ data WidgetDisplay = WidgetDisplay MessageHeader String [DisplayData]
instance
ToJSON
WidgetDisplay
where
instance
ToJSON
WidgetDisplay
where
toJSON
(
WidgetDisplay
replyHeader
source
ddata
)
=
toJSON
(
WidgetDisplay
replyHeader
source
ddata
)
=
let
pbval
=
toJSON
$
PublishDisplayData
replyHeader
source
ddata
let
pbval
=
toJSON
$
PublishDisplayData
replyHeader
source
ddata
in
object
in
toJSON
$
IPythonMessage
replyHeader
pbval
DisplayDataMessage
[
"header"
.=
replyHeader
,
"parent_header"
.=
str
""
-- Override toJSON for ClearOutput
,
"metadata"
.=
str
"{}"
data
WidgetClear
=
WidgetClear
MessageHeader
Bool
,
"content"
.=
pbval
]
instance
ToJSON
WidgetClear
where
toJSON
(
WidgetClear
replyHeader
wait
)
=
let
clrVal
=
toJSON
$
ClearOutput
replyHeader
wait
in
toJSON
$
IPythonMessage
replyHeader
clrVal
ClearOutputMessage
data
IPythonMessage
=
IPythonMessage
MessageHeader
Value
MessageType
instance
ToJSON
IPythonMessage
where
toJSON
(
IPythonMessage
replyHeader
val
msgType
)
=
object
[
"header"
.=
replyHeader
,
"parent_header"
.=
str
""
,
"metadata"
.=
str
"{}"
,
"content"
.=
val
,
"msg_type"
.=
(
toJSON
.
showMessageType
$
msgType
)
]
str
::
String
->
String
str
::
String
->
String
str
=
id
str
=
id
...
...
src/IHaskell/Types.hs
View file @
aed969c2
...
@@ -208,7 +208,10 @@ data WidgetMsg = Open Widget Value Value
...
@@ -208,7 +208,10 @@ data WidgetMsg = Open Widget Value Value
|
|
-- ^ A json object that is sent to the widget without modifications.
-- ^ A json object that is sent to the widget without modifications.
DispMsg
Widget
Display
DispMsg
Widget
Display
-- ^ A 'display_data' message, sent as a [method .= custom] comm_msg
-- ^ A 'display_data' message, sent as a [method .= custom] comm_msg
|
ClrOutput
Widget
Bool
-- ^ A 'clear_output' message, sent as a [method .= custom] comm_msg
deriving
(
Show
,
Typeable
)
deriving
(
Show
,
Typeable
)
data
WidgetMethod
=
UpdateState
Value
data
WidgetMethod
=
UpdateState
Value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment