colorful-terminal


Namecolorful-terminal JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/ICreedenI/colorful_terminal
SummaryPrint with color, style your output and take full control of your terminal.
upload_time2024-05-08 20:27:04
maintainerNone
docs_urlNone
authorAndré Herber
requires_pythonNone
licenseNone
keywords python print color colour colored coloured rainbow terminal console colorama
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Colorful Terminal

With the help of ANSI Escape Sequences, this package allows the coloring of the output as well as further sending of commands to the terminal. Highlighting text is thus very simple. It is also possible to update previous lines. This package is an altenative to colorama but provides more options.

This has only been tested on Windows.



## Content

- Installation

- Description

- Usage

- Demonstrations

- Limitations



## Installation

Comming soon



## Description

The model for this package is colorama. However, the standard output is not manipulated here, but appropriate escape characters are inserted into the string. Since the color change is permanent, the colored_print function should be used so that the color settings are reset after each use. Colorama is better developed and tested, but does not offer the color selection that ANSI Escape Sequences allow. 

In addition, this package allows the cursor to be controlled by ANSI escape sequences. So you can also overwrite previous lines or hide the cursor. 



You should just try the demo. There you can see which style adjustments have an effect and which don't work. This also depends on the used terminal.



## Usage

In common usage, the corresponding string of the ANSI escape sequences is prepended to the string. Using the colored_print function will automatically reset all style adjustments. Alternatively Style.RESET_ALL can be used.

```python

colored_print(Fore.RED + "This will be printet in red characters.")

```

```python

colored_print(Back.RED + "This will be printet on a red background.")

```

```python

print(Fore.CYAN + Style.DOUBLY_UNDERLINED + "This text is colored cyan and doubly underlined." + Style.RESET_ALL + " Dieser Text ist völlig normal.")

```

*Most of the available parameters are self-explanatory, so I'll just briefly introduce most of it.*  

**See https://en.wikipedia.org/wiki/ANSI_escape_code for more information.**



## Overview of all the possible color manipulations using **Fore** or **Back**:

- Use **Fore** to manipulate **Foreground Colors**

- Use **Back** to manipulate **Background Colors**

- Normal Colors -> *Parameters* of Fore / Back:

    - `Fore.BLACK`

    - `Fore.RED`

    - `Fore.GREEN`

    - `Fore.YELLOW`

    - `Fore.BLUE`

    - `Fore.MAGENTA`

    - `Fore.CYAN`

    - `Fore.WHITE`

    - `Fore.RESET` -> resets only the foreground / background color



- More intense Colors -> *Parameters* of Fore / Back:

    - `Fore.BRIGHT_BLACK`

    - `Fore.BRIGHT_RED`

    - `Fore.BRIGHT_GREEN`

    - `Fore.BRIGHT_YELLOW`

    - `Fore.BRIGHT_BLUE`

    - `Fore.BRIGHT_MAGENTA`

    - `Fore.BRIGHT_CYAN`

    - `Fore.BRIGHT_WHITE`



- Most intense Colors -> *Parameters* of Fore / Back:

    - `Fore.NEON_RED`

    - `Fore.NEON_GREEN`

    - `Fore.NEON_BLUE`

    - `Fore.NEON_YELLOW`

    - `Fore.NEON_MAGENTA`

    - `Fore.NEON_CYAN`



- *Methods* of Fore / Back:

    - `Fore.rgb(red:int=0, green:int=0, blue:int=0) -> str`  

      Allows you to use any color you can create with the standard 0 to 255 color channels.

    

    - `Fore.color_mode_256(number) -> str`  

      Choose from the 256-color lookup table  

      See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit for more information.

    

    - `Fore.color_mode_256_demo(colors_per_line:int=32, spacing:int=2) -> None`  

      Prints every of the possible colors in the 256-color lookup table. So you don't have to open your browser to know which number you need for which color.

    

    - `Fore.get_rainbow_string(string:str) -> str`  

      Yes, you can use it to get a string with a rainbow-like gradient. This doesn't print the string.

    

## Overview of all the possible style manipulations using **Style**:

