diff options
-rw-r--r-- | utils/ghc-pkg/Main.hs | 54 | ||||
-rw-r--r-- | utils/ghc-pkg/ghc-pkg.cabal.in | 8 |
2 files changed, 17 insertions, 45 deletions
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index 5e91d905e6..5fb6a85bce 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -10,13 +10,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -fno-warn-orphans #-} --- We never want to link against terminfo while bootstrapping. -#if defined(BOOTSTRAPPING) -#if defined(WITH_TERMINFO) -#undef WITH_TERMINFO -#endif -#endif - -- Fine if this comes from make/Hadrian or the pre-built base. #include <ghcplatform.h> @@ -100,10 +93,6 @@ import System.Posix hiding (fdToHandle) import qualified System.Info(os) #endif -#if defined(WITH_TERMINFO) -import System.Console.Terminfo as Terminfo -#endif - #if defined(mingw32_HOST_OS) # if defined(i386_HOST_ARCH) # define WINDOWS_CCONV stdcall @@ -1582,37 +1571,28 @@ listPackages verbosity my_flags mPackageName mModuleName = do if simple_output then show_simple stack else do -#if !defined(WITH_TERMINFO) +#if defined(mingw32_HOST_OS) mapM_ show_normal stack #else let - show_colour withF db@PackageDB{ packages = pkg_confs } = - if null pkg_confs - then termText (location db) <#> termText "\n (no packages)\n" - else - mconcat $ map (<#> termText "\n") $ - (termText (location db) - : map (termText " " <#>) (map pp_pkg pkg_confs)) - where - pp_pkg p - | installedUnitId p `elem` broken = withF Red doc - | exposed p = doc - | otherwise = withF Blue doc - where doc | verbosity >= Verbose - = termText (printf "%s (%s)" pkg (display (installedUnitId p))) - | otherwise - = termText pkg - where - pkg = display (mungedId p) + show_colour PackageDB{ location = db_name, packages = pkg_confs } = + do hPutStrLn stdout db_name + if null pkg_confs + then hPutStrLn stdout " (no packages)" + else hPutStrLn stdout $ unlines (map (" " ++) (map pp_pkg pkg_confs)) + where + pp_pkg p + | installedUnitId p `elem` broken = printf "\ESC[31m%s\ESC[0m" doc -- red color + | exposed p = doc + | otherwise = printf "\ESC[34m%s\ESC[0m" doc -- blue color + where doc | verbosity >= Verbose = printf "%s (%s)" pkg (display (installedUnitId p)) + | otherwise = pkg + where + pkg = display (mungedId p) is_tty <- hIsTerminalDevice stdout - if not is_tty - then mapM_ show_normal stack - else do tty <- Terminfo.setupTermFromEnv - case Terminfo.getCapability tty withForegroundColor of - Nothing -> mapM_ show_normal stack - Just w -> runTermOutput tty $ mconcat $ - map (show_colour w) stack + -- Coloured text is a part of ANSI standard, no reason to query terminfo + mapM_ (if is_tty then show_colour else show_normal) stack #endif simplePackageList :: [Flag] -> [InstalledPackageInfo] -> IO () diff --git a/utils/ghc-pkg/ghc-pkg.cabal.in b/utils/ghc-pkg/ghc-pkg.cabal.in index 4d9402c2d3..2503f0bba3 100644 --- a/utils/ghc-pkg/ghc-pkg.cabal.in +++ b/utils/ghc-pkg/ghc-pkg.cabal.in @@ -15,11 +15,6 @@ Category: Development build-type: Simple cabal-version: >=1.10 -Flag terminfo - Description: Build GHC with terminfo support on non-Windows platforms. - Default: True - Manual: False - Executable ghc-pkg Default-Language: Haskell2010 Main-Is: Main.hs @@ -35,9 +30,6 @@ Executable ghc-pkg binary, ghc-boot, bytestring - if !os(windows) && flag(terminfo) - Build-Depends: terminfo - Cpp-Options: -DWITH_TERMINFO if !os(windows) Build-Depends: unix if os(windows) |