← Back
Editing: tokenutil.cpython-311.pyc
� �@�cX � �h � d Z ddlmZ ddlmZ ddlmZ ddlZ edg d�� � Zd� Z dd �Z dd �ZdS )zToken-related utilities� )� namedtuple)�StringIO)� iskeywordN�Token)�token�text�start�end�linec # �n K � t j | � � D ]}|V � �dS # t j $ r Y dS w xY w)z(wrap generate_tokens to catch EOF errorsN)�tokenize�generate_tokens� TokenError)�readliner s �9/usr/lib/python3/dist-packages/IPython/utils/tokenutil.pyr r s_ � � � ���-�h�7�7� � �E��K�K�K�K� � ���� � � �������s �! �4�4c � � d}| � d� � }|D ]8}|t |� � z }|� d� � s|dz }||k r n|}�9d}||fS )a� Return the line in a cell at a given cursor position Used for calling line-based APIs that don't support multi-line input, yet. Parameters ---------- cell : str multiline block of text cursor_pos : integer the cursor position Returns ------- (line, offset): (string, integer) The line with the current cursor, and the character offset of the start of the line. r T� � � )� splitlines�len�endswith)�cell� cursor_pos�offset�linesr �next_offsets r �line_at_cursorr s � �"