on master help sign in
Reporting.Doc.cycle now works on Windows

Use ASCII characters if running on Windows, avoiding the various encoding problems that are common there. It's not as pretty, but I guess it has a charm of its own. Also make the API guarantee that there is at least one name to display.

commit1a2e65d3d72395dacb700541cd6a749e111e4709 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 26 Mar 2019, 17:03 (8 years ago) parent8cd5c29
3 files changed+25−8
builder/src/Reporting/Exit.hs+7−1 builder/src/Stuff.hs+1 compiler/src/Reporting/Doc.hs+17−7
builder/src/Reporting/Exit.hs+7−1
@@ -190,13 +190,19 @@ diffToReport diff =
190190
191191
192192data Install
193− = InstallNoArgs FilePath
193+ = InstallNoProject
194+ | InstallNoArgs FilePath
194195 | InstallNoSolution [Pkg.Name]
195196
196197
197198installToReport :: Install -> Help.Report
198199installToReport exit =
199200 case exit of
201+ InstallNoProject ->
202+ Help.report "NEW PROJECT?" Nothing
203+ (error "TODO InstallNoProject")
204+ (error "TODO InstallNoProject details")
205+
200206 InstallNoArgs elmHome ->
201207 Help.report "INSTALL WHAT?" Nothing
202208 "I am expecting commands like:"
builder/src/Stuff.hs+1
@@ -15,6 +15,7 @@ module Stuff
1515 , registry
1616 , package
1717 , getReplCache
18+ , getElmHome
1819 )
1920 where
2021
compiler/src/Reporting/Doc.hs+17−7
@@ -28,6 +28,7 @@ import Data.Monoid ((<>))
2828import qualified Data.Name as Name
2929import qualified Data.Utf8 as Utf8
3030import qualified System.Console.ANSI.Types as Ansi
31+import qualified System.Info as Info
3132import System.IO (Handle)
3233import qualified Text.PrettyPrint.ANSI.Leijen as P
3334
@@ -204,16 +205,25 @@ intToOrdinal number =
204205
205206
206207
207−cycle :: Int -> [Name.Name] -> P.Doc
208−cycle indent names =
208+cycle :: Int -> Name.Name -> [Name.Name] -> P.Doc
209+cycle indent name names =
209210 let
210− topLine = "┌─────┐"
211− nameLine name = "│ " <> P.dullyellow (fromName name)
212− midLine = "│ ↓"
213− bottomLine = "└─────┘"
211+ toLn n = cycleLn <> P.dullyellow (fromName n)
214212 in
215213 P.indent indent $ P.vcat $
216− topLine : List.intersperse midLine (map nameLine names) ++ [ bottomLine ]
214+ cycleTop : List.intersperse cycleMid (toLn name : map toLn names) ++ [ cycleEnd ]
215+
216+
217+cycleTop, cycleLn, cycleMid, cycleEnd :: P.Doc
218+cycleTop = if isWindows then "+-----+" else "┌─────┐"
219+cycleLn = if isWindows then "| " else "│ "
220+cycleMid = if isWindows then "| |" else "│ ↓"
221+cycleEnd = if isWindows then "+-<---+" else "└─────┘"
222+
223+
224+isWindows :: Bool
225+isWindows =
226+ Info.os == "mingw32"
217227
218228
219229