{"id":13677185,"url":"https://github.com/Cysharp/Kokuban","last_synced_at":"2025-04-29T10:32:10.337Z","repository":{"id":41377011,"uuid":"400338996","full_name":"Cysharp/Kokuban","owner":"Cysharp","description":"Simplifies styling strings in the terminal for .NET application.","archived":false,"fork":false,"pushed_at":"2025-03-19T06:31:21.000Z","size":96,"stargazers_count":144,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T06:04:17.528Z","etag":null,"topics":["c-sharp","dotnet","terminal"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cysharp.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-27T00:11:12.000Z","updated_at":"2025-04-08T05:56:25.000Z","dependencies_parsed_at":"2023-12-15T08:30:57.760Z","dependency_job_id":"7159c7de-1350-4691-920b-ffff7a6f8b83","html_url":"https://github.com/Cysharp/Kokuban","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FKokuban","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FKokuban/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FKokuban/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cysharp%2FKokuban/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cysharp","download_url":"https://codeload.github.com/Cysharp/Kokuban/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251484021,"owners_count":21596646,"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":["c-sharp","dotnet","terminal"],"created_at":"2024-08-02T13:00:38.378Z","updated_at":"2025-04-29T10:32:05.312Z","avatar_url":"https://github.com/Cysharp.png","language":"C#","funding_links":[],"categories":["C#"],"sub_categories":[],"readme":"# 🖍 Kokuban\nKokuban simplifies styling strings in the terminal for .NET applications. (Kokuban is \"blackboard\" in Japanese.)\n\n![](docs/assets/Screen-01.png)\n\nKokuban is based on JavaScript library [Chalk](https://github.com/chalk/chalk) for many of its concepts and some of its code.\n\n## Features\n- Expressive API\n- Auto detects color support\n- Auto enables escape sequence support on Windows 10 20H1 or later\n- 256 (8-bit) / TrueColor (24-bit) colors support\n\n## Requirements\n\n- .NET Standard 2.0 or higher\n- Linux, macOS, Windows ...\n    - Windows 10 Anniversary Update or later\n\n## Install\n```\ndotnet package add Kokuban\n```\n\n## Usage\n\n```csharp\nusing Kokuban;\n\n// Use `+` operator.\nConsole.WriteLine(Chalk.Red + \"Hello\");\nConsole.WriteLine(Chalk.Red + (\"Hello \" + (Chalk.Underline.BgBlue + \"World\")) + \"!\");\n\n// Use indexer.\nConsole.WriteLine(Chalk.Red.Underline[\"Hello\"]);\nConsole.WriteLine(Chalk.Red.Underline[\"Hello \" + Chalk.Underline.BgBlue[\"World\"]]);\n\n// Use `ToStyledString` extension method.\nConsole.WriteLine(\"Foo Bar Baz\".ToStyledString(Chalk.White.Blue));\n\n// Use `Render` method.\nConsole.WriteLine(Chalk.Rgb(255, 128, 128).Render(\"Hello Konnichiwa!\"));\n```\n### Nested styles\nIf you nest styled strings, the styles will be automatically stacked.\n\n```csharp\nConsole.WriteLine(\n    Chalk.Bold.Gray.BgYellow[\n        \"＼\" + \n        Chalk.White.BgRed[\"Hello\"] +\n        \" \" +\n        Chalk.White.BgBlue[\"コンニチハ\"] +\n        \"!!／\"\n    ]\n);\n// or\nConsole.WriteLine(\n    Chalk.Bold.Gray.BgYellow + (\n        \"＼\" + (Chalk.White.BgRed + \"Hello\") + \" \" + (Chalk.White.BgBlue + \"コンニチハ\") + \"!!／\"\n    )\n);\n\n```\n![](docs/assets/Screen-02.png)\n\n\n## API\n### `Chalk.\u003cstyle\u003e{.\u003cstyle\u003e...}[string]` (indexer)\n\n```csharp\nChalk.Red.Underline[\"Hello\"] // =\u003e \"Hello\" (Red + Underlined)\n```\n\n### `Chalk.\u003cstyle\u003e{.\u003cstyle\u003e...} + string` (`+` operator)\n\n```csharp\n(Chalk.Red.Underline + \"Hello\") // =\u003e \"Hello\" (Red + Underlined)\n```\n\n### `ToStyledString` extension method\n\n```csharp\nConsole.WriteLine(\"Foo Bar Baz\".ToStyledString(Chalk.White.Blue));\n```\n\n### `Chalk.Create` method\nYou can customize the behavior by explicitly instancing the AnsiStyle and use it.\n\n```csharp\nvar chalk = Chalk.Create(new KokubanOptions\n{\n    // The output will be forced to plain text, whether the terminal supports colors or not.\n    Mode = KokubanColorMode.None,\n});\n\nConsole.WriteLine(chalk.Red.Underline[\"Hello\"]); // =\u003e \"Hello\" without escape sequences.\n```\n\n### `KokubanColorValue` struct\n`KokubanColorValue` struct represents a color of AnsiStyle.\n\n```csharp\nvar byColor = KokubanColorValue.FromColor(KokubanColor.Blue);\nvar byCode = KokubanColorValue.FromBasic(31); // 4-bit\nvar byIndex = KokubanColorValue.FromIndex(196); // 8-bit (Index)\nvar byRgb = KokubanColorValue.FromRgb(128, 0, 0); // 24-bit\n\nConsole.WriteLine(Chalk.Foreground(byColor) + \"Foo Bar\");\n```\n\n## Styles\n- Decorations\n    - Bold\n    - Dim\n    - Italic\n    - Underline\n    - Inverse\n    - Overline\n- Foreground colors\n    - Black\n    - Red\n    - Green\n    - Yellow\n    - Blue\n    - Magenta\n    - Cyan\n    - White\n    - Gray\n    - Grey\n    - BrightBlack\n    - BrightRed\n    - BrightGreen\n    - BrightYellow\n    - BrightBlue\n    - BrightMagenta\n    - BrightCyan\n    - BrightWhite\n    - `Foreground` (for 3 or 4-bit)\n    - `Ansi256` (for 8-bit)\n    - `Rgb` (for 24-bit)\n- Background colors\n    - BgBlack\n    - BgRed\n    - BgGreen\n    - BgYellow\n    - BgBlue\n    - BgMagenta\n    - BgCyan\n    - BgWhite\n    - BgGray\n    - BgGrey\n    - BgBrightBlack\n    - BgBrightRed\n    - BgBrightGreen\n    - BgBrightYellow\n    - BgBrightBlue\n    - BgBrightMagenta\n    - BgBrightCyan\n    - BgBrightWhite\n    - `Background` (for 3 or 4-bit)\n    - `BgAnsi256` (for 8-bit)\n    - `BgRgb` (for 24-bit)\n\n## 256 colors (8-bit) and TrueColor (24-bit) support\nKokuban also supports 256 colors (8-bit) and TrueColors (24-bit) on supported terminals, same as [Chalk](https://github.com/chalk/chalk#256-and-truecolor-color-support).\n\nThe automatic detection of support states and color downsampling are derived from Chalk.\n\nKokuban supports ANSI 256-palette index (`Ansi256` method) and RGB format (`Rgb` method). However, Hex format (e.g. `#AABBCC`) is not yet supported.\n\n## License\n\n```\nMIT License\n\nCopyright (c) Cysharp, Inc.\nCopyright (c) Mayuki Sawatari \u003cmayuki@misuzilla.org\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n---- \nPart of the source code of this library is derived from the following libraries.\nThe original source codes are licensed under the MIT License.\n\nchalk/supports-color\nCopyright (c) Sindre Sorhus \u003csindresorhus@gmail.com\u003e (https://sindresorhus.com)\n\nchalk/ansi-styles\nCopyright (c) Sindre Sorhus \u003csindresorhus@gmail.com\u003e (https://sindresorhus.com)\n\nQix-/color-convert\nCopyright © 2011-2016, Heather Arthur. Copyright © 2016-2021, Josh Junon.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCysharp%2FKokuban","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCysharp%2FKokuban","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCysharp%2FKokuban/lists"}