8f$Y UdZddlZddlZddlmZdZeed<ejdkrejej Zne e dddl Z ddlm Z mZmZddlmZmZmZmZdd lmZdd lmZd Zd ZejZGd deZGddeZGdde ZGddej Z ej!j"Z#ej$ge#_%ej&e#_'efde(dej&fdZ"ej!j)Z*ej&ej+ge*_%ej,e*_'dej&de(fdZ)ej!j-Z.ej&ej/ej$eeeeej0ej$ge._%ej,e._'dej&de1de(dede(f dZ2ej!j3Z4ej&ej5ej$eeeeej0ej$ge4_%ej,e4_'dej&de(de(dede(f dZ3ej!j6Z7ej&ej5ge7_%ej,e7_'dej&dej5de8fd Z6ej!j9Z:ej&ej0ege:_%ej,e:_'dej&defd!Z9ej!j;Zej&ej0e ge>_%ej,e>_'dej&d$e de8fd%Z=ej!j?Z@ej&ej0e ge@_%ej,e@_'dej&d$e de8fd&Z?ej!jAZBejCgeB_%ej,eB_'d'e1de8fd(ZDGd)d*ZEe d+krte"ZFdd,lGmHZHeHZIeEejJZKeKLd-ed.d/0ZMejNd1ZOeIPd2eIQd3eIQd4eIQd5eIQd6eIQd7eIQd8eIQd9eIQd:eIQd;eIQd<eIQd=eIQd>eIQd?eIQd@eIQdAeIPdBeIQeKReKReKSdCe jTdDeKUeKSdEe jTdDeKVeKSdFe jTdDeKUeKReKReKSdGe jTdDeKVeKReKReKSdHe jTdDeKWeIQeIPdIeIQdJeKSdKe jTdDeKXdLeKYdMejNdNeKRe jTdDeKZe jTdDeIQdOeKSdKe jTdDeKXdLeKYdPejNdNe jTdDeK[e jTdDeIQdQeKYdRejNdSTe jTdDeK\eK]eQdUdSdS)VzLight wrapper around the Win32 Console API - this module should only be imported on Windows The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions N)Anywindllwin32z can only be imported on Windows) Structurebyrefwintypes)IO NamedTupleTypecast) ColorSystem)StyleiceZdZdS)LegacyWindowsErrorN)__name__ __module__ __qualname__/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/rich/_win32_console.pyrrsDrrcHeZdZUdZeed<eed<edddefdZdS)WindowsCoordinateszCoordinates in the Windows Console API are (y, x), not (x, y). This class is intended to prevent that confusion. Rows and columns are indexed from 0. This class can be used in place of wintypes._COORD in arguments and argtypes. rowcolvaluereturnc6t|j|jS)aEConverts a WindowsCoordinates into a wintypes _COORD structure. This classmethod is internally called by ctypes to perform the conversion. Args: value (WindowsCoordinates): The input coordinates to convert. Returns: wintypes._COORD: The converted coordinates struct. )COORDrr)clsrs r from_paramzWindowsCoordinates.from_param*sUY ***rN) rrr__doc__int__annotations__ classmethodrr!rrrrr sa HHH HHH +3 + + + +[ + + +rrcDeZdZdefdefdejfdejfdefgZdS)CONSOLE_SCREEN_BUFFER_INFOdwSizedwCursorPosition wAttributessrWindowdwMaximumWindowSizeN)rrrrrWORD SMALL_RECT_fields_rrrr'r'8sB 5 U#  & X() & HHHrr'c2eZdZdejfdejfgZdS)CONSOLE_CURSOR_INFOr(bVisibleN)rrrrDWORDBOOLr/rrrr1r1Bs&8>*Z,GHHHHrr1handlercPttjt|S)zRetrieves a handle to the specified standard device (standard input, standard output, or standard error). Args: handle (int): Integer identifier for the handle. Defaults to -11 (stdout). Returns: wintypes.HANDLE: The handle )r rHANDLE _GetStdHandle)r5s r GetStdHandler9Ms v!6!6 7 77r std_handlectj}tt||}|st d|jS)aRetrieves the current input mode of a console's input buffer or the current output mode of a console screen buffer. Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. Raises: LegacyWindowsError: If any error occurs while calling the Windows console API. Returns: int: Value representing the current console mode as documented at https://docs.microsoft.com/en-us/windows/console/getconsolemode#parameters z)Unable to get legacy Windows Console Mode)rr3bool_GetConsoleModerr)r: console_modesuccesss rGetConsoleModer@^sI>##L?:|<<==G N !LMMM  rcharlengthstartc tj|}tj|}tjd}t ||||t ||jS)aWrites a character to the console screen buffer a specified number of times, beginning at the specified coordinates. Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. char (str): The character to write. Must be a string of length 1. length (int): The number of times to write the character. start (WindowsCoordinates): The coordinates to start writing at. Returns: int: The number of characters written. r)ctypesc_charencoderr3_FillConsoleOutputCharacterWrr)r:rArBrC characternum_characters num_writtens rFillConsoleOutputCharacterrLsm" dkkmm,,I^F++N.##K   k   r attributesc tj|}tj|}tjd}t||||t ||jS)alSets the character attributes for a specified number of character cells, beginning at the specified coordinates in a screen buffer. Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. attributes (int): Integer value representing the foreground and background colours of the cells. length (int): The number of cells to set the output attribute of. start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set. Returns: int: The number of cells whose attributes were actually set. r)rr3r-_FillConsoleOutputAttributerr)r:rMrBrC num_cells style_attrsrKs rFillConsoleOutputAttributerRsa$v&&I- ++K.##KKE53E3E  rc<tt||S)a|Set the colour attributes for all text written after this function is called. Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. attributes (int): Integer value representing the foreground and background colours. Returns: bool: True if the attribute was set successfully, otherwise False. )r<_SetConsoleTextAttribute)r:rMs rSetConsoleTextAttributerUs (Z@@ A AArc\t}t|t||S)aqRetrieves information about the specified console screen buffer. Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. Returns: CONSOLE_SCREEN_BUFFER_INFO: A CONSOLE_SCREEN_BUFFER_INFO ctype struct contain information about screen size, cursor position, colour attributes, and more.)r'_GetConsoleScreenBufferInfor)r:console_screen_buffer_infos rGetConsoleScreenBufferInforYs/" >>r cursor_infocVtt|t|S)aGet the cursor info - used to get cursor visibility and width Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct that receives information about the console's cursor. Returns: bool: True if the function succeeds, otherwise False. )r<_GetConsoleCursorInforr:r^s rGetConsoleCursorInforbs% %j% 2D2DEE F FFrcVtt|t|S)awSet the cursor info - used for adjusting cursor visibility and width Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct containing the new cursor info. Returns: bool: True if the function succeeds, otherwise False. )r<_SetConsoleCursorInforras rSetConsoleCursorInfore*s% %j% 2D2DEE F FFrtitlec:tt|S)zSets the title of the current console window Args: title (str): The new title of the console window. Returns: bool: True if the function succeeds, otherwise False. )r<_SetConsoleTitle)rfs rSetConsoleTitleri>s  '' ( ((rceZdZdZdZgdZddZedefd Z edefd Z d e ddfd Z d e d e ddfdZdeddfdZd dZd dZd dZd dZd dZd dZdeddfdZd dZd dZd dZde ddfdZdefdZdS)!LegacyWindowsTermaThis class allows interaction with the legacy Windows Console API. It should only be used in the context of environments where virtual terminal processing is not available. However, if it is used in a Windows environment, the entire API should work. Args: file (IO[str]): The file which the Windows Console API HANDLE is retrieved from, defaults to sys.stdout. )rrrl  fileIO[str]rNc tt}||_t|j}||_|dz|_|dz dz|_|j|jdzz|_||_ |j |_ |j |_ dS)Nrrr) r9STDOUT_handlerYr* _default_text _default_fore _default_back_default_attrs_filewriteflush)selfrzr5 default_texts r__init__zLegacyWindowsTerm.__init__isf%% 1&99E ))A-*a/14"0D4F!4KL Z Z rct|jj}tt t |jt t |jS)zReturns the current position of the cursor (0-based) Returns: WindowsCoordinates: The current cursor position. rr)rYr~r)rr r#YX)rcoords rcursor_positionz!LegacyWindowsTerm.cursor_positionwsA2$,??P!d3&8&8d3>P>PQQQQrct|jj}tt t |jt t |jS)zReturns the current size of the console screen buffer, in character columns and rows Returns: WindowsCoordinates: The width and height of the screen as WindowsCoordinates. r)rYr~r(rr r#rr)r screen_sizes rrzLegacyWindowsTerm.screen_sizesJ8 EEL !S+-((d3 .F.F    rtextcX|||dS)zWrite text directly to the terminal without any modification of styles Args: text (str): The text to write to the console N)rr)rrs r write_textzLegacyWindowsTerm.write_texts' 4 rstylecN|j}|j}|jr||}}|r[|tjj}||nd}|jr ||jz}|j r ||jz}|j |}n|j }|r8|tjj}||nd}|j |}n|j }|J|Jt|jtj||dzz||t|j|jdS)zWrite styled text to the terminal. Args: text (str): The text to write style (Style): The style of the text Nrrrr)rM)colorbgcolorreverse downgrader WINDOWSnumberbold BRIGHT_BITdimANSI_TO_WINDOWSrrrUr~rEc_ushortrr)rrrrrforebacks r write_styledzLegacyWindowsTerm.write_styledsY - = ,$e7E  &??;#677>D+44Dz .do-y /t..'-DD%D  &$$[%899@D+44D'-DD%D LV_TTQY5G%H%H      9KLLLLLLr new_positioncb|jdks |jdkrdSt|j|dS)zSet the position of the cursor Args: new_position (WindowsCoordinates): The WindowsCoordinates representing the new position of the cursor. rNrZ)rrr]r~)rrs rmove_cursor_toz LegacyWindowsTerm.move_cursor_tos?  a  <#3a#7#7 F lCCCCCCrc|j}|j}|j}t|jd}t |jd||t|j|j||dS)z@Erase all content on the line the cursor is currently located atrr rBrCN) rrrrrrLr~rRr)rrrcells_to_erasestart_coordinatess r erase_linezLegacyWindowsTerm.erase_lines& .$.?3FANNN" L#nz) ...Now the whole line will be erased...zI'm going to disappear!z black on cyan)r )^r"rEsystypingrrr$platform LibraryLoaderWinDLL ImportErrorrtimerrrr r r r pip._vendor.rich.colorr pip._vendor.rich.stylerr}"ENABLE_VIRTUAL_TERMINAL_PROCESSING_COORDr Exceptionrrr'r1kernel32r9r8r3argtypesr7restyper#r@r=LPDWORDr4FillConsoleOutputCharacterWrHrFPOINTERrrLrRrOr-rUrTr<rYrWr]r\rbr`rerdSetConsoleTitleWrhLPCWSTRrirkr5pip._vendor.rich.consolerconsolestdouttermrrparseheadingruleprintrrsleeprrrrrrrrrrrrrsN  <7 !V !&- 0 0FF +CCC D DD ----------------------......(((((( %&"        ++++++++0IIIII&*III,  N !  & 8 8 8(/ 8 8 8 8/0$OX-=>"-x3, &J O M NDe())FN8>"" )%(0}$      <%oH O M NDe())FN8>"" ($'/m#     6"?B O M%!$,=  B B-5] B  B B B B %oH OFN-..($'/m# & & & & & & #OD ODe())&"%-M! ? ?); ?  ? ? ? ?< OFN&''"!)  G G.A G  G G G G < OFN&''"!)  G G.A G  G G G G?3%-.#= )3 )4 ) ) ) )s's's's's's's's'l z \^^F000000giiG  SZ ( (DNN+,,, E / / /Eek*++G LL)*** MM#$$$ MM-    MM#$$$ MM-... MM1222 MM9::: MM-... MM;<<< MMKLLL MM;<<< MM3444 MM1222 MM3444 MM3444 MM;<<< LL+,,, MMOOOOO8999DJqMMMOOJDJqMMMOOJDJqMMMOO+,,,DJqMMMOO-...DJqMMM  MMOOO LL())) MM=>>>OOUVVVDJqMMMr"""c;5;~66777DJqMMMDJqMMM MM8999OOUVVVDJqMMMr"""c;5;~66777DJqMMMDJqMMM MM?@@@/{u{?7S7STTTDJqMMMOO E$KKKKKmr