e@l %SSKJr SSKrSSKJr SSKJrJrJr SSK J r J r SSK J r JrJr SSKJrJrJr SS KJr \ R*rSS KJrJrJrJr \"S 5urrrSHS jrSIS jr \!"/SPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSPSP\RDS :XaS!OS"QS#PS$PS%PS&PS'PS(PS)PS*PS+PS,PS-PS.PS/PS0PS1PS2PS3PS4PS5PS6PS7PS8PS9PS:P\#"\$\"S;S<55Vs/sHoS=:wdM US>4PM sn-\#"\$\"S?S@55Vs/sHoRK5(dMUS>4PM sn-/SAQ-5r&SB\'SC'\"SDSE9"SFSG55r(gs snfs snf)J) annotationsN)contextmanager) dataclassfieldfields) can_colorize ANSIColors)commandsconsoleinput)wlen unbracketdisp_str)trace)CallbackSimpleContextManagerKeySpec CommandNamec0n[[[S55H n[X'M [[[S55Vs/sHo"R 5(dMUPM snH n[ X'M [ =US'US'U$s snf)N  )mapchrrange SYNTAX_SYMBOLisalnum SYNTAX_WORDSYNTAX_WHITESPACE)stcas 4/opt/imh/python3.13/lib/python3.13/_pyrepl/reader.pymake_default_syntax_tabler&.srB eCj !"S%*- =-Aa- =>**BtHr#w I>s B "B cN0n[[5R5Hn[U[5(dM[ U[ 5(dM1URSR5(dMUXUR'XURRSS5'M U$)Nr_-) varsr values isinstancetype issubclassCommand__name__islowerreplace)resultvs r%make_default_commandsr59sy/1F (^ " " $ a  :a#9#9ajjm>S>S>U>U!"1:: 341::%%c3/ 0% M)z\C-abeginning-of-line)z\C-bleft)z\C-c interrupt)z\C-ddelete)z\C-e end-of-line)z\C-fright)z\C-gcancel)z\C-h backspace)z\C-jaccept)z \r?)z\C-kz kill-line)z\C-lz clear-screen)z\C-mr?)z\C-tztranspose-characters)z\C-uzunix-line-discard)z\C-wzunix-word-rubout)z\C-x\C-uz upcase-region)z\C-yyankwin32))z\C-zsuspend)z\M-b backward-word)z\M-czcapitalize-word)z\M-dz kill-word)z\M-f forward-word)z\M-lz downcase-word)z\M-tztranspose-words)z\M-uz upcase-word)z\M-yzyank-pop)z\M-- digit-arg)z\M-0rF)z\M-1rF)z\M-2rF)z\M-3rF)z\M-4rF)z\M-5rF)z\M-6rF)z\M-7rF)z\M-8rF)z\M-9rF)z\M-\nr?)z\\ self-insert)z \x1b[200~enable_bracketed_paste)z \x1b[201~disable_bracketed_paste)z\x03zctrl-c \rGr))z\up)z\down)z\r8)z \C-\rD)z\r<)z \C-\rE)z \r:)z\x1b[3~r:)z \r>)z\M-\zbackward-kill-word)z\r;)z\r7)z\help)z\z show-history)z\z paste-mode)z\EOFend)z\EOHhome'tuple[tuple[KeySpec, CommandName], ...]default_keymapT)slotsc\rSrSr%SrS\S'\"\S9rS\S'Sr S \S 'S r S \S 'Sr S \S'Sr S \S'Sr S \S'\"\S9rS\S'SrS \S'SrS\S'SrS\S'SrS\S'SrS\S'SrS\S '\"\S9rS!\S"'SrS#\S$'\"\S9rS%\S&'S'rS(\S)'\"SS*9rS+\S,'\"\S9rS-\S.'\"\S9rS\S/'\"SS*9rS0\S1'\"SS*9rS2\S3'\"SS*9r S2\S4'\"\S9r!S\S5'Sr"S\S6'Sr#S7\S8'\$"S9S:55r%\"\%S9r&S:\S;'S_S<jr'S`S=jr(SaS>jr)\*SbS?j5r+ScSdS@jjr,ScSdSAjjr-ScSdSBjjr.ScSdSCjjr/SeSDjr0SfSEjr1SgShSFjjr2SiSGjr3SjSHjr4S_SIjr5SkSJjr6SlSKjr7SmSLjr8S_SMjr9SnSNjr:S_SOjr;SoSPjrSpSRj5r?S_SSjr@SqSrSTjjrAS_SUjrBS_SVjrCSsSWjrDS_SXjrEStSuSYjjrFSvSZjrGScSwS[jjrHSxS\jrISyS]jrJS^rKg)zReadera`The Reader class implements the bare bones of a command reader, handling such details as editing and cursor motion. What it does not support are such things as completion or history support - these are implemented elsewhere. Instance variables of note include: * buffer: A *list* (*not* a string at the moment :-) containing all the characters that have been entered. * console: Hopefully encapsulates the OS dependent stuff. * pos: A 0-based index into `buffer' for where the insertion point is. * screeninfo: Ahem. This list contains some info needed to move the insertion point around reasonably efficiently. * cxy, lxy: the position of the insertion point in screen ... * syntax_table: Dictionary mapping characters to `syntax class'; read the emacs docs to see what this means :-) * commands: Dictionary mapping command names to command classes. * arg: The emacs-style prefix argument. It will be None if no such argument has been provided. * dirty: True if we need to refresh the display. * kill_ring: The emacs-style kill-ring; manipulated with yank & yank-pop * ps1, ps2, ps3, ps4: prompts. ps1 is the prompt for a one-line input; for a multiline input it looks like: ps2> first line of input goes here ps3> second and further ps3> lines get ps3 ... ps4> and the last one gets ps4 As with the usual top-level, you can set these to instances if you like; str() will be called on them (once) at the beginning of each command. Don't put really long or newline containing strings here, please! This is just the default policy; you can change it freely by overriding get_prompt() (and indeed some standard subclasses do). * finished: handle1 will set this to a true value if a command signals that we're done. zconsole.Consoler default_factory list[str]bufferrintposz->> strps1z/>> ps2z|.. ps3z\__ ps4zlist[list[str]] kill_ringmsgN int | NoneargFbooldirtyfinished paste_modein_bracketed_pastezdict[str, type[Command]]r ztype[Command] | None last_commanddict[str, int] syntax_tablerBztuple[tuple[str, str], ...]keymapinitinput.KeymapTranslator input_transzlist[input.KeymapTranslator]input_trans_stackscreenlist[tuple[int, list[int]]] screeninfotuple[int, int]cxylxyscheduled_commandsrCallback | Nonethreading_hookc\rSrSr%SrS\S'\"\S9rS\S'\"SS9r S \S '\"\S9r S \S '\"SS9r S \S'\"SS9r S\S'\"SS9r S\S'SrS\S'SSjrSSjrSSjrSrg)Reader.RefreshCacheFrirmrYr[rwrrrxryz list[int]line_end_offsetsr]r^rzr{ dimensions invalidatedc.URUlUR5UlUR5UlURUlUR UlUR RUR R4Ul SUl gNF) rmcopyrwryr^r{r widthheightrr)selfreaderrwrys r% update_cache Reader.RefreshCache.update_cachesk '-&?&?D # ++-DK(oo/DOzzDHzzDH$nn22FNN4I4IIDO$D r6cUR(agURRURR4nX R:gnUR UR :gnU=(d U(+$r)rr rrrrm)rrrdimensions_changed paste_changeds r%validReader.RefreshCache.valids]--v~~/D/DDJ!+!> "559P9PPM*;m< '>'R'RSW'X $F((// $ %,,77 ( )(,(?(?(P(P% )*; <hh #G FQJ(?4(G FG,-33D9 !%:HB4yHC#8#7# #q(#&)<)<< $)!-A-A-AB&.(.(8(8(>% Av-44V< j)!!1b'* &. a< C!%!4!4V!< FJ!)$ E;[)J64<<;M;MMI +y AA~[Q,&-44V< frwwu~56!!:{";<#!)a-0D+,(F&1 !J.74<<;M;MM!,1,*, '2 5z$88"66#!""6"::! "188@ 27751F2F+G#HH4OF$/0E1E$F$NMMM&)%%v}&=>!"6"78E"-.B.C"DKCF11G;x%;;= 88- e$!!1b'*. ,,T:F r6cD[USS9n[USS9nU[U54$)zReturn a tuple with the prompt string and its visible length. The prompt string has the zero-width brackets recognized by shells (\x01 and \x02) removed. The length ignores anything between those brackets as well as any ANSI escape sequences. F)including_contentT)rr)r out_promptvisible_prompts r%rReader.process_prompts,v? "6TB4///r6cUc URnURnURnUS-nUS:aMURX1[5[:wa-US-nUS:a"URX1[5[:waM-US:aMURX1[5[:Xa-US-nUS:a"URX1[5[:XaM-US-$)zReturn the 0-based index of the word break preceding p most immediately. p defaults to self.pos; word boundaries are determined using self.syntax_table.r r)r^rpr\getr rpr"bs r%bow Reader.bows 9A    KK Q1fk2kA FA1fk2kA1fk2kA FA1fk2kA1u r6cUc URnURnURnU[U5:aVUR X1[ 5[ :wa6US- nU[U5:a"UR X1[ 5[ :waM6U[U5:aVUR X1[ 5[ :Xa6US- nU[U5:a"UR X1[ 5[ :XaM6U$)zReturn the 0-based index of the word break following p most immediately. p defaults to self.pos; word boundaries are determined using self.syntax_table.r )r^rpr\rrr rs r%eow Reader.eows 9A    KK#a&jRVVAD+6+E FA#a&jRVVAD+6+E#a&jRVVAD+6+E FA#a&jRVVAD+6+Er6cUc URnURnUS-nUS:aX!S:waUS-nUS:a X!S:waMUS-$)zaReturn the 0-based index of the line break preceding p most immediately. p defaults to self.pos.r rr)r^r\rrrs r%bol Reader.bolsV 9A KK Q1f FA1f1u r6cUc URnURnU[U5:a&X!S:waUS- nU[U5:a X!S:waMU$)zaReturn the 0-based index of the line break following p most immediately. p defaults to self.pos.rr )r^r\rrs r%eol Reader.eolsQ 9A KK#a&jQTT\ FA#a&jQTT\r6c^URUS[URUS5-$)z#Return the last x-offset for line yrr )ryr)rys r% max_columnReader.max_columns.q!!$s4??1+=a+@'AAAr6c2[UR5S- $)Nr )rryrs r%max_rowReader.max_rows4??#a''r6c8URcU$UR$)zmReturn any prefix argument that the user has supplied, returning `default' if there is None. Defaults to 1. )rh)rdefaults r%get_argReader.get_args 88 Nxxr6cURbU(aSURS3nOUR(aUR(dSnOxSUR;a\US:Xa URnOUUR (a+XRR S5:Xa UR nOURnO URnUR(a$[RU[R3nU$)z@Return what should be in the left-hand margin for line `lineno'.z(arg: z) z(paste) rr) rhrlrmr\rarccountrbr`rr BOLD_MAGENTARESET)rlinenocursor_on_liners r%rReader.get_prompts 88 NdhhZr*F __T%<%<F T[[ {f (9(9$(??XXF   "//09I9I8JKF r6cZURRUR5 Xlgr)rvrru)ritranss r%push_input_transReader.push_input_transs" %%d&6&67!r6cBURR5Ulgr)rvpoprurs r%pop_input_transReader.pop_input_transs11557r6cSnSnXB:acURUupV[U5nU[U5-URR:nU(aX7S- - nOX7S-- nUS- nXB:aMcSn URUSn X:aHURUSU S:XaU S- n M%XRUSU - n U S- n US- nX:aMHX0lg)z%Set pos according to coordinates x, yrr N)ryrrr rr^) rxrr^irrrin_wrapped_linejcur_xs r%setpos_from_xyReader.setpos_from_xys e&*ooa&8 #J%F(3{+;;t||?Q?QQOz!z! FAe "1%iq!!$Q'1,Q __Q'*1- -E FA 1HC ir6cFSup/nURnSUs=::a[UR5::de eU[UR5:XaR[UR5S:a9[UR5S- nURUupU[ U5-U4$URH]up[U5nU[ U5-UR R :nU(aUS-nXT:a OU(dUS- nXE-nUS- nM_ U[ USU5-U4$)z.Return the x, y coordinates of position 'pos'.rrr N)r^rr\ryrr r)rrrrr^rr s r%r Reader.pos2xys !# hhC+3t{{++++++ #dkk" "s4??';a'?DOO$q(A&*ooa&8 #JK 00!3 3'+ #J%F(3{+;;t||?Q?QQO! }"!  MC FA(7C DS 122A55r6c[U5URURUR&U=R[U5- slSUlg)z%Insert 'text' at the insertion point.TN)rr\r^rrj)rtexts r%insert Reader.insert1s7+/: DHHtxx( CI r6ctUR5UlURR"UR6 g)z.Move the cursor to reflect changes in self.posN)rr{r move_cursorrs r% update_cursorReader.update_cursor7s%;;=   $((+r6c`[USS5(aURbSUlSUlgg)z6This function is called to allow post command cleanup.kills_digit_argTN)getattrrhrjrcmds r% after_commandReader.after_command<s/ 3)4 0 0xx#! DH 1r6cURR5 SUlSUlURSS2 SUlSUlSUlUR5 UR(aAURR5nURU/45 UR(aM@gg![a UR5 ef=f)z~Get ready to run. Call restore when finished. You must not write to the console in between the calls to prepare and restore.NFrT)r preparerhrkr\r^rjrnr BaseExceptionrestorer}rdo_cmdrs r%r$Reader.prepareCs  LL "DH!DM ADHDJ $D      %%))--/C KKb "%%%   LLN  s AB11C cPUR(dg[XR5$r)rnr.)rclss r%last_command_isReader.last_command_isXs  #0011r6c8URR5 g)zClean up after a run.N)r r&rs r%r&Reader.restore]s r6c #V# [U5Vs0sH"oR[XR5_M$ nnUR5 Sv SHn[ XX#5 M UR 5 gs snf!SHn[ XX#5 M UR 5 f=f7f)z0A context manager to delegate to another reader.N)rfr`rarbrcrl)rnamerr&setattrr$)rf prev_staterhs r%rCReader.suspendas>DD\J\ffgdFF33\ J  LLN H:?3I LLNK I:?3I LLNs&B))A8B)A=-B)=)B&&B)cg)z2Called when a command signals that we're finished.NrBrs r%finish Reader.finishms r6c`SU-S-UlSUlURR5 g)Nz! rT)rfrjr beep)rrfs r%error Reader.errorqs)#:#  r6cHUR(aUR5 ggr)rjrefreshrs r% update_screenReader.update_screenvs :: LLN r6cUR(a%UR(aURSS:XdgUR5UlURR URUR 5 SUlg)z#Recalculate and refresh the screen.rNF)rmr\rrwr r=r{rjrs r%r=Reader.refreshzsX  " "t{{4;;r?d;R &&(  T[[$((3 r6c[SUS9 [US[5(a.URR US[R 5nO[US[ 5(aUSnOgU"U/UQ76nUR5 URU5 UR(aUR5 OUR5 [U[R5(dX l [UR5UlUR (a+UR"R5 UR5 gg)z`cmd` is a tuple of "event_name" and "event", which in the current implementation is always just the "buffer" which happens to be a list of single-character strings.zreceived command {cmd})r rN)rr,r_r rinvalid_commandr-dor!rjr=r digit_argrnrir6rkr )rr  command_typecommands r%r' Reader.do_cmds &C0 c!fc " "==,,SVX5M5MNL A % %q6L t*c*  7# :: LLN    #x1122 , W^^, == LL   ! KKM r6cURnUc"S[R;aSSKJn U"U5 UbU"5 UR RnU(a U"5 gg![ a N3f=f![ a gf=f)N threadingr )install_threading_hook)rsysmodules_threading_handlerrL Exceptionr input_hook)rrrLrQs r% run_hooksReader.run_hookss,,  !kS[[&@ B "4 (  %  \\,,         s#A$A4$ A10A14 BBcUR(aSUlSUlUR5 URR S5 URR SS9nU(d U(aMUgSnUR S:XaURRU5 ODUR S:XaUR5 O#UR S:XaUR5 OSnU(aURR5nOUR UR/nUc U(aGMgURU5 g) zHandle a single event. Wait as long as it takes if block is true (the default), otherwise return False if no event is pending.reTdFblockkeyscrollresize) rfrjrRr wait get_eventevtrupushr=rdatar')rrWevent translater s r%handle1Reader.handle1s 88DHDJ NN  LL  c "LL***7EIyyE!  %%e,h& h& ! &&**,yy%**-{ KK r6cXURRU5 URSS9 g)NFrV)r push_charrb)rchars r%reReader.push_chars" t$ 5 !r6c*UR5 UbU"5 UR5 UR(d#UR5 UR(dM#UR 5UR 5 $!UR 5 f=f)z|Read a line. The implementation of this method also shows how to drive Reader if you want more control over the event loop.)r$r=rkrb get_unicoder&)r startup_hooks r%readlineReader.readlinesb  ' LLNmm mmm##% LLNDLLNsA B BBczURX44-Ul[R"URSSS9Ulg)NrrGr)rqr rru)rspecrHs r%bind Reader.binds5kkd_$66  11 KK]- r6c8SRUR5$)z.Return the current buffer as a unicode string.re)rr\rs r%riReader.get_unicodeswwt{{##r6) rhrr{rjrkrurqrnr|rfr^rwry)rr)rrS)rr[)rr_rztuple[str, int]r)rrgrr])rr]rr])rr])r )rr]rr])rr]rrirr_)rrtrr)r r]rr]rr)rrz)rzstr | list[str]rr)r r/rr)r*r-rri)rr)none)rfr_rr)r ztuple[str, list[str]]rr)T)rWrirri)rfz int | bytesrr)rjr~rr_)rnrrHrrr)rr_)Lr0rrr__doc__rrrr\r^r`rarbrcrdrfrhrjrkrlrmr5r rnr&rprqrurvrwryr{r|r}rrrrrrrr staticmethodrrrrrrrrrrrrrrrr!r$r+r&rrCr6r:r>r=r'rRrbrerkrorirrBr6r%rWrWsN2hd3FI3CLCCCC!&t!$)V"  $r6rW)rro)rz dict[CommandName, type[Command]])) __future__rrM contextlibr dataclassesrrr _colorizerr rer r r utilsrrrrr/typesrrrrrr!r rr&r5tupleplatformrrisalpharTrrW)r#s0r%rs,# %00.'&,,   GG 16a-; ;@,&,, ,  , ! ,  , , , , !, , ", , *, ', &!," '#,$ %,& '"-E',( #),* %+,, -,. "/,0 #1,2 %3,4 !5,6 7,8 9,: ;,< =,> ?,@ A,B C,D E,F G,H I,J K,L M,N O,P Q,R 1S,T 2U,V W,Z$'sE"cN#;I#;aDy=#;I[-J\$'sE#sO#<L#