+
    i3  c            
      s  a 0 t $ ^ RIHt ^ RIHt ^ RIHtHt ^RIH	t	H
t
 ^RIHt  ]! ]! R4       U u. uF  p ]! T 4      R8w  g   K  RT ,          R	3NK  	  up ]! ]]! ^ ^4      4       U u. uF  q R8w  g   K  T R
3NK  	  up ,           ]! R4       U u. uF;  p ]! T 4      P+                  4       '       g   K!  ]! T 4      R8w  g   K0  RT ,          R
3NK=  	  up ,           . R6O,           4      tR]R&   RtRtRt ! R R]	P6                  4      t ! R R]	P6                  4      t ! R R]	P6                  4      t ! R R]	P6                  4      t ! R R]	P6                  4      t  ! R R]	P6                  4      t! ! R R]	P6                  4      t" ! R R]	PF                  4      t$ ! R  R!]	P6                  4      t% ! R" R#]	P6                  4      t& ! R$ R%]	P6                  4      t' ! R& R']	P6                  4      t( ! R( R)]	P6                  4      t) ! R* R+]	P6                  4      t* ! R, R-]	P6                  4      t+ ! R. R/]	P6                  4      t, ! R0 R1]	P6                  4      t-] ! R2 R3]4      4       t.R4t/R5# u up i u up i u up i )7    )annotations)contextmanager)	dataclassfield)commandsinput)Readeri   Z\z\%03ozisearch-endzisearch-add-character'tuple[tuple[KeySpec, CommandName], ...]isearch_keymap rZfc                  s"    ] tR t^8tR R ltRtR# )next_historyc                   V ^8  d   QhRR/#    returnNone Zformat   "2/usr/lib64/python3.14/_pyrepl/historical_reader.py__annotate__Znext_history.__annotate__9        & &D &    c                	s    V P                   pVP                  \        VP                  4      8X  d   VP	                  R 4       R# VP                  VP                  ^,           4       R# )zend of history listN)readerhistoryilenhistoryerrorselect_itemselfr      & r   doZnext_history.do9   sC    KK::QYY'GG)*	ajj1n%r   r   N__name__
__module____qualname____firstlineno__r"   __static_attributes__r   r   r   r   r   8       & &r   r   c                  s"    ] tR t^AtR R ltRtR# )previous_historyc               r   r   r   r   r   r   r   Zprevious_history.__annotate__B   r   r   c                	s    V P                   pVP                  ^ 8X  d   VP                  R4       R# VP                  VP                  ^,
          4       R# )r    zstart of history listN)r   r   r   r   r   r!   r   r"   Zprevious_history.doB   s:    KK::?GG+,	ajj1n%r   r   Nr#   r   r   r   r*   r*   A   r)   r   r*   c                  s"    ] tR t^JtR R ltRtR# )history_search_backwardc               r   r   r   r   r   r   r   Z$history_search_backward.__annotate__K   s     & &D &r   c                	B    V P                   pVP                  R R7       R# )FforwardsNr   search_nextr   r!   r   r"   Zhistory_search_backward.doK   s    KK	u%r   r   Nr#   r   r   r   r+   r+   J   s    & &r   r+   c                  s"    ] tR t^PtR R ltRtR# )history_search_forwardc               r   r   r   r   r   r   r   Z#history_search_forward.__annotate__Q   s     % %D %r   c                	r,   )Tr-   Nr/   r   r!   r   r"   Zhistory_search_forward.doQ   s    KK	t$r   r   Nr#   r   r   r   r1   r1   P   s    % %r   r1   c                  s"    ] tR t^VtR R ltRtR# )restore_historyc               r   r   r   r   r   r   r   Zrestore_history.__annotate__W   s      D r   c                	sf   V P                   pVP                  \        VP                  4      8w  d   VP	                  4       VP                  VP                  ,          8w  dO   \        VP                  VP                  ,          4      Vn        \        VP                  4      Vn        R Vn        R# R# R# TN)	r   r   r   r   get_unicodelistbufferposdirtyr   r!   r   r"   Zrestore_history.doW   ss    KK::QYY'}}!))AJJ"77		!** 56AHH 8 (r   r   Nr#   r   r   r   r2   r2   V   s     r   r2   c                  s"    ] tR t^`tR R ltRtR# )first_historyc               r   r   r   r   r   r   r   Zfirst_history.__annotate__a   s     # #D #r   c                	s<    V P                   P                  ^ 4       R# )r    N)r   r   r       &r   r"   Zfirst_history.doa   s    "r   r   Nr#   r   r   r   r9   r9   `   s    # #r   r9   c                  s"    ] tR t^etR R ltRtR# )last_historyc               r   r   r   r   r   r   r   Zlast_history.__annotate__f   s     : :D :r   c                	sv    V P                   P                  \        V P                   P                  4      4       R # N)r   r   r   r   r:   r;   r   r"   Zlast_history.dof   s#    DKK$7$7 89r   r   Nr#   r   r   r   r<   r<   e   s    : :r   r<   c                  s"    ] tR t^jtR R ltRtR# )operate_and_get_nextc               r   r   r   r   r   r   r   Z!operate_and_get_next.__annotate__k   s     < <D <r   c                	s^    V P                   P                  ^,           V P                   n        R# )   N)r   r   r   r:   r;   r   r"   Zoperate_and_get_next.dok   s    #';;#7#7!#; r   r   Nr#   r   r   r   r>   r>   j   s    < <r   r>   c                  s"    ] tR t^otR R ltRtR# )yank_argc               r   r   r   r   r   r   r   Zyank_arg.__annotate__p   s      D r   c                	s2   V P                   pVP                  V P                  J d   V;P                  ^,          un        M^ Vn        VP                  VP                  8  d   VP                  R4       R# VP                  R4      pVP                  VP                  VP                  ,
          ^,
          4      P                  4       pV\        V4      ) 8  g   V\        V4      8  d   VP                  R4       R# W2,          pVP                  pVP                  ^ 8  d   \        VP                  4      pM^ p\        V4      WQP                  V,
          VP                  % WAn        V;P                  \        V4      V,
          ,          un        RVn        R# )r?   zbeginning of history listNzno such argT)r   Zlast_command	__class__
