@@ -407,6 +407,21 @@ getUndefined :: Idris [Name]
407getUndefined = do i <- getIState
407getUndefined = do i <- getIState
408 return (map fst (idris_metavars i) \\ primDefs)
408 return (map fst (idris_metavars i) \\ primDefs)
410+getWidth :: Idris ConsoleWidth
411+getWidth = fmap idris_consolewidth getIState
413+setWidth :: ConsoleWidth -> Idris ()
414+setWidth w = do ist <- getIState
415+ put ist { idris_consolewidth = w }
417+iRender :: Doc a -> Idris (SimpleDoc a)
418+iRender d = do w <- getWidth
420+ InfinitelyWide -> renderCompact d
421+ ColsWide n -> if n < 1
422+ then renderCompact d
423+ else renderPretty 0.5 n d
410ihPrintResult :: Handle -> String -> Idris ()
425ihPrintResult :: Handle -> String -> Idris ()
411ihPrintResult h s = do i <- getIState
426ihPrintResult h s = do i <- getIState
412 case idris_outputmode i of
427 case idris_outputmode i of
@@ -420,9 +435,11 @@ ihPrintResult h s = do i <- getIState
420-- | Write a pretty-printed term to the console with semantic coloring
435-- | Write a pretty-printed term to the console with semantic coloring
421consoleDisplayAnnotated :: Handle -> Doc OutputAnnotation -> Idris ()
436consoleDisplayAnnotated :: Handle -> Doc OutputAnnotation -> Idris ()
422consoleDisplayAnnotated h output = do ist <- getIState
437consoleDisplayAnnotated h output = do ist <- getIState
438+ rendered <- iRender $ output
423 runIO . hPutStrLn h .
439 runIO . hPutStrLn h .
424− displayDecorated (consoleDecorate ist) .
440+ displayDecorated (consoleDecorate ist) $
425− renderCompact $ output
441+ rendered
427-- | Write pretty-printed output to IDESlave with semantic annotations
444-- | Write pretty-printed output to IDESlave with semantic annotations
428ideSlaveReturnAnnotated :: Integer -> Handle -> Doc OutputAnnotation -> Idris ()
445ideSlaveReturnAnnotated :: Integer -> Handle -> Doc OutputAnnotation -> Idris ()
@@ -451,7 +468,7 @@ ihPrintFunTypes h n overloads = do imp <- impShow
451 RawOutput -> consoleDisplayAnnotated h output
468 RawOutput -> consoleDisplayAnnotated h output
452 IdeSlave n -> ideSlaveReturnAnnotated n h output
469 IdeSlave n -> ideSlaveReturnAnnotated n h output
453 where fullName n = annotate (AnnName n Nothing Nothing) $ text (show n)
470 where fullName n = annotate (AnnName n Nothing Nothing) $ text (show n)
454− ppOverload imp n tm = fullName n <+> colon <+> prettyImp imp tm
471+ ppOverload imp n tm = fullName n <+> colon <+> align (prettyImp imp tm)
456fancifyAnnots :: IState -> OutputAnnotation -> OutputAnnotation
473fancifyAnnots :: IState -> OutputAnnotation -> OutputAnnotation
457fancifyAnnots ist annot@(AnnName n _ _) =
474fancifyAnnots ist annot@(AnnName n _ _) =