- *Parameters* - probably not all of them will work

    - `Style.RESET_ALL`

    - `Style.BOLD`

    - `Style.DIM`

    - `Style.ITALIC`

    - `Style.UNDERLINED`

    - `Style.CORSSED_OUT`

    - `Style.NORMAL`

    - `Style.DOUBLY_UNDERLINED`

    - `Style.NOT_UNDERLINED`

    - `Style.NOT_CORSSED_OUT`

    - `Style.OVERLINED`

    - `Style.NOT_OVERLINED`

    - `Style.SUPERSCRIPT`

    - `Style.SUBSCRIPT`

    - `Style.NEITHER_SUPERSCRIPT_NOR_SUBSCRIPT`

- *Method*

    - `Style.underline_rgb(red:int=0, green:int=0, blue:int=0) -> str`  

      Will underline with the specified color.



## Overview of all the possible terminal actions using **TermAct**:

- *Parameters*

    - `TermAct.cursor_up`  

      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.

    - `TermAct.cursor_down`  

      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.

    - `TermAct.cursor_forward`  

      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.

    - `TermAct.cursor_back`  

      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.

    - `TermAct.cursor_next_line`  

      Moves cursor to beginning of the line 1 line down. (not ANSI.SYS)

    - `TermAct.cursor_previous_line`  

      Moves cursor to beginning of the line 1 line up. (not ANSI.SYS)

    - `TermAct.scroll_up`  

      Scroll whole page up by 1 line. New lines are added at the bottom. (not ANSI.SYS)

    - `TermAct.scroll_down`  

      Scroll whole page down by 1 line. New lines are added at the top. (not ANSI.SYS)

- *Methods*

    - `TermAct.cursor_horizontal_absolute(n=1) -> str`  

      Moves the cursor to column n (default 1). (not ANSI.SYS)

    - `TermAct.cursor_position(n=1, m=1) -> str`  

      Moves the cursor to row n, column m. The values are 1-based, and default to 1 (top left corner) if omitted. A sequence such as CSI ;5H is a synonym for CSI 1;5H as well as CSI 17;H is the same as CSI 17H and CSI 17;1H

    - `TermAct.erase_in_display(n=0) -> str`  

      Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS). If n is 3, clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications).

    - `TermAct.erase_in_line(n=0) -> str`  

      Erases part of the line. If n is 0 (or missing), clear from cursor to the end of the line. If n is 1, clear from cursor to beginning of the line. If n is 2, clear entire line. Cursor position does not change.

    - `TermAct.horizontal_vertical_position(n, m) -> str`  

      Same as CUP, but counts as a format effector function (like CR or LF) rather than an editor function (like CUD or CNL). This can lead to different handling in certain terminal modes.

    - `TermAct.sgr_reset() -> str`  

      Resets colors and style of the characters following this code.

    - `TermAct.save_current_cursor_position() -> str`  

      Saves the cursor position/state in SCO console mode. In vertical split screen mode, instead used to set (as CSI n ; n s) or reset left and right margins.

    - `TermAct.restore_saved_cursor_position() -> str`  

      Restores the cursor position/state in SCO console mode.

    - `TermAct.show_cursor() -> str`  

      Shows the cursor, from the VT220.

    - `TermAct.hide_cursor() -> str`  

      Hides the cursor.

    - `TermAct.undo_line()`  

      Goes one line up and clears the line.

    - `TermAct.clear_current_line()`  

      Clears everything in current line.

    - `clear_terminal()`  

      Clears your terminal with either cls or clear

    - `TermAct.clear_console()`  

      Alias for clear_terminal



## The resetting output function **colored_print**

- colored_print(*args, end="  n", sep=" ")

  Use just like print. Pay attention: Writing `colored_print(Fore.RED, "This is red.")` will print `" This is red."` since the seperator is `" "`. Choose a `+` instaed of the comma to avoid this  

  -> `colored_print(Fore.RED + "This is red.")`  

### If you want to use **print** instead.

Using the print function will not reset your manipulations automatically. You will need to add `Style.RESET_ALL` to reset all changes.



## Demonstrations

There are 6 demo prints (`foreground_demo`, `background_demo`, `style_demo`, `rgb_demo`, `rainbow_demo`, `termact_demo`), the function `demo_print` will call all of them. 

Each demo will show the special effects you can create with this package.  

Here is an image that shows what to expect.

