Ë Ô¾ù[j°ÞÆãóè—dZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z dd„Z Gd „d ej«ZGd „d «Zej#«ed k(rddlmZeddd¬«yy)a An IDLE extension to avoid having very long texts printed in the shell. A common problem in IDLE's interactive shell is printing of large amounts of text into the shell. This makes looking at the previous history difficult. Worse, this can cause IDLE to become very slow, even to the point of being completely unusable. This extension will automatically replace long texts with a small button. Double-clicking this button will remove it and insert the original text instead. Middle-clicking will copy the text to the clipboard. Right-clicking will open the text in a separate viewing window. Additionally, any output can be manually "squeezed" by the user. This includes output written to the standard error stream ("stderr"), such as exception messages and their tracebacks. éN)Ú messagebox)ÚidleConf)Ú view_text)ÚHovertip)Úmacosxcób—d}d}d}d}tjd|«D]e}|j«|z }||z }||z }||dk(r||kDr ||dz |zz }|dz }d}n!||dk(sJ‚||||zz z }||kDr|dz }|}|dz }Œg|t|«|z z }|dkDr ||dz |zz }|S|dz}|S)zÔCount the number of lines in a given string. Lines are counted as if the string was wrapped so that lines are never over linewidth characters long. Tabs are considered tabwidth characters long. éréz[\t\n]Ú Ú )ÚreÚfinditerÚstartÚlen)ÚsÚ linewidthÚtabwidthÚposÚ linecountÚcurrent_columnÚmÚnumcharss ú'/usr/lib/python3.12/idlelib/squeezer.pyÚcount_lines_with_wrappingrs€ð€HØ €CØ€IØ€Nä �[‰[˜ AÖ &ˆà—7‘7“9˜s‘?ˆØ ˆx‰ˆØ˜(Ñ"ˆð ˆS‰6�TŠ>ð  Ò)ð ˜n¨qÑ0°YÑ>Ñ>� Ø ˜‰NˆI؉Nà�S‘6˜T’>Ð !�>Ø ˜h¨.¸8Ñ*CÑDÑ DˆNð  Ò)ؘQ‘� Ø!)�à ˆq‰‰ð;'ð@”c˜!“f˜s‘lÑ"€Nà˜ÒØ�n qÑ(¨YÑ6Ñ6ˆ ð Ðð �Q‰ˆ à Ðócó>—eZdZdZd„Zd„Zd d„Zd d„Zd d„ZdZ d „Z y) ÚExpandingButtona¾Class for the "squeezed" text buttons used by Squeezer These buttons are displayed inside a Tk Text widget in place of text. A user can then use the button to replace it with the original text, copy the original text to the clipboard or view the original text in a separate window. Each button is tied to a Squeezer instance, and it knows to update the Squeezer instance when it is expanded (and therefore removed). c󊇗‰|_||_||_||_|jx|_}|j x|_}|j j|_|dk7rdnd}d|›d|›d�}tjj|||dd¬ «d } t|| d ¬ «|jd |j«tj «r|jd|j"«n|jd|j"«|j%ˆfd„«d|_|j)|j*«y)Nr ÚlinesÚlinezSqueezed text (Ú z).z#FFFFC0z#FFFFE0)ÚtextÚ backgroundÚactivebackgroundz5Double-click to expand, right-click for more options.éP)Ú hover_delayzz z cóJ•—‰t|«t|«t|«zS©N)Úint)ÚoffsetÚlengthrs €rÚz*ExpandingButton.__init__..zsø€ 1¤S¨£[´°V³¼sÀ6»{Ñ1JÑ#Kr)rÚtagsÚ numoflinesÚsqueezerÚeditwinr"ÚperÚbottomÚ base_textÚtkÚButtonÚ__init__rÚbindÚexpandrÚisAquaTkÚcontext_menu_eventÚselection_handleÚ is_dangerousÚ after_idleÚset_is_dangerous) Úselfrr-r.r/r0r"Úline_pluralityÚ button_textÚbutton_tooltip_texts ` rr6zExpandingButton.__init___s$ø€ØˆŒØˆŒ Ø$ˆŒØ ˆŒ Ø!)×!1Ñ!1Ð1ˆŒ �wØ"Ÿ<™<Ð'ˆŒ �Dà Ÿ™×+Ñ+ˆŒà$.°!¢O™¸ˆØ'¨  |°1°^Ð4DÀBÐGˆ Ü � ‰ ×ј4 ¨KØ&/À)ð ô Mð Dð ô �Ð*¸Õ;à � ‰ Ð% t§{¡{Ô3Ü �?‰?Ô à �I‰I�l D×$;Ñ$;Õ <à �I‰I�l D×$;Ñ$;Ô <Ø ×ÑÛ Kô Mð!ˆÔØ �‰˜×-Ñ-Õ.rcó‡—d|jj«zŠ|jdkDxsLt|j«dkDxs2t ˆfd„t jd|j«D««|_y)Né2ièiPÃc3óX•K—|]!}t|jd««‰k\–—Œ#y­w)rN)rÚgroup)Ú.0Ú line_matchÚdangerous_line_lens €rÚ z3ExpandingButton.set_is_dangerous..„s/øèø€ðá"@�Jô�J×$Ñ$ QÓ'Ó(Ð,>Õ>Ù"@ùsƒ'*z[^\n]+) r"Ú winfo_widthr.rrÚanyr rr<)r?rIs @rr>z ExpandingButton.set_is_dangeroussmø€Ø $§)¡)×"7Ñ"7Ó"9Ñ9Ðà �O‰O˜dÑ "ò Ü �—‘‹K˜%Ñ ò ä óä"$§+¡+¨i¸¿¹Ô"@óó ð ÕrNcóœ—|j€|j«|jrgtjddj gd¢«|j t |j«fztj|j¬«}|sy|jj|«}|jj||j|j«|jj|«|jj!||j|j«|j"j$j'|«y)aAexpand event handler This inserts the original text in place of the button in the Text widget, removes the button and updates the Squeezer instance. If the original text is dangerously long, i.e. expanding it could cause a performance degradation, ask the user for confirmation. NzExpand huge output?z )z5The squeezed output is very long: %d lines, %d chars.z2Expanding it could make IDLE slow or unresponsive.z5It is recommended to view or copy the output instead.zReally expand?)ÚtitleÚmessageÚdefaultÚparentÚbreak)r<r>rÚ askokcancelÚjoinr.rrÚCANCELr"Úindexr3Úinsertr-Údeleter0Úon_squeezed_expandr/ÚexpandingbuttonsÚremove)r?ÚeventÚconfirmrVs rr8zExpandingButton.expandŠsö€ð × Ñ Ð $Ø × !Ñ !Ô #Ø × Ò Ü ×,Ñ,Ø+ØŸ ™ ò%óð —o‘o¤s¨4¯6©6£{Ð3ñ 4ô #×)Ñ)Ø—y‘yô "ˆGñØà— ‘ —‘ Ó%ˆØ �‰×јe T§V¡V¨T¯Y©YÔ7Ø �‰×јdÔ#Ø � ‰ ×'Ñ'¨¨t¯v©v°t·y±yÔAØ � ‰ ×&Ñ&×-Ñ-¨dÕ3rcóZ—|j«|j|j«y)zMcopy event handler Copy the original text to the clipboard. N)Úclipboard_clearÚclipboard_appendr©r?r\s rÚcopyzExpandingButton.copy©s"€ð ×ÑÔØ ×јdŸf™fÕ%rcóL—t|jd|jdd¬«y)z]view event handler View the original text in a separate text viewer window. zSqueezed Output ViewerFÚnone)ÚmodalÚwrapN)rr"rras rÚviewzExpandingButton.view±s €ô �$—)‘)Ð5°t·v±vØ Fö ,r))rbrb)rgrgcó^—|jjdd|j|jfz«t j |jd¬«}|j D]"\}}|j|t||«¬«Œ$|j|j|j«y)NrWz@%d,%dr)Útearoff)ÚlabelÚcommandrR) r"Úmark_setÚxÚyr4ÚMenuÚ rmenu_specsÚ add_commandÚgetattrÚtk_popupÚx_rootÚy_root)r?r\ÚrmenurjÚ method_names rr:z"ExpandingButton.context_menu_event¿s„€Ø � ‰ ×ј8 X°·±¸%¿'¹'Ð0BÑ%BÔCÜ—‘˜Ÿ ™ ¨1Ô-ˆØ"&×"2Ô"2Ñ ˆE�;Ø × Ñ  E´7¸4ÀÓ3MÐ Õ Nð#3à �‰�u—|‘| U§\¡\Ô2Ørr() Ú__name__Ú __module__Ú __qualname__Ú__doc__r6r>r8rbrgrpr:©rrrrTs-„ñ ò/ò@  ó4ó>&ó,ð€Kó rrcó2—eZdZdZed„«Zd„Zd„Zd„Zy)ÚSqueezerzÈReplace long outputs in the shell with a simple button. This avoids IDLE's shell slowing down considerably, and even becoming completely unresponsive, when very long outputs are written. cóB—tjddddd¬«|_y)z!Load class variables from config.ÚmainÚPyShellzauto-squeeze-min-linesr)rD)ÚtyperPN)rÚ GetOptionÚauto_squeeze_min_lines)Úclss rÚreloadzSqueezer.reloadÎs$€ô&.×%7Ñ%7Ø �IÐ7Ø ô& ˆÕ"rcó.‡‡—|‰_|jx‰_Š|jj‰_dt ‰j d««t ‰j d««zz‰_g‰_d|jfˆˆfd„ }||_ y)aeInitialize settings for Squeezer. editwin is the shell's Editor window. self.text is the editor window text widget. self.base_test is the actual editor window Tk text widget, rather than EditorWindow's wrapper. self.expandingbuttons is the list of all buttons representing "squeezed" output. éÚborderÚpadxr|cóä•—|dk7r |||«S‰j}t|«|kr |||«S‰j|«}||kr |||«St|||‰«}‰j dt j «‰jd|dd¬«‰jd«‰j«‰j dt j«‰jj|«y)NÚstdoutÚiomarkéé©ÚwindowrŠÚpady) r„rÚ count_linesrÚ mark_gravityr4ÚRIGHTÚ window_createÚseeÚupdateÚLEFTrZÚappend)rr-Úwriter„r.Úexpandingbuttonr?r"s €€rÚmywritez"Squeezer.__init__..mywriteõsæø€à�xÒÙ˜Q “~Ð%ð&*×%@Ñ%@Ð "ä�1‹vÐ.Ò.Ù˜Q “~Ð%à×)Ñ)¨!Ó,ˆJØÐ2Ò2Ù˜Q “~Ð%ô.¨a°°zÀ4ÓHˆOð × Ñ ˜h¬¯©Ô 1Ø × Ñ ˜x°Ø$%¨Að ô /à �H‰H�XÔ Ø �K‰KŒMØ × Ñ ˜h¬¯©Ô 0ð × !Ñ !× (Ñ (¨Õ 9rN) r0r"r1r2r3r)ÚcgetÚwindow_width_deltarZr›)r?r0r�r"s` @rr6zSqueezer.__init__Ösˆù€ðˆŒ Ø"Ÿ<™<Ð'ˆŒ �Dð!Ÿ™×+Ñ+ˆŒð#$Ü �— ‘ ˜(Ó#Ó $Ü �— ‘ ˜&Ó!Ó "ñ #ñ# ˆÔð !#ˆÔð g§m¡mö :ð< ˆ� rcóB—t||jj«S)abCount the number of lines in a given text. Before calculation, the tab width and line length of the text are fetched, so that up-to-date values are used. Lines are counted as if the string was wrapped so that lines are never over linewidth characters long. Tabs are considered tabwidth characters long. )rr0Úwidth)r?rs rr“zSqueezer.count_liness€ô)¨¨D¯L©L×,>Ñ,>Ó?Ð?rcóš—|jjtj«}dD]}||vsŒn|jj «y|jj |tjdz«\}}|jj ||«}t|«dkDr+|ddk(r#|jjd|z«}|dd}|jj||«|j|«}t||||«}|jj||d d ¬ «t|j«}|dkDre|jj|j|d z d |«r8|d z}|dkDr.|jj|j|d z d |«rŒ8|jj!||«y)z±Squeeze the text block where the insertion cursor is. If the cursor is not in a squeezable block of text, give the user a small warning and do nothing. )rŒÚstderrrRz+1créÿÿÿÿr z%s-1cNrŽr�r�r Ú>)r"Ú tag_namesr4ÚINSERTÚbellÚ tag_prevrangeÚgetrrVr3rXr“rr–rZÚcomparerW) r?r¦Útag_namerÚendrr.rœÚis rÚsqueeze_current_textzSqueezer.squeeze_current_text"s¥€ð—I‘I×'Ñ'¬¯ © Ó2ˆ Û,ˆHؘ9Ò$Ùð-ð �I‰I�N‰NÔ Øð—Y‘Y×,Ñ,¨X´r·y±yÀ5Ñ7HÓI‰ ˆˆsØ �I‰I�M‰M˜% Ó %ˆô ˆq‹6�AŠ:˜!˜B™% 4š-Ø—)‘)—/‘/ '¨C¡-Ó0ˆCØ�#�2�ˆAð �‰×јe SÔ)ð×%Ñ% aÓ(ˆ Ü)¨!¨X°zÀ4ÓHˆð � ‰ ×Ñ ¨oØ%&¨Qð ô 0ô �×%Ñ%Ó &ˆØ�!Še˜Ÿ ™ ×)Ñ)¨$×*?Ñ*?ÀÀ!ÁÑ*DØ*-¨ô@à �‰FˆAð�!Še˜Ÿ ™ ×)Ñ)¨$×*?Ñ*?ÀÀ!ÁÑ*DØ*-¨õ@ð ×Ñ×$Ñ$ Q¨Ô8àrN) rxryrzr{Ú classmethodr†r6r“r¯r|rrr~r~Ès,„ñð ñ óð ò= ò~ @ó-rr~Ú__main__)r€zidlelib.idle_test.test_squeezerrˆF)Ú verbosityÚexit)r%)r{r Útkinterr4rÚidlelib.configrÚidlelib.textviewrÚidlelib.tooltiprÚidlelibrrr5rr~r†rxÚunittestr€r|rrÚrºsrðñó  ãÝå#Ý&Ý$Ýó5ôpq�b—i‘iôq÷hGñGðT ‡�Ôð ˆzÒÝÙÐ *°a¸eÖDðr