%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/container.cpython-310.pyc

o

K��^5Q�@sNdZddlZddlZddlZe�d�Zdd�Zdd�Zeej	j
���D]\ZZ
e
dd	ejfvr6e
ej	ed
<q#ej	��Zded<ded<Gd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�d�ZGdd�dee�ZGdd�dee�ZGdd�de�ZeZeZGdd�dej�Zd$dd�dd �Ze�d!�ZGd"d#�d#ej�Z e ZdS)%a"Extended versions of urwid containers.

This module provides versions of urwid's Columns, Pile and ListBox
containers. It adds support for tab-cycling, callbacks on
gaining/losing focus and scrollbars on listboxes.

 1. Tab-cycling

Tab advances to the next selectable item and wraps when it gets to the
end of the screen. Shift tab goes the other way. In addition, an
unhandled "enter" key also advances to the next selectable item.

 2. Callbacks when a widget gains/loses focus

Define lost_focus or gained_focus callbacks on widgets and they'll be
called when the widget gains or loses focus.

 3. Scrollbars on ListBoxes.

All ListBoxes in subiquity gain a scrollbar when their contents don't
entirely fit on screen. The implementation assumes that there are not
too many elements in the ListBox.
�Nzsubiquitycore.ui.containercCs0|durdSt|j|d�}|dur|�dSdS�N)�getattr�base_widget)�w�methname�m�r�2/usr/share/subiquity/subiquitycore/ui/container.py�_maybe_callas
�r
cCs,t|�D]\}}||kr|��rdSqdS�NTF)�	enumerate�
selectable)�widgets�	cur_focus�irrrr	�_has_other_selectableis
�r�next selectable�prev selectable� no wrap�enterz
enter no wrapc@s8eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dS)�TabCyclingPilecCs"|jD]\}}|��rdSqdSr)�contentsr
)�selfr�_rrr	r
|s
�zTabCyclingPile.selectablecC�>t|j�D]\}\}}|��r|�|�t|d�dSqdS�z6Select first selectable child (possibily recursively).�_select_first_selectableN�rrr
�	set_focusr
�rrr�orrr	r��

��z'TabCyclingPile._select_first_selectablecC�Fttt|j���D]\}\}}|��r |�|�t|d�dSq	dS�z5Select last selectable child (possibily recursively).�_select_last_selectableN��reversed�listrrr
rr
rrrr	r$��

��z&TabCyclingPile._select_last_selectablecCsdd�|jD�S)NcSsg|]\}}|�qSrr)�.0rr rrr	�
<listcomp>�sz+TabCyclingPile._widgets.<locals>.<listcomp>)�	_contents�rrrr	�_widgets��zTabCyclingPile._widgetscCs�|js|S|}|�d�s|j|dvrt|��|j�r|d7}d}t|�dkr.|j|dd�}|j}|��rM|�	||d|�}|j
�||�}|j|dvrM|S|j|dkr�|jd	}t|j
|d�|�D]\}\}	}
|	��rz|�|�t|	d
�dSqc|�d�s�|��|S|j|dkr�|j
d|j�}ttt|���D]\}\}	}
|	��r�|�|�t|	d�dSq�|�d�s�|��|S|j|d
kr�tt|d	dd��}d}
ntt|d	t|j���}d
}
|s�|j|dd�}|D]_}|j|d��s�q�|�|�||_t|j
|
�t|j
d��sdS||}|j|d
k�r(tt|d	dd��}ntt|��}|D]}|�	||d|�}|j�||j|��rHdS�q0dS|S)zjPass the keypress to the widget in focus.
        Unhandled 'up' and 'down' keys may cause a focus change.r�rrN�T)�focus)�	cursor upzcursor downrrr�rrr$r2���r�move_cursor_to_coords)r�endswith�_command_maprr-�focus_position�len�
get_item_rowsr
�
get_item_sizer1�keypressrr+rr
rr&r'r$�range�_update_pref_col_from_focus�hasattr�
focus_itemr5�pref_col)r�size�key�downkey�	item_rowsr�tsize�upkey�next_fprr �	positions�
candidates�meth�j�rows�rowlist�rowrrr	r<�s��
 

�


�

��zTabCyclingPile.keypressN)
�__name__�
__module__�__qualname__�enter_advancing_command_mapr7r
rr$r-r<rrrr	rysrcs2eZdZ		d
�fdd�	Zdd�Zdd	�Z�ZS)�OneSelectableColumnsrNr3c	sLt��|||||�d}|jD]\}}|��r|d7}q|dkr$td��dS)Nrr3z3subiquity only supports one selectable in a Columns)�super�__init__r+r
�	Exception)	r�widget_list�dividechars�focus_column�	min_width�box_columns�selectablesrr ��	__class__rr	rV�s����zOneSelectableColumns.__init__cCrrrrrrr	rr!z-OneSelectableColumns._select_first_selectablecCr"r#r%rrrr	r$
r(z,OneSelectableColumns._select_last_selectable)rNr3N)rPrQrRrVrr$�
__classcell__rrr^r	rT�s�rTcsDeZdZeZ�fdd�Zdd�Zdd�Zdd�Z�fd	d
�Z	�Z
S)�TabCyclingListBoxcs*t|dd�dur
t�|�}t��|�dS)N�	get_focus)r�urwid�SimpleFocusListWalkerrUrV)r�bodyr^rr	rVs
zTabCyclingListBox.__init__cCs |�|�|�|�|��dSr)r�_invalidate)rrrrr	�_set_focus_no_moves

z$TabCyclingListBox._set_focus_no_movecCs:t|j�D]\}}|��r|�|�t|d�dSqdSr)rrer
rgr
�rrrrrr	r)s

��z*TabCyclingListBox._select_first_selectablecCsBttt|j���D]\}}|��r|�|�t|d�dSq	dSr#)r&r'rrer
rgr
rhrrr	r$1s

��z)TabCyclingListBox._select_last_selectablec	s@|}|�d�s|j|dvrt|j|j�r|d7}t��||�}||kr&|}t|j�dkr/|S|j|dkrf|jd}t|j|d�|�D]\}}|�	�rZ|�
|�t|d�dSqE|�d�sd|��|S|j|dkr�|jd|j�}t
tt|���D]\}}|�	�r�|�
|�t|d�dSq}|�d�s�|��|S|S)	Nrr/rrr3rrr$)r6r7rrer8rUr<r9rr
rr
rr&r'r$)	rrBrCrDrGrHrrrIr^rr	r<9sD�


�


�
zTabCyclingListBox.keypress)rPrQrRrSr7rVrgrr$r<r`rrr^r	rasracs4eZdZ�fdd�Zdd�Zdd�Zdd�Z�ZS)	�FocusTrackingMixincs$t�j|i|��|j�|j�dSr)rUrVr+�set_focus_changed_callback�_focus_changed�r�args�kwr^rr	rVaszFocusTrackingMixin.__init__cCs.z|j}Wn
tyYdSwt|d�dS�N�
lost_focus)r1�
IndexErrorr
)rrrrr	rpes
�zFocusTrackingMixin.lost_focuscC�t|jd�dS�N�gained_focus�r
r1r,rrr	rtmr.zFocusTrackingMixin.gained_focuscCsBz|j}Wn	tyYnwt|d�t||d�|��dS�Nrprt)r1rqr
rf)r�	new_focusrrrr	rkps
�
z!FocusTrackingMixin._focus_changed)rPrQrRrVrprtrkr`rrr^r	ri_s
ric@�eZdZdS)�FocusTrackingPileN�rPrQrRrrrr	ry{�ryc@rx)�FocusTrackingColumnsNrzrrrr	r|r{r|cs@eZdZ�fdd�Zdd�Zdd�Zdd�Z�fd	d
�Z�ZS)�FocusTrackingListBoxcs*t�j|i|��|j�|j�d|_dS)NF)rUrVrerjrk�_in_set_focus_completerlr^rr	rV�s
zFocusTrackingListBox.__init__cCs2|jst|jd�t|j|d�|��dSdSrv)r~r
r1rerf)rrwrrr	rk�s
�z#FocusTrackingListBox._focus_changedcCrrrorur,rrr	rp�r.zFocusTrackingListBox.lost_focuscCrrrsrur,rrr	rt�r.z!FocusTrackingListBox.gained_focuscs*d|_z
t��||�Wd|_dSd|_wr)r~rU�_set_focus_complete�rrBr1r^rr	r�sz(FocusTrackingListBox._set_focus_complete)	rPrQrRrVrkrprtrr`rrr^r	r}�sr}csdeZdZe�d�Ze�d�Ze�d�Ze�d�Zdd��fdd�
Z	d	d
�Z
dd�Zdd
d�Z�Z
S)�ScrollBarListBoxu▴u█� u▾F��
always_scrollcs`tdd|jfdd|jfdd|jfdd|jfdd|jfg�}t�|dd�|_||_t	��
|�dS)N�fixedr3�weight�	scrollbarzscrollbar focus)�Pile�top�bg�box�botrc�AttrMap�bar�_always_scrollrUrV)r�lbr��piler^rr	rV�s