yank_arg_ir   r   Zget_argget_itemZsplitr   r6   yank_arg_yankedr5   r7   r8   )r    r   ZaZwordsZwbZos   &      r   r"   Zyank_arg.dop   s   KK>>T^^+LLALAL::$GG/0IIbM

1::4q89??AE
{?a3u:oGGM"HHH<<!A%%&AA#Aw%%!)aee	Q!r   r   Nr#   r   r   r   r@   r@   o   s     r   r@   c                  s"    ] tR t^tR R ltRtR# )forward_history_isearchc               r   r   r   r   r   r   r   Z$forward_history_isearch.__annotate__        , ,D ,r   c                	s    V P                   p\        Vn        VP                  VP                  3Vn        R Vn        RVn        VP                  VP                  4       R# )r
   TN)
r   ISEARCH_DIRECTION_FORWARDSisearch_directionr   r7   isearch_startisearch_termr8   push_input_transisearch_transr   r!   r   r"   Zforward_history_isearch.do   sG    KK8**aee+	1??+r   r   Nr#   r   r   r   rG   rG          , ,r   rG   c                  s"    ] tR t^tR R ltRtR# )reverse_history_isearchc               r   r   r   r   r   r   r   Z$reverse_history_isearch.__annotate__   rH   r   c                	s    V P                   p\        Vn        R Vn        RVn        VP                  VP                  4       VP                  VP                  3Vn	        R# )Tr
   N)
