Current Dir: /snap/core22/2955/usr/lib/python3/dist-packages/urwid/__pycache__/

[FILE] canvas.cpython-310.pyc [ edit | delete | rename ]
[FILE] command_map.cpython-310.pyc [ edit | delete | rename ]
[FILE] compat.cpython-310.pyc [ edit | delete | rename ]
[FILE] container.cpython-310.pyc [ edit | delete | rename ]
[FILE] curses_display.cpython-310.pyc [ edit | delete | rename ]
[FILE] decoration.cpython-310.pyc [ edit | delete | rename ]
[FILE] display_common.cpython-310.pyc [ edit | delete | rename ]
[FILE] escape.cpython-310.pyc [ edit | delete | rename ]
[FILE] font.cpython-310.pyc [ edit | delete | rename ]
[FILE] graphics.cpython-310.pyc [ edit | delete | rename ]
[FILE] html_fragment.cpython-310.pyc [ edit | delete | rename ]
[FILE] lcd_display.cpython-310.pyc [ edit | delete | rename ]
[FILE] listbox.cpython-310.pyc [ edit | delete | rename ]
[FILE] main_loop.cpython-310.pyc [ edit | delete | rename ]
[FILE] monitored_list.cpython-310.pyc [ edit | delete | rename ]
[FILE] numedit.cpython-310.pyc [ edit | delete | rename ]
[FILE] old_str_util.cpython-310.pyc [ edit | delete | rename ]
[FILE] raw_display.cpython-310.pyc [ edit | delete | rename ]
[FILE] signals.cpython-310.pyc [ edit | delete | rename ]
[FILE] split_repr.cpython-310.pyc [ edit | delete | rename ]
[FILE] text_layout.cpython-310.pyc [ edit | delete | rename ]
[FILE] treetools.cpython-310.pyc [ edit | delete | rename ]
[FILE] util.cpython-310.pyc [ edit | delete | rename ]
[FILE] version.cpython-310.pyc [ edit | delete | rename ]
[FILE] vterm.cpython-310.pyc [ edit | delete | rename ]
[FILE] web_display.cpython-310.pyc [ edit | delete | rename ]
[FILE] widget.cpython-310.pyc [ edit | delete | rename ]
[FILE] wimp.cpython-310.pyc [ edit | delete | rename ]
[FILE] _async_kw_event_loop.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2955/usr/lib/python3/dist-packages/urwid/__pycache__/old_str_util.cpython-310.pyc

o

��o_O'�@s�ddlmZmZddlZddlmZmZmZmZe�	d�Z
e�	ed��Zdagd�a
dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zed krge�dSdS)!�)�division�print_functionN)�bytes�B�ord2�	text_typez^[ -~]*$)&)�~�)�r)i�r	)i�r)i�r	)i�r)i�r	)ior)i�r	)i�r)i�r	)i_�)i+r	)iar)i� r	)i� r)i(#r	)i*#r)i
+r	)i>0r)i?0r	)i�0r)i�0r)i�Mr)i�Mr	)i��r)i��r	)ij�r)i�r	)i#�r)ik�r)i��r	)i`�r)i�r	)i�r)i��r	)i��r)i��r	cCs6|dks|dkr
dStD]\}}||kr|SqdS)z5Return the screen column width for unicode ordinal o.��rr	)�widths)�o�num�wid�r�4/usr/lib/python3/dist-packages/urwid/old_str_util.py�	get_widthQs�rc	Cst|t�s	J|��t||�}|d@s||dfStd�|df}t|�}||}|dkr/|S|d@dkr[t||d�}|d@dkrE|S|d@d>|d	@B}|dkrU|S||dfS|d
kra|S|d@dkr�t||d�}|d@dkrw|St||d�}|d@dkr�|S|d@d
>|d	@d>B|d	@B}|dkr�|S||d
fS|dkr�|S|d@dk�rt||d�}|d@dkr�|St||d�}|d@dkr�|St||d�}|d@dkr�|S|d@d>|d	@d
>B|d	@d>B|d	@B}|dkr�|S||dfS|S)zH
    Return (ordinal at pos, next position) for UTF-8 encoded text.
    �r	�?r������?���r