�zScrollBarListBox.__init__cCs |jrdSt|j�||��dkS)NTr0)r�r9�original_widget�ends_visibler�rrr	�_scroll�szScrollBarListBox._scrollcCs2|j}|�|d�s|dd|df}|�||�S)NTrr3)r�r�r<)rrBrCr�rrr	r<�szScrollBarListBox.keypresscCs�|j}|�||�r|�||�S|\}}|�|d|f�\}}|�|d|f|�}d}	d}
}|j��\}}
|jD]}|�|df�}||urId}	n|	sO||7}|
|7}
q8d|vr[d}n|||}d|vrhd}n|
||}|jj	j
}|||kr|dd�}n|d|�}|j}|dkr�t�
|d	�}|j}|dkr�t�
|d	�}||dd�f|j|d|�f|j|f|j|d|�f||dd�fg|jj	jdd�<|�|d|f|�}|j�d|f|�}t�||jd|df|dddfg�S)
Nr3FrTr��bottom�givenr�r�)r�r��render�get_focus_offset_insetr�rerbrMr�r�optionsr�rcr�r�r�r�r�
CanvasJoinr8)rrBr1r��maxcol�maxrow�offset�inset�visible�
seen_focus�height�height_before_focus�focus_widget�	focus_pos�widgetrMr�r�r �boxopt�	top_arrow�	bot_arrow�	lb_canvas�
bar_canvasrrr	r��sX



�
�zScrollBarListBox.render)F)rPrQrRrc�	SolidFillr�r�r�r�rVr�r<r�r`rrr^r	r��s



r�Fr�cCsF|durg}|t|dd�urdurnnt�|�}tt|�|d�S)Nrbr�)rrcrdr�r})rer�rrr	�ListBox
s 
�r�z_wrapped_widget.base_widgetc@s<eZdZedd��Zedd��Zedd��Zedd��ZdS)�
OurWidgetWrapcC�
t|�jSr)�get_delegaterr,rrr	�<lambda>!�
zOurWidgetWrap.<lambda>cCr�r)r�r$r,rrr	r�#r�cCr�r)r�rpr,rrr	r�$r�cCr�r)r�rtr,rrr	r�%r�N)rPrQrR�propertyrr$rprtrrrr	r�s��r�r)!�__doc__�logging�operatorrc�	getLogger�logr
rr'�command_map�_command�itemsrC�command�ACTIVATE�copyrSr�r�ColumnsrTr�rariryr|r}�WidgetDecorationr��
attrgetterr��
WidgetWrapr�rrrr	�<module>s8&
�
|Lh


Zerion Mini Shell 1.0