)L i6dZddlmZddlmZmZmZddlmZddl m Z m Z m Z m Z mZddlmZmZmZgdZeeeee fZGd d ZGd d eZddd Zy)z Wrapper for the layout. ) annotations) GeneratorIterableUnion)Buffer) AnyContainerConditionalContainer ContainerWindow to_container) BufferControlSearchBufferControl UIControl)LayoutInvalidLayoutErrorwalkcpeZdZdZ d ddZddZd dZd!dZd"dZd#dZ e d$d Z e jd%d Z e d&d Z e jd'd Z e d(d Ze d)dZd*dZd+dZe d,dZd-dZe d(dZe d$dZd.dZd.dZd.dZd/dZd/dZd.dZd.dZd0dZy)1raL The layout for a prompt_toolkit :class:`~prompt_toolkit.application.Application`. This also keeps track of which user control is focused. :param container: The "root" container for the layout. :param focused_element: element to be focused initially. (Can be anything the `focus` function accepts.) Nc2t||_g|_i|_i|_|; |jj t |jg|_ y|j|g|_ y#t$r}td|d}~wwxYw)Nz>Invalid layout. The layout does not contain any Window object.) r container_stack search_links_child_to_parentappendnextfind_all_windows StopIterationrfocusvisible_windows)selfrfocused_elementes b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/prompt_toolkit/layout/layout.py__init__zLayout.__init__(s &i0$& GI =?  "  ""4(=(=(?#@A.0 JJ '.0! (T s2A<< B BBc<d|jd|jdS)NzLayout(z, current_window=))rcurrent_windowr s r#__repr__zLayout.__repr__Js%**;Delements r# has_focuszLayout.has_focuss eS !""*&&++u4 4 eV $&&%/ / eY '''50 0 'E%(**e33 $E{$G$"5"55#$r*c4|jdjS)zI Get the :class:`.UIControl` to currently has the focus. )rr0r(s r#r<zLayout.current_controls {{2&&&r*cr|jD]}|j|k(s||_ytd)zC Set the :class:`.UIControl` to receive the focus. Nz(Control not found in the user interface.)rr0r'r:)r r?windows r#r<zLayout.current_controlsA ++- F~~(&,#  CDDr*c |jdS)z=Return the :class:`.Window` object that is currently focused.rH)rr(s r#r'zLayout.current_windows{{2r*c:|jj|y)z8Set the :class:`.Window` object to be currently focused.N)rr)r r>s r#r'zLayout.current_windows 5!r*c2|j|jvS)z#True if we are searching right now.)r<rr(s r# is_searchingzLayout.is_searchings##t'8'888r*cr|j}t|tr|jj |Sy)zY Return the :class:`.BufferControl` in which we are searching or `None`. N)r<r,rrget)r r?s r#search_target_buffer_controlz#Layout.search_target_buffer_controls4&& g2 3$$((1 1r*c#K|jD]2}t|ts|jj s/|4yw)zl Return all the :class:`.Window` objects which are focusable (in the 'modal' area). N)walk_through_modal_arear,r r0r;)r rBs r#get_focusable_windowszLayout.get_focusable_windowss> --/ A!V$)?)?)A s$A A A cj|j}|jDcgc] }||vs| c}Scc}w)zO Return a list of :class:`.Window` objects that are focusable. )rrT)r rrBs r#get_visible_focusable_windowsz$Layout.get_visible_focusable_windowss3 ..557Pa1;OPPPs 00cT|j}t|tr |jSy)zD The currently focused :class:`~.Buffer` or `None`. N)r<r,rr8r ui_controls r#rDzLayout.current_buffers( )) j- 0$$ $r*c|jD]i}t|tst|jts/|jj j |k(sS|jj cSy)zt Look in the layout for a buffer with the given name. Return `None` when nothing was found. N)rr,r r0rr8r9)r buffer_namerBs r#get_buffer_by_namezLayout.get_buffer_by_name s]  ,A!V$AII})M99##((K799+++ ,r*c:|j}t|tS)z Return `True` if the currently focused control is a :class:`.BufferControl`. (For instance, used to determine whether the default key bindings should be active or not.) )r<r,rrXs r#buffer_has_focuszLayout.buffer_has_focuss)) *m44r*c |jdjS#t$r|jdjcYSwxYw)zJ Get the :class:`.UIControl` to previously had the focus. rH)rr0 IndexErrorr(s r#previous_controlzLayout.previous_control!s>  +;;r?** * +;;r?** * +s"AAc^t|jdkDr|jdd|_yy)z= Give the focus to the last focused control. rNrH)lenrr(s r# focus_lastzLayout.focus_last+s, t{{ a ++cr*DK r*c|j}t|dkDrB |j|j}|dzt|z}|j ||yy#t$rd}Y#wxYw)z: Focus the next visible/focusable Window. rrNrVrdindexr'r:rr r@rhs r# focus_nextzLayout.focus_next2v446 w Focus the previous visible/focusable Window. rrNrgris r#focus_previouszLayout.focus_previousBrkrlc#JKt|jEd{y7w)zX Walk through all the layout nodes (and their children) and yield them. N)rrr(s r#rz Layout.walkRs'''s #!#c#K|j}|js<||jvr.|j|}|js||jvr.t|Ed{y7w)zn Walk through all the containers which are in the current 'modal' part of the layout. N)r'is_modalrr)r roots r#rSzLayout.walk_through_modal_areaXs`----/dd.C.C&C((.D--/dd.C.C&C:sAA1A1)A/*A1cLidfd |j|_y)z= Update child->parent relationships mapping. cJ|jD]}||<|yr/) get_children)r"rAparentsrs r#rz-Layout.update_parents_relations..walkks)^^%  Q r*N)r"r returnNone)rr)r rvrs @@r#update_parents_relationszLayout.update_parents_relationses%  T^^ 'r*cl|jj|jjyr/)rclearrresetr(s r#r|z Layout.resetts& ! r*c@ |j|S#t$rYywxYw)zo Return the parent container for the given container, or ``None``, if it wasn't found. N)rKeyErrorr1s r# get_parentzLayout.get_parent}s*  ((3 3  s  r/)rr r!zFocusableElement | Nonerwrx)rwr7)rwzGenerator[Window, None, None])rwzIterable[UIControl])r>FocusableElementrwrx)r>rrwbool)rwr)r?rrwrx)rwr )r>r rwrx)rwr)rwzBufferControl | None)rwzIterable[Window])rwz list[Window])rw Buffer | None)r[r7rwr)rwrx)rwIterable[Container])rr rwzContainer | None)__name__ __module__ __qualname____doc__r$r)rr2rrFpropertyr<setterr'rNrQrTrVrDr\r^rbrerjrnrrSryr|rr*r#rrsD48 0 01 0  0DU$L\2''  E E""99  Q 55+++' ' (  (r*rc eZdZy)rN)rrrrr*r#rrsr*rc#K|r!t|tr|jsy||jD]}t ||Ed{y7w)z: Walk through layout, starting at this container. Nr5)r,r filterrur)rr6rAs r#rrsU  y"6 7  " O  # # %4{33343sA A AAN)F)rr r6rrwr)r __future__rtypingrrrprompt_toolkit.bufferr containersr r r r r controlsrrr__all__r7rr Exceptionrrrr*r#rsf#--(DC  fi=>hhV   4r*