r   ISEARCH_DIRECTION_BACKWARDSrJ   r8   rL   rM   rN   r   r7   rK   r   r!   r   r"   Zreverse_history_isearch.do   sG    KK9	1??+**aee+r   r   Nr#   r   r   r   rP   rP      rO   r   rP   c                  s"    ] tR t^tR R ltRtR# )isearch_cancelc               r   r   r   r   r   r   r   Zisearch_cancel.__annotate__   s      D r   c                	s    V P                   p\        Vn        VP                  4        VP	                  VP
                  ^ ,          4       VP
                  ^,          Vn        RVn        R# )r    TN)r   ISEARCH_DIRECTION_NONErJ   pop_input_transr   rK   r7   r8   r   r!   r   r"   Zisearch_cancel.do   sK    KK4		aooa()"r   r   Nr#   r   r   r   rR   rR      s     r   rR   c                  s"    ] tR t^tR R ltRtR# )isearch_add_characterc               r   r   r   r   r   r   r   Z"isearch_add_character.__annotate__   s      D r   c                	sZ   V P                   pVP                  pV;P                  V P                  R,          ,          un        RVn        VP
                  \        VP                  4      ,           ^,
          pW#V^,            VP                  R,          .8w  d   VP                  4        R# R# )r?   TNrA   )r   r6   rL   Zeventr8   r7   r   isearch_next)r    r   rF   ps   &   r   r"   Zisearch_add_character.do   sx    KKHH	$**R.(EEC''!+Q<ANN2.//NN 0r   r   Nr#   r   r   r   rU   rU      s     r   rU   c                  s"    ] tR t^tR R ltRtR# )isearch_backspacec               r   r   r   r   r   r   r   Zisearch_backspace.__annotate__   s     ) )D )r   c                	s    V P                   p\        VP                  4      ^ 8  d   VP                  RR Vn        RVn        R# VP	                  R4       R# )r    NTznothing to ruboutrA   )r   r   rL   r8   r   r   r!   r   r"   Zisearch_backspace.do   sB    KKq~~"^^CR0ANAGGG'(r   r   Nr#   r   r   r   rX   rX      s    ) )r   rX   c                  s"    ] tR t^tR R ltRtR# )isearch_forwardsc               r   r   r   r   r   r   r   Zisearch_forwards.__annotate__         D r   c                	T    V P                   p\        Vn        VP                  4        R # r=   )r   rI   rJ   rV   r   r!   r   r"   Zisearch_forwards.do   s    KK8	r   r   Nr#   r   r   r   rY   rY           r   rY   c                  s"    ] tR t^tR R ltRtR# )isearch_backwardsc               r   r   r   r   r   r   r   Zisearch_backwards.__annotate__   rZ   r   c                	r[   r=   )r   rQ   rJ   rV   r   r!   r   r"   Zisearch_backwards.do   s    KK9	r   r   Nr#   r   r   r   r]   r]      r\   r   r]   c                  s"    ] tR t^tR R ltRtR# )isearch_endc               r   r   r   r   r   r   r   Zisearch_end.__annotate__   s      D r   c                	s    V P                   p\        Vn        VP                  P	                  4        VP                  4        R Vn        R# r3   )r   rS   rJ   ZconsoleZforgetinputrT   r8   r   r!   r   r"   Zisearch_end.do   s6    KK4				r   r   Nr#   r   r   r   r^   r^      s     r   r^   c                  s  a  ] tR t^t$ Rt]! ]R7      tR]R&   ^ t	R]R&   Rt
R]R	&   ]! ]R7      tR
]R&   RtR]R&   ]tR]R&   ]! RR7      tR]R&   ]! RR7      tR]R&   ^ tR]R&   RtR]R&   R V 3R lltR V 3R lltR R ltR R lt]R  V 3R! ll4       t]R" R# l4       tR$ V 3R% lltR& V 3R' lltR( R) ltR* R+ ltR, V 3R- lltR.t V ;t!# )/HistoricalReaderzOAdds history support (with incremental history searching) to the
Reader class.
)Zdefault_factoryz	list[str]r   intr   Nz
int | Noner   zdict[int, str]transient_historyr
   strrL   rJ   F)Zinitztuple[int, int]rK   zinput.KeymapTranslatorrN   rC   rE   c               r   r   r   r   r   r   r   HistoricalReader.__annotate__   s     
 
