Package: colorful-terminal
Colorful TerminalWith 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.ContentInstallationDescriptionUsageDemonstrationsLimitationsInstallationComming soonDescriptionThe 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.UsageIn 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.colored_print(Fore.RED+"This will be printet in red characters.")colored_print(Back.RED+"This will be printet on a red background.")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.Seehttps://en.wikipedia.org/wiki/ANSI_escape_codefor more information.Overview of all the possible color manipulations usingForeorBack:UseForeto manipulateForeground ColorsUseBackto manipulateBackground ColorsNormal Colors ->Parametersof Fore / Back:Fore.BLACKFore.REDFore.GREENFore.YELLOWFore.BLUEFore.MAGENTAFore.CYANFore.WHITEFore.RESET-> resets only the foreground / background colorMore intense Colors ->Parametersof Fore / Back:Fore.BRIGHT_BLACKFore.BRIGHT_REDFore.BRIGHT_GREENFore.BRIGHT_YELLOWFore.BRIGHT_BLUEFore.BRIGHT_MAGENTAFore.BRIGHT_CYANFore.BRIGHT_WHITEMost intense Colors ->Parametersof Fore / Back:Fore.NEON_REDFore.NEON_GREENFore.NEON_BLUEFore.NEON_YELLOWFore.NEON_MAGENTAFore.NEON_CYANMethodsof Fore / Back:Fore.rgb(red:int=0, green:int=0, blue:int=0) -> strAllows you to use any color you can create with the standard 0 to 255 color channels.Fore.color_mode_256(number) -> strChoose from the 256-color lookup tableSeehttps://en.wikipedia.org/wiki/ANSI_escape_code#8-bitfor more information.Fore.color_mode_256_demo(colors_per_line:int=32, spacing:int=2) -> NonePrints 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) -> strYes, 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 usingStyle:Parameters- probably not all of them will workStyle.RESET_ALLStyle.BOLDStyle.DIMStyle.ITALICStyle.UNDERLINEDStyle.CORSSED_OUTStyle.NORMALStyle.DOUBLY_UNDERLINEDStyle.NOT_UNDERLINEDStyle.NOT_CORSSED_OUTStyle.OVERLINEDStyle.NOT_OVERLINEDStyle.SUPERSCRIPTStyle.SUBSCRIPTStyle.NEITHER_SUPERSCRIPT_NOR_SUBSCRIPTMethodStyle.underline_rgb(red:int=0, green:int=0, blue:int=0) -> strWill underline with the specified color.Overview of all the possible terminal actions usingTermAct:ParametersTermAct.cursor_upMoves 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_downMoves 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_forwardMoves 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_backMoves 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_lineMoves cursor to beginning of the line 1 line down. (not ANSI.SYS)TermAct.cursor_previous_lineMoves cursor to beginning of the line 1 line up. (not ANSI.SYS)TermAct.scroll_upScroll whole page up by 1 line. New lines are added at the bottom. (not ANSI.SYS)TermAct.scroll_downScroll whole page down by 1 line. New lines are added at the top. (not ANSI.SYS)MethodsTermAct.cursor_horizontal_absolute(n=1) -> strMoves the cursor to column n (default 1). (not ANSI.SYS)TermAct.cursor_position(n=1, m=1) -> strMoves 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;1HTermAct.erase_in_display(n=0) -> strClears 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) -> strErases 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) -> strSame 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() -> strResets colors and style of the characters following this code.TermAct.save_current_cursor_position() -> strSaves 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() -> strRestores the cursor position/state in SCO console mode.TermAct.show_cursor() -> strShows the cursor, from the VT220.TermAct.hide_cursor() -> strHides 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 clearTermAct.clear_console()Alias for clear_terminalThe resetting output functioncolored_printcolored_print(*args, end="  n", sep=" ")Use just like print. Pay attention: Writingcolored_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 useprintinstead.Using the print function will not reset your manipulations automatically. You will need to addStyle.RESET_ALLto reset all changes.DemonstrationsThere are 6 demo prints (foreground_demo,background_demo,style_demo,rgb_demo,rainbow_demo,termact_demo), the functiondemo_printwill 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.LimitationsSome packages likecoloramaandmoviepybreak 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.