From dc262d1628aa3e1bfe17ce99bfe89782b6185cc5 Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 3 Feb 2022 05:14:45 +0000 Subject: TextOutputColor -> TextOutputFormat Thinking of eventually adding a Sway JSON output, or simply add fonts to Pango specification, so it's more than colors. Also, NoColors -> Plain. --- doc/quick-start.org | 4 ++-- examples/xmobar.config | 2 +- examples/xmobar.hs | 4 ++-- readme.org | 4 ++-- src/Xmobar/App/Config.hs | 2 +- src/Xmobar/App/Opts.hs | 4 ++-- src/Xmobar/App/TextEventLoop.hs | 10 +++++----- src/Xmobar/Config/Parse.hs | 6 +++--- src/Xmobar/Config/Types.hs | 6 +++--- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/quick-start.org b/doc/quick-start.org index 1c48c43..3cf11aa 100644 --- a/doc/quick-start.org +++ b/doc/quick-start.org @@ -162,9 +162,9 @@ the =Config= block in your configuration. this mode, icon and action specifications are ignored. Default is False. -- =textOutputColors= NoColors, Ansi or Pango, to emit, when in text +- =textOutputFormat= Plain, Ansi or Pango, to emit, when in text mode, escape color sequences using ANSI controls (for terminals) or - pango markup. Default is NoColors. + pango markup. Default is Plain. ** The Output =template= diff --git a/examples/xmobar.config b/examples/xmobar.config index 150f4fd..e951b67 100644 --- a/examples/xmobar.config +++ b/examples/xmobar.config @@ -15,7 +15,7 @@ Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*" , iconRoot = "." , allDesktops = True , overrideRedirect = True - , textOutputColors = Ansi + , textOutputFormat = Ansi , commands = [ Run Weather "EGPF" ["-t",": C", "-L","18","-H","25", "--normal","green", diff --git a/examples/xmobar.hs b/examples/xmobar.hs index ea519eb..791d3af 100644 --- a/examples/xmobar.hs +++ b/examples/xmobar.hs @@ -1,6 +1,6 @@ ------------------------------------------------------------------------------ -- | --- Copyright: (c) 2018, 2019 Jose Antonio Ortega Ruiz +-- Copyright: (c) 2018, 2019, 2022 Jose Antonio Ortega Ruiz -- License: BSD3-style (see LICENSE) -- -- Maintainer: jao@gnu.org @@ -49,7 +49,7 @@ config = defaultConfig { , iconRoot = "." , allDesktops = True , overrideRedirect = True - , textOutputColors = Ansi + , textOutputFormat = Ansi , commands = [ Run $ Weather "EGPH" ["-t",": C", "-L","18","-H","25", "--normal","green", diff --git a/readme.org b/readme.org index ac9e72e..b7d7845 100644 --- a/readme.org +++ b/readme.org @@ -119,10 +119,10 @@ or set the parameter =textOutput= to True in its configuration. You can also specify the format of color escapes, for instance - omitting them altogether with ~NoColors~: + omitting them altogether with ~Plain~: #+begin_src shell - xmobar -TNoColors /path/to/config & + xmobar -TPlain /path/to/config & #+end_src Other options are ~Ansi~ and ~Pango~. diff --git a/src/Xmobar/App/Config.hs b/src/Xmobar/App/Config.hs index 7d3c781..a284973 100644 --- a/src/Xmobar/App/Config.hs +++ b/src/Xmobar/App/Config.hs @@ -66,7 +66,7 @@ defaultConfig = , verbose = False , signal = SignalChan Nothing , textOutput = False - , textOutputColors = NoColors + , textOutputFormat = Plain } -- | Return the path to the xmobar data directory. This directory is diff --git a/src/Xmobar/App/Opts.hs b/src/Xmobar/App/Opts.hs index 2925d26..9f19ff6 100644 --- a/src/Xmobar/App/Opts.hs +++ b/src/Xmobar/App/Opts.hs @@ -61,7 +61,7 @@ options = , Option "r" ["recompile"] (NoArg Recompile) "Force recompilation" , Option "V" ["version"] (NoArg Version) "Show version information" , Option "T" ["text"] (OptArg TextOutput "color") - "Write text-only output to stdout. NoColors/Ansi/Pango" + "Write text-only output to stdout. Plain/Ansi/Pango" , Option "f" ["font"] (ReqArg Font "font name") "Font name" , Option "N" ["add-font"] (ReqArg AddFont "font name") "Add to the list of additional fonts" @@ -136,7 +136,7 @@ doOpts conf (o:oo) = Recompile -> doOpts' conf TextOutput s -> doOpts' $ case s of Just fmt -> conf {textOutput = True, - textOutputColors = read fmt} + textOutputFormat = read fmt} Nothing -> conf {textOutput = True} Verbose -> doOpts' (conf {verbose = True}) Font s -> doOpts' (conf {font = s}) diff --git a/src/Xmobar/App/TextEventLoop.hs b/src/Xmobar/App/TextEventLoop.hs index 3b754ac..e516298 100644 --- a/src/Xmobar/App/TextEventLoop.hs +++ b/src/Xmobar/App/TextEventLoop.hs @@ -27,7 +27,7 @@ import Control.Concurrent.Async (Async) import Control.Concurrent.STM import Xmobar.System.Signal -import Xmobar.Config.Types (Config(textOutputColors), TextColorFormat(..)) +import Xmobar.Config.Types (Config(textOutputFormat), TextOutputFormat(..)) import Xmobar.X11.Parsers (Segment, Widget(..), parseString, tColorsString, colorComponents) import Xmobar.App.CommandThreads (initLoop, loop) @@ -100,16 +100,16 @@ withPangoColor (fg, bg) s = printf fmt (xmlEscape fg) (xmlEscape bg) (xmlEscape s) where fmt = "%s" -withColor :: TextColorFormat -> (String, String) -> String -> String +withColor :: TextOutputFormat -> (String, String) -> String -> String withColor format color = case format of - NoColors -> id + Plain -> id Ansi -> withAnsiColor color Pango -> withPangoColor color - + asText :: Config -> Segment -> String asText conf (Text s, info, _, _) = - withColor (textOutputColors conf) components s + withColor (textOutputFormat conf) components s where components = colorComponents conf color color = tColorsString info asText colors (Hspace n, i, x, y) = diff --git a/src/Xmobar/Config/Parse.hs b/src/Xmobar/Config/Parse.hs index fa99c59..89af808 100644 --- a/src/Xmobar/Config/Parse.hs +++ b/src/Xmobar/Config/Parse.hs @@ -62,7 +62,7 @@ parseConfig defaultConfig = perms = permute $ Config <$?> pFont <|?> pFontList <|?> pWmClass <|?> pWmName <|?> pBgColor <|?> pFgColor <|?> pPosition - <|?> pTextOutput <|?> pTextOutputColors + <|?> pTextOutput <|?> pTextOutputFormat <|?> pTextOffset <|?> pTextOffsets <|?> pIconOffset <|?> pBorder <|?> pBdColor <|?> pBdWidth <|?> pAlpha <|?> pHideOnStart @@ -78,11 +78,11 @@ parseConfig defaultConfig = , "allDesktops", "overrideRedirect", "pickBroadest" , "hideOnStart", "lowerOnStart", "persistent", "iconRoot" , "alpha", "commands", "verbose", "signal", "textOutput" - , "textOutputColors" + , "textOutputFormat" ] pTextOutput = readField textOutput "textOutput" - pTextOutputColors = readField textOutputColors "textOutputColors" + pTextOutputFormat = readField textOutputFormat "textOutputFormat" pFont = strField font "font" pFontList = strListField additionalFonts "additionalFonts" pWmClass = strField wmClass "wmClass" diff --git a/src/Xmobar/Config/Types.hs b/src/Xmobar/Config/Types.hs index 5f19528..7914a87 100644 --- a/src/Xmobar/Config/Types.hs +++ b/src/Xmobar/Config/Types.hs @@ -16,7 +16,7 @@ module Xmobar.Config.Types ( -- * Configuration -- $config Config (..) - , XPosition (..), Align (..), Border (..), TextColorFormat (..) + , XPosition (..), Align (..), Border (..), TextOutputFormat (..) , SignalChan (..) ) where @@ -37,7 +37,7 @@ data Config = , fgColor :: String -- ^ Default font color , position :: XPosition -- ^ Top Bottom or Static , textOutput :: Bool -- ^ Write data to stdout instead of X - , textOutputColors :: TextColorFormat -- ^ Which color format to use for stdout: Ansi or Pango + , textOutputFormat :: TextOutputFormat -- ^ Which color format to use for stdout: Ansi or Pango , textOffset :: Int -- ^ Offset from top of window for text , textOffsets :: [Int] -- ^ List of offsets for additionalFonts , iconOffset :: Int -- ^ Offset from top of window for icons @@ -98,7 +98,7 @@ data Border = NoBorder | FullBM Int deriving ( Read, Show, Eq ) -data TextColorFormat = NoColors | Ansi | Pango deriving ( Read, Show, Eq ) +data TextOutputFormat = Plain | Ansi | Pango deriving ( Read, Show, Eq ) newtype SignalChan = SignalChan { unSignalChan :: Maybe (STM.TMVar SignalType) } -- cgit v1.2.3