Ë
    #´˜j«  ã                   óª   — d Z ddlmZmZmZmZ ddlmZ dZdZ	dZ
dZdZd	Z G d
„ de«      Zd„ Zedk(  r ddlmZ  eddd¬«       ddlmZ  ee«       yy)zvA call-tip window class for Tkinter/IDLE.

After tooltip.py, which uses ideas gleaned from PySol.
Used by calltip.py.
é    )ÚLabelÚLEFTÚSOLIDÚTclError)ÚTooltipBasez<<calltipwindow-hide>>)z<Key-Escape>z
<FocusOut>z<<calltipwindow-checkhide>>)z<KeyRelease>z<ButtonRelease>éd   Úcalltipwindowregion_rightc                   óf   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ fd„Zˆ fd„Zd„ Zdd„Z	d„ Z
ˆ fd	„Zd
„ Zd„ Zˆ xZS )ÚCalltipWindowz+A call-tip widget for tkinter text widgets.c                 ó”   •— t         ‰| �  |«       dx| _        | _        dx| _        x| _        | _        dx| _        | _        d| _	        y)z}Create a call-tip; shown by showtip().

        text_widget: a Text widget with code for which call-tips are desired
        N)
ÚsuperÚ__init__ÚlabelÚtextÚ	parenlineÚparencolÚlastlineÚhideidÚcheckhideidÚcheckhide_after_id)ÚselfÚtext_widgetÚ	__class__s     €ú#lib/python3.12/idlelib/calltip_w.pyr   zCalltipWindow.__init__   sL   ø€ ô 	‰Ñ˜Ô%à!%Ð%ˆŒ
�T”YØ9=Ð=ˆŒÐ=˜œ¨¬Ø)-Ð-ˆŒ�dÔ&Ø"&ˆÕó    c                 óˆ  — t        | j                  j                  d«      j                  d«      d   «      }|| j                  k(  r| j                  | j
                  f}n|df}| j                  j                  d|z  «      }|s.t        | j                  j                  d«      «      }d|d<   d|d<   |d   dz   |d   |d   z   fS )z$Choose the position of the call-tip.ÚinsertÚ.r   z%d.%dé   é   é   )ÚintÚanchor_widgetÚindexÚsplitr   r   ÚbboxÚlist)r   ÚcurlineÚanchor_indexÚboxs       r   Úget_positionzCalltipWindow.get_position#   s¾   € ä�d×(Ñ(×.Ñ.¨xÓ8×>Ñ>¸sÓCÀAÑFÓGˆØ�d—n‘nÒ$Ø ŸN™N¨D¯M©MÐ:‰Là# Q˜<ˆLØ× Ñ ×%Ñ% g°Ñ&<Ó=ˆÙÜ�t×)Ñ)×.Ñ.¨xÓ8Ó9ˆCàˆC�‰FØˆC�‰FØ�1‰v˜‰z˜3˜q™6 C¨¡F™?Ð*Ð*r   c                 óò   •— t        | j                  j                  d«      j                  d«      d   «      }|| j                  k(  ry|| _        | j                  j                  d«       t        ‰| �  «        y)z Reposition the window if needed.r   r   r   N)r"   r#   r$   r%   r   Úseer   Úposition_window)r   r(   r   s     €r   r.   zCalltipWindow.position_window2   sc   ø€ ä�d×(Ñ(×.Ñ.¨xÓ8×>Ñ>¸sÓCÀAÑFÓGˆØ�d—m‘mÒ#ØØˆŒØ×Ñ×Ñ˜xÔ(Ü‰ÑÕ!r   c                 óL  •— || _         | j                  s| j                   sy| j                  j                  t        |«       t        t        | j                  j                  |«      j                  d«      «      \  | _	        | _
        t        ‰| �1  «        | j                  «        y)a_  Show the call-tip, bind events which will close it and reposition it.

        text: the text to display in the call-tip
        parenleft: index of the opening parenthesis in the text widget
        parenright: index of the closing parenthesis in the text widget,
                    or the end of the line if there is no closing parenthesis
        Nr   )r   Ú	tipwindowr#   Úmark_setÚ