t 
r   c                	s  < \         SV `  4        \        \        \        \
        \        \        \        \        \        \        \        \        \        \        \        \         \"        \$        3 FC  pWP&                  VP(                  &   WP&                  VP(                  P+                  R R4      &   KE  	  V P,                  V P.                  3V n        \2        P4                  ! \6        \        \        R7      V n        R# )Z_Z-)Zinvalid_clsZcharacter_clsN)super__post_init__r   r*   r2   r9   r<   r@   rG   rP   r^   rU   rR   rX   rY   r]   r>   r+   r1   r   r$   Zreplacer   r7   rK   r   ZKeymapTranslatorr	   rN   )r    crB   s   & r   re   ZHistoricalReader.__post_init__   s    ##!! #"%
A( )*MM!**%:;MM!**,,S#67+
, "]]DHH4"33CX
r   c               r   )r   r   r   r   r   r   r   r   rc     s     
 
 G 
r   c                	s.   < \         SV `  4       R,           # )\C-n))rg   znext-history)z\C-pzprevious-history)z\C-ozoperate-and-get-next)\C-rzreverse-history-isearch)\C-szforward-history-isearch)z\M-rzrestore-history)z\M-.zyank-arg)z\<page down>history-search-forward)z\x1b[6~rj   )z
\<page up>history-search-backward)z\x1b[5~rk   )rd   collect_keymapr    rB      &r   rl   ZHistoricalReader.collect_keymap  s    w%' +
 
 	
r   c                    V ^8  d   QhRRRR/# )r   ir`   r   r   r   r   r   r   r   rc     s     	3 	3S 	3T 	3r   c                	sd   V P                  4       V P                  V P                  &   V P                  P                  V4      pVf"   V P                  V,          P                  4       p\        V4      V n        Wn        \        V P                  4      V n	        RV n
        RV P                  n        R # )NT)r4   ra   r   getr   Zrstripr5   r6   r   r7   r8   Zlast_refresh_cacheZinvalidated)r    rp   Zbufs   && r   r   ZHistoricalReader.select_item  s    040@0@0Bt}}-$$((+;,,q/((*C3it{{#
.2+r   c               ro   )r   rp   r`   r   rb   r   r   r   r   r   rc     s     E E# E# Er   c                	s    V\        V P                  4      8w  d-   V P                  P                  WP                  V,          4      # V P                  P                  WP	                  4       4      # r=   )r   r   ra   rq   r4   )r    rp   s   &&r   rD   ZHistoricalReader.get_item  sR    DLL!!))--aaAA))--a1A1A1CDDr   c               r   r   r   SimpleContextManagerr   r   r   r   r   rc   $  s      - r   c           	   #  	s   <"   \         SV `  4       ;_uu_ 4        V P                  4       ;_uu_ 4        R x  R R R 4       R R R 4       R #   + '       g   i     L; i  + '       g   i     R # ; i5ir=   )rd   suspendsuspend_historyrm   rn   r   rt   ZHistoricalReader.suspend#  s?     W_ 4 4 6 6 !7 6 6s2   A1AA
	A 
A1
AAA.	(	A1c               r   rr   r   r   r   r   r   rc   )  s     * *!5 *r   c              #  	s   "    V P                   R ,          pV P                   R  Rx  WP                   R &   R#   XT P                   R &   i ; i5i)NNNN)r   )r    Zold_historyr!   r   ru   Z HistoricalReader.suspend_history(  s=     	*,,q/KQ)LLOkDLLOs   A$8 AA		Ac               r   r   r   r   r   r   r   rc   1  s       r   c                	s  < \         SV `  4         / V n        V P                  e   V P                  \	        V P
                  4      8  d   V P                  V n        \        V P
                  V P                  ,          4      V P                  R&   \	        V P                  4      V n	        RV P                  \	        V P
                  4      &   M\	        V P
                  4      V n        R V n        R #    T P                  4        h ; i)Nrv   r
   )rd   preparera   r   r   r   r   r5   r6   r7   Zrestorerm   rn   r   rw   ZHistoricalReader.prepare1  s    	%'D"  ,1B1BSEV1V $ 1 1!%dll43D3D&E!FAt{{+<>&&s4<<'89 #DLL 1 $D	LLNs   CC. .Dc               s$    V ^8  d   QhRRRRRR/# )r   linenor`   cursor_on_lineboolr   rb   r   r   r   r   r   rc   A  s!     > > >d >s >r   c                	s   < V'       dE   V P                   \        8w  d0   R V P                   \        8H  ,          pRV: RV P                  : R2# \        SV `  W4      # )ZrfZ(z	-search `z') )rJ   rS   rI   rL   rd   
get_prompt)r    rx   ry   ZdrB   s   &&& r   r{   ZHistoricalReader.get_promptA  sK    d448NNT++/IIJA*+T->->??7%f==r   c               ro   )r   r.   rz   r   r   r   r   r   r   r   rc   H  s     3% 3%t 3% 3%r   c               s   V P                   pV P                  4       pV P                  pVP                  R^ V4      pW5^,           V p\	        V4      p\	        V4      p^ pV\	        V P
                  4      8  d   \	        V P                  V4      4      pV'       d
   W(8X  d   RpM
V'       g   Rp V'       d!   V\	        V P
                  4      ^,
          8  p	MV^ 8H  p	V	'       d;   V'       d    V'       g   ^ V n         . V n        RV n        R# V P                  R4       R# YA'       d   ^MR,          pV P                  V4      pV'       g   V P                  V4       R# ^ p
\        VP                  RR7      4       FO  w  rVP                  V4      '       d"   V P                  V4       W*,           V n          R# V
\	        V4      ,          p
KQ  	  EK!  )zSearch history for the current line contents up to the cursor.

