{"id":23185782,"url":"https://github.com/lovasko/paint","last_synced_at":"2025-04-05T04:44:07.783Z","repository":{"id":56874423,"uuid":"80928476","full_name":"lovasko/paint","owner":"lovasko","description":":art: Colorization of text for command-line utilities","archived":false,"fork":false,"pushed_at":"2020-02-22T23:31:01.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-15T00:51:50.142Z","etag":null,"topics":["ansi-colors","ansi-escape-codes","color","haskell","text"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovasko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-04T15:32:24.000Z","updated_at":"2023-07-12T11:37:13.000Z","dependencies_parsed_at":"2022-08-20T22:31:12.518Z","dependency_job_id":null,"html_url":"https://github.com/lovasko/paint","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fpaint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fpaint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fpaint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Fpaint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovasko","download_url":"https://codeload.github.com/lovasko/paint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289398,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi-colors","ansi-escape-codes","color","haskell","text"],"created_at":"2024-12-18T10:12:44.246Z","updated_at":"2025-04-05T04:44:07.753Z","avatar_url":"https://github.com/lovasko.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Text.Paint\n[![Build Status](https://travis-ci.org/lovasko/paint.svg?branch=master)](https://travis-ci.org/lovasko/paint)\n\nThe `paint` module implements the essential subset of the ANSI terminal codes\nthat provide various text styling features, such as underlining, blinking or\ndifferent foreground and background coloring.\n\nThe motivation behind this module is to wrap the historic ANSI color codes\nbehind a simple and readable API that would allow clean and effect-bounded\nstyling of output based on the `String` type.\n\n## Build \u0026 Install\nThere are two standard ways of obtaining the module:\n * by cloning the git repository: `git clone https://github.com/lovasko/paint`\n * by using the central Hackage server: `cabal install paint`\n\nIn order to build the library and example executables, run:\n * `cabal build`\n\n### Dependencies\nThe library depends on two packages:\n * `base`\n * `text`\n\n## API\n### Types\nThe `Color` type is a simple enumeration of all 16 supported colors, plus the\nsetting to use the `Default` color set by the terminal. These colors can be\nused for both the foreground and background layers. The full listing of\navailable color hues is as follows:\n * `Black`\n * `Maroon`\n * `Green`\n * `Olive`\n * `Navy`\n * `Purple`\n * `Teal`\n * `Silver`\n * `Gray`\n * `Red`\n * `Lime`\n * `Yellow`\n * `Blue`\n * `Fuchsia`\n * `Aqua`\n * `White`\n\nThe default color set for the terminal can be accessed using the `Default`\nconstructor.\n\nThe `Flag` type enumerates features that are applicable to only one of the\nlayers, or to both at the same time. Currently there are three supported flags:\n`Bold` for bold text (beware that some implementations treat this as a slightly\nlighter version of selected colors), `Underline` for underlining the text and\n`Blink` to achieve periodic (dis)appearance of the text (both layers) with a\nfrequency of less than 150 beats per minute.\n\nThe overarching type that defines the resulting styling combines the previous\ntwo types is `Paint`, which is defined as `data Paint = Paint Color Color\n[Flag]`.\n\n### Functions\nThe only function exported by the `Text.Paint` module is `paint` with the\nfollowing prototype: `paint :: Paint -\u003e Text -\u003e Text`. This function can be\nused to apply selected styling to a particular `Text`. All changes are reset to\nthe default state at the end of such text object and therefore the styling\neffect is limited to the said `Text` instance.\n\n## Example\nThe following code will act as a UNIX filter, while adding yellow and\nred stylization to lines that start with `WARNING` and `ERROR` strings\nrespectively:\n```haskell\n{-# LANGUAGE OverloadedStrings #-}\n\nimport Text.Paint\nimport qualified Data.Text as T\nimport qualified Data.Text.IO as T\n\n-- | Apply the paint to a line depending on its prefix.\ncolorize :: T.Text -- ^ line\n         -\u003e T.Text -- ^ colored line\ncolorize text\n  | T.isPrefixOf \"ERROR\"   text = paint red    text\n  | T.isPrefixOf \"WARNING\" text = paint yellow text\n  | otherwise                   = text\n  where\n    red    = Paint White  Maroon  [Underline]\n    yellow = Paint Yellow Default []\n\nmain :: IO ()\nmain = fmap (T.unlines . map colorize . T.lines) T.getContents \u003e\u003e= T.putStr\n```\n\n## License\nThe `paint` package is licensed under the terms of the [2-clause BSD\nlicense](LICENSE). In case you need any other license, feel free to\ncontact the author.\n\n## Author\nDaniel Lovasko \u003cdaniel.lovasko@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Fpaint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovasko%2Fpaint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Fpaint/lists"}