MARK_RIGHTÚmapr"   r$   r%   r   r   r   ÚshowtipÚ_bind_events)r   r   Ú	parenleftÚ
parenrightr   s       €r   r4   zCalltipWindow.showtip;   s   ø€ ð ˆŒ	Ø�>Š> §¢Øà×Ñ×#Ñ#¤J°
Ô;Ü(+Ü�×#Ñ#×)Ñ)¨)Ó4×:Ñ:¸3Ó?ó)AÑ%ˆŒ˜œô 	‰‰Ôà×ÑÕr   c                 óº   — t        | j                  | j                  t        ddt        d| j
                  d   ¬«      | _        | j                  j                  «        y)zCreate the call-tip widget.z#ffffd0Úblackr    Úfont)r   ÚjustifyÚ
backgroundÚ
foregroundÚreliefÚborderwidthr:   N)r   r0   r   r   r   r#   r   Úpack)r   s    r   ÚshowcontentszCalltipWindow.showcontentsP   sD   € ä˜4Ÿ>™>°·	±	Ä4Ø&/¸GÜ"'°QØ $× 2Ñ 2°6Ñ :ô<ˆŒ
ð 	�
‰
�‰Õr   c                 ó2  — | j                   syt        t        | j                  j	                  d«      j                  d«      «      \  }}|| j                  k  s?|| j                  k(  r|| j                  k  s!| j                  j                  ddt        «      r| j                  «        y| j                  «        | j                  �%| j                  j                  | j                  «       | j                  j                  t        | j                   «      | _        y)z4Handle CHECK_HIDE_EVENT: call hidetip or reschedule.Nr   r   Ú>Úbreak)r0   r3   r"   r#   r$   r%   r   r   Úcomparer2   Úhidetipr.   r   Úafter_cancelÚafterÚCHECKHIDE_TIMEÚcheckhide_event)r   Úeventr(   Úcurcols       r   rJ   zCalltipWindow.checkhide_eventX   sÞ   € à�~Š~ð ô œc 4×#5Ñ#5×#;Ñ#;¸HÓ#E×#KÑ#KÈCÓ#PÓQ‰ˆ�Ø�T—^‘^Ò#Ø�t—~‘~Ò%¨&°D·M±MÒ*AØ×Ñ×%Ñ% h°´ZÔ@Ø�L‰LŒNØð 	×ÑÔà×"Ñ"Ð.Ø×Ñ×+Ñ+¨D×,CÑ,CÔDà×Ñ×$Ñ$¤^°T×5IÑ5IÓJð 	Ôàr   c                 ó>   — | j                   sy| j                  «        y)z%Handle HIDE_EVENT by calling hidetip.NrD   )r0   rF   )r   rK   s     r   Ú
hide_eventzCalltipWindow.hide_events   s   € à�~Š~àØ�‰ŒØr   c                 ór  •— | j                   sy	 | j                  j                  «        d| _        dx| _        x| _        | _        	 | j                  j                  t        «       	 | j                  «        t        ‰| �5  «        y# t        $ r Y Œgw xY w# t        $ r Y Œ:w xY w# t        t        f$ r Y Œ>w xY w)zHide the call-tip.N)r0   r   Údestroyr   r   r   r   r#   Ú
mark_unsetr2   Ú_unbind_eventsÚ
ValueErrorr   rF   )r   r   s    €r   rF   zCalltipWindow.hidetip{   sµ   ø€ à�~Š~Øð	Ø�J‰J×ÑÔ ð ˆŒ
à9=Ð=ˆŒÐ=˜œ¨¬ð	Ø×Ñ×)Ñ)¬*Ô5ð	Ø×ÑÔ!ô
 	‰‰Õøô! ò 	Ùð	ûô ò 	Ùð	ûô
 œ*Ð%ò 	áð	ús5   �B ÁB Á'B$ Â	BÂBÂ	B!Â B!Â$B6Â5B6c                 óÀ  — | j                   j                  t        | j                  «      | _        t
        D ]"  }| j                   j                  t        |«       Œ$ | j                   j                  t        | j                  «       | j                   j                  t        | j                  «      | _        t        D ]"  }| j                   j                  t        |«       Œ$ y)zBind event handlers.N)r#   ÚbindÚCHECKHIDE_EVENTrJ   r   ÚCHECKHIDE_SEQUENCESÚ	event_addrH   rI   Ú
