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 @@
"celltoolbar": "Hiding",
"language": "haskell",
"name": "",
"signature": "sha256:15cf13f0b51aedf4b16cbd0be35d8f1f0e7cca10ef18411c270d26f993eda4a7"
"signature": "sha256:bfb92bc59c8c3f67da7b83650a8f51392e6267254808a7bba3df4f09cbad6081"
},
"nbformat": 3,
"nbformat_minor": 0,
......@@ -53,7 +53,16 @@
"metadata": {
"hidden": false
},
"outputs": []
"outputs": [
{
"metadata": {},
"output_type": "display_data",
"text": [
"18"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
......
......@@ -201,10 +201,9 @@ htmlSuggestions = concatMap toHtml
showSuggestion :: String -> String
showSuggestion = removeSplices . remove lintIdent . dropDo
showSuggestion = remove lintIdent . dropDo
where
remove str = replace str ""
removeSplices = id
-- Drop leading ' do ', and blank spaces following.
dropDo :: String -> String
......
......@@ -78,7 +78,6 @@ parseString codeString = do
-- Split input into chunks based on indentation.
let chunks = layoutChunks $ removeComments codeString
result <- joinFunctions <$> processChunks [] chunks
liftIO $ print result
-- 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
......
......@@ -148,6 +148,7 @@ data KernelState = KernelState
useSvg :: Bool,
useShowErrors :: Bool,
useShowTypes :: Bool,
usePager :: Bool,
openComms :: Map UUID Widget
}
deriving Show
......@@ -160,6 +161,7 @@ defaultKernelState = KernelState
useSvg = True,
useShowErrors = False,
useShowTypes = False,
usePager = True,
openComms = empty
}
......@@ -185,6 +187,8 @@ kernelOpts =
, KernelOpt ["no-show-types"] ["-t"] $ \state -> state { useShowTypes = False }
, KernelOpt ["show-errors"] [] $ \state -> state { useShowErrors = True }
, 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.
......
......@@ -164,14 +164,14 @@ runKernel profileSrc initInfo = do
-- running some code.
let extLines = map (":extension " ++) $ extensions initInfo
noPublish _ = return ()
evaluator line = do
evaluator line = void $ do
-- Create a new state each time.
stateVar <- liftIO initialKernelState
state <- liftIO $ takeMVar stateVar
evaluate state line noPublish
mapM evaluator extLines
mapM evaluator $ initCells initInfo
mapM_ evaluator extLines
mapM_ evaluator $ initCells initInfo
forever $ do
-- Read the request from the request channel.
......@@ -335,8 +335,9 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
-- If this has some pager output, store it for later.
let pager = pagerOut result
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 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
idleHeader <- liftIO $ dupHeader replyHeader StatusMessage
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 {
header = replyHeader,
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