ansiplus


Nameansiplus JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/xyzpw/ansiplus/
SummaryA Python package designed to enhance code readability and CLI experience.
upload_time2024-03-17 05:33:31
maintainerxyzpw
docs_urlNone
authorxyzpw
requires_python
licenseMIT
keywords ansi cursor style color
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ansiplus
![Pepy Total Downlods](https://img.shields.io/pepy/dt/ansiplus?color=blue)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ansiplus)
![GitHub repo size](https://img.shields.io/github/repo-size/xyzpw/ansiplus)
![PyPI - License](https://img.shields.io/pypi/l/ansiplus)

A Python package designed to enhance code readability and CLI experience.

![ansiplus-preview](https://github.com/xyzpw/ansiplus/assets/76017734/bf852703-e04a-444e-aa78-7bdaae98ac41)

## Usage
> [!WARNING]
> Not all terminals work perfectly with ANSI codes.
> Ideally you should use xterm-256color.

> [!NOTE]
> Terminal themes can change colors, e.g. magenta might show up as yellow, but it is still using the magenta ANSI code.

### Prerequisites
- Python version >=3.10
- A terminal emulator that accepts ANSI codes
- A terminal emulator that uses xterm-256color

> [!NOTE]
> ANSI codes aren't just limited to xterm-256color, but they may still be limited to all features this package includes.

#### Tested Terminals on Linux
Terminal ($TERM)
- Konsole (xterm-256color) - no missing features
- Xterm (xterm) - no missing features
- Alacritty (alacritty) - blinking text does not work
- Kitty (xterm-kitty) - blinking text does not work

### Colors
Printing colored text can be used from a single function:
```python
>>> from ansiplus import print_color
>>> print_color(text="hello world", color="red")
hello world
>>>
```
Optionally, you can also use the `bgcolor` parameter to change the background color.<br><br>
Manually putting the color ANSI codes could be used at well:
```python
>>> from ansiplus.ansi.colors import Fore, Back
>>> Fore.RED
'\x1b[31m'
>>> Back.RED
'\x1b[41m'
>>> print(f"{Fore.RED}hello world{Fore.RESET}") #output will appear in red
hello world
>>>
```

RGB colors are also an option:
```python
>>> from ansiplus import print_rgb
>>> print_rgb(text="custom rgb text", rgb=(200, 108, 0))
custom rgb text
>>>
```

### User Input
User input during a prompt can be colored:
```python
>>> from ansiplus import input_color
>>> foo = input_color(text="name: ", color="blue") #users input will appear in blue
name:
>>>
```

Classes can be used for input, which will allow the ability to have user input history:
```python
>>> from ansiplus import NewPrompt
>>> myprompt = NewPrompt()
>>> myprompt.set_color("blue")
>>> myprompt.prompt("say something: ")
say something: this text is blue
'this text is blue'
>>> myprompt.prompt("say something: ", 'red')
say something: this text is red, default is blue
'this text is red, default is blue'
>>> myprompt.latest
'this text is red, default is blue'
>>> myprompt.history
['this text is blue', 'this text is red, default is blue']
>>>
```

### Text Styles
Text can be stylized and printed:
```python
>>> from ansiplus import print_style
>>> print_style("bold text", 'bold')
bold text
>>>
```
Like colors, this can also be done manually:
```python
>>> from ansiplus.ansi.styles import BOLD, BOLD_RESET
>>> BOLD
'\x1b[1m'
>>> BOLD_RESET
'\x1b[22m'
>>> print(f"{BOLD}bold text{BOLD_RESET}")
bold text
>>>
```

### More Functions
There are more ANSI code features beyond colors and styles, these could be viewed by using `help(ansiplus)` inside the python interpreter.

## Developers
### Wheels
When building the package for testing, it is recommended to use `python3 -m build`.
### PIP Virtual Environments
Virtual environments should be named ".venv" or ".env", as this is used in the ".gitignore" file.

### Contributing
Contributions must not include:
- breaking code
- major changes
- changes to the version number
- wheel files or egg-info files
- spaghetti code


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xyzpw/ansiplus/",
    "name": "ansiplus",
    "maintainer": "xyzpw",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ansi,cursor,style,color",
    "author": "xyzpw",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ef/cb/94a5f59b171630b88dbf03d1da9650b3cad5a7011597402a5afb16cbcda1/ansiplus-1.1.0.tar.gz",
    "platform": null,
    "description": "# ansiplus\n![Pepy Total Downlods](https://img.shields.io/pepy/dt/ansiplus?color=blue)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ansiplus)\n![GitHub repo size](https://img.shields.io/github/repo-size/xyzpw/ansiplus)\n![PyPI - License](https://img.shields.io/pypi/l/ansiplus)\n\nA Python package designed to enhance code readability and CLI experience.\n\n![ansiplus-preview](https://github.com/xyzpw/ansiplus/assets/76017734/bf852703-e04a-444e-aa78-7bdaae98ac41)\n\n## Usage\n> [!WARNING]\n> Not all terminals work perfectly with ANSI codes.\n> Ideally you should use xterm-256color.\n\n> [!NOTE]\n> Terminal themes can change colors, e.g. magenta might show up as yellow, but it is still using the magenta ANSI code.\n\n### Prerequisites\n- Python version >=3.10\n- A terminal emulator that accepts ANSI codes\n- A terminal emulator that uses xterm-256color\n\n> [!NOTE]\n> ANSI codes aren't just limited to xterm-256color, but they may still be limited to all features this package includes.\n\n#### Tested Terminals on Linux\nTerminal ($TERM)\n- Konsole (xterm-256color) - no missing features\n- Xterm (xterm) - no missing features\n- Alacritty (alacritty) - blinking text does not work\n- Kitty (xterm-kitty) - blinking text does not work\n\n### Colors\nPrinting colored text can be used from a single function:\n```python\n>>> from ansiplus import print_color\n>>> print_color(text=\"hello world\", color=\"red\")\nhello world\n>>>\n```\nOptionally, you can also use the `bgcolor` parameter to change the background color.<br><br>\nManually putting the color ANSI codes could be used at well:\n```python\n>>> from ansiplus.ansi.colors import Fore, Back\n>>> Fore.RED\n'\\x1b[31m'\n>>> Back.RED\n'\\x1b[41m'\n>>> print(f\"{Fore.RED}hello world{Fore.RESET}\") #output will appear in red\nhello world\n>>>\n```\n\nRGB colors are also an option:\n```python\n>>> from ansiplus import print_rgb\n>>> print_rgb(text=\"custom rgb text\", rgb=(200, 108, 0))\ncustom rgb text\n>>>\n```\n\n### User Input\nUser input during a prompt can be colored:\n```python\n>>> from ansiplus import input_color\n>>> foo = input_color(text=\"name: \", color=\"blue\") #users input will appear in blue\nname:\n>>>\n```\n\nClasses can be used for input, which will allow the ability to have user input history:\n```python\n>>> from ansiplus import NewPrompt\n>>> myprompt = NewPrompt()\n>>> myprompt.set_color(\"blue\")\n>>> myprompt.prompt(\"say something: \")\nsay something: this text is blue\n'this text is blue'\n>>> myprompt.prompt(\"say something: \", 'red')\nsay something: this text is red, default is blue\n'this text is red, default is blue'\n>>> myprompt.latest\n'this text is red, default is blue'\n>>> myprompt.history\n['this text is blue', 'this text is red, default is blue']\n>>>\n```\n\n### Text Styles\nText can be stylized and printed:\n```python\n>>> from ansiplus import print_style\n>>> print_style(\"bold text\", 'bold')\nbold text\n>>>\n```\nLike colors, this can also be done manually:\n```python\n>>> from ansiplus.ansi.styles import BOLD, BOLD_RESET\n>>> BOLD\n'\\x1b[1m'\n>>> BOLD_RESET\n'\\x1b[22m'\n>>> print(f\"{BOLD}bold text{BOLD_RESET}\")\nbold text\n>>>\n```\n\n### More Functions\nThere are more ANSI code features beyond colors and styles, these could be viewed by using `help(ansiplus)` inside the python interpreter.\n\n## Developers\n### Wheels\nWhen building the package for testing, it is recommended to use `python3 -m build`.\n### PIP Virtual Environments\nVirtual environments should be named \".venv\" or \".env\", as this is used in the \".gitignore\" file.\n\n### Contributing\nContributions must not include:\n- breaking code\n- major changes\n- changes to the version number\n- wheel files or egg-info files\n- spaghetti code\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package designed to enhance code readability and CLI experience.",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/xyzpw/ansiplus/"
    },
    "split_keywords": [
        "ansi",
        "cursor",
        "style",
        "color"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3012ac3692d880d64eaed5e8ff5bc0be8e436e7e5dc2b3868c7d694ac56fcc38",
                "md5": "3f1bd6bd3f033fcf21cc4137ff486c3f",
                "sha256": "a80bd95f13019bb22ee268c4d19f27e32a64ce8fbbcb88a812b7104aa4f3b5ab"
            },
            "downloads": -1,
            "filename": "ansiplus-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f1bd6bd3f033fcf21cc4137ff486c3f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11633,
            "upload_time": "2024-03-17T05:33:29",
            "upload_time_iso_8601": "2024-03-17T05:33:29.754480Z",
            "url": "https://files.pythonhosted.org/packages/30/12/ac3692d880d64eaed5e8ff5bc0be8e436e7e5dc2b3868c7d694ac56fcc38/ansiplus-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "efcb94a5f59b171630b88dbf03d1da9650b3cad5a7011597402a5afb16cbcda1",
                "md5": "2391c83d22d77a2506b6778da0dfee1f",
                "sha256": "64ad4d0d2cc622535f09e3122cad49e3ff7a676b1a5c001c44b79e64c9e70cad"
            },
            "downloads": -1,
            "filename": "ansiplus-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2391c83d22d77a2506b6778da0dfee1f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10349,
            "upload_time": "2024-03-17T05:33:31",
            "upload_time_iso_8601": "2024-03-17T05:33:31.844605Z",
            "url": "https://files.pythonhosted.org/packages/ef/cb/94a5f59b171630b88dbf03d1da9650b3cad5a7011597402a5afb16cbcda1/ansiplus-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-17 05:33:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xyzpw",
    "github_project": "ansiplus",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ansiplus"
}
        
Elapsed time: 0.20467s