)L i hddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddlm Z m Z m Z m Z mZmZddlmZmZddlmZddlmZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"ddl#m$Z$dd l%m&Z&dd l'm(Z(m)Z)dd l*m+Z+m,Z,dd l-m.Z.dd l/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5ddl6m7Z7ddl8m9Z9m:Z:m;Z;mZ>ddl?m@Z@ddlAmBZBmCZCddlDmEZEddlFmGZGddlHmIZIddlJmKZKmLZLmMZMmNZNmOZOmPZPmQZQddlRmSZSmTZTddlUmVZVddlWmXZXddlYmZZZm[Z[ddl\m]Z]m^Z^ddl_m`Z`ddlambZbmcZcddldmeZemfZfdd lgmhZhmiZidd!ljmkZkdd"llmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtdd#lumvZvmwZwd$d%lxmyZymzZzd$d&l{m|Z|m{Z{d'gZ}eSZ~e d(Zed)gdfZeed*dZeed+dZGd,d'eeZGd-d.eOZd2d/Ze d3d0Zed4d1Zy)5) annotationsN)AbstractEventLoopFutureTask ensure_futureget_running_loopsleep) ExitStackcontextmanager)Popen) format_tb) AnyCallable Coroutine GeneratorGenericHashableIterableIteratorTypeVarcastoverload)Buffer) SimpleCache) ClipboardInMemoryClipboard)AnyCursorShapeConfigto_cursor_shape_config)Size) EditingMode) InputHookget_traceback_from_contextnew_eventloop_with_inputhookrun_in_executor_with_context)call_soon_threadsafe) ConditionFilter FilterOrBool to_filter)AnyFormattedText)Input) get_typeaheadstore_typeahead)load_page_navigation_bindings)load_key_bindings) EmacsState)BindingConditionalKeyBindingsGlobalOnlyKeyBindings KeyBindingsKeyBindingsBase KeysTuplemerge_key_bindings) KeyPressEvent KeyProcessor)ViState)Keys) ContainerWindow) BufferControl UIControl)create_dummy_layout)Layoutwalk) ColorDepthOutput)Rendererprint_formatted_text) SearchState) BaseStyle DummyStyleDummyStyleTransformation DynamicStyleStyleTransformationdefault_pygments_styledefault_ui_style merge_styles)Eventin_main_thread)get_app_sessionset_app) in_terminalrun_in_terminal Application _AppResultApplication[_AppResult]SIGWINCHSIGTSTPceZdZdZdddddddddddej dddddddddddddf d,dZd-dZed.d Z ed/d Z ed0d Z d1d Z d1d Z ed2dZd3d4dZd1dZd1dZd5dZd1dZd6d7dZ d8 d9dZ d: d;dZ ddZ d?dZd@dZd1dZd1dZd1dZe d1dZ!e d d!dAd"Z!e d d! dBd#Z! dC dDd$Z!d1d%Z" dE dFd&Z#dGdHd'Z$ d6 dId(Z%ed2d)Z&ed2d*Z'dJd+Z(y)KrWa' The main Application class! This glues everything together. :param layout: A :class:`~prompt_toolkit.layout.Layout` instance. :param key_bindings: :class:`~prompt_toolkit.key_binding.KeyBindingsBase` instance for the key bindings. :param clipboard: :class:`~prompt_toolkit.clipboard.Clipboard` to use. :param full_screen: When True, run the application on the alternate screen buffer. :param color_depth: Any :class:`~.ColorDepth` value, a callable that returns a :class:`~.ColorDepth` or `None` for default. :param erase_when_done: (bool) Clear the application output when it finishes. :param reverse_vi_search_direction: Normally, in Vi mode, a '/' searches forward and a '?' searches backward. In Readline mode, this is usually reversed. :param min_redraw_interval: Number of seconds to wait between redraws. Use this for applications where `invalidate` is called a lot. This could cause a lot of terminal output, which some terminals are not able to process. `None` means that every `invalidate` will be scheduled right away (which is usually fine). When one `invalidate` is called, but a scheduled redraw of a previous `invalidate` call has not been executed yet, nothing will happen in any case. :param max_render_postpone_time: When there is high CPU (a lot of other scheduled calls), postpone the rendering max x seconds. '0' means: don't postpone. '.5' means: try to draw at least twice a second. :param refresh_interval: Automatically invalidate the UI every so many seconds. When `None` (the default), only invalidate when `invalidate` has been called. :param terminal_size_polling_interval: Poll the terminal size every so many seconds. Useful if the applications runs in a thread other then then main thread where SIGWINCH can't be handled, or on Windows. Filters: :param mouse_support: (:class:`~prompt_toolkit.filters.Filter` or boolean). When True, enable mouse support. :param paste_mode: :class:`~prompt_toolkit.filters.Filter` or boolean. :param editing_mode: :class:`~prompt_toolkit.enums.EditingMode`. :param enable_page_navigation_bindings: When `True`, enable the page navigation key bindings. These include both Emacs and Vi bindings like page-up, page-down and so on to scroll through pages. Mostly useful for creating an editor or other full screen applications. Probably, you don't want this for the implementation of a REPL. By default, this is enabled if `full_screen` is set. Callbacks (all of these should accept an :class:`~prompt_toolkit.application.Application` object as input.) :param on_reset: Called during reset. :param on_invalidate: Called when the UI has been invalidated. :param before_render: Called right before rendering. :param after_render: Called right after rendering. I/O: (Note that the preferred way to change the input/output is by creating an `AppSession` with the required input/output objects. If you need multiple applications running at the same time, you have to create a separate `AppSession` using a `with create_app_session():` block. :param input: :class:`~prompt_toolkit.input.Input` instance. :param output: :class:`~prompt_toolkit.output.Output` instance. (Probably Vt100_Output or Win32Output.) Usage: app = Application(...) app.run() # Or await app.run_async() NTFg{Gz??c| tfd} t| } t| } t|}t| } t|}| t}| t}|_|_|_t_t_ |_ |xs t_ |_|_| _| _| _| _|_| _|_|_|_|_t5|_t9|_t9|_t9|_t9|_ tC}|xs |jD_"|xs |jF_#g_$d_%d_&d_'d_(d_)d_*tW_,t[_.d_/d_0jc|_2tgjdjD|| jh_5d_6d_7g_8d_9tutw_<d_=d_>jy)NcjSN) full_screenselfsl/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/prompt_toolkit/application/application.pyz&Application.__init__..s @P@PFr]g?)ra mouse_supportcpr_not_supported_callbackrg)@r&r)r@rJstylestyle_transformation key_bindingsr/_default_bindingsr._page_navigation_bindingslayoutr clipboardra _color_depthrg paste_mode editing_modeerase_when_donereverse_vi_search_directionenable_page_navigation_bindingsmin_redraw_intervalmax_render_postpone_timerefresh_intervalterminal_size_polling_intervalrcursorrP on_invalidateon_reset before_render after_renderrSoutputinputpre_run_callables _is_runningfutureloop _loop_threadcontext quoted_insertr:vi_stater0 emacs_state ttimeoutlen timeoutlen_create_merged_style _merged_stylerErhrendererrender_counter _invalidated_invalidate_events_last_redraw_timer9_CombinedRegistry key_processor_running_in_terminal_running_in_terminal_freset)rcrnriinclude_default_pygments_stylerjrkrora color_depthrgrurqrrrsrtrvrwrxryrzr|r{r}r~rrsessions` rd__init__zApplication.__init__s@ + 2.78P.Q +z* !-0 &/0K&L#*34S*T')23Q)R& >(*F  '#;#=  $8!)!2!4)F)H& "9&7&9!,'*$(.+F(/N,#6 (@% 0.L+,V4 #47dH- "47!$ 5"#. +gmm <> 15 .2 5937 #  %<"667UV    KK#''+'F'F    "  "%**;D*AB%*!;?# rfctttdfd }tt |tfdgS)z Create a `Style` object that merges the default UI style, the default pygments style, and the custom user style. crSSr`) dummy_stylerpygments_stylesrdconditional_pygments_stylezDApplication._create_merged_style..conditional_pygments_style[s-/%%""rfcjSr`rirbsrdrez2Application._create_merged_style..fs TZZrf)returnrH)rIrMrKrOrN)rcrrrrs`` @@rdrz Application._create_merged_styleSsL !l /1  #  #  "*/0   rfcz|j}t|r|}||jj}|S)a The active :class:`.ColorDepth`. The current value is determined as follows: - If a color depth was given explicitly to this application, use that value. - Otherwise, fall back to the color depth that is reported by the :class:`.Output` implementation. If the :class:`.Output` class was created using `output.defaults.create_output`, then this value is coming from the $PROMPT_TOOLKIT_COLOR_DEPTH environment variable. )rpcallablerget_default_color_depth)rcdepths rdrzApplication.color_depthjs9!! E?GE =KK779E rfcJ|jjxs tdS)a  The currently focused :class:`~.Buffer`. (This returns a dummy :class:`.Buffer` when none of the actual buffers has the focus. In this case, it's really not practical to check for `None` values or catch exceptions every time.) z dummy-buffer)name)rncurrent_bufferrrbs rdrzApplication.current_buffers%{{)) V.  rfcz|jj}t|tr |jSt S)zv Return the current :class:`.SearchState`. (The one for the focused :class:`.BufferControl`.) )rncurrent_control isinstancer> search_staterG)rc ui_controls rdcurrent_search_statez Application.current_search_states1 [[00 j- 0** *= rfc&d|_t|_|jj |j j |j j |jj |jj |jj|j }|jjs9|jD]%}|jjs||_yyy)z? Reset everything, for reading the next input. N) exit_styleset_background_tasksrrrrnrrr|firer is_focusablefind_all_windowscontentcurrent_window)rcrnws rdrzApplication.resets25%    "     %%224,,. 99))+,-F) 5rfcjsyjjjryjryd_jj j j dfd dfd jr`tjjz jkr(dfd jj fdyyy)zW Thread safe way of sending a repaint trigger to the input event loop. NTc4d_jyNF)r_redrawrbsrdredrawz&Application.invalidate..redraws %D  LLNrfcJtjjy)N)max_postpone_timer)r%rwr)rrcsrdschedule_redrawz/Application.invalidate..schedule_redraws $*G*Gdii rfc|Ktttjz d{y7 wr`)r rfloatrv)diffrrcsrdredraw_in_futurez0Application.invalidate..redraw_in_futures3UD,D,D E LMMM#%Ns *<: <c0jSr`)create_background_task)rrcsrdrez(Application.invalidate..sD778H8JKrfrNone) rr is_closedrr%r{rrvtimer)rcrrrrs`@@@@rd invalidatezApplication.invalidates  99  3 3 5      $D  &&t'9'9'>'>?    # #99;!7!77Dd...& ..K !  rfc|jS)z0True when a redraw operation has been scheduled.)rrbs rd invalidatedzApplication.invalidateds   rfcdfd }j*jjj|yy)z Render the command line again. (Not thread safe!) (From other threads, or if unsure, use :meth:`.Application.invalidate`.) :param render_as_done: make sure to put the cursor after the UI. c^jrjsjrtj_xj dz c_j jrPjrjjnOjjjn&jjjjjjjjyyy)NrR)is_done)rrrvrrrr}rrsreraserenderrnupdate_parents_relationsr~_update_invalidate_events)render_as_donercsrdrun_in_contextz+Application._redraw..run_in_contexts(A(A++-1YY[D*##q(#""'')!++ ++- ,,T4;;,WMM((t{{; 446!!&&(..0-)BrfNr)rcopyrun)rcrrs`` rdrzApplication._redraws5 1B << # LL    # #N 3 $rfcj8jdk7r(dfd }j|jyyy)zi Start a while/true loop in the background for automatic invalidation of the UI. NrcZK t|d{j$7wr`)r r)rxrcs rd auto_refreshz:Application._start_auto_refresh_task..auto_refresh(s+ 0111OO%1s +)+)rxrrr)rxr)rcrs` rd_start_auto_refresh_taskz$Application._start_auto_refresh_task!sG  ,1F1F!1K &  ' ' T5J5J(K L2L ,rfcjD]}|jz}dfd }t|_jD]}|jz }y)zg Make sure to attach 'invalidate' handlers to all invalidate events in the UI. c3KjjD]}|jEd{y7wr`)rnfind_all_controlsget_invalidate_events)crcs rd gather_eventsz.gather_events;s8[[224 522444 54s 1><>N)rzIterable[Event[object]])r_invalidate_handlerlist)rcevrs` rdrz%Application._update_invalidate_events/se)) +B $** *B +  5#'}"7)) +B $** *B +rfc$|jy)a Handler for invalidate events coming from UIControls. (This handles the difference in signature between event handler and `self.invalidate`. It also needs to be a method -not a nested function-, so that we can remove it again .) N)r)rcsenders rdrzApplication._invalidate_handlerDs rfc||jjd|j|jy)z When the window size changes, we erase the current output and request again the cursor position. When the CPR answer arrives, the output is drawn again. F)leave_alternate_screenN)rr!_request_absolute_cursor_positionrrbs rd _on_resizezApplication._on_resizeNs. 59 ..0 rfcd|r||jD] }| |jdd=y)a Called during `run`. `self.future` should be set to the new future at the point where this is called in order to avoid data races. `pre_run` can be used to set a `threading.Event` to synchronize with UI termination code, running in another thread that would call `Application.exit`. (See the progress bar code for an example.) N)r)rcpre_runrs rd_pre_runzApplication._pre_runZs6  I'' A C   " "1 %rfcKjrJdtrtjdk(rdd fd }tdfd }tdfd }tdfd }tdfd } tdfd } t dfd } t 5} | j |d_| j |} | j || | j | | | j | | | j t| j j| j | | } ||d {jd {cd d d S7%7#jd {7wxYw#1swYnxYwJd w)aY Run the prompt_toolkit :class:`~prompt_toolkit.application.Application` until :meth:`~prompt_toolkit.application.Application.exit` has been called. Return the value that was passed to :meth:`~prompt_toolkit.application.Application.exit`. This is the main entry point for a prompt_toolkit :class:`~prompt_toolkit.application.Application` and usually the only place where the event loop is actually running. :param pre_run: Optional callable, which is called right after the "reset" of the application. :param set_exception_handler: When set, in case of an exception, go out of the alternate screen and hide the application, display the exception, and wait for the user to press ENTER. :param handle_sigint: Handle SIGINT signal if possible. This will call the `` key binding when a SIGINT is received. (This only works in the main thread.) :param slow_callback_duration: Display warnings if code scheduled in the asyncio event loop takes more time than this. The asyncio default of `0.1` is sometimes not sufficient on a slow system, because exceptionally, the drawing of the app, which happens in the event loop, can take a bit longer from time to time. zApplication is already running.win32Fc   Ktj _d j j  j j t j j jd fd d fd }d fd d fd  jj5 jj|5t j5 j j j! j# j% d{} jd j&jd _ j*D]}| j,z}g _ j.j0r" j&j3d{ j4}|r |d{t7 j j j9|cdddcdddcdddS77i7S# j&jd _ j*D]}| j,z}g _ j.j0r# j&j3d{7 j4}|r |d{7t7 j j j9wxYw# jd j&jd _ j*D]}| j,z}g _ j.j0r# j&j3d{7 j4}|r |d{7t7 j j j9w# j&jd _ j*D]}| j,z}g _ j.j0r# j&j3d{7 j4}|r |d{7t7 j j j9wxYwxYw#1swYnxYwdddn #1swYnxYwdddy#1swYyxYww) Ncjsjjsyjj }j j |j jjjr'jsjtyyrjjyr`)rrwaiting_for_cprr read_keysr feed_multiple process_keyscloseddone set_exceptionEOFErrorcancelr)keysauto_flush_inputf flush_taskrcs rdread_from_inputzBApplication.run_async.._run_async..read_from_inputs'' 0M0Mzz++-""006""//1::$$6681$""))+!%!._run_async..read_from_input_in_contexts ""?3rfcZKtjd{y7 wr`)r r) flush_inputrcsrdrzCApplication.run_async.._run_async..auto_flush_inputs'D,,--- .s +) +cjs|jj}jj |jj jj rjtyyyr`) rr flush_keysrrrrrr)rrrcs rdrz>Application.run_async.._run_async..flush_inputse||::002D&&44T:&&335zz((1) $rfT)rFr) contextvars copy_contextrrrrrr,rrraw_modeattachattach_winch_signal_handlerrrrrr_poll_output_sizerrrrrresponds_to_cprwait_for_cpr_responsesrr- empty_queue) rrresultrprevious_run_in_terminal_frrrrrrrcs ` @@@@@rd _run_asyncz)Application.run_async.._run_asyncs4!..0G"DL 59J JJL MM' "    , ,]4::-F G    + + - Q Q6 4  2$$&3  (9(9*)3 *4??;3 668 --/++D,B,B,DE&V#$WF!V D 9  ++- ,1(#'"9"9;B$":"::B;24/ ;;66"&--"F"F"HHH6:5P5P25"<<<( D4F4F4R4R4TUg3 3 3 3 %8I =1 ++- ,1(#'"9"9;B$":"::B;24/ ;;66"&--"F"F"HHH6:5P5P25"<<<( D4F4F4R4R4TUC!V D 9  ++- ,1(#'"9"9;B$":"::B;24/ ;;66"&--"F"F"HHH6:5P5P25"<<<( D4F4F4R4R4TU7 ++- ,1(#'"9"9;B$":"::B;24/ ;;66"&--"F"F"HHH6:5P5P25"<<<( D4F4F4R4R4TUc3 3 3 3 3 3 3 3 sB?TS5$S :AS  LI LI(A;S #I $S ;I <3S / S 8 S5 T L S S A:Tc3Kt}|_tj_ |d_d_y#d_d_wxYwwr`)rr threadingcurrent_threadr)rrcs rdset_loopz'Application.run_async..set_loopsR#%DDI ) 8 8 :D  )   $(!! $(!s+AAAAAc3LKd_ dd_y#d_wxYww)NTFrrbsrdset_is_runningz-Application.run_async..set_is_runnings'#D  )#( 5 s$$ !$c36Kr]t5jtjfd dj tj dddydy#j tjwxYw#1swYyxYww)NcNjjjSr`)r%r send_sigint)_rrcs rdrezBApplication.run_async..set_handle_sigint../s!4#<#< ..::$rf)_restore_sigint_from_ctypesadd_signal_handlersignalSIGINTremove_signal_handler)r handle_sigintrcs`rdset_handle_sigintz0Application.run_async..set_handle_sigint's02 B++  B226==A B B226==A B Bs2 B%B A)B B)!B  B  BBc3KrB|j}|jj d|j|ydy#|j|wxYwwr`)get_exception_handlerset_exception_handler_handle_exception)rprevious_exc_handlerrcr+s rdset_exception_handler_ctxz8Application.run_async..set_exception_handler_ctx:s\$'+'A'A'C$**4+A+ABE../CD../CDs.A#A A# A  A#c3dK|j}|_ d||_y#||_wxYwwr`)slow_callback_duration)roriginal_slow_callback_durationr0s rdset_callback_durationz4Application.run_async..set_callback_durationGs:/3.I.I +*@D ' N/N+.M+s0$0 -0c3lK|j}|_ |d_y#d_wxYwwr`) create_futurer)rrrcs rdr4z,Application.run_async..create_futureRs8""$ADK # # d s4(4 14N unreachable)rzasyncio.Future[_AppResult]rrX)rzIterator[AbstractEventLoop])rIterator[None])rrrr6)rrrz$Iterator[asyncio.Future[_AppResult]]) rrQsysplatformr r enter_contextrrT_enable_breakpointhook$cancel_and_wait_for_background_tasks)rcrr+r'r0rrrr(r.r2r4stackrrs````` rd run_asynczApplication.run_asyncls>##F%FF#3<<7#: "M} ~  )  )  )  )    $      N  N  ## # 1 #  #[ BE    0 1!&D &&xz2D    1$ 7 8    9$ ? @    5d ; <    .    ; ; = >##M$$78A B']* ??AAA7 B B*+ Bd??AAA7 B BB $m#usgB$G+C G5 F*F&F*GF(G G&F*(G*G>G ?GGG Gc> |rId d  fd }tj|}|j|j   Sj |}dd} Mt } | j | | j | j| j S| r& tj} | j |Stj|S#t$rtj|cYSwxYw)a A blocking 'run' call that waits until the UI is finished. This will run the application in a fresh asyncio event loop. :param pre_run: Optional callable, which is called right after the "reset" of the application. :param set_exception_handler: When set, in case of an exception, go out of the alternate screen and hide the application, display the exception, and wait for the user to press ENTER. :param in_thread: When true, run the application in a background thread, and block the current thread until the application terminates. This is useful if we need to be sure the application won't use the current event loop (asyncio does not support nested event loops). A new event loop will be created in this background thread, and that loop will also be closed when the background thread terminates. When this is used, it's especially important to make sure that all asyncio background tasks are managed through `get_appp().create_background_task()`, so that unfinished tasks are properly cancelled before the event loop is closed. This is used for instance in ptpython. :param handle_sigint: Handle SIGINT signal. Call the key binding for `Keys.SIGINT`. (This only works in the main thread.) Ncb jdy#t$r }|Yd}~yd}~wwxYw)NF)rr+r' inputhook)r BaseException)e exceptionr@rrrcr+s rd run_in_threadz&Application.run..run_in_threads> "!XX '.C&+"+ &F%" !I"s .).)target)rr+r'c tjdjdkxr+dtjdjj vS#t $rYywxYw)NIPython)rrz$IPython/terminal/interactiveshell.pyF)r7modules version_info _getframef_code co_filenamerArrfrd_called_from_ipythonz-Application.run.._called_from_ipythons\ KK *77.H;>}}Q'..::; !  sA A AArrbool) rThreadstartjoinr=r#run_until_completeshutdown_asyncgenscloseasyncioget_event_loop RuntimeErrorr) rcrr+r' in_threadr@rDthreadcororPrrCrs ``` ` @@rdrzApplication.runs@ .2I " "%%];F LLN KKM$M~~"7'     0 :D,,T2F  # #D$;$;$= > JJLM ! # 5--/ ..t44;;t$ $  ){{4(( )sC;;DDct}djt|dfd }t|y)zr Handler for event loop exceptions. This will print the exception, using run_in_terminal. rc.Kt4d{tdttdjjdt dd{dddd{y7g77 #1d{7swYyxYww)Nz# Unhandled exception in event loop:z Exception {}rCPress ENTER to continue...)rUprintformatget_do_wait_for_enter)r formatted_tbsrdin_termz.Application._handle_exception..in_terms"} G G<=l#n++GKK ,DEF()EFFF G G GG G G G GsWBA:BAB$A<%B) B4A>5B<B>BBB BBNr)r"rUr r)rcrrtbrgrfs ` @rdr,zApplication._handle_exceptions3( 0wwy}-  G gi rfc#Ktjtjk(r4|jt_ dtjt_ydy#tjt_wxYww)z Install our custom breakpointhook for the duration of this context manager. (We will only install the hook if no other custom hook was set.) N)r7breakpointhook__breakpointhook___breakpointhookrbs rdr:z"Application._enable_breakpointhooksT   !7!7 7!%!5!5C  <%(%;%;" &)%;%;"s7A;AA;A88A;cP ddl}ddlm}t|tt gt f}t d fd t d fd G fdd|j}tjj}|tjj|y) am Breakpointhook which uses PDB, but ensures that the application is hidden and input echoing is restored during each debugger dispatch. This can be called from any thread. In any case, the application's event loop will be blocked while the PDB input is displayed. The event will continue after leaving the debugger. rN) FrameTypec3Kjjjj5jj 5dddddddy#1swYxYw#1swYyxYww)z`Stop application if `__breakpointhook__` is called from within the App's event loop.N)rrrdetach cooked_mode)appsrdhide_app_from_eventloop_threadzCApplication._breakpointhook..hide_app_from_eventloop_thread'sl LL   !!# YY**,    s45BA5A)A5 B)A2 .A55A>:Bc3Ktjtjdfd }j|j dj y#j wxYww)zmStop application if `__breakpointhook__` is called from a thread other than the App's event loop.c>Kjjjj5jj 5j j ddddddy#1swYxYw#1swYyxYwwr`)rrrrprqrwait)rrrreadysrdin_loopzPApplication._breakpointhook..hide_app_from_other_thread..in_loop?s} ""$YY%%'$..0$  $$$$$$$s45BB!B4B< BB BBBNr)rrPrrvr)rxrrwrrrcs @@rdhide_app_from_other_threadz?Application._breakpointhook..hide_app_from_other_thread8s[OO%E??$D $*  ' ' 2 JJL   sABA2!B2BBc8eZdZ dfd ZxZS).Application._breakpointhook..CustomPdbc8jt| |||Sjtjk(r"5t| |||cdddS5t| |||cdddS#1swY+xYw#1swYyxYwr`)rsupertrace_dispatchrr)rcframeeventarg __class__rrrsrys rdr~z=Application._breakpointhook..CustomPdb.trace_dispatch\s##+ 71%DD##y'?'?'AA79I$w5eUCHII01E 71%DEEIIEEsB)BB B)rrnrstrrrr TraceDispatch)__name__ __module__ __qualname__r~ __classcell__)rrrrsrys@rd CustomPdbr{[s3 E& E/2 E9< E E Erfr)stdoutrGenerator[None, None, None]) pdbtypesrnrrrr Pdbr7rMf_back __stdout__ set_trace) rcakwrrnrrrrrrsrys ` @@@rdrlzApplication._breakpointhooks# )S#!6!;<        D E E E &&(2259rfc|jxs t}|j|}|jj ||j |j |S)a Start a background task (coroutine) for the running application. When the `Application` terminates, unfinished background tasks will be cancelled. Given that we still support Python versions before 3.11, we can't use task groups (and exception groups), because of that, these background tasks are not allowed to raise exceptions. If they do, we'll call the default exception handler from the event loop. If at some point, we have Python 3.11 as the minimum supported Python version, then we can use a `TaskGroup` (with the lifetime of `Application.run_async()`, and run run the background tasks in there. This is not threadsafe. )rr create_taskraddadd_done_callback_on_background_task_done)rc coroutinertasks rdrz"Application.create_background_tasklsS&yy.,.#'#3#3I#> ""4( t<<= rfc|jj||jry|j}|"t j d|d||dyy)z Called when a background task completes. Remove it from `_background_tasks`, and handle exceptions if any. Nz+prompt_toolkit.Application background task z raised an unexpected exception.)messagerCr)rdiscard cancelledrCrcall_exception_handler)rcrexcs rdrz$Application._on_background_task_donesi &&t, >>  nn ?   5 5!LTHU6 6!$   rfcK|jD]}|jt|jdkDr9tj|jdtj d{yy7w)a# Cancel all background tasks, and wait for the cancellation to complete. If any of the background tasks raised an exception, this will also propagate the exception. (If we had nurseries like Trio, this would be the `__aexit__` of a nursery.) rN)timeout return_when)rrlenrYrv ALL_COMPLETED)rcrs rdr;z0Application.cancel_and_wait_for_background_taskssn** D KKM $ t%% & *,,&&'BWBW   + sA-A8/A60A8cKd}|j}|y tj|d{|jj }|||k7r|j |}Q78w)z Coroutine for polling the terminal dimensions. Useful for situations where `attach_winch_signal_handler` is not sufficient: - If we are not running in the main thread. - On Windows. N)ryrYr rget_sizer)rcsizeintervalnew_sizes rdrzApplication._poll_output_sizesl!66   --) ) ){{++-HH$4!D  )s+A(A&9A(cVjjsydfd }t|y)zT Called when we don't receive the cursor position response in time. Ncpjjdjjy)NzHWARNING: your terminal doesn't support cursor position requests (CPR). )rwriteflushrbsrdrUz;Application.cpr_not_supported_callback..in_terminals* KK  \  KK   rfr)rrrV)rcrUs` rdrhz&Application.cpr_not_supported_callbacks${{**   $rfcy)zExit without arguments.Nrrbs rdexitzApplication.exitrfrrcy)zExit with `_AppResult`.Nr)rcrris rdrzApplication.exitrrfcy)zExit with exception.Nr)rcrCris rdrzApplication.exitrrfc$||J|j td|jjr td||_||jj |y|jj t t|y)a Exit application. .. note:: If `Application.exit` is called before `Application.run()` is called, then the `Application` won't exit (because the `Application.future` doesn't correspond to the current run). Use a `pre_run` hook and an event to synchronize the closing if there's a chance this can happen. :param result: Set this result for the application. :param exception: Set this exception as the result for an application. For a prompt, this is often `EOFError` or `KeyboardInterrupt`. :param style: Apply this style on the whole content when quitting, often this is 'class:exiting' for a prompt. (Used when `erase_when_done` is not set.) Nz6Application is not running. Application.exit() failed.z4Return value already set. Application.exit() failed.)r Exceptionrrr set_resultrrX)rcrrCris rdrzApplication.exits~0~!222 ;; TU U ;;   RS S  KK % %i 0 KK " "4 F#; .run_command>s) 34'XiPrfr) rUrfilenoAttributeErrorr7rrrr$re)rcrwait_for_enterr wait_textrrrs`` ` @@rdrun_system_commandzApplication.run_system_commands$= 4 4 .::,,. 0 KK..0    /{; ; ;(333- 4 4 4 " .99++- ." 0JJ--/  0 <4- 4 4 4 4sD BD C6BCC6)C0*C6>C2?C6 D C4D 'C=C6?CC6'C-*C6,C--C62C64D 6D<C? =DD c6tdfd }t|yy)z (Not thread safe -- to be called from inside the key bindings.) Suspend process. :param suspend_group: When true, suspend the whole process group. (This is the default, and probably what you want.) Ncttt}rtjd|ytjtj |y)Nr)rint_SIGTSTPoskillgetpid)r$ suspend_groups rdrz.Application.suspend_to_background..runUs6c8, !GGAv&GGBIIK0rfr)rrV)rcrrs ` rdsuspend_to_backgroundz!Application.suspend_to_backgroundIs   1 C  rfc|t|j||xs |j|j|jy)a\ Print a list of (style_str, text) tuples to the output. (When the UI is running, this method has to be called through `run_in_terminal`, otherwise it will destroy the UI.) :param text: List of ``(style_str, text)`` tuples. :param style: Style class to use. Defaults to the active style in the CLI. )rformatted_textrirrjN)rFrrrrj)rctextris rdrzApplication.print_textcs6 ;;-4--((!%!:!:  rfc|jS)z8`True` when the application is currently active/running.rrbs rd is_runningzApplication.is_runningvsrfcP|jr|jjSyr)rrrbs rdrzApplication.is_done{s ;;;;##% %rfcv|jj}|r td|jDSgS)z| Return a list of used style strings. This is helpful for debugging, and for writing a new `Style`. c3fK|])}tjdd|j+yw)z\s+ N)resubstrip).0 style_strs rd z5Application.get_used_style_strings..s.vsI.446s/1)r_attrs_for_stylesortedr)rcattrs_for_styles rdget_used_style_stringsz"Application.get_used_style_stringss@ --88 !0!5!5!7   rf)4rnz Layout | NoneriBaseStyle | Nonerr(rjzStyleTransformation | NonerkzKeyBindingsBase | NonerozClipboard | NonerarRrz3ColorDepth | Callable[[], ColorDepth | None] | Nonergr(ruzNone | FilterOrBoolrqr(rrr rsrRrtr(rvfloat | int | Nonerwrrx float | Noneryrrzrr|*ApplicationEventHandler[_AppResult] | Noner{rr}rr~rrz Input | Nonerz Output | Nonerr)rr'rrH)rrC)rr)rrGrrQ)F)rrRrr)robjectrrr`)rCallable[[], None] | Nonerr)NTTr]) rrr+rRr'rRr0rrrX)NTTFN) rrr+rRr'rRr\rRr@zInputHook | NonerrX)rrrzdict[str, Any]rrr)rrrrrr)rzCoroutine[Any, Any, None]rasyncio.Task[None])rrrr)rrXrirrr)rCz#BaseException | type[BaseException]rirrr)NNr)rz_AppResult | NonerCz*BaseException | type[BaseException] | Nonerirrr)Trra) rrrrRrr*rrrr)T)rrRrr)rr*rirrr)rz list[str]))rrr__doc__r EMACSrrpropertyrrrrrrrrrrrrr=rr,r r:rlrrr;rrhrrrrrrrrrrrfrdrWrWis5Nd!%"&7;;?/3&*!MQ&+#($/$5$5 %49267;)-7:'+?CDHDHCG" $9WW W)5 W 9 W - W$WWJW$W*W!W"WW &2!W"0#W$#5%W&''W()5)W*%+W,=-W.B/W0B1W2A3W67W89W: ;Wr ..     ! !@3j!!*4X M+* &(.2&*"(+ V$*V$ $V$ V$ !& V$  V$t.2&*"&* f%*f% $f% f%  f% $ f% f%P!%!0>! !4 S:j2 4*@, %""79""NP?HK %)@D %=!%=>%= %=  %=N= $025 (4(4(4. (4  (4  (4T!6AE $ -=  &   rfcreZdZdZd dZed dZed dZ d dZeddZ ddZ ddZ y )rz The `KeyBindings` of key bindings for a `Application`. This merges the global key bindings with the one of the current user control. c0||_t|_yr`)rrr_cache)rcrrs rdrz_CombinedRegistry.__init__s M rfctzZNot needed - this object is not going to be wrapped in another KeyBindings object.NotImplementedErrorrbs rd_versionz_CombinedRegistry._version "!rfctrrrbs rdbindingsz_CombinedRegistry.bindingsrrfcg}t}|} |j||j}||j||j rn+|j j j|}|n|}pt|D]4}||vs|j}||jt|6|j jr%|j|j j|jt|j j|j j|j|j j|ddd}t|S)z Create a `KeyBindings` object that merges the `KeyBindings` from the `UIControl` with all the parent controls and the global key bindings. N)rrget_key_bindingsappendis_modalrrrn get_parentrBr3rkr2rmrurlr7) rcrother_controlsrkcollected_containers containerkbparentrs rd_create_key_bindingsz&_CombinedRegistry._create_key_bindingssX "u .  $ $Y /++-B~##B'!!#XX__// :F~"  i CA,,'')> ''(=b(AB  C 88    5 5 6  "2288  DHH667$DbD) !,//rfcjjjtjjj t f}j j|fdS)Nc(jSr`)r)rrrcsrdrez1_CombinedRegistry._key_bindings..s22>>Rrf)rrrnrrr frozensetrrd)rckeyrrs` @@rd _key_bindingsz_CombinedRegistry._key_bindingss[77dhhoo??ABi77{{ R  rfc8|jj|Sr`)r get_bindings_for_keysrcrs rdrz'_CombinedRegistry.get_bindings_for_keyss!!77==rfc8|jj|Sr`)r get_bindings_starting_with_keysrs rdrz1_CombinedRegistry.get_bindings_starting_with_keyss!!AA$GGrfN)rrrYrr)rr)r list[Binding])rr=rzlist[UIControl]rr5)rr5)rr6rr) rrrrrrrrrr rrrrfrdrrsq  "" "" 40$406E40 40l  >Hrfrc$Kddlm}t}|jddd}|jtj dd}|||} |j jd{y7#t$rYywxYww) z Create a sub application to wait for the enter key press. This has two advantages over using 'input'/'raw_input': - This will share the same input/output I/O. - This doesn't block the event loop. r) PromptSessionenterc8|jjyr`)rrrrs rd_okz_do_wait_for_enter.._oks rfcy)zDisallow typing.Nrrs rd_ignorez#_do_wait_for_enter.._ignores rf)rrkN)rErr) prompt_toolkit.shortcutsrr4rr;rrrr=KeyboardInterrupt)rrrkrrrs rdreres7=Lgdhh   $1 $G kk##%%%    s<ABB9A?:B>B?B B  B B  Bc#Kttdd}| tsdyt}t|dij |} |j ||d|j ||)|j ||jg|jyy#|j ||)|j ||jg|jwwxYww)a  Attach the given callback as a WINCH signal handler within the context manager. Restore the original signal handler when done. The `Application.run` method will register SIGWINCH, so that it will properly repaint when the terminal window resizes. However, using `run_in_terminal`, we can temporarily send an application to the background, and run an other app in between, which will then overwrite the SIGWINCH. This is why it's important to restore the handler when the app terminates. rZN_signal_handlers) getattrr$rQrrdr#r& _callback_args)handlersigwinchrprevious_winch_handlers rdrrs*vz40H~/   D$T+=rBFFxP  '2  ""8, ! - #D # #&00 (--  . ""8, ! - #D # #&00 (--  .sA C  B"=C >CC c#K ddlm}m}m}tj j dk7}|rGj_ f|j_ ||j_ ||f|j_ tjtj}|rjtj} d|$tjtj||r!jtjyy#t$rd}YwxYw#|$tjtj||r!jtjwwxYww)Nr)c_intc_void_p pythonapigraalpyF)ctypesr'r(r)r7implementationr ImportError PyOS_getsigrestypeargtypes PyOS_setsigr$ getsignalr%)r'r(r)have_ctypes_signalsigint sigint_oss rdr"r";s( B55 !//44 A(0 %*/ &)1 %  * &   fmm ,F))&--8 <   MM&-- 0   ! !&-- ; 7 #"#2   MM&-- 0   ! !&-- ; sBE& DB*E&9D=A E& DE&DE&A E##E&)rr*rr)r#zCallable[[], None]rrr) __future__rrYr rrr$r7rrrrrrrr contextlibr r subprocessr tracebackr typingrrrrrrrrrrrprompt_toolkit.bufferrprompt_toolkit.cacherprompt_toolkit.clipboardrrprompt_toolkit.cursor_shapesrrprompt_toolkit.data_structuresrprompt_toolkit.enumsr prompt_toolkit.eventloopr!r"r#r$prompt_toolkit.eventloop.utilsr%prompt_toolkit.filtersr&r'r(r)prompt_toolkit.formatted_textr*prompt_toolkit.input.baser+prompt_toolkit.input.typeaheadr,r-3prompt_toolkit.key_binding.bindings.page_navigationr.#prompt_toolkit.key_binding.defaultsr/&prompt_toolkit.key_binding.emacs_stater0'prompt_toolkit.key_binding.key_bindingsr1r2r3r4r5r6r7(prompt_toolkit.key_binding.key_processorr8r9#prompt_toolkit.key_binding.vi_stater:prompt_toolkit.keysr; prompt_toolkit.layout.containersr<r=prompt_toolkit.layout.controlsr>r?prompt_toolkit.layout.dummyr@prompt_toolkit.layout.layoutrArBprompt_toolkit.outputrCrDprompt_toolkit.rendererrErFprompt_toolkit.searchrGprompt_toolkit.stylesrHrIrJrKrLrMrNrOprompt_toolkit.utilsrPrQcurrentrSrTrVrU__all__rrXApplicationEventHandlerr  _SIGWINCHrrWrrerr"rrfrdr[s"  1    ),AU/, @MM:+IB=Q7$>C;54B-   7-9   \ " "$=#>#DE FJ - 69d +e'*%eP)]H]H@ :) ) ))X"<"