tQOhVdZddlmZGddZedk(rddlmZeddd y y ) z9Implement Idle Shell history mechanism with History class)idleConfc.eZdZdZdZdZdZdZdZy)Historya@ Implement Idle Shell history mechanism. store - Store source statement (called from pyshell.resetoutput). fetch - Fetch stored statement matching prefix already entered. history_next - Bound to <> event (default Alt-N). history_prev - Bound to <> event (default Alt-P). c||_g|_d|_d|_t j ddddd|_|jd|j|jd|jy) adInitialize data attributes and bind event methods. .text - Idle wrapper of tk Text widget, with .bell(). .history - source statements, possibly with multiple lines. .prefix - source already entered at prompt; filters history list. .pointer - index into history. .cyclic - wrap around history list (or not). Nmainrcyclicboolz<>z<>) texthistoryprefixpointerr GetOptionrbind history_prev history_next)selfr s 6/opt/alt/python312/lib64/python3.12/idlelib/history.py__init__zHistory.__init__sd    ((HaP  ($*;*;< $d&7&78c(|jdy)z5Fetch later statement; start with earliest if cyclic.Freversebreakfetchrevents rrzHistory.history_nexts 5 !rc(|jdy)z0Fetch earlier statement; start with most recent.Trrrrs rrzHistory.history_prev$s 4  rcrt|j}|j}|j}|k|i|jj ddds,|jj dd|j|k7r dx}}|jjdd||K|jj dd}|r|}n*|jrd}n|jjyt|} ||rdndz }|dks||k\r|jj|js|dkry|jj dd|k7r9|jjdd|jjd|d dx}}n`|j|}|d||k(rHt||kDr:|jjdd|jjd|d n|jjd|jjd d d ||_||_y) a+Fetch statement and replace current line in text widget. Set prefix and pointer as needed for successive fetches. Reset them to None, None when returning to the start line. Sound bell when return to start line or cannot leave a line because cyclic is False. Ninsertz!=zend-1ciomarkr rstdinselz1.0end)lenr rr r comparegetmark_setrbelldeleter!see tag_remove)rrnhistrr nprefixitems rrz History.fetch)sDLL!,,  6#5yy  4:IIMM(H5g9NN#''& ""8X6 ?fnYY]]8X6F;; GIINN$f+ Wr! +G{g.  {{w{yy}}Xx8FB ((8< ((67C'++Gf<<(DHW~'CI,?   84   49!" h UE51  rc|j}t|dkDr7 |jj||jj |d|_d|_y#t$rY5wxYw)z.Store Shell input statement into history list.N)stripr'r remove ValueErrorappendrr )rsources rstorez History.storeZse v;?  ##F+ LL   '    sA%% A10A1N) __name__ __module__ __qualname____doc__rrrrr9rrrrs!9"  /b rr__main__)rzidlelib.idle_test.test_historyr3F) verbosityexitN)r=idlelib.configrrr:unittestrr>rrrDs7;#__D z )QUCr