X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fghci%2FInteractiveUI.hs;h=e45e738a5b3364e8a72c62f2139b285aa8f3c9d5;hb=5ac833ec6a3ecb038249e5ea9c43b372f77481b5;hp=c53fcf20793c81c5d45028c449daf2ddc1191832;hpb=6756c64349881d67aeeee08373d9a3083c3d4eb8;p=ghc-hetmet.git diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index c53fcf2..e45e738 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -76,6 +76,7 @@ import System.Exit ( exitWith, ExitCode(..) ) import System.Directory import System.IO import System.IO.Error as IO +import System.IO.Unsafe import Data.Char import Data.Dynamic import Data.Array @@ -1817,18 +1818,18 @@ findBreakByCoord mb_file (line, col) arr GHC.srcSpanStartLine span == line, GHC.srcSpanStartCol span >= col ] --- for now, use ANSI bold on Unixy systems. On Windows, we add a line --- of carets under the active expression instead. The Windows console --- doesn't support ANSI escape sequences, and most Unix terminals --- (including xterm) do, so this is a reasonable guess until we have a --- proper termcap/terminfo library. -#if !defined(mingw32_TARGET_OS) -do_bold = True -#else -do_bold = False -#endif +-- For now, use ANSI bold on terminals that we know support it. +-- Otherwise, we add a line of carets under the active expression instead. +-- In particular, on Windows and when running the testsuite (which sets +-- TERM to vt100 for other reasons) we get carets. +-- We really ought to use a proper termcap/terminfo library. +do_bold :: Bool +do_bold = unsafePerformIO (System.Environment.getEnv "TERM") `elem` + ["xterm", "linux"] +start_bold :: String start_bold = "\ESC[1m" +end_bold :: String end_bold = "\ESC[0m" listCmd :: String -> GHCi () @@ -1940,7 +1941,7 @@ listAround span do_highlight = do = BS.concat [line, nl, indent, BS.replicate col2 '^'] | otherwise = line where - indent = BS.pack " " + indent = BS.pack (" " ++ replicate (length (show no)) ' ') nl = BS.singleton '\n' -- --------------------------------------------------------------------------