[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"v62trBGKbD":3},"# Pigment\n\nA terminal color library for Lean 4.\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n\n## Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Examples](#examples)\n- [API Reference](#api-reference)\n- [Configuration](#configuration)\n- [Contributing](#contributing)\n\n## Features\n\n- Chainable API using the pipe operator\n- Multiple color modes: 8, 16, 256, and 24-bit RGB\n- Automatic terminal capability detection\n- Text styling (bold, italic, underline, dim, etc.)\n- Hex color codes support\n- Inline color composition\n- Zero dependencies\n\n## Installation\n\nAdd Pigment to your `lakefile.toml`:\n\n```toml\n[[require]]\nname = \"Pigment\"\ngit = \"https://github.com/RSoulatIOHK/Pigment\"\nrev = \"main\"\n```\n\nThen import it in your Lean file:\n\n```lean\nimport Pigment\nopen Pigment\n```\n\n## Quick Start\n\n```lean\nimport Pigment\nopen Pigment\n\ndef main : IO Unit := run do\n  println (\"Hello, World!\".style |> green |> bold)\n```\n\nColors and styles are chained with the pipe operator:\n\n```lean\n\"Error\".style |> red |> bold |> underline\n```\n\nAvailable color modes:\n\n```lean\n-- Basic colors\n\"text\".style |> red\n\n-- RGB\n\"text\".style |> rgb 255 128 64\n\n-- Hex codes\n\"text\".style |> hex \"#FF1493\"\n\n-- 256-color palette\n\"text\".style |> color256 196\n\n-- Backgrounds\n\"text\".style |> white |> bgRed\n```\n\n## Examples\n\n### Success/Error Messages\n\n```lean\ndef showBuildStatus : IO Unit := run do\n  Quicky.success \"Build completed successfully\"\n  Quicky.error \"Failed to connect to database\"\n  Quicky.warning \"Disk space running low (85%)\"\n  Quicky.info \"Processing 1000 items...\"\n  Quicky.debug \"Cache hit: 95%\"\n```\n\n### Progress Bars\n\n```lean\ndef showProgress (percent : Nat) : IO Unit := run do\n  let done := \"█\".style |> green\n  let pending := \"░\".style |> dim\n  let pct := s!\"{percent}%\".style |> yellow |> bold\n\n  let doneCount := percent / 10\n  let pendingCount := 10 - doneCount\n\n  let blocks := List.replicate doneCount done ++ List.replicate pendingCount pending\n  printLine (blocks ++ [\" \".style, pct])\n```\n\n### Inline Status Messages\n\n```lean\ndef compileStatus (file : String) (status : String) : IO Unit := run do\n  let label := \"[\".style |> dim\n  let statusText := if status == \"OK\"\n    then \"OK\".style |> green |> bold\n    else \"FAIL\".style |> red |> bold\n  let close := \"]\".style |> dim\n  let filename := file.style |> cyan\n\n  printLine [label, statusText, close, \" \".style, filename]\n```\n\n### Code Syntax Highlighting\n\n```lean\ndef showCode : IO Unit := run do\n  let kw := \"def\".style |> magenta |> bold\n  let name := \"factorial\".style |> blue |> bold\n  let punct := \"(\".style |> dim\n  let param := \"n\".style |> cyan\n  let punct2 := \":\".style |> dim\n  let type_ := \"Nat\".style |> yellow\n  let punct3 := \")\".style |> dim\n\n  printLine [kw, \" \".style, name, punct, param, punct2, \" \".style, type_, punct3]\n```\n\n### Dashboards\n\n```lean\ndef systemDashboard : IO Unit := run do\n  let title := \"System Status\".style |> hex \"#00BFFF\" |> bold |> underline\n  println title\n  IO.println \"\"\n\n  Quicky.success \"CPU: 25% (Normal)\"\n  Quicky.success \"Memory: 4.2 GB / 16 GB\"\n  Quicky.warning \"Disk: 85% used (127 GB free)\"\n  Quicky.error \"Network: Connection lost\"\n\n  IO.println \"\"\n  let time := \"Last updated: 14:32:05\".style |> dim\n  println time\n```\n\n## API Reference\n\n### Colors\n\nBasic: `red`, `green`, `blue`, `yellow`, `cyan`, `magenta`, `white`, `black`\n\nBackgrounds: `bgRed`, `bgGreen`, `bgBlue`, `bgYellow`, `bgCyan`, `bgMagenta`, `bgWhite`, `bgBlack`\n\nAdvanced:\n- `rgb r g b` - 24-bit RGB\n- `bgRgb r g b` - RGB background\n- `hex \"#RRGGBB\"` - Hex color\n- `bgHex \"#RRGGBB\"` - Hex background\n- `color256 idx` - 256-color palette (0-255)\n- `bgColor256 idx` - 256-color background\n\n### Styles\n\n`bold`, `dim`, `italic`, `underline`, `blink`, `reverse`, `hidden`, `strikethrough`\n\n### Output\n\n- `println` - Print with newline\n- `print` - Print without newline\n- `printLine` - Print multiple styled texts on one line\n\n### Quick Helpers\n\n- `Quicky.success msg` - Green checkmark\n- `Quicky.error msg` - Red X\n- `Quicky.warning msg` - Yellow warning\n- `Quicky.info msg` - Cyan info\n- `Quicky.debug msg` - Dim debug\n\n## Configuration\n\nManual configuration:\n\n```lean\n-- Force 256-color mode\ndef main : IO Unit := runWith { enabled := true, support := .colors256 } do\n  println (\"256-color mode\".style |> color256 196)\n\n-- Disable colors\ndef main : IO Unit := runPlain do\n  println (\"No colors\".style |> red)\n\n-- Conditional colors\ndef main : IO Unit := run do\n  println (\"Colored\".style |> green)\n  withEnabled false do\n    println (\"Plain\".style |> red)\n  println (\"Colored again\".style |> blue)\n```\n\nFunctions:\n- `run` - Auto-detected config (recommended)\n- `runWith cfg` - Explicit configuration\n- `runPlain` - No colors\n- `withEnabled bool` - Toggle colors temporarily\n- `withSupport level` - Override color support level\n\n### Environment Variables\n\nThe library respects standard environment variables:\n\n- `NO_COLOR` - Disable all colors\n- `COLORTERM=truecolor` or `COLORTERM=24bit` - Enable 24-bit RGB\n- `TERM=*256color*` - Enable 256-color mode\n- `TERM=*color*` - Enable basic colors\n\n```bash\nNO_COLOR=1 lake exe myapp\nCOLORTERM=truecolor lake exe myapp\n```\n\n### Troubleshooting\n\nIf colors aren't showing, check your terminal:\n\n```bash\necho $TERM\n```\n\nForce colors if auto-detection fails:\n\n```lean\ndef main : IO Unit := runWith { enabled := true, support := .truecolor } do\n  -- your code\n```\n\nFor hex colors, ensure your terminal supports truecolor (24-bit).\n\n## More Examples\n\nThe library includes 22 examples in [Pigment/Examples.lean](Pigment/Examples.lean):\n\n- Example 2: Success/Error Messages\n- Example 13: Progress Bars\n- Example 16: Syntax Highlighting\n- Example 17: Dashboards\n- Example 18: RGB Gradients\n- Example 20: All Text Styles\n- Example 21: Color Grid (9×6)\n- Example 22: Inline Colors\n\nRun all examples:\n\n```bash\nlake build\nlake test\n```\n\n## Tips\n\nFor CI/CD, respect `NO_COLOR`:\n```bash\nNO_COLOR=1 lake exe myapp\n```\n\n## Contributing\n\nContributions welcome. Open an issue for bugs or feature requests, or submit a PR.\n\n```bash\ngit clone https://github.com/RSoulatIOHK/Pigment\ncd Pigment\nlake build          # Build library\nlake test           # Run examples\n```\n\n## License\n\nApache License 2.0 - see [LICENSE](LICENSE) for details.\n",1780846781743]