Mini Shell

Direktori : /usr/lib/python3.6/site-packages/orca/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/orca/__pycache__/find.cpython-36.pyc

3

�2[3�@srdZdZdZdZdZdZddlZddlZdd	lm	Z	dd
lm
Z
ddlmZddlmZGd
d�d�Z
dd�ZdS)z(Provides support for a flat review find.z$Id$z
$Revision$z$Date$z-Copyright (c) 2005-2008 Sun Microsystems Inc.ZLGPL�N�)�debug)�flat_review)�messages)�
orca_statec@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SearchQueryz3Represents a search that the user wants to perform.cCs0d|_d|_d|_d|_d|_d|_tj|_dS)a�Creates a new SearchQuery. A searchQuery has the following
           properties:

           searchString     - the string to find
           searchBackwards  - if true, search upward for matches
           caseSensitive    - if true, case counts
           matchEntireWord  - if true, only match on the entire string
           startAtTop       - if true, begin the search from the top of
                              the window, rather than at the current
                              location
           windowWrap       - if true, when the top/bottom edge of the
                              window is reached wrap to the bottom/top
                              and continue searching
        �FN)	�searchString�searchBackwards�
caseSensitive�matchEntireWord�
windowWrap�
startAtToprZLEVEL_FINEST�
debugLevel)�self�r�/usr/lib/python3.6/find.py�__init__(szSearchQuery.__init__cCs�tj|jd�tj|jd||j|j|j|jf�tj|jdt|j��tj|jdt|j|jj	��tj|jdt|j|jj	|jj
��tj|jd�dS)z:Prints out the context and the string to find to debug.outz<------------------------------------------------------------z-findQuery: %s line=%d zone=%d word=%d char=%dzNumber of lines: %dz#Number of zones in current line: %dz#Number of words in current zone: %dz<==========================================================

N)r�printlnr�	lineIndex�	zoneIndex�	wordIndex�	charIndex�len�lines�zones�words)r�context�stringrrr�debugContextAs 
zSearchQuery.debugContextc
Cs�td�x�tdt|j��D]�}td|�x�tdt|j|j��D]t}td|�xbtdt|j|j|j��D]B}td||j|j|j|jt|j|j|j|j�f�qpWqBWqWdS)z+Debug utility which prints out the context.ZDUMPrz	  Line %dz    Zone: %dz"      Word %d = `%s` len(word): %dN)�print�rangerrrrr)rr�i�j�krrr�dumpContextVs"zSearchQuery.dumpContextc
Cs�|j}|j}|j}|j}tj|jd||||f�tj}|j	sH|tj
B}|jr^d|jd}n|j}tj
||�}	tj|jd|j|f�|jr�|jtjj�|j|d�d}
d}d}d}
�xl|�s&|jtjj�\}}}}}tj|jd|||||f�tj|	|��r|
�r�x|�s|jtjj�\}}}}}tj|jd|||f�tj|jd	||f�tj|	|��r�|j|jj|j}||jk�o�||jk}y|jj�WnYn�Xtj|	|�}g}x|D]}|j|jd
���q�W|j�r�|j �d
}x�|�r�|t!|�k�r�|j"||�\}}|�r�|j#|j}|j�rB|d
k�sV|j�rj|d
k�rj|j#|_d
|_d}n$|�r�|�s�|�r�d}n|d7}nP�q�W|�s|j�r�|j$tjjtjj%�}|j|d
�|j&tjj�|j|d�n |j'tjjtjj%�}|j|d�|�sd}
P�qWq�|j�r@|j$tjjtjj%�}|j|d�n |j'tjjtjj%�}|j|d�|�r�|j�r$|j&tjj�}|j|d�q�|j(�r"|�r"t)j*}d}
d}|j�r�|j+t,j-�|j$tjjtjj.�}|j|d�n,|j+t,j/�|j'tjjtjj.�}|j|d�|�s$tj|jd�Pq�Pq�W|�r8t0j0|�}
|j|d�|j1||||�|j|d�|
�r�tj|jd|
j|
j|
j|
jf�|
S)a9Performs a search on the string specified in searchQuery.

           Arguments:
           - context: The context from active script
           - justEnteredFlatReview: If true, we began the search in focus
             tracking mode.

           Returns:
           - The context of the match, if found
        z;findQuery: original context line=%d zone=%d word=%d char=%dz\bz'findQuery: startAtTop: %d  regexp: `%s`zgo beginNFz9findQuery: current line=`%s` x=%d y=%d width=%d height=%dz'findQuery: current zone=`%s` x=%d y=%d zwidth=%d height=%drTrz[1] go previousz
[1] go endz[1] go nextz[2] go previousz[2] go nextz
[2] go endz[3] go previousz[3] go nextzfindQuery: cannot wrapzbefore setting originalzafter setting originalz4findQuery: returning line=%d zone=%d word=%d char=%d)2rrrrrrr�re�LOCALEr�
IGNORECASErr	�compilerZgoBeginrZContextZWINDOWrZ
getCurrentZLINE�searchZZONErrZ
accessibleZ	queryText�finditer�append�startr
�reverserZgetWordAtOffset�indexZ
goPreviousZ	WRAP_LINEZgoEndZgoNextr
rZactiveScriptZpresentMessagerZWRAPPING_TO_BOTTOMZWRAP_ALLZWRAPPING_TO_TOP�copyZ
setCurrent)rrZjustEnteredFlatReviewZoriginalLineIndexZoriginalZoneIndexZoriginalWordIndexZoriginalCharIndex�flagsZregexp�pattern�location�foundZ
wrappedYetZdoneWithLineZcurrentLine�x�y�widthZheightZcurrentZoneZtheZoneZstartedInThisZoneZ
allMatchesZoffsets�mr"ZnextInstance�offsetZ
offsetDiffZmovedZscriptrrr�	findQuerybs


















zSearchQuery.findQueryN)�__name__�
__module__�__qualname__�__doc__rrr%r:rrrrr%s
rcCstjtj�}|S)z�Grabs the last search query performed from orca_state.

       Returns:
       - A copy of the last search query, if it exists
    )r0rZsearchQuery)Z	lastQueryrrr�getLastQuery!sr?)r>Z__id__�__version__Z__date__Z
__copyright__Z__license__r0r&rrrrrrr?rrrr�<module>s}