mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-01 09:49:24 +03:00
[ fix ] emacs' terminal is "dumb"
emacs sets the TERM variable to "dumb" and expects not to have to handle any ANSI escape codes as a consequence. We need to patch the renderer to unannotate the Doc in this situation.
This commit is contained in:
parent
62519c5352
commit
7c3960ab52
@ -9,6 +9,8 @@ import Libraries.Text.PrettyPrint.Prettyprinter
|
||||
import public Libraries.Text.PrettyPrint.Prettyprinter.Render.Terminal
|
||||
import Libraries.Utils.Term
|
||||
|
||||
import System
|
||||
|
||||
getPageWidth : {auto o : Ref ROpts REPLOpts} -> Core PageWidth
|
||||
getPageWidth = do
|
||||
consoleWidth <- getConsoleWidth
|
||||
@ -25,11 +27,16 @@ render : {auto o : Ref ROpts REPLOpts} ->
|
||||
Doc ann -> Core String
|
||||
render stylerAnn doc = do
|
||||
color <- getColor
|
||||
isDumb <- (Just "dumb" ==) <$> coreLift (getEnv "TERM")
|
||||
-- ^-- emacs sets the TERM variable to `dumb` and expects the compiler
|
||||
-- to not emit any ANSI escape codes
|
||||
pageWidth <- getPageWidth
|
||||
let opts = MkLayoutOptions pageWidth
|
||||
let layout = layoutPretty opts doc
|
||||
pure $ renderString $
|
||||
if color then reAnnotateS stylerAnn layout else unAnnotateS layout
|
||||
if color && not isDumb
|
||||
then reAnnotateS stylerAnn layout
|
||||
else unAnnotateS layout
|
||||
|
||||
export
|
||||
renderWithoutColor : {auto o : Ref ROpts REPLOpts} -> Doc ann -> Core String
|
||||
|
Loading…
Reference in New Issue
Block a user