![Demo-Screenshot](images/demo_screenshot.png "Demo-Screenshot")



## Limitations

Some packages like *colorama* and *moviepy* break this package because they manipulate the terminal output, while colorful_terminal does not interfere with other terminal output because the colored_print function always resets the terminal output settings.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ICreedenI/colorful_terminal",
    "name": "colorful-terminal",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, print, color, colour, colored, coloured, rainbow, terminal, console, colorama",
    "author": "Andr\u00e9 Herber",
    "author_email": "andre.herber.programming@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3f/47/4b9e6e3fff550f7973d6993637624ac56a8f0fc569745bfe3fda29188ab6/colorful_terminal-0.1.6.tar.gz",
    "platform": null,
    "description": "\n# Colorful Terminal\n\nWith the help of ANSI Escape Sequences, this package allows the coloring of the output as well as further sending of commands to the terminal. Highlighting text is thus very simple. It is also possible to update previous lines. This package is an altenative to colorama but provides more options.\n\nThis has only been tested on Windows.\n\n\n\n## Content\n\n- Installation\n\n- Description\n\n- Usage\n\n- Demonstrations\n\n- Limitations\n\n\n\n## Installation\n\nComming soon\n\n\n\n## Description\n\nThe model for this package is colorama. However, the standard output is not manipulated here, but appropriate escape characters are inserted into the string. Since the color change is permanent, the colored_print function should be used so that the color settings are reset after each use. Colorama is better developed and tested, but does not offer the color selection that ANSI Escape Sequences allow. \n\nIn addition, this package allows the cursor to be controlled by ANSI escape sequences. So you can also overwrite previous lines or hide the cursor. \n\n\n\nYou should just try the demo. There you can see which style adjustments have an effect and which don't work. This also depends on the used terminal.\n\n\n\n## Usage\n\nIn common usage, the corresponding string of the ANSI escape sequences is prepended to the string. Using the colored_print function will automatically reset all style adjustments. Alternatively Style.RESET_ALL can be used.\n\n```python\n\ncolored_print(Fore.RED + \"This will be printet in red characters.\")\n\n```\n\n```python\n\ncolored_print(Back.RED + \"This will be printet on a red background.\")\n\n```\n\n```python\n\nprint(Fore.CYAN + Style.DOUBLY_UNDERLINED + \"This text is colored cyan and doubly underlined.\" + Style.RESET_ALL + \" Dieser Text ist v\u00f6llig normal.\")\n\n```\n\n*Most of the available parameters are self-explanatory, so I'll just briefly introduce most of it.*  \n\n**See https://en.wikipedia.org/wiki/ANSI_escape_code for more information.**\n\n\n\n## Overview of all the possible color manipulations using **Fore** or **Back**:\n\n- Use **Fore** to manipulate **Foreground Colors**\n\n- Use **Back** to manipulate **Background Colors**\n\n- Normal Colors -> *Parameters* of Fore / Back:\n\n    - `Fore.BLACK`\n\n    - `Fore.RED`\n\n    - `Fore.GREEN`\n\n    - `Fore.YELLOW`\n\n    - `Fore.BLUE`\n\n    - `Fore.MAGENTA`\n\n    - `Fore.CYAN`\n\n    - `Fore.WHITE`\n\n    - `Fore.RESET` -> resets only the foreground / background color\n\n\n\n- More intense Colors -> *Parameters* of Fore / Back:\n\n    - `Fore.BRIGHT_BLACK`\n\n    - `Fore.BRIGHT_RED`\n\n    - `Fore.BRIGHT_GREEN`\n\n    - `Fore.BRIGHT_YELLOW`\n\n    - `Fore.BRIGHT_BLUE`\n\n    - `Fore.BRIGHT_MAGENTA`\n\n    - `Fore.BRIGHT_CYAN`\n\n    - `Fore.BRIGHT_WHITE`\n\n\n\n- Most intense Colors -> *Parameters* of Fore / Back:\n\n    - `Fore.NEON_RED`\n\n    - `Fore.NEON_GREEN`\n\n    - `Fore.NEON_BLUE`\n\n    - `Fore.NEON_YELLOW`\n\n    - `Fore.NEON_MAGENTA`\n\n    - `Fore.NEON_CYAN`\n\n\n\n- *Methods* of Fore / Back:\n\n    - `Fore.rgb(red:int=0, green:int=0, blue:int=0) -> str`  \n\n      Allows you to use any color you can create with the standard 0 to 255 color channels.\n\n    \n\n    - `Fore.color_mode_256(number) -> str`  \n\n      Choose from the 256-color lookup table  \n\n      See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit for more information.\n\n    \n\n    - `Fore.color_mode_256_demo(colors_per_line:int=32, spacing:int=2) -> None`  \n\n      Prints every of the possible colors in the 256-color lookup table. So you don't have to open your browser to know which number you need for which color.\n\n    \n\n    - `Fore.get_rainbow_string(string:str) -> str`  \n\n      Yes, you can use it to get a string with a rainbow-like gradient. This doesn't print the string.\n\n    \n\n## Overview of all the possible style manipulations using **Style**:\n\n- *Parameters* - probably not all of them will work\n\n    - `Style.RESET_ALL`\n\n    - `Style.BOLD`\n\n    - `Style.DIM`\n\n    - `Style.ITALIC`\n\n    - `Style.UNDERLINED`\n\n    - `Style.CORSSED_OUT`\n\n    - `Style.NORMAL`\n\n    - `Style.DOUBLY_UNDERLINED`\n\n    - `Style.NOT_UNDERLINED`\n\n    - `Style.NOT_CORSSED_OUT`\n\n    - `Style.OVERLINED`\n\n    - `Style.NOT_OVERLINED`\n\n    - `Style.SUPERSCRIPT`\n\n    - `Style.SUBSCRIPT`\n\n    - `Style.NEITHER_SUPERSCRIPT_NOR_SUBSCRIPT`\n\n- *Method*\n\n    - `Style.underline_rgb(red:int=0, green:int=0, blue:int=0) -> str`  \n\n      Will underline with the specified color.\n\n\n\n## Overview of all the possible terminal actions using **TermAct**:\n\n- *Parameters*\n\n    - `TermAct.cursor_up`  \n\n      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.\n\n    - `TermAct.cursor_down`  \n\n      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.\n\n    - `TermAct.cursor_forward`  \n\n      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.\n\n    - `TermAct.cursor_back`  \n\n      Moves the cursor 1 cell in the given direction. If the cursor is already at the edge of the screen, this has no effect.\n\n    - `TermAct.cursor_next_line`  \n\n      Moves cursor to beginning of the line 1 line down. (not ANSI.SYS)\n\n    - `TermAct.cursor_previous_line`  \n\n      Moves cursor to beginning of the line 1 line up. (not ANSI.SYS)\n\n    - `TermAct.scroll_up`  \n\n      Scroll whole page up by 1 line. New lines are added at the bottom. (not ANSI.SYS)\n\n    - `TermAct.scroll_down`  \n\n      Scroll whole page down by 1 line. New lines are added at the top. (not ANSI.SYS)\n\n- *Methods*\n\n    - `TermAct.cursor_horizontal_absolute(n=1) -> str`  \n\n      Moves the cursor to column n (default 1). (not ANSI.SYS)\n\n    - `TermAct.cursor_position(n=1, m=1) -> str`  \n\n      Moves the cursor to row n, column m. The values are 1-based, and default to 1 (top left corner) if omitted. A sequence such as CSI ;5H is a synonym for CSI 1;5H as well as CSI 17;H is the same as CSI 17H and CSI 17;1H\n\n    - `TermAct.erase_in_display(n=0) -> str`  \n\n      Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS). If n is 3, clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications).\n\n    - `TermAct.erase_in_line(n=0) -> str`  \n\n      Erases part of the line. If n is 0 (or missing), clear from cursor to the end of the line. If n is 1, clear from cursor to beginning of the line. If n is 2, clear entire line. Cursor position does not change.\n\n    - `TermAct.horizontal_vertical_position(n, m) -> str`  \n\n      Same as CUP, but counts as a format effector function (like CR or LF) rather than an editor function (like CUD or CNL). This can lead to different handling in certain terminal modes.\n\n    - `TermAct.sgr_reset() -> str`  \n\n      Resets colors and style of the characters following this code.\n\n    - `TermAct.save_current_cursor_position() -> str`  \n\n      Saves the cursor position/state in SCO console mode. In vertical split screen mode, instead used to set (as CSI n ; n s) or reset left and right margins.\n\n    - `TermAct.restore_saved_cursor_position() -> str`  \n\n      Restores the cursor position/state in SCO console mode.\n\n    - `TermAct.show_cursor() -> str`  \n\n      Shows the cursor, from the VT220.\n\n    - `TermAct.hide_cursor() -> str`  \n\n      Hides the cursor.\n\n    - `TermAct.undo_line()`  \n\n      Goes one line up and clears the line.\n\n    - `TermAct.clear_current_line()`  \n\n      Clears everything in current line.\n\n    - `clear_terminal()`  \n\n      Clears your terminal with either cls or clear\n\n    - `TermAct.clear_console()`  \n\n      Alias for clear_terminal\n\n\n\n## The resetting output function **colored_print**\n\n- colored_print(*args, end=\"  n\", sep=\" \")\n\n  Use just like print. Pay attention: Writing `colored_print(Fore.RED, \"This is red.\")` will print `\" This is red.\"` since the seperator is `\" \"`. Choose a `+` instaed of the comma to avoid this  \n\n  -> `colored_print(Fore.RED + \"This is red.\")`  \n\n### If you want to use **print** instead.\n\nUsing the print function will not reset your manipulations automatically. You will need to add `Style.RESET_ALL` to reset all changes.\n\n\n\n## Demonstrations\n\nThere are 6 demo prints (`foreground_demo`, `background_demo`, `style_demo`, `rgb_demo`, `rainbow_demo`, `termact_demo`), the function `demo_print` will call all of them. \n\nEach demo will show the special effects you can create with this package.  \n\nHere is an image that shows what to expect.\n\n![Demo-Screenshot](images/demo_screenshot.png \"Demo-Screenshot\")\n\n\n\n## Limitations\n\nSome packages like *colorama* and *moviepy* break this package because they manipulate the terminal output, while colorful_terminal does not interfere with other terminal output because the colored_print function always resets the terminal output settings.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Print with color, style your output and take full control of your terminal.",
    "version": "0.1.6",
    "project_urls": {
        "Homepage": "https://github.com/ICreedenI/colorful_terminal"
    },
    "split_keywords": [
        "python",
        " print",
        " color",
        " colour",
        " colored",
        " coloured",
        " rainbow",
        " terminal",
        " console",
        " colorama"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "18e45a413f494bd93d6fe06dd75937ceccaaaa165c4ea7a7e13eb3b88d3c2de9",
                "md5": "aa4f66722f72207c226d7da8bccaf230",
                "sha256": "9840ead8141582d7a441d51e1a333ba4a223f24a32a07dcef903cd6131c270a7"
            },
            "downloads": -1,
            "filename": "colorful_terminal-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa4f66722f72207c226d7da8bccaf230",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12093,
            "upload_time": "2024-05-08T20:27:02",
            "upload_time_iso_8601": "2024-05-08T20:27:02.382134Z",
            "url": "https://files.pythonhosted.org/packages/18/e4/5a413f494bd93d6fe06dd75937ceccaaaa165c4ea7a7e13eb3b88d3c2de9/colorful_terminal-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f474b9e6e3fff550f7973d6993637624ac56a8f0fc569745bfe3fda29188ab6",
                "md5": "ffc73002e135b3c38e79f016787abe1e",
                "sha256": "e5842c1ce7605d1c1564a93aa50b7e95bbc10287d15e3cfdd4afc78c48acd3d9"
            },
            "downloads": -1,
            "filename": "colorful_terminal-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "ffc73002e135b3c38e79f016787abe1e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13924,
            "upload_time": "2024-05-08T20:27:04",
            "upload_time_iso_8601": "2024-05-08T20:27:04.146414Z",
            "url": "https://files.pythonhosted.org/packages/3f/47/4b9e6e3fff550f7973d6993637624ac56a8f0fc569745bfe3fda29188ab6/colorful_terminal-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-08 20:27:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ICreedenI",
    "github_project": "colorful_terminal",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "colorful-terminal"
}
        
Elapsed time: 0.65058s