Selects the first item found. If nothing is under the cursor, any next
item in history is selected.
Z
FT	not foundN)ZkeependsrA   )r7   r4   r   rfindr   r   rD   r6   r8   r   r   Z	enumerateZ
splitlinesZ
startswith)r    r.   r7   sZhistory_indexZnl_indexZprefixZmatch_prefixZlen_itemZout_of_boundsZlen_accrp   Zlines   &$           r   r0   ZHistoricalReader.search_nextH  sy    hh 774C(a<$&k6{3t||,,4==78H L L -T\\1BQ1F F - 2L DH"$DK!%DJ  JJ{+(Q2Mm,A  /G$Q\\4\%@A??6**$$]3"}DH3t9$ Br   c               r   r   r   r   r   r   r   rc   }  s      d r   c                	s   V P                   pV P                  pV P                  pV P                  4       pV P                  \
        8H  p V'       d   VP                  W^,           4      pM*VP                  V^ V\        V4      ,           ^,
          4      pVR8w  d   V P                  V4       W n        R# V'       d"   V\        V P                  4      ^,
          8  g   V'       g   V^ 8X  d   V P                  R4       R# V'       d   V^,          pV P                  V4      pRpK  V^,          pV P                  V4      p\        V4      pEK  )r?   Nr|   rA   )rL   r7   r   r4   rJ   rI   Zfindr}   r   r   r   r   rD   )r    ZstrW   rp   r~   r.   s   &     r   rV   ZHistoricalReader.isearch_next}  s   HHMM))-GGFF21u%GGB1s2w;?3Bw  #qC$5$998PQUVPV

;'FAa(AAFAa(AAAr   c               r   r   r   r   r   r   r   rc     s     % % %r   c                	sh  < \         SV `  4        V P                  4       pV P                  P	                  4        FA  w  r#V\        V P                  4      8  g   K!  W P                  8w  g   K3  W0P                  V&   KC  	  V'       d,   \        '       d   V P                  P                  V4       R # R # R # r=   )
rd   finishr4   ra   Zitemsr   r   r   should_auto_add_historyZappend)r    Zretrp   ZtrB   s   &   r   r   ZHistoricalReader.finish  s     **002DA3t||$$mm);"#Q 3 **LL$ +3r   )r6   r8   r   rK   rN   r   r7   ra   )"r$   r%   r&   r'   Z__doc__r   r5   r   __annotations__r   r   Zdictra   rL   rS   rJ   rK   rN   rC   rE   re   rl   r   rD   r   rt   ru   rw   r{   r0   rV   r   r(   Z__classcell__)rB   s   @r   r_   r_      s     t4GY4Hc#L*#(-d(C~CL#3s3%*%6M?6,1u,=M)=JOS
 
:
 
	3E   * *  > >3%j8% %r   r_   TN))z\\zself-insert)rh   zisearch-backwards)ri   zisearch-forwards)z\C-cisearch-cancel)z\C-gr   )z\<backspace>zisearch-backspace)0__conditional_annotations__Z
__future__r   Z
contextlibr   Zdataclassesr   r   r
   r   r   r   r   Ztypesrs   ZKeySpecZCommandNameZtupleZrangeZchrZmapZisalphar	   r   rS   rQ   rI   ZCommandr   r*   r+   r1   r2   r9   r<   ZFinishCommandr>   r@   rG   rP   rR   rU   rX   rY   r]   r^   r_   r   )rf   r   s   0@r   <module>r      sj  ( # " % (   	 ;@,1#JIJq#a&D."hlM"JI-0eBn-ES-Ed#"#-EST sAq6>> 	0 #A$ 	0A./;7 $  !   &8## &&x'' &&h.. &%X-- %h&& #H$$ #
:8## :
<811 <
x 8,h.. ,,h.. ,X%% H,, )(( )x'' (( (""  J%v J% J%Z  C JSs)   I-I-+I2
8I2
I7
5
I7
I7