HIDE_EVENTrN   r   ÚHIDE_SEQUENCES©r   Úseqs     r   r5   zCalltipWindow._bind_events”   s¤   € à×-Ñ-×2Ñ2´?Ø37×3GÑ3GóIˆÔç&ˆCØ×Ñ×(Ñ(¬¸#Õ>ð 'à×Ñ× Ñ ¤°×1EÑ1EÔFØ×(Ñ(×-Ñ-¬jØ.2¯o©oó?ˆŒç!ˆCØ×Ñ×(Ñ(¬°SÕ9ñ "r   c                 ót  — t         D ]"  }| j                  j                  t        |«       Œ$ | j                  j	                  t        | j
                  «       d| _        t        D ]"  }| j                  j                  t        |«       Œ$ | j                  j	                  t        | j                  «       d| _        y)zUnbind event handlers.N)	rW   r#   Úevent_deleterV   Úunbindr   rZ   rY   r   r[   s     r   rR   zCalltipWindow._unbind_events    s‡   € ç&ˆCØ×Ñ×+Ñ+¬O¸SÕAð 'à×Ñ×!Ñ!¤/°4×3CÑ3CÔDØˆÔß!ˆCØ×Ñ×+Ñ+¬J¸Õ<ð "à×Ñ×!Ñ!¤*¨d¯k©kÔ:Øˆ�r   ©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r+   r.   r4   rA   rJ   rN   rF   r5   rR   Ú__classcell__)r   s   @r   r   r      s8   ø„ Ù5ô'ò+ô"ôò*óò6ôò2
:ö	r   r   c                 óD  ‡— ddl m}m}m}m}  || «      }|j                  d«       t        t        | j                  «       j                  d«      dd  «      \  }}|j                  d|dz   |dz   fz  «        ||«      }|j                  ||d¬	«       |j                  d
d«       |j                  «        t        |«      Šˆfd„}	ˆfd„}
|j                  dd«       |j                  dd«       |j                  d|	«       |j                  d|
«       |j!                  «        y )Nr   )ÚToplevelÚTextr   ÚBOTHzTest call-tipsÚ+r    z250x100+%d+%dé¯   é–   )ÚsideÚfillÚexpandr   zstring.splitc                 ó,   •— ‰j                  ddd«       y )Nz(s='Hello world')r   Úend)r4   ©rK   Úcalltips    €r   Úcalltip_showz%_calltip_window.<locals>.calltip_show¹   s   ø€ Ø�‰Ð+¨X°uÕ=r   c                 ó&   •— ‰j                  «        y r`   )rF   rr   s    €r   Úcalltip_hidez%_calltip_window.<locals>.calltip_hide»   s   ø€ Ø�‰Õr   z<<calltip-show>>Ú(z<<calltip-hide>>Ú))Útkinterrg   rh   r   ri   Útitler3   r"   Úgeometryr%   r@   r   Úupdater   rX   rU   Ú	focus_set)Úparentrg   rh   r   ri   ÚtopÚxÚyr   rt   rv   rs   s              @r   Ú_calltip_windowr‚   ¬   só   ø€ ß2Ó2á
�6Ó
€CØ‡I�IÐÔÜŒs�F—O‘OÓ%×+Ñ+¨CÓ0°°Ð4Ó5�D€A€qØ‡L�L� A¨¡G¨Q°©WÐ#5Ñ5Ô6Ù�‹9€DØ‡I�I�4˜d¨1€IÔ-Ø‡K�K�˜.Ô)Ø‡J�J„Lä˜DÓ!€Gô>ôà‡N�NÐ% sÔ+Ø‡N�NÐ% sÔ+Ø‡I�IÐ  ,Ô/Ø‡I�IÐ  ,Ô/à‡N�NÕr   Ú__main__)Úmainz idlelib.idle_test.test_calltip_wr   F)Ú	verbosityÚexit)ÚrunN)rd   ry   r   r   r   r   Úidlelib.tooltipr   rY   rZ   rV   rW   rI   r2   r   r‚   ra   Úunittestr„   Úidlelib.idle_test.htestr‡   © r   r   Ú<module>rŒ      sr   ðñ÷
 1Ó 0å 'à%€
Ø/€Ø/€Ø9Ð Ø€à(€
ôV�Kô Vòrð2 ˆzÒÝÙÐ	+°q¸uÕEå+ÙˆÕð r   