wL i dZddlZddlZddlZddlmZdaejdk(rdZ nejdk(rdZ nd Z d Z d Z d Z d adZdZejdk(r2ej"j%ddZej)drMeZ eZ nHejdk(r9ddlZej,j.j0Zej2ge_dZ dZdZddededeeeffdZy)z Utilities for working with terminals. Authors: * Brian E. Granger * Fernando Perez * Alexander Belchenko (e-mail: bialix AT ukr.net) N)get_terminal_sizeTposixc.tjdy)Nclearossystem\/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/utils/terminal.py _term_clearr s 'r win32c.tjdy)Nclsrr r r r r s %r cyNr r r r r r s r c | ay)aControl whether set_term_title is active or not. set_term_title() allows writing to the console titlebar. In embedded widgets this can cause problems, so this call can be used to toggle it on or off as needed. The default state of the module is for the function to be disabled. Parameters ---------- val : bool If True, set_term_title() actually writes to the terminal (using the appropriate platform-specific module). If False, it is a no-op. N)ignore_termtitle)vals r toggle_set_term_titler%s xr cy)z Dummy no-op.Nr )argskws r _set_term_titler8sr cyrr r r r _restore_term_titler=sr Fcts!tjjddatjjd|zy)z3 Change virtual terminal title in xterm-workalikes zTz]0;%sN)_xterm_term_title_savedsysstdoutwritetitles r _set_term_title_xtermr$Ds6 # &"&JJ_u,-r ctstjddytjj dday)NzYExpecting xterm_term_title_saved to be True, but is not; will not restore terminal title.) stacklevelzF)rwarningswarnrr r!r r r _restore_term_title_xtermr*Ps6 # g  JJ\"#r TERMxtermct|y)z9Set terminal title using ctypes to access the Win32 APIs.N)SetConsoleTitleWr"s r rris r c(tryt|y)z@Set terminal title using the necessary platform-dependent calls.N)rrr"s r set_term_titler1nsEr c&tryty)z:Restore, if possible, terminal title to the original stateN)rrr r r restore_term_titler3usr defaultxdefaultyreturnct||fSr)_get_terminal_size)r4r5s r rr|s x2 33r )P)__doc__rrr(shutilrr8rnamer platformrrrrr$r*environgetr+ startswithctypeswindllkernel32r/ c_wchar_pargtypesr1r3inttupler r r rIs  :77g\\W  &    . $77g ::>>& $D w/7\\W}}-->>!'!1!1 2 44C4sCx4r