ig$}dZddlZddlZddlmZddlmZmZmZm Z m Z ddl m Z dZ e dZe dZd ZGd d eZejZ eje d Zeje d Zeje dZeje dZeje dZeje dZeje dZdedefdZdedefdZdedefdZ deededdfdZ!dedefdZ"dIdedefdZ#dIdedefd Z$Gd!d"Z%Gd#d$e%Z&Gd%d&e%Z'Gd'd(Z(Gd)d*e%eZ)Gd+d,e&eZ*Gd-d.e'eZ+Gd/d0e&eZ,Gd1d2e'eZ-Gd3d4e&Z.Gd5d6e'Z/ddddddddd7d8ed9e e&d:e e'd;e e0de e0d?e e0d@e e0defdAZ1ej2e1e*j3BZ4 ej2e1e*j5BZ6 ej2e1e*j7BZ8 dCedDedEedFedGedef dHZ9dS)Jz Support for ANSI escape sequences which are used for things like applying style to text, setting the window title, and asynchronous alerts. N)Enum)IOAnyListOptionalcast)wcswidth[]c6eZdZdZdZdZdZdefdZdefdZ dS) AllowStylez$Values for ``cmd2.ansi.allow_style``AlwaysNeverTerminalreturnc*t|jS)zDReturn value instead of enum name for printing in cmd2's set command)strvalueselfs Y/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/cmd2/ansi.py__str__zAllowStyle.__str__(s4:c*t|jS)zRReturn quoted value instead of enum description for printing in cmd2's set command)reprrrs r__repr__zAllowStyle.__repr__,sDJrN) __name__ __module__ __qualname____doc__ALWAYSNEVERTERMINALrrrrrrr!s_.. F EH #      rrz\[[^m]*mz\[(?:[39][0-7]|39)mz\[(?:(?:4|10)[0-7]|49)mz.\[38;5;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])mz.\[48;5;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])mz5\[38;2(?:;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])){3}mz5\[48;2(?:;(?:1?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])){3}mtextrc8td|S)z Strip ANSI style sequences from a string. :param text: string which may contain ANSI style sequences :return: the same string with any ANSI style sequences removed ) ANSI_STYLE_REsubr's r strip_styler-Ws   R & &&rc`tttt|S)a% Wrap wcswidth to make it compatible with strings that contain ANSI style sequences. This is intended for single line strings. If text contains a newline, this function will return -1. For multiline strings, call widest_line() instead. :param text: the string being measured :return: The width of the string when printed to the terminal if no errors occur. If text contains characters with no absolute width (i.e. tabs), then this function returns -1. Replace tabs with spaces before calling this. )rintr r-r,s rstyle_aware_wcswidthr0as$ Xk$//00 1 11rcp|sdSd|D}d|vrdSt|S)a Return the width of the widest line in a multiline string. This wraps style_aware_wcswidth() so it handles ANSI style sequences and has the same restrictions on non-printable characters. :param text: the string being measured :return: The width of the string when printed to the terminal if no errors occur. If text contains characters with no absolute width (i.e. tabs), then this function returns -1. Replace tabs with spaces before calling this. rc,g|]}t|Sr&)r0).0lines r zwidest_line..}s!MMM4(..MMMr) splitlinesmax)r' lines_widthss r widest_liner:psL qMM4??;L;LMMML \r |  rfileobjmsgcttjks)ttjkr#|st |}||dS)z Write a string to a fileobject and strip its ANSI style sequences if required by allow_style setting :param fileobj: the file object being written to :param msg: the string being written N) allow_stylerr$r%isattyr-write)r;r<s rstyle_aware_writerAsVj&&&;*:M+M+MV]VdVdVfVf+M# MM#rtitlec(td|tS)z Generate a string that, when printed, sets a terminal's window title. :param title: new title for the window :return: the set title string z2;)OSCBEL)rBs r set_titlerFs ! !U !C ! !!r clear_typecXd|cxkrdkrnn t|dStd)a^ Generate a string that, when printed, clears a terminal screen based on value of clear_type. :param clear_type: integer which specifies how to clear the screen (Defaults to 2) Possible values: 0 - clear from cursor to end of screen 1 - clear from cursor to beginning of the screen 2 - clear entire screen 3 - clear entire screen and delete all lines saved in the scrollback buffer :return: the clear screen string :raises ValueError: if clear_type is not a valid value rJz)clear_type must in an integer from 0 to 3CSI ValueErrorrHs r clear_screenrPsI J!$z$$$$ @ A AArcXd|cxkrdkrnn t|dStd)a Generate a string that, when printed, clears a line based on value of clear_type. :param clear_type: integer which specifies how to clear the line (Defaults to 2) Possible values: 0 - clear from cursor to the end of the line 1 - clear from cursor to beginning of the line 2 - clear entire line :return: the clear line string :raises ValueError: if clear_type is not a valid value rrGKz)clear_type must in an integer from 0 to 2rLrOs r clear_linerSsI J!$z$$$$ @ A AArc2eZdZdZdedefdZdedefdZdS) AnsiSequencez*Base class to create ANSI sequence stringsotherrc@t|t|zS)z Support building an ANSI sequence string when self is the left operand e.g. Fg.LIGHT_MAGENTA + "hello" rrrVs r__add__zAnsiSequence.__add__s 4yy3u::%%rc@t|t|zS)zy Support building an ANSI sequence string when self is the right operand e.g. "hello" + Fg.RESET rXrYs r__radd__zAnsiSequence.__radd__s 5zzCII%%rN)rr r!r"rrrZr\r&rrrUrUs^44&S&S&&&&&c&c&&&&&&rrUceZdZdZdS)FgColorz=Base class for ANSI Sequences which set foreground text colorNrr r!r"r&rrr^r^GGDrr^ceZdZdZdS)BgColorz=Base class for ANSI Sequences which set background text colorNr_r&rrrbrbr`rrbceZdZdZed dedefdZed dedefdZed dedefdZ ed dedefdZ ed ed edefd Z d S)Cursorz2Create ANSI sequences to alter the cursor positioncountrct|dS)z>Move the cursor up a specified amount of lines (Defaults to 1)ArMrfs rUPz Cursor.UPurct|dS)z@Move the cursor down a specified amount of lines (Defaults to 1)Brirjs rDOWNz Cursor.DOWNrlrct|dS)zCMove the cursor forward a specified amount of lines (Defaults to 1)Crirjs rFORWARDzCursor.FORWARDrlrct|dS)z@Move the cursor back a specified amount of lines (Defaults to 1)Drirjs rBACKz Cursor.BACKrlrxyc t|d|dS)z8Set the cursor position to coordinates which are 1-based;Hri)rvrws rSET_POSzCursor.SET_POSs q1rN)re) rr r!r" staticmethodr/rrkrorrrur{r&rrrdrds<<  # c   \   C    \   s 3   \   C    \  3 3 3   \   rrdcReZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdefdZdS) TextStylez Create text style ANSI sequencesrr)rerGrJ57 rc$t|jdS)z Return ANSI text style sequence instead of enum name This is helpful when using a TextStyle in an f-string or format() call e.g. my_str = f"{TextStyle.UNDERLINE_ENABLE}hello{TextStyle.UNDERLINE_DISABLE}" mrMrrs rrzTextStyle.__str__ $tz$$$$rN)rr r!r" RESET_ALL ALT_RESET_ALLINTENSITY_BOLD INTENSITY_DIMINTENSITY_NORMAL ITALIC_ENABLEITALIC_DISABLEOVERLINE_ENABLEOVERLINE_DISABLESTRIKETHROUGH_ENABLESTRIKETHROUGH_DISABLEUNDERLINE_ENABLEUNDERLINE_DISABLErrr&rrr~r~s~**IMNMMNO%%%%%%%rr~cbeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdefdZdS)Fgz Create ANSI sequences for the 16 standard terminal foreground text colors. A terminal's color settings affect how these colors appear. To reset any foreground color, use Fg.RESET.  !"#$%Z[\]^_`a'rc$t|jdS)z Return ANSI color sequence instead of enum name This is helpful when using an Fg in an f-string or format() call e.g. my_str = f"{Fg.BLUE}hello{Fg.RESET}" rrrs rrz Fg.__str__;rrNrr r!r"BLACKREDGREENYELLOWBLUEMAGENTACYAN LIGHT_GRAY DARK_GRAY LIGHT_RED LIGHT_GREEN LIGHT_YELLOW LIGHT_BLUE LIGHT_MAGENTA LIGHT_CYANWHITERESETrrr&rrrr!s E C E F DG DJIIKLJMJ E E%%%%%%%rrcbeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdefdZdS)Bgz Create ANSI sequences for the 16 standard terminal background text colors. A terminal's color settings affect how these colors appear. To reset any background color, use Bg.RESET. ()*+,-./defghijk1rc$t|jdS)z Return ANSI color sequence instead of enum name This is helpful when using a Bg in an f-string or format() call e.g. my_str = f"{Bg.BLACK}hello{Bg.RESET}" rrrs rrz Bg.__str__^rrNrr&rrrrDs E C E F DG DJIIKLJMJ E E%%%%%%%rrc4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Zd=Z?d>Z@d?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJdIZKdJZLdKZMdLZNdMZOdNZPdOZQdPZRdQZSdRZTdSZUdTZVdUZWdVZXdWZYdXZZdYZ[dZZ\d[Z]d\Z^d]Z_d^Z`d_Zad`ZbdaZcdbZddcZeddZfdeZgdfZhdgZidhZjdiZkdjZldkZmdlZndmZodnZpdoZqdpZrdqZsdrZtdsZudtZvduZwdvZxdwZydxZzdyZ{dzZ|d{Z}d|Z~d}Zd~ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdefdZdS( EightBitFga Create ANSI sequences for 8-bit terminal foreground text colors. Most terminals support 8-bit/256-color mode. The first 16 colors correspond to the 16 colors from Fg and behave the same way. To reset any foreground color, including 8-bit, use Fg.RESET. rrerGrJrr rrrrrrrrrrrr&rrrrrrrrr0r234r6r89:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYrrrrrrrrbcrrrrrrrrlmnopqrstuvwxyz{|}~rc&td|jdS)z Return ANSI color sequence instead of enum name This is helpful when using an EightBitFg in an f-string or format() call e.g. my_str = f"{EightBitFg.SLATE_BLUE_1}hello{Fg.RESET}" z38;5;rrrs rrzEightBitFg.__str__o ))DJ))))rNrr r!r"rrrrrrrrrrrrrrrrGRAY_0 NAVY_BLUE DARK_BLUEBLUE_3ABLUE_3BBLUE_1 DARK_GREENDEEP_SKY_BLUE_4ADEEP_SKY_BLUE_4BDEEP_SKY_BLUE_4C DODGER_BLUE_3 DODGER_BLUE_2GREEN_4SPRING_GREEN_4 TURQUOISE_4DEEP_SKY_BLUE_3ADEEP_SKY_BLUE_3B DODGER_BLUE_1GREEN_3ASPRING_GREEN_3A DARK_CYANLIGHT_SEA_GREENDEEP_SKY_BLUE_2DEEP_SKY_BLUE_1GREEN_3BSPRING_GREEN_3BSPRING_GREEN_2ACYAN_3DARK_TURQUOISE TURQUOISE_2GREEN_1SPRING_GREEN_2BSPRING_GREEN_1MEDIUM_SPRING_GREENCYAN_2CYAN_1 DARK_RED_1 DEEP_PINK_4A PURPLE_4A PURPLE_4BPURPLE_3 BLUE_VIOLET ORANGE_4AGRAY_37MEDIUM_PURPLE_4 SLATE_BLUE_3A SLATE_BLUE_3B ROYAL_BLUE_1 CHARTREUSE_4DARK_SEA_GREEN_4APALE_TURQUOISE_4 STEEL_BLUE STEEL_BLUE_3CORNFLOWER_BLUE CHARTREUSE_3ADARK_SEA_GREEN_4B CADET_BLUE_2 CADET_BLUE_1 SKY_BLUE_3 STEEL_BLUE_1A CHARTREUSE_3B PALE_GREEN_3A SEA_GREEN_3 AQUAMARINE_3MEDIUM_TURQUOISE STEEL_BLUE_1B CHARTREUSE_2A SEA_GREEN_2 SEA_GREEN_1A SEA_GREEN_1B AQUAMARINE_1ADARK_SLATE_GRAY_2 DARK_RED_2 DEEP_PINK_4BDARK_MAGENTA_1DARK_MAGENTA_2DARK_VIOLET_1A PURPLE_1A ORANGE_4B LIGHT_PINK_4PLUM_4MEDIUM_PURPLE_3AMEDIUM_PURPLE_3B SLATE_BLUE_1 YELLOW_4AWHEAT_4GRAY_53LIGHT_SLATE_GRAY MEDIUM_PURPLELIGHT_SLATE_BLUE YELLOW_4BDARK_OLIVE_GREEN_3ADARK_GREEN_SEALIGHT_SKY_BLUE_3ALIGHT_SKY_BLUE_3B SKY_BLUE_2 CHARTREUSE_2BDARK_OLIVE_GREEN_3B PALE_GREEN_3BDARK_SEA_GREEN_3ADARK_SLATE_GRAY_3 SKY_BLUE_1 CHARTREUSE_1 LIGHT_GREEN_2 LIGHT_GREEN_3 PALE_GREEN_1A AQUAMARINE_1BDARK_SLATE_GRAY_1RED_3A DEEP_PINK_4CMEDIUM_VIOLET_RED MAGENTA_3ADARK_VIOLET_1B PURPLE_1BDARK_ORANGE_3A INDIAN_RED_1A HOT_PINK_3AMEDIUM_ORCHID_3 MEDIUM_ORCHIDMEDIUM_PURPLE_2ADARK_GOLDENRODLIGHT_SALMON_3A ROSY_BROWNGRAY_63MEDIUM_PURPLE_2BMEDIUM_PURPLE_1GOLD_3A DARK_KHAKINAVAJO_WHITE_3GRAY_69LIGHT_STEEL_BLUE_3LIGHT_STEEL_BLUE YELLOW_3ADARK_OLIVE_GREEN_3DARK_SEA_GREEN_3BDARK_SEA_GREEN_2 LIGHT_CYAN_3LIGHT_SKY_BLUE_1 GREEN_YELLOWDARK_OLIVE_GREEN_2 PALE_GREEN_1BDARK_SEA_GREEN_5BDARK_SEA_GREEN_5APALE_TURQUOISE_1RED_3B DEEP_PINK_3A DEEP_PINK_3B MAGENTA_3B MAGENTA_3C MAGENTA_2ADARK_ORANGE_3B INDIAN_RED_1B HOT_PINK_3B HOT_PINK_2ORCHIDMEDIUM_ORCHID_1AORANGE_3LIGHT_SALMON_3B LIGHT_PINK_3PINK_3PLUM_3VIOLETGOLD_3BLIGHT_GOLDENROD_3TAN MISTY_ROSE_3 THISTLE_3PLUM_2 YELLOW_3BKHAKI_3LIGHT_GOLDENROD_2ALIGHT_YELLOW_3GRAY_84LIGHT_STEEL_BLUE_1YELLOW_2DARK_OLIVE_GREEN_1ADARK_OLIVE_GREEN_1BDARK_SEA_GREEN_1 HONEYDEW_2 LIGHT_CYAN_1RED_1 DEEP_PINK_2 DEEP_PINK_1A DEEP_PINK_1B MAGENTA_2B MAGENTA_1 ORANGE_RED_1 INDIAN_RED_1C INDIAN_RED_1D HOT_PINK_1A HOT_PINK_1BMEDIUM_ORCHID_1B DARK_ORANGESALMON_1 LIGHT_CORALPALE_VIOLET_RED_1ORCHID_2ORCHID_1ORANGE_1 SANDY_BROWNLIGHT_SALMON_1 LIGHT_PINK_1PINK_1PLUM_1GOLD_1LIGHT_GOLDENROD_2BLIGHT_GOLDENROD_2CNAVAJO_WHITE_1 MISTY_ROSE1 THISTLE_1YELLOW_1LIGHT_GOLDENROD_1KHAKI_1WHEAT_1 CORNSILK_1GRAY_100GRAY_3GRAY_7GRAY_11GRAY_15GRAY_19GRAY_23GRAY_27GRAY_30GRAY_35GRAY_39GRAY_42GRAY_46GRAY_50GRAY_54GRAY_58GRAY_62GRAY_66GRAY_70GRAY_74GRAY_78GRAY_82GRAY_85GRAY_89GRAY_93rrr&rrrrgj E C E F DG DJIIKLJMJ E FIIGG FJMMGNKMHOIOOOHOO FNKGON F FJLIIHKIGOMMLLJLOMLLJMMMKLMMKLLMJLNNNIIL FLIGGMINJMMJLMMMM FLJNINMKOMNOJGOGJNGILLM FLLJJJNMKJ FHOL F F FG CLI FIGNGHJL EKLLJILMMKKKHKHHHKNL F F FNKIHGGJH F FGGGGGGGGGGGGGGGGGGGGGG*******rrc4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Zd=Z?d>Z@d?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJdIZKdJZLdKZMdLZNdMZOdNZPdOZQdPZRdQZSdRZTdSZUdTZVdUZWdVZXdWZYdXZZdYZ[dZZ\d[Z]d\Z^d]Z_d^Z`d_Zad`ZbdaZcdbZddcZeddZfdeZgdfZhdgZidhZjdiZkdjZldkZmdlZndmZodnZpdoZqdpZrdqZsdrZtdsZudtZvduZwdvZxdwZydxZzdyZ{dzZ|d{Z}d|Z~d}Zd~ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdefdZdS( EightBitBga Create ANSI sequences for 8-bit terminal background text colors. Most terminals support 8-bit/256-color mode. The first 16 colors correspond to the 16 colors from Bg and behave the same way. To reset any background color, including 8-bit, use Bg.RESET. rrerGrJrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUrVrWrXrYrZr[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrc&td|jdS)z Return ANSI color sequence instead of enum name This is helpful when using an EightBitBg in an f-string or format() call e.g. my_str = f"{EightBitBg.KHAKI_3}hello{Bg.RESET}" z48;5;rrrs rrzEightBitBg.__str__rrNrr&rrrrxrrrc6eZdZdZdedededdfdZdefdZdS) RgbFgz Create ANSI sequences for 24-bit (RGB) terminal foreground text colors. The terminal must support 24-bit/true-color mode. To reset any foreground color, including 24-bit, use Fg.RESET. rgbrNctd|||fDrtdtd|d|d|d|_dS)aC RgbFg initializer :param r: integer from 0-255 for the red component of the color :param g: integer from 0-255 for the green component of the color :param b: integer from 0-255 for the blue component of the color :raises ValueError: if r, g, or b is not in the range 0-255 c3.K|]}|dkp|dkVdSrrNr&r3cs r z!RgbFg.__init__../33Aq1uC333333r4RGB values must be integers in the range of 0 to 255z38;2;ryrNanyrNrM _sequencerrrrs r__init__zRgbFg.__init__e 33!Q333 3 3 USTT T22a22!22a222rc|jS)z Return ANSI color sequence instead of enum name This is helpful when using an RgbFg in an f-string or format() call e.g. my_str = f"{RgbFg(0, 55, 100)}hello{Fg.RESET}" rrs rrz RgbFg.__str__ ~rrr r!r"r/rrrr&rrrri 3# 3# 3# 3$ 3 3 3 3rrc6eZdZdZdedededdfdZdefdZdS) RgbBgz Create ANSI sequences for 24-bit (RGB) terminal background text colors. The terminal must support 24-bit/true-color mode. To reset any background color, including 24-bit, use Bg.RESET. rrrrNctd|||fDrtdtd|d|d|d|_dS)aC RgbBg initializer :param r: integer from 0-255 for the red component of the color :param g: integer from 0-255 for the green component of the color :param b: integer from 0-255 for the blue component of the color :raises ValueError: if r, g, or b is not in the range 0-255 c3.K|]}|dkp|dkVdSrr&rs rrz!RgbBg.__init__..rrrz48;2;ryrNrrs rrzRgbBg.__init__rrc|jS)z Return ANSI color sequence instead of enum name This is helpful when using an RgbBg in an f-string or format() call e.g. my_str = f"{RgbBg(100, 255, 27)}hello{Bg.RESET}" rrs rrz RgbBg.__str__rrrr&rrrrrrr)fgbgbolddimitalicoverline strikethrough underlinerrrrrrrrrc4g} g} |Xt|tstd| || tj|Xt|t std| || tj|r>| tj | tj |r>| tj | tj |r>| tj | tj |r>| tj| tj|r>| tj| tj|r>| tj| tjdt+t,| t-|zdt+t,| zS)aw Apply ANSI colors and/or styles to a string and return it. The styling is self contained which means that at the end of the string reset code(s) are issued to undo whatever styling was done at the beginning. :param value: object whose text is to be styled :param fg: foreground color provided as any subclass of FgColor (e.g. Fg, EightBitFg, RgbFg) Defaults to no color. :param bg: foreground color provided as any subclass of BgColor (e.g. Bg, EightBitBg, RgbBg) Defaults to no color. :param bold: apply the bold style if True. Defaults to False. :param dim: apply the dim style if True. Defaults to False. :param italic: apply the italic style if True. Defaults to False. :param overline: apply the overline style if True. Defaults to False. :param strikethrough: apply the strikethrough style if True. Defaults to False. :param underline: apply the underline style if True. Defaults to False. :raises TypeError: if fg isn't None or a subclass of FgColor :raises TypeError: if bg isn't None or a subclass of BgColor :return: the stylized string Nz fg must be a subclass of FgColorzbg must a subclass of BgColorr)) isinstancer^ TypeErrorappendrrrbrr~rrrrrrrrrrrjoinmapr) rrrrrrrrr additionsremovalss rstylers,B%'I$&H ~"g&& @>?? ?!!! ~"g&& =;<< <!!! 41222 2333 40111 2333 20111 011142333 233397888 788853444 3444 773sI&& ' '#e** 4rwws3?Q?Q7R7R RRr)rterminal_columnspromptr4 cursor_offset alert_msgc@|pdg}d}|ddD])}t|}|t||z dzz }*|d} t| } | t|z} t| |z dz} | |z} t| |z dz}d}|| kr |t| |z z }|| z}|t tdz|dz zz }|t z }|d|zz }|S)aCalculate the desired string, including ANSI escape codes, for displaying an asynchronous alert message. :param terminal_columns: terminal width (number of columns) :param prompt: current onscreen prompt :param line: current contents of the Readline line buffer :param cursor_offset: the offset of the current cursor position within line :param alert_msg: the message to display to the user :return: the correct string so that the alert message appears to the user to be printed above the current line. r)rNr6re )r7r0r/rdrorSrk)rrr4rr prompt_linesnum_prompt_terminal_lines prompt_lineprompt_line_widthlast_prompt_linelast_prompt_line_width input_widthnum_input_terminal_linescursor_input_offsetcursor_input_line terminal_str total_liness rasync_alert_strrsl$$&&.2$L!"#CRC(SS 0==!S):=M)M%N%NQR%RR!!$B'12BCC(+?+E+EEK";1A#ABBQF1=@/2BBCCaGL444 $compiler* STD_FG_RE STD_BG_REEIGHT_BIT_FG_REEIGHT_BIT_BG_RE RGB_FG_RE RGB_BG_RErr-r/r0r:rArFrPrSrUr^rbrdr~rrrrrrboolrpartialr style_successr style_warningr style_errorrr&rrrs@    iii iii           "!   s,,,--  BJ3333 4 4  BJ3777 8 8 "*TTTUU"*TTTUU BJ3WWW X X  BJ3WWW X X 'c'c'''' 2s 2s 2 2 2 2cc( r#w S T    "S"S""""BBSBBBBB$BB3BsBBBB(&&&&&&&&$     l        l           :%%%%% d%%%@ % % % % %$ % % %F % % % % %$ % % %FN*N*N*N*N*$N*N*N*bN*N*N*N*N*$N*N*N*bG:G@! !#$( $LSLSLS LS LS  LS 4. LS $ LS TNLStnLSD>LS~LS LSLSLSLSd" !%BH555 f! !%BO<<< hi",777 g33c33UX3eh3mp333333r