{"id":22509022,"url":"https://github.com/nanato12/term-printer","last_synced_at":"2025-06-27T03:04:50.076Z","repository":{"id":49493774,"uuid":"377027588","full_name":"nanato12/term-printer","owner":"nanato12","description":"Print 'text color' and 'text format' on Term with Python","archived":false,"fork":false,"pushed_at":"2021-06-17T04:21:27.000Z","size":3184,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-27T03:04:39.519Z","etag":null,"topics":["colorization","pypi-package","python-colored-output","python3","terminal","terminal-color"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/term-printer/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nanato12.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":"2021-06-15T03:46:21.000Z","updated_at":"2024-10-28T14:59:18.000Z","dependencies_parsed_at":"2022-09-12T21:02:05.438Z","dependency_job_id":null,"html_url":"https://github.com/nanato12/term-printer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nanato12/term-printer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanato12%2Fterm-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanato12%2Fterm-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanato12%2Fterm-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanato12%2Fterm-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nanato12","download_url":"https://codeload.github.com/nanato12/term-printer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanato12%2Fterm-printer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262180921,"owners_count":23271311,"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":["colorization","pypi-package","python-colored-output","python3","terminal","terminal-color"],"created_at":"2024-12-07T01:26:41.891Z","updated_at":"2025-06-27T03:04:50.023Z","avatar_url":"https://github.com/nanato12.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# term-printer\nPrint 'text color' and 'text format' on Term with Python\n\n**※ It may not work depending on the OS and shell used.**\n\n## PIP\n\n```bash\n$ pip install term-printer\n```\n\n## import\n\n```python\nfrom term_printer import Color, Color256, ColorRGB, StdText, cprint\n```\n\nIf you want to override bultin `print` function\n\n\n```python\nfrom term_printer import Color, Color256, ColorRGB, StdText, cprint as print\n```\n\n\n## Usage\n\n### 1. Attrs print\n\nApplies to all characters.\n\nYou can specify `Format`, `Color`, `Color256`, and `ColorRGB`.\n\nAble to specify more than one.\n\n#### **[source](https://github.com/nanato12/term-printer/blob/main/examples/attrs_print.py)**\n\n```python\nfrom term_printer import Color, Color256, ColorRGB, Format, cprint\n\n# default\ncprint(\"this is a default pen\")\n\n# bold\ncprint(\"this is a bold pen\", attrs=[Format.BOLD])\n\n# italic\ncprint(\"this is a italic pen\", attrs=[Format.ITALIC])\n\n# red color\ncprint(\"this is a red pen\", attrs=[Color.RED])\n\n# bright red color\ncprint(\"this is a bright red pen\", attrs=[Color.BRIGHT_RED])\n\n# background magenta color\ncprint(\"this is a bg magenta pen\", attrs=[Color.BG_MAGENTA])\n\n# background bright magenta color\ncprint(\"this is a bg bright magenta pen\", attrs=[Color.BG_BRIGHT_MAGENTA])\n\n# magenta color \u0026 italic\ncprint(\"this is a magenta italic pen\", attrs=[Color.MAGENTA, Format.ITALIC])\n\n# bold \u0026 italic\ncprint(\"this is a bold italic pen\", attrs=[Format.BOLD, Format.ITALIC])\n\n# cyan color \u0026 bold \u0026 italic\ncprint(\"this is a cyan bold italic pen\", attrs=[Color.CYAN, Format.BOLD, Format.ITALIC])\n\n# 8-bit color 154\ncprint(\"this is a 8-bit 154 pen\", attrs=[Color256(154)])\n\n# 8-bit bg color 154 and magenta color\ncprint(\"this is a bg 8-bit 154 pen\", attrs=[Color256(154, is_bg=True), Color.MAGENTA])\n\n# rgb(100, 255, 255) color\ncprint(\"this is a rgb(100, 255, 255) pen\", attrs=[ColorRGB(100, 255, 255)])\n\n# bg rgb(100, 255, 255) color and black color\ncprint(\n    \"this is a bg rgb(100, 255, 255) pen\",\n    attrs=[ColorRGB(100, 255, 255, is_bg=True), Color.BLACK],\n)\n```\n\n#### result\n\n\u003cimg src=\"https://raw.githubusercontent.com/nanato12/term-printer/main/docs/images/examples_attrs_print_result.png\"\u003e\n\n### 2. StdText print\n\n#### **[source](https://github.com/nanato12/term-printer/blob/main/examples/std_text_print.py)**\n\n```python\nfrom term_printer import Color, Format, StdText, cprint\n\n# default\ncprint(\"this is a default pen\")\n\n# bold\ncprint(f\"this is a {StdText('bold', Format.BOLD)} pen\")\n\n# italic\ncprint(f\"this is a {StdText('italic', Format.ITALIC)} pen\")\n\n# reverse\ncprint(f\"this is a {StdText('reverse', Format.REVERSE)} pen\")\n\n# red color\ncprint(f\"this is a {StdText('red', Color.RED)} pen\")\n\n# background magenta color\ncprint(f\"this is a {StdText('bg magenta', Color.BG_MAGENTA)} pen\")\n\n# magenta color \u0026 italic\ncprint(f\"this is a {StdText('magenta', Color.MAGENTA)} {StdText('italic', Format.ITALIC)} pen\")\n\n# bold \u0026 italic\ncprint(f\"this is a {StdText('bold', Format.BOLD)} {StdText('italic', Format.ITALIC)} pen\")\n\n# cyan color \u0026 bold \u0026 italic\ncprint(f\"this is a {StdText('cyan', Color.CYAN)} {StdText('bold', Format.BOLD)} {StdText('italic', Format.ITALIC)} pen\")\n```\n\n#### result\n\n\u003cimg src=\"https://raw.githubusercontent.com/nanato12/term-printer/main/docs/images/examples_std_text_print_result.png\"\u003e\n\n\n## Color\n\n```python\nclass Color(Enum)\n```\n\nEnum class.\n\nExample\n```python\nfrom term_printer import Color\n\nColor.RED  # RED foreground color\nColor.BG_RED  # RED background color\n\nColor.BLUE  # BLUE foreground color\nColor.BG_BLUE  # BLUE background color\n```\n\n### **[source](https://github.com/nanato12/term-printer/blob/main/examples/std_text_print.py#L20-L52)**\n\nDefinition is [3-bit and 4-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit)\n\n\u003cimg src=\"https://raw.githubusercontent.com/nanato12/term-printer/main/docs/images/color.png\"\u003e\n\n\n## Color256\n\n```python\nclass Color256(n: int, is_bg: bool = False)\n```\n\n- First argument takes `int` (0 - 255).\n\n- Second argument takes `bool` (default: False).  \nFalse: change foreground color  \nTrue: change background color\n\nExample\n```python\nfrom term_printer import Color256\n\nColor256(9)  # RED foreground color\nColor256(9, True)  # RED background color\n\nColor256(12)  # BLUE foreground color\nColor256(12, True)  # BLUE background color\n```\n\nDefinition is [8-bit 256 colors](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit)\n\n\u003cimg src=\"https://raw.githubusercontent.com/nanato12/term-printer/main/docs/images/color256.png\"\u003e\n\n## ColorRGB\n\n```python\nclass ColorRGB(r: int, g: int, b: int, is_bg: bool = False)\n```\n\n- Three arguments takes `int` (0 - 255).\n\n- Fourth argument takes `bool` (default: False).  \nFalse: change foreground color  \nTrue: change background color\n\nExample\n```python\nfrom term_printer import ColorRGB\n\nColorRGB(255, 0, 0)  # RED foreground color\nColorRGB(255, 0, 0, True)  # RED background color\n\nColorRGB(0, 0, 255)  # BLUE foreground color\nColorRGB(0, 0, 255, True)  # BLUE background color\n```\n\n## Format\n\n```python\nclass Format(Enum):\n    BOLD = 1\n    FAINT = 2\n    ITALIC = 3\n    UNDERLINE = 4\n    BLINK = 5\n    FAST_BLINK = 6\n    REVERSE = 7\n    CONCEAL = 8\n    STRIKE = 9\n```\n\nEnum class.\n\nExample\n```python\nfrom term_printer import Format\n\nFormat.BOLD  # BOLD font\nFormat.FAINT  # FAINT font\nFormat.ITALIC  # ITALIC font\nFormat.UNDERLINE  # UNDERLINE font\n```\n\nDefinition is [SGR](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanato12%2Fterm-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnanato12%2Fterm-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanato12%2Fterm-printer/lists"}