Commit e68fbb8e authored by Sumit Sahrawat's avatar Sumit Sahrawat

Reformat with hindent

parent 8f3f18c5
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module IHaskell.Display.Widgets.Common ( module IHaskell.Display.Widgets.Common (ButtonStyle(..), ImageFormat(..)) where
-- * Predefined button styles
ButtonStyle(..),
-- * Image formats
ImageFormat(..),
) where
import Data.Aeson (ToJSON(..)) import Data.Aeson (ToJSON(..))
import qualified Data.Text as T import qualified Data.Text as T
...@@ -28,7 +23,9 @@ instance ToJSON ButtonStyle where ...@@ -28,7 +23,9 @@ instance ToJSON ButtonStyle where
toJSON None = "" toJSON None = ""
-- | Image formats for ImageWidget -- | Image formats for ImageWidget
data ImageFormat = PNG | SVG | JPG data ImageFormat = PNG
| SVG
| JPG
deriving Eq deriving Eq
instance Show ImageFormat where instance Show ImageFormat where
......
...@@ -50,8 +50,9 @@ data ImageWidget = ...@@ -50,8 +50,9 @@ data ImageWidget =
newtype ImageInt = ImageInt { unwrap :: Int } newtype ImageInt = ImageInt { unwrap :: Int }
instance ToJSON ImageInt where instance ToJSON ImageInt where
toJSON (ImageInt n) | n > 0 = toJSON $ str $ show n toJSON (ImageInt n)
| otherwise = toJSON $ str $ "" | n > 0 = toJSON $ str $ show n
| otherwise = toJSON $ str $ ""
-- | Create a new image widget -- | Create a new image widget
mkImageWidget :: IO ImageWidget mkImageWidget :: IO ImageWidget
...@@ -64,13 +65,7 @@ mkImageWidget = do ...@@ -64,13 +65,7 @@ mkImageWidget = do
val <- newIORef "" val <- newIORef ""
let initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Image"] let initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Image"]
b = ImageWidget b = ImageWidget { uuid = commUUID, format = fmt, height = hgt, width = wdt, b64value = val }
{ uuid = commUUID
, format = fmt
, height = hgt
, width = wdt
, b64value = val
}
-- Open a comm for this widget, and store it in the kernel state -- Open a comm for this widget, and store it in the kernel state
widgetSendOpen b initData (toJSON b) widgetSendOpen b initData (toJSON b)
......
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