Compare commits
No commits in common. "49ffea3f2eb03e0c24dc5da804ee6ab9fb181759" and "86f952e572b3d9176c225640baec7a1b96ed1f0c" have entirely different histories.
49ffea3f2e
...
86f952e572
|
@ -33,10 +33,7 @@ executable hxbrief
|
|||
async >=2.2.3 && <2.3,
|
||||
transformers >=0.5.6.2 &&<0.6,
|
||||
clock >=0.8 &&<0.9,
|
||||
pretty >=1.1.3.6 && <1.2,
|
||||
text >=1.2.4,
|
||||
regex-base >=0.94 && <0.95,
|
||||
regex-pcre-builtin >=0.95 && < 0.96
|
||||
pretty >=1.1.3.6 && <1.2
|
||||
hs-source-dirs: src-hxbrief
|
||||
default-language: Haskell2010
|
||||
ghc-options: -rtsopts -threaded -Wall
|
||||
|
|
13
seaaye.nix
13
seaaye.nix
|
@ -4,24 +4,23 @@
|
|||
{
|
||||
hackage-8-10 = {
|
||||
resolver = "hackage";
|
||||
index-state = "2022-07-01T00:00:00Z";
|
||||
index-state = "2021-07-01T00:00:00Z";
|
||||
ghc-ver = "ghc8107";
|
||||
};
|
||||
hackage-9-00 = {
|
||||
hackage-9-01 = {
|
||||
resolver = "hackage";
|
||||
index-state = "2022-07-01T00:00:00Z";
|
||||
ghc-ver = "ghc902";
|
||||
index-state = "2021-07-01T00:00:00Z";
|
||||
ghc-ver = "ghc901";
|
||||
enabled = false;
|
||||
};
|
||||
hackage-9-02 = {
|
||||
resolver = "hackage";
|
||||
index-state = "2022-07-01T00:00:00Z";
|
||||
ghc-ver = "ghc925";
|
||||
index-state = "2021-11-01T00:00:00Z";
|
||||
ghc-ver = "ghc921";
|
||||
enabled = false;
|
||||
};
|
||||
};
|
||||
module-flags = [
|
||||
# { enableLibraryProfiling = true; }
|
||||
# N.B.: There are haskell-nix module options. See the haskell-nix docs
|
||||
# for details. Also, be careful about typos: In many cases you
|
||||
# will not get errors but the typo'd flag will just not have any
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,9 +3,6 @@
|
|||
module Util where
|
||||
|
||||
|
||||
import qualified Data.Char as Char
|
||||
import Data.Text ( Text )
|
||||
import qualified Data.Text as Text
|
||||
import qualified System.Console.ANSI as Ansi
|
||||
import System.Exit ( ExitCode
|
||||
( ExitFailure
|
||||
|
@ -14,60 +11,27 @@ import System.Exit ( ExitCode
|
|||
)
|
||||
|
||||
|
||||
t :: String -> Text
|
||||
t = Text.pack
|
||||
|
||||
fGrey :: Text
|
||||
fGrey =
|
||||
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Dull Ansi.White]
|
||||
fWhite :: Text
|
||||
fWhite =
|
||||
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Vivid Ansi.White]
|
||||
fWhiteDis :: Text
|
||||
fWhiteDis = t ""
|
||||
fRedDis :: Text
|
||||
fRedDis = t "" -- TODO disabled until the bug is fixed.
|
||||
fGrey :: String
|
||||
fGrey = Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Dull Ansi.White]
|
||||
fWhite :: String
|
||||
fWhite = Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Vivid Ansi.White]
|
||||
fWhiteDis :: String
|
||||
fWhiteDis = ""
|
||||
fRedDis :: String
|
||||
fRedDis = "" -- TODO disabled until the bug is fixed.
|
||||
-- setFGColorDull Ansi.Red
|
||||
|
||||
fReset :: Text
|
||||
fReset = t $ Ansi.setSGRCode [Ansi.Reset]
|
||||
fReset :: String
|
||||
fReset = Ansi.setSGRCode [Ansi.Reset]
|
||||
|
||||
setFGColorVivid :: Ansi.Color -> Text
|
||||
setFGColorVivid :: Ansi.Color -> String
|
||||
setFGColorVivid c =
|
||||
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Vivid c]
|
||||
setFGColorDull :: Ansi.Color -> Text
|
||||
setFGColorDull c =
|
||||
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Dull c]
|
||||
Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Vivid c]
|
||||
setFGColorDull :: Ansi.Color -> String
|
||||
setFGColorDull c = Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Dull c]
|
||||
|
||||
showEC :: ExitCode -> Text
|
||||
showEC :: ExitCode -> String
|
||||
showEC = \case
|
||||
ExitSuccess -> setFGColorVivid Ansi.Green <> t "0" <> fReset
|
||||
ExitFailure i -> setFGColorVivid Ansi.Red <> t (show i) <> fReset
|
||||
|
||||
filterEscapeFunc :: Text -> Text
|
||||
filterEscapeFunc input = go Text.empty input
|
||||
where
|
||||
isSpecial c = Char.isControl c
|
||||
go clean open = case Text.break isSpecial open of
|
||||
(a, b) -> case Text.uncons b of
|
||||
Nothing -> clean <> a
|
||||
Just ('\x07', rest) -> go (clean <> a) rest -- bell
|
||||
Just ('\x08', rest) -> if Text.null a -- backspace
|
||||
then if Text.null clean
|
||||
then go clean rest
|
||||
else go (Text.init clean) rest
|
||||
else go (clean <> Text.init a) rest
|
||||
Just ('\x09', rest) -> -- tab
|
||||
go (clean <> a <> Text.pack " ") rest
|
||||
Just ('\x1b', rest) -> -- esc
|
||||
clean <> a <> case Text.uncons rest of
|
||||
Nothing -> Text.empty
|
||||
Just ('\x5b', more) -> finishEscape more
|
||||
Just ('\x9b', more) -> finishEscape more
|
||||
Just (_ , more) -> filterEscapeFunc more
|
||||
Just (_, rest) -> go (clean <> a) rest
|
||||
finishEscape remain = case Text.uncons remain of
|
||||
Nothing -> remain
|
||||
Just (c, rest) -> if c >= '\x40' && c <= '\x7e'
|
||||
then filterEscapeFunc rest
|
||||
else finishEscape rest
|
||||
ExitSuccess -> setFGColorVivid Ansi.Green ++ "0" ++ fReset
|
||||
ExitFailure i -> setFGColorVivid Ansi.Red ++ show i ++ fReset
|
||||
|
|
Loading…
Reference in New Issue