pkg!: Remove Hledger.Utils.Color module.
This module was only used in one place in Hledger.Data.Amount. The code has been moved directly into Hledger.Utils.
This commit is contained in:
parent
f1994d5aa8
commit
a0f9d7560f
@ -158,6 +158,7 @@ import qualified Data.Text as T
|
||||
import qualified Data.Text.Lazy.Builder as TB
|
||||
import Data.Word (Word8)
|
||||
import Safe (headDef, lastDef, lastMay)
|
||||
import System.Console.ANSI (Color(..),ColorIntensity(..))
|
||||
import Text.Printf (printf)
|
||||
|
||||
import Hledger.Data.Types
|
||||
|
||||
@ -24,7 +24,6 @@ module Hledger.Utils (---- provide these frequently used modules - or not, for c
|
||||
module Hledger.Utils.String,
|
||||
module Hledger.Utils.Text,
|
||||
module Hledger.Utils.Test,
|
||||
module Hledger.Utils.Color,
|
||||
-- Debug.Trace.trace,
|
||||
-- module Data.PPrint,
|
||||
-- the rest need to be done in each module I think
|
||||
@ -38,6 +37,7 @@ import Data.List.Extra (foldl', foldl1', uncons, unsnoc)
|
||||
import qualified Data.Set as Set
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text.IO as T
|
||||
import qualified Data.Text.Lazy.Builder as TB
|
||||
import Data.Time.Clock (getCurrentTime)
|
||||
import Data.Time.LocalTime (LocalTime, ZonedTime, getCurrentTimeZone,
|
||||
utcToLocalTime, utcToZonedTime)
|
||||
@ -46,6 +46,7 @@ import Language.Haskell.TH (DecsQ, Name, mkName, nameBase)
|
||||
import Language.Haskell.TH.Syntax (Q, Exp)
|
||||
import Lens.Micro ((&), (.~))
|
||||
import Lens.Micro.TH (DefName(TopName), lensClass, lensField, makeLensesWith, classyRules)
|
||||
import System.Console.ANSI (Color,ColorIntensity,ConsoleLayer(..), SGR(..), setSGRCode)
|
||||
import System.Directory (getHomeDirectory)
|
||||
import System.FilePath (isRelative, (</>))
|
||||
import System.IO
|
||||
@ -58,7 +59,6 @@ import Hledger.Utils.Regex
|
||||
import Hledger.Utils.String
|
||||
import Hledger.Utils.Text
|
||||
import Hledger.Utils.Test
|
||||
import Hledger.Utils.Color
|
||||
|
||||
|
||||
-- tuples
|
||||
@ -245,6 +245,25 @@ embedFileRelative f = makeRelativeToProject f >>= embedStringFile
|
||||
-- where
|
||||
-- QuasiQuoter{quoteExp=hereFileExp} = hereFile
|
||||
|
||||
-- | Wrap a string in ANSI codes to set and reset foreground colour.
|
||||
color :: ColorIntensity -> Color -> String -> String
|
||||
color int col s = setSGRCode [SetColor Foreground int col] ++ s ++ setSGRCode []
|
||||
|
||||
-- | Wrap a string in ANSI codes to set and reset background colour.
|
||||
bgColor :: ColorIntensity -> Color -> String -> String
|
||||
bgColor int col s = setSGRCode [SetColor Background int col] ++ s ++ setSGRCode []
|
||||
|
||||
-- | Wrap a WideBuilder in ANSI codes to set and reset foreground colour.
|
||||
colorB :: ColorIntensity -> Color -> WideBuilder -> WideBuilder
|
||||
colorB int col (WideBuilder s w) =
|
||||
WideBuilder (TB.fromString (setSGRCode [SetColor Foreground int col]) <> s <> TB.fromString (setSGRCode [])) w
|
||||
|
||||
-- | Wrap a WideBuilder in ANSI codes to set and reset background colour.
|
||||
bgColorB :: ColorIntensity -> Color -> WideBuilder -> WideBuilder
|
||||
bgColorB int col (WideBuilder s w) =
|
||||
WideBuilder (TB.fromString (setSGRCode [SetColor Background int col]) <> s <> TB.fromString (setSGRCode [])) w
|
||||
|
||||
|
||||
-- | Make classy lenses for Hledger options fields.
|
||||
-- This is intended to be used with BalancingOpts, InputOpt, ReportOpts,
|
||||
-- ReportSpec, and CliOpts.
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
-- | Basic color helpers for prettifying console output.
|
||||
|
||||
module Hledger.Utils.Color
|
||||
(
|
||||
color,
|
||||
bgColor,
|
||||
colorB,
|
||||
bgColorB,
|
||||
Color(..),
|
||||
ColorIntensity(..)
|
||||
)
|
||||
where
|
||||
|
||||
import qualified Data.Text.Lazy.Builder as TB
|
||||
import System.Console.ANSI
|
||||
import Hledger.Utils.Text (WideBuilder(..))
|
||||
|
||||
|
||||
-- | Wrap a string in ANSI codes to set and reset foreground colour.
|
||||
color :: ColorIntensity -> Color -> String -> String
|
||||
color int col s = setSGRCode [SetColor Foreground int col] ++ s ++ setSGRCode []
|
||||
|
||||
-- | Wrap a string in ANSI codes to set and reset background colour.
|
||||
bgColor :: ColorIntensity -> Color -> String -> String
|
||||
bgColor int col s = setSGRCode [SetColor Background int col] ++ s ++ setSGRCode []
|
||||
|
||||
-- | Wrap a WideBuilder in ANSI codes to set and reset foreground colour.
|
||||
colorB :: ColorIntensity -> Color -> WideBuilder -> WideBuilder
|
||||
colorB int col (WideBuilder s w) =
|
||||
WideBuilder (TB.fromString (setSGRCode [SetColor Foreground int col]) <> s <> TB.fromString (setSGRCode [])) w
|
||||
|
||||
-- | Wrap a WideBuilder in ANSI codes to set and reset background colour.
|
||||
bgColorB :: ColorIntensity -> Color -> WideBuilder -> WideBuilder
|
||||
bgColorB int col (WideBuilder s w) =
|
||||
WideBuilder (TB.fromString (setSGRCode [SetColor Background int col]) <> s <> TB.fromString (setSGRCode [])) w
|
||||
@ -78,7 +78,6 @@ library
|
||||
Hledger.Reports.MultiBalanceReport
|
||||
Hledger.Reports.PostingsReport
|
||||
Hledger.Utils
|
||||
Hledger.Utils.Color
|
||||
Hledger.Utils.Debug
|
||||
Hledger.Utils.Parse
|
||||
Hledger.Utils.Regex
|
||||
|
||||
@ -130,7 +130,6 @@ library:
|
||||
- Hledger.Reports.MultiBalanceReport
|
||||
- Hledger.Reports.PostingsReport
|
||||
- Hledger.Utils
|
||||
- Hledger.Utils.Color
|
||||
- Hledger.Utils.Debug
|
||||
- Hledger.Utils.Parse
|
||||
- Hledger.Utils.Regex
|
||||
|
||||
@ -45,7 +45,7 @@ import Graphics.Vty
|
||||
)
|
||||
import Lens.Micro.Platform
|
||||
|
||||
import Hledger hiding (Color)
|
||||
import Hledger
|
||||
import Hledger.Cli (CliOpts)
|
||||
import Hledger.Cli.DocFiles
|
||||
import Hledger.UI.UITypes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user