Commit 2762da3e authored by Andrew Gibiansky's avatar Andrew Gibiansky

Added `pager` and `no-pager` options for controlling whether to use the

pager. Closes #126.
parent 6038faf1
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"celltoolbar": "Hiding", "celltoolbar": "Hiding",
"language": "haskell", "language": "haskell",
"name": "", "name": "",
"signature": "sha256:15cf13f0b51aedf4b16cbd0be35d8f1f0e7cca10ef18411c270d26f993eda4a7" "signature": "sha256:bfb92bc59c8c3f67da7b83650a8f51392e6267254808a7bba3df4f09cbad6081"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
...@@ -53,7 +53,16 @@ ...@@ -53,7 +53,16 @@
"metadata": { "metadata": {
"hidden": false "hidden": false
}, },
"outputs": [] "outputs": [
{
"metadata": {},
"output_type": "display_data",
"text": [
"18"
]
}
],
"prompt_number": 2
}, },
{ {
"cell_type": "code", "cell_type": "code",
......
...@@ -201,10 +201,9 @@ htmlSuggestions = concatMap toHtml ...@@ -201,10 +201,9 @@ htmlSuggestions = concatMap toHtml
showSuggestion :: String -> String showSuggestion :: String -> String
showSuggestion = removeSplices . remove lintIdent . dropDo showSuggestion = remove lintIdent . dropDo
where where
remove str = replace str "" remove str = replace str ""
removeSplices = id
-- Drop leading ' do ', and blank spaces following. -- Drop leading ' do ', and blank spaces following.
dropDo :: String -> String dropDo :: String -> String
......
...@@ -78,7 +78,6 @@ parseString codeString = do ...@@ -78,7 +78,6 @@ parseString codeString = do
-- Split input into chunks based on indentation. -- Split input into chunks based on indentation.
let chunks = layoutChunks $ removeComments codeString let chunks = layoutChunks $ removeComments codeString
result <- joinFunctions <$> processChunks [] chunks result <- joinFunctions <$> processChunks [] chunks
liftIO $ print result
-- Return to previous flags. When parsing, flags can be set to make -- Return to previous flags. When parsing, flags can be set to make
-- sure parsing works properly. But we don't want those flags to be -- sure parsing works properly. But we don't want those flags to be
......
...@@ -148,6 +148,7 @@ data KernelState = KernelState ...@@ -148,6 +148,7 @@ data KernelState = KernelState
useSvg :: Bool, useSvg :: Bool,
useShowErrors :: Bool, useShowErrors :: Bool,
useShowTypes :: Bool, useShowTypes :: Bool,
usePager :: Bool,
openComms :: Map UUID Widget openComms :: Map UUID Widget
} }
deriving Show deriving Show
...@@ -160,6 +161,7 @@ defaultKernelState = KernelState ...@@ -160,6 +161,7 @@ defaultKernelState = KernelState
useSvg = True, useSvg = True,
useShowErrors = False, useShowErrors = False,
useShowTypes = False, useShowTypes = False,
usePager = True,
openComms = empty openComms = empty
} }
...@@ -185,6 +187,8 @@ kernelOpts = ...@@ -185,6 +187,8 @@ kernelOpts =
, KernelOpt ["no-show-types"] ["-t"] $ \state -> state { useShowTypes = False } , KernelOpt ["no-show-types"] ["-t"] $ \state -> state { useShowTypes = False }
, KernelOpt ["show-errors"] [] $ \state -> state { useShowErrors = True } , KernelOpt ["show-errors"] [] $ \state -> state { useShowErrors = True }
, KernelOpt ["no-show-errors"] [] $ \state -> state { useShowErrors = False } , KernelOpt ["no-show-errors"] [] $ \state -> state { useShowErrors = False }
, KernelOpt ["pager"] [] $ \state -> state { usePager = True }
, KernelOpt ["no-pager"] [] $ \state -> state { usePager = False }
] ]
-- | Initialization information for the kernel. -- | Initialization information for the kernel.
......
...@@ -164,14 +164,14 @@ runKernel profileSrc initInfo = do ...@@ -164,14 +164,14 @@ runKernel profileSrc initInfo = do
-- running some code. -- running some code.
let extLines = map (":extension " ++) $ extensions initInfo let extLines = map (":extension " ++) $ extensions initInfo
noPublish _ = return () noPublish _ = return ()
evaluator line = do evaluator line = void $ do
-- Create a new state each time. -- Create a new state each time.
stateVar <- liftIO initialKernelState stateVar <- liftIO initialKernelState
state <- liftIO $ takeMVar stateVar state <- liftIO $ takeMVar stateVar
evaluate state line noPublish evaluate state line noPublish
mapM evaluator extLines mapM_ evaluator extLines
mapM evaluator $ initCells initInfo mapM_ evaluator $ initCells initInfo
forever $ do forever $ do
-- Read the request from the request channel. -- Read the request from the request channel.
...@@ -335,8 +335,9 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do ...@@ -335,8 +335,9 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
-- If this has some pager output, store it for later. -- If this has some pager output, store it for later.
let pager = pagerOut result let pager = pagerOut result
unless (null pager) $ unless (null pager) $
modifyMVar_ pagerOutput (return . (++ pager ++ "\n")) if usePager state
then modifyMVar_ pagerOutput (return . (++ pager ++ "\n"))
else sendOutput $ Display [html pager]
let execCount = getExecutionCounter state let execCount = getExecutionCounter state
-- Let all frontends know the execution count and code that's about to run -- Let all frontends know the execution count and code that's about to run
...@@ -350,7 +351,10 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do ...@@ -350,7 +351,10 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
idleHeader <- liftIO $ dupHeader replyHeader StatusMessage idleHeader <- liftIO $ dupHeader replyHeader StatusMessage
send $ PublishStatus idleHeader Idle send $ PublishStatus idleHeader Idle
pager <- liftIO $ readMVar pagerOutput -- Take pager output if we're using the pager.
pager <- if usePager state
then liftIO $ readMVar pagerOutput
else return ""
return (updatedState, ExecuteReply { return (updatedState, ExecuteReply {
header = replyHeader, header = replyHeader,
pagerOutput = pager, pagerOutput = pager,
......
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