�i����i)�
isinstancerr�ord�len)	�text�pos�b1�error�lt�b2r�b3�b4rrr�
decode_one[s^ ,r.cCst||�|dfS)z7
    decode_one implementation for unicode strings
    r	)r$)r&�irrr�decode_one_uni�sr0cCs�t|t�s	J|��td�|df}|}|dkr@t||�d@dkr.t||�\}}||dfS|d8}||dkr:|S|dksdSdS)z�
    Return (ordinal at pos, next position) for UTF-8 encoded text.
    pos is assumed to be on the trailing byte of a utf-8 sequence.
    rr	rrrrN)r#rr$rr.)r&r'r)�pr�nextrrr�decode_one_right�s�r3cCs|dvsJ�|adS)N)�utf8�narrow�wide��_byte_encoding)�encrrr�set_byte_encoding�sr:cCstS)Nr7rrrr�get_byte_encoding�sr;cCs||ksJt||f���t|t�otdk}t|t�}|s|rRttg|}|}d}d}	||krN|||�\}
}	t|
�}|||krD||fS|	}||7}||ks/||fSt|�tks^Jt|���||}||krl|||fStdkr|t|||�dkr||d8}|||fS)a9
    Calculate the closest position to the screen column pref_col in text
    where start_offs is the offset into text assumed to be screen column 0
    and end_offs is the end of the range to search.

    text may be unicode or a byte string in the target _byte_encoding

    Returns (position, actual_col).
    r4rr	r6r)	�reprr#rr8r.r0r�type�within_double_byte)r&�
start_offs�end_offs�pref_col�utfs�unis�decoder/�sc�nr�wrrr�
calc_text_pos�s2
�rHcCs�||ksJt||f���t|t�otdk}t|t�}|r"t�|�r)|rPt�|�sPttg|}|}d}d}||krN|||�\}	}t	|	�}
|}||
7}||ks9|S||S)am
    Return the screen column width of text between start_offs and end_offs.

    text may be unicode or a byte string in the target _byte_encoding

    Some characters are wide (take two columns) and others affect the
    previous character (take zero columns).  Use the widths table above
    to calculate the screen column width of text[start_offs:end_offs]
    r4rr	)
r<r#rr8�
SAFE_ASCII_RE�match�SAFE_ASCII_BYTES_REr.r0r)r&r?r@rBrCrDr/rErFrrGrrr�
calc_width�s(���rLcCsnt|t�rt||�}t|�dkSt|t�sJ�tdkr)t||�\}}t|�dkStdkr5t|||�dkSdS)z�
    Test if the character at offs within text is wide.

    text may be unicode or a byte string in the target _byte_encoding
    rr4r6r	F)r#rr$rrr8r.r>)r&�offsrrFrrr�is_wide_char�s
rNcCs�||ksJ�t|t�r|dSt|t�sJ�tdkr8|d}t||�d@dkr6|d8}t||�d@dks(|StdkrJt|||d�dkrJ|dS|dS)z?
    Return the position of the character before end_offs.
    r	r4rrr6r�r#rrr8rr>�r&r?r@rrrr�move_prev_chars"
���rQcCs�||ksJ�t|t�r|dSt|t�sJ�tdkr@|d}||kr>t||�d@dkr>|d7}||kr>t||�d@dks,|StdkrPt|||�dkrP|dS|dS)z@
    Return the position of the character after start_offs.
    r	r4rrr6rrOrPrrr�move_next_chars"
���rRcCs�t|t�sJ�t||�}|dkr3|dkr3||krdSt||d�dkr1t|||d�dkr1dSdS|dkr9dS|d}||krRt||�dkrJn|d8}||ksA||d@rZdSdS)ajReturn whether pos is within a double-byte encoded character.

    text -- byte string in question
    line_start -- offset of beginning of line (< pos)
    pos -- offset in question

    Return values:
    0 -- not within dbe char, or double_byte_encoding == False
    1 -- pos is on the 1st half of a dbe char
    2 -- pos is on the 2nd half of a dbe char
    �@�rr	�rr)r#rrr>)r&�
line_startr'�vr/rrrr>$s$�r>cCs ddl}g}d}|j��D]h}|dd�dkrq
|��}|�dd�\}}|�dd�\}}|�dd�d}d|vr?|�d�d}t|d	�}|d
vrKd}	n	|dvrRd}	nd}	|dura|�d|	f�|	}||	krl||	f|d
<q
|�||	f�|	}q
td�|dd�D]	}
td|
f�q�td�dS)Nrr	�#�;z # � �.z..�)�	COMBINING�MODIFIERz	<control>)�W�Fr���z
widths = [z	%r,�])�sys�stdin�	readlines�strip�split�int�append�print)rc�out�last�line�hex�restr�word1r�lrrrr�process_east_asian_widthJs8
rr�__main__)�
__future__rr�re�urwid.compatrrrr�compilerIrKr8rrr.r0r3r:r;rHrLrNrQrRr>rr�__name__rrrr�<module>s.
+
4$&%
�
Upload File: