Mini Shell

Direktori : /proc/self/root/lib/python3.6/site-packages/orca/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/orca/__pycache__/flat_review.cpython-36.pyc

3

�p5[���@s�dZdZdZdZdZdZddlZddlZdd	lm	Z	dd
lm
Z
ddlmZddlmZdd
lm
Z
ddlmZdZGdd�d�ZGdd�d�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd�d�ZdS) z=Provides the default implementation for flat review for Orca.z$Id$z
$Revision$z$Date$zLCopyright (c) 2005-2008 Sun Microsystems Inc.Copyright (c) 2016 Igalia, S.L.ZLGPL�N�)�braille)�debug)�eventsynthesizer)�messages)�
orca_state)�settingsuc@seZdZdZdd�ZdS)�Charz/A character's worth of presentable information.c		Cs>||_||_||_|d|_||_||_||_||_||_dS)aCreates a new char.

        Arguments:
        - word: the Word instance this belongs to
        - startOffset: the start offset with respect to the accessible
        - string: the actual char
        - x, y, width, height: the extents of this Char on the screen
        rN)	�word�index�startOffset�	endOffset�string�x�y�width�height)	�selfr
rrrrrrr�r�!/usr/lib/python3.6/flat_review.py�__init__-s

z
Char.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr	*sr	cs0eZdZdZdd�Z�fdd�Zdd�Z�ZS)�Wordz;A single chunk (word or object) of presentable information.c		CsT||_||_||_||_t|�|_|jt|�|_||_||_||_	||_
g|_dS)aGCreates a new Word.

        Arguments:
        - zone: the Zone instance this belongs to
        - index: the index of this Word in the Zone
        - startOffset: the start offset with respect to the accessible
        - string: the actual string
        - x, y, width, height: the extents of this Word on the screen
        N)�zonerrr�len�lengthr
rrrr�chars)	rrrrrrrrrrrrrEs
z
Word.__init__c
s�|dkrt�j|�S|j|j|j|jf}y|jjj�}Wnd}YnXg}xRt	|j
�D]D\}}||j}|r�|j||dt
j�}|jt||||f|���qZW|S)Nrr)�super�__getattribute__rrrrr�
accessible�	queryText�	enumeraterr�getRangeExtents�pyatspi�DESKTOP_COORDS�appendr	)r�attr�extents�textr�i�char�start)�	__class__rrr!\s

zWord.__getattribute__cCs4|j|ko |jt|j�knr0||jSdS)z8Returns the char offset with respect to this word or -1.r���)rrr)r�offsetrrr�getRelativeOffsetrs&
zWord.getRelativeOffset)rrrrrr!r2�
__classcell__rr)r/rrBsrcsjeZdZdZejdej�Zddd�Z�fdd�Z	dd	�Z
ddd�Zd
d�Zdd�Z
dd�Zdd�Z�ZS)�Zonez>Represents text that is a portion of a single horizontal line.z(\S+\s*)NcCsL||_d|_||_t|�|_||_||_||_||_|p>|j	�|_
g|_dS)aCreates a new Zone.

        Arguments:
        - accessible: the Accessible associated with this Zone
        - string: the string being displayed for this Zone
        - extents: x, y, width, height in screen coordinates
        - role: Role to override accessible's role.
        rN)r"r�_stringrrrrrr�getRole�role�_words)rr"rrrrrr7rrrr�s

z
Zone.__init__cs�|dkrt�j|�S|dkr"|jS|j�s0|jS|j|j|j|jf}g}xBt	t
j|j|j��D]*\}}|j
t|||j�|j�f|���q^W||_|S)z To ensure we update the content.�wordsr)r9r)r r!r5�_shouldFakeTextr8rrrrr$�re�finditer�WORDS_REr(rr.�group)rr)r*r9r,r
)r/rrr!�s&zZone.__getattribute__cCs6tjtjtjtjtjtjtjtjg}|j	|kr2dSdS)z8Returns True if we should try to fake the text interfaceTF)
r&�
ROLE_LABEL�	ROLE_MENUZROLE_MENU_ITEM�ROLE_CHECK_MENU_ITEM�ROLE_RADIO_MENU_ITEMZ
ROLE_PAGE_TABZROLE_PUSH_BUTTON�ROLE_TABLE_CELLr7)rZ	textRolesrrrr:�s
zZone._shouldFakeText�cCs�|jdkr8|jdkr8|j|jko2|j|jkSS|jdkrp|jdkrp|j|jkoj|j|jkSSt|j|j|j|j�}t|j|j�}||kr�dS|j|jd}|j|jd}t||�|kr�dSdS)zAReturns True if this Zone is physically on the same line as zone.rF�T)rrr�min�max�abs)rrZ
pixelDeltaZ
highestBottomZ	lowestTopZmiddleZ
zoneMiddlerrr�_extentsAreOnSameLine�s$$zZone._extentsAreOnSameLinec	Csptj|j|jgkr|j|jkSy|jjj�}|jjj�}WnYn Xtj||gkrf|jj|jjkS|j|�S)zAReturns True if we treat this Zone and zone as being on one line.)r&�ROLE_SCROLL_BARr7r"�parentr6Z
ROLE_MENU_BARrI)rrZthisParentRoleZzoneParentRolerrr�
onSameLine�szZone.onSameLinecCs.x(|jD]}|j|�}|dkr||fSqWdS)Nrrr0)Nr0)r9r2)rZ
charOffsetr
r1rrr�getWordAtOffset�s

zZone.getWordAtOffsetcCsdS)z-Returns True if this Zone contains the caret.Fr)rrrr�hasCaret�sz
Zone.hasCaretcCsdS)z4Returns the Word and relative offset with the caret.Nrr0)Nr0r)rrrr�
wordWithCaret�szZone.wordWithCaret)N)rD)rrrrr;�compile�UNICODEr=rr!r:rIrLrMrNrOr3rr)r/rr4{s

r4cs>eZdZdZd�fdd�	Z�fdd�Zdd�Zd	d
�Z�ZS)�TextZonez5A Zone whose purpose is to display text of an object.Nc		s>t�j|||||||�||_|jt|�|_|jj�|_dS)N)r rrrr
r"r#�_itext)	rr"rrrrrrr7)r/rrr�szTextZone.__init__c	s�|dkrt�j|�S�jj�j�j�}g}xhttj�j	|��D]R\}}t
�fdd�|j��\}}�jj||t
j�}|jt�|||j�f|���q>W|�_|�_t�j|�S)z To ensure we update the content.r9rcs
|�jS)N)r)r)rrr�<lambda>sz+TextZone.__getattribute__.<locals>.<lambda>)r9r)r r!rS�getTextrr
r$r;r<r=�map�spanr%r&r'r(rr>r5r8)	rr)rr9r,r
r.�endr*)r/)rrr!�s"zTextZone.__getattribute__cCs6|jj}|j|ko|jknr(dS|j|jjkS)z-Returns True if this Zone contains the caret.T)rS�caretOffsetrr
�characterCount)rr1rrrrNszTextZone.hasCaretcCs|j�sdS|j|jj�S)z4Returns the Word and relative offset with the caret.Nrr0)Nr0)rNrMrSrY)rrrrrOszTextZone.wordWithCaret)N)	rrrrrr!rNrOr3rr)r/rrR�s
	rRcs.eZdZdZd�fdd�	Z�fdd�Z�ZS)�	StateZonez:A Zone whose purpose is to display the state of an object.Ncst�j|d|||||�dS)N�)r r)rr"rrrrr7)r/rrr%szStateZone.__init__csP|dkrt�j|�S|dkr&tjj}ntjj}|j|j|jd�}|rL|dSdS)zTo ensure we update the state.r�
brailleString)r7rr\)rr])	r r!r�activeScript�speechGenerator�brailleGeneratorZgetStateIndicatorr"r7)rr)�	generator�result)r/rrr!(s
zStateZone.__getattribute__)N)rrrrrr!r3rr)r/rr["sr[cs.eZdZdZd�fdd�	Z�fdd�Z�ZS)�	ValueZonez:A Zone whose purpose is to display the value of an object.Ncst�j|d|||||�dS)Nr\)r r)rr"rrrrr7)r/rrr=szValueZone.__init__csf|dkrt�j|�S|dkr&tjj}ntjj}d}|j|j�}|j|j�}|rb|rbd||df}|S)zTo ensure we update the value.rr]r\z%s %sr)rr])	r r!rr^r_r`ZgetLocalizedRoleNamer"ZgetValue)rr)rarbZrolename�value)r/rrr!@s
zValueZone.__getattribute__)N)rrrrrr!r3rr)r/rrc:srccs0eZdZdZdd�Z�fdd�Zdd�Z�ZS)�LinezAA Line is a single line across a window and is composed of Zones.cCs||_||_d|_dS)z�Creates a new Line, which is a horizontal region of text.

        Arguments:
        - index: the index of this Line in the window
        - zones: the Zones that make up this line
        N)r�zones�brailleRegions)rrrfrrrrZs	z
Line.__init__cs�|dkrdjdd�|jD��S|dkr:tdd�|jD��S|dkrVtdd�|jD��S|d	krrtd
d�|jD��S|dkr�tdd�|jD��St�j|�S)
Nr� cSsg|]
}|j�qSr)r)�.0rrrr�
<listcomp>isz)Line.__getattribute__.<locals>.<listcomp>rcSsg|]
}|j�qSr)r)rirrrrrjlsrcSsg|]
}|j�qSr)r)rirrrrrjosrcSsg|]
}|j�qSr)r)rirrrrrjrsrcSsg|]
}|j�qSr)r)rirrrrrjus)�joinrfrF�sumrGr r!)rr))r/rrr!gszLine.__getattribute__cCs`ds|j�rZg|_d}x�|jD]�}t|t�rz|jj�tjtjtj	fksb|jj�tj
tjtjfkrzt
j|j|j|j|�}n0y
|j}Wn|j}YnXt
j|j|d|�}t|j�r�t
jd�}||_|jj|�|d7}||_||_|jj|�|j}|t|�7}q Wtj�sZt|j��r>t
jd�}||_|jj|�|d7}t
jd�}||_|jj|�|jS)NTrrhrz$l)rgrf�
isinstancerRr"r6r&Z	ROLE_TEXTZROLE_PASSWORD_TEXTZ
ROLE_TERMINALZROLE_PARAGRAPHZROLE_HEADINGZ	ROLE_LINKrZ
ReviewTextrrr]ZReviewComponentrZRegion�
brailleOffsetr(�
brailleRegionrZdisableBrailleEOL)rrnrZregionr]ZpadZregionStringZeolrrr�getBrailleRegionsysZ







zLine.getBrailleRegions)rrrrrr!rpr3rr)r/rreWs
rec@seZdZdZdZdZdZdZdZdZ	d3Z
d4Ze
eBZdd�Z
d	d
�Zdd�Zd
d�Zdd�Zd5dd�Zdd�Zefdd�Zdd�Zdd�Zdd�Zd6dd�Zd d!�Zd"d#�Zd$d%�Zefd&d'�Zefd(d)�Zeed*fd+d,�Zeed*fd-d.�Zeefd/d0�Z eefd1d2�Z!dS)7�ContextzBContains the flat review regions for the current top-level object.rrrE��c
s�||_g|_g|_d|_d|_d|_d|_d|_d|_d|_	t
j|_|j
j|j�|_d|_y|jj�}|jtj�|_Wn&d|j}tjtj|d�YnXtjg��fdd�}tj|j|�}|r�||j�r�|j}|p�|j|_	|j|j	�\|_|_|j|j�|_|j�o|j�sdSx`t|j�D]R\}}|j|jk�r$||_|jj|j�|_|jj�\}}	|�rr|j|_|	|_P�q$Wd|j|j|j|jf}tjtj|d�dS)	z Create a new Context for script.rNz&ERROR: Exception getting extents of %sTcs|o|j��kS)N)r6)r)�containerRolesrrrT�sz"Context.__init__.<locals>.<lambda>z2FLAT REVIEW: On line %i, zone %i, word %i, char %i)rrrr)�scriptrf�lines�	lineIndex�	zoneIndex�	wordIndex�	charIndex�targetCharInfo�	focusZone�	containerrZlocusOfFocus�focusObj�	utilitiesZtopLevelObjectZtopLevel�bounds�queryComponent�
getExtentsr&r'r�println�
LEVEL_INFOr@ZfindAncestor�getShowingZones�clusterZonesByLiner$rrO)
rru�	component�msgZisContainerr}r,�liner
r1r)rtrr�sR

zContext.__init__cCs
d}g}|j�}|}|}	d}
|}x�tdt|�d�D]�}|t|�krZ||tkrZ|	d7}	q4|	|krx|d7}|}	|d}
q4|j||	d�}
|jjj|
|�r4d}|jjj|
|�}||
|�}|j	t
||||d|d|d|d��|	d}|}	|d}
q4W|�r|SdSdS)aTTraverses the string, splitting it up into separate zones if the
        string contains the EMBEDDED_OBJECT_CHARACTER, which is used by apps
        such as Firefox to handle containment of things such as links in
        paragraphs.

        Arguments:
        - accessible: the accessible
        - string: a substring from the accessible's text specialization
        - startOffset: the starting character offset of the string
        - cliprect: the extents that the Zones must fit inside.

        Returns a list of Zones for the visible text or None if nothing is
        visible.
        FrrTrErrN)r#�ranger�EMBEDDED_OBJECT_CHARACTERr%rurZcontainsRegion�intersectionr(rR)rr"rr�cliprectZ
anyVisiblerfr+ZsubstringStartOffsetZsubstringEndOffsetZunicodeStartOffsetZ
unicodeStringr,r*ZclippingZ	substringrrr�splitTextIntoZones�sD


zContext.splitTextIntoZonescCs�y|j�}Wntk
r gSXg}tjd|jdd
��s>gSdtj|�kr�|j�jtj	�r�|j
�jd�}t|d|jdd�f|��gSt
jt
jd�d}d}|j}}	t|d�}
}d}}
d}}d}xZ||
k�r$|
}|j|
|
dd�\}}}}|}||jk�r
|
}n|
}t||d�|}
q�Wd}|j|j}xZ||k�r�|}|j||dd�\}}}}|}||k�rt|}	n|}
t|	|
d�|
}�q8W|}|	}�x||k�r�|j|tj�\}}}t
jt
jd||||f�|dk�s|dk�s||k�s||k�s||k�st||�dk�r@t
jt
jd	|j|j�||||f�P||k�rft|d|d�}|}�q�n|}|}|j||||�}|�r�|j|�nt|��r�P�q�W|S)
aGets a list of Zones from an object that implements the
        AccessibleText specialization.

        Arguments:
        - accessible: the accessible
        - cliprect: the extents that the Zones must fit inside.

        Returns a list of Zones.
        u[^]rrZEditableTextz  looking at text:rEz)    line at %d is (start=%d end=%d): '%s'g S$Az�flat_review:getZonesFromText detected garbage from getTextAtOffset for accessible name='%s' role'='%s': offset used=%d, start/end offset returned=(%d,%d), string='%s'r0r0r0)r#�NotImplementedErrorr;�searchrUr&ZlistInterfacesZgetState�containsZSTATE_SINGLE_LINEr�r�rRrr�ZLEVEL_FINESTrZ�intr%rrZgetTextAtOffsetZTEXT_BOUNDARY_LINE_STARTrHZ
LEVEL_WARNING�name�getRoleNamerGr��extendr)rr"r�r+rfr*r1Z
lastEndOffsetZupperMaxZlowerMaxZupperMidZlowerMidZupperMinZlowerMinZupperYZlowerYZoldMidrrrr�limitrrrr
Z	textZonesrrr�getZonesFromTextPs�










zContext.getZonesFromTextcCs@|j|jd|jg}|j�}|tjkrLt|f|�d|i�}|rH|jd|�dS|tjkrj|j	j
j|�rjtj}|tjtj
tjtjgkr�dSd}d}t|�dko�t|dt��r|d}|j|j}	|j|j|j|j}
|	dk}|r�|	|d<n|j|j|d<|
|d<t|f|�d|i�}|�r<|�r2|jd|�n
|j|�dS)z�If the accessible presents non-textual state, such as a
        checkbox or radio button, insert a StateZone representing
        that state.rr7rNT�rE)rrrr6r&ZROLE_TOGGLE_BUTTONr[�insertrCrurZhasMeaningfulToggleActionZROLE_CHECK_BOXrAZROLE_RADIO_BUTTONrBrrmrRrr()rrfr"r*ZindicatorExtentsr7rZstateOnLeftZtextZoneZtextToLeftEdgeZtextToRightEdgerrr�_insertStateZone�s>



zContext._insertStateZonec	Cs�y|j�}|jtj�}Wn
gSy|j�}Wn
gS|j||�}|rx|tjtjtjgkrx|j	t
|f|���nT|s�|jjj
|�}tjtjg}|r�||kr�|jjj|�}|r�|j	t||f|���|j|||�|S)z1Returns a list of Zones for the given accessible.)r�r�r&r'r6r�rJZROLE_SLIDERZROLE_PROGRESS_BARr(rcrur_ZgetNamerCr?r�r4r�)	rr"r�r�r*r7rfrZuselessrrr�getZonesFromAccessibles.
zContext.getZonesFromAccessibleNc	Cs�|dkr|j}|jjj||�}dt|�|f}tjtj|d�gd}}xd|D]\}|j||�}|sdqN|j	|�|rN|rN||j
ks�||j
krNttdd�|��p�|}|d}qNWdt|�|f}tjtj|d�||fS)zGReturns an unsorted list of all the zones under root and the focusZone.Nz.FLAT REVIEW: %i on-screen objects found for %sTcSs|j�S)N)rN)�zrrrrT8sz)Context.getShowingZones.<locals>.<lambda>rz"FLAT REVIEW: %i zones found for %s)
r�rurZgetOnScreenObjectsrrr�r�r�r�r~�list�filter)	r�rootZboundingboxZobjsr�ZallZonesr|�orfrrrr�&s"


zContext.getShowingZonescCs�|sgSg}t|dd�d�}|jd�g}xB|D]:}|j|d
�rL|j|�q.|jt|dd�d��|g}q.W|r�|jt|dd�d��g}xJt|�D]>\}}|jt||��x$t|�D]\}	}|||_|	|_q�Wq�Wdt|�}
t	j
t	j|
d	�|S)z?Returns a sorted list of Line clusters containing sorted Zones.cSs|jS)N)r)r�rrrrTFsz,Context.clusterZonesByLine.<locals>.<lambda>)�keyrrcSs|jS)N)r)r�rrrrTLscSs|jS)N)r)r�rrrrTPsz*FLAT REVIEW: Zones clustered into %i linesTr0)�sorted�poprLr(r$rer�rrrr�r�)rrfZlineClustersZsortedZonesZ
newClusterrrvrwZlineClusterrxr�rrrr�?s*


zContext.clusterZonesByLinecCsl|j�}|sdS|}|tjkr&|j}n.|jrT|j|j}|tjkrT|jrT|j|j}|j	|j
|j|j|j
fS)z;Returns the current string, offset, and extent information.Nrr0r0r0r0)Nr0r0r0r0)�_getCurrentZonerq�LINEr�r9ry�CHARrrzrrrrr)r�flatReviewTyperZcurrentrrr�
getCurrent]s
zContext.getCurrentcCs*||_||_||_||_|jtj�|_dS)a=Sets the current character of interest.

        Arguments:
        - lineIndex: index into lines
        - zoneIndex: index into lines[lineIndex].zones
        - wordIndex: index into lines[lineIndex].zones[zoneIndex].words
        - charIndex: index lines[lineIndex].zones[zoneIndex].words[wordIndex].chars
        N)rwrxryrzr�rqr�r{)rrwrxryrzrrr�
setCurrentqs

zContext.setCurrentcCs\|jtj�\}}}}}|dkr*|dkr*dStt|||dd��}t||d�}||fS)NrrrEr0r0)r0r0)r�rqr�r�rG)rrrrrrrrr�_getClickPoint�szContext._getClickPointcCs2|j�\}}|dks|dkr dStj||d�dS)z3Routes the mouse pointer to the current accessible.rFrHT)r�rZrouteToPoint)rrrrrr�routeToCurrent�s
zContext.routeToCurrentcCs2|j�\}}|dks|dkr dStj|||�dS)z1Performs a mouse click on the current accessible.rFT)r�rZ
clickPoint)rZbuttonrrrrr�clickCurrent�s
zContext.clickCurrentcCsj|jo$d|jko t|j�kns*dS|j|j}|oXd|jkoTt|j�kns^dS|j|jS)Nr)rvrwrrxrf)rr�rrrr��s&$zContext._getCurrentZonecCs|j�}|sdS|jS)zReturns the current accessible.N)r�r")rrrrr�getCurrentAccessible�szContext.getCurrentAccessiblecCs�|js|j|jjr ddgSd}|j|j}|j�}xv|jD]l}|j|jkr@|j}d|_|jr�x.t	d|j
�D]}|jt|j|j�7_qpW|j|j
7_|j�Pq@W||gS)zbGets the braille for the entire current line.

        Returns [regions, regionWithFocus]
        Nr)rvrwrfrprrxroZcursorOffsetr9r�ryrrrzZrepositionCursor)rZregionWithFocusr�Zregionsrryrrr�getCurrentBrailleRegions�s$z Context.getCurrentBrailleRegionscCs�|tjks|tjkr|j}n|tjkr,d}ntd|��|tjkrJ|j}nd}d}d}|j|kp||j|kp||j|kp||j|k}|r�||_||_||_||_|j	tj
�|_|S)z�Moves this context's locus of interest to the first char
        of the first relevant zone.

        Arguments:
        - flatReviewType: one of ZONE, LINE or WINDOW

        Returns True if the locus of interest actually changed.
        rzInvalid type: %d)rqr��ZONErw�WINDOW�	Exceptionrxryrzr�r�r{)rr�rwrxryrz�movedrrr�goBegin�s*






zContext.goBeginc	Cs|tjks|tjkr|j}n&|tjkr6t|j�d}ntd|��|tjkrT|j}nt|j|j	�d}|j|j	|}|j
r�t|j
�d}|j
|j}|r�t|�d}q�d}nd}d}|j|kp�|j|kp�|j|kp�|j
|k}|�r||_||_||_||_
|jtj�|_|S)z�Moves this context's locus of interest to the last char
        of the last relevant zone.

        Arguments:
        - flatReviewType: one of ZONE, LINE, or WINDOW

        Returns True if the locus of interest actually changed.
        rzInvalid type: %dr)rqr�r�rwr�rrvr�rxrfr9rryrzr�r�r{)	rr�rwrxrryrrzr�rrr�goEnd�s8






z
Context.goEndTcCs|jstjtjd�dSd}|tjkr�|jdkrP|jd8_d|_d|_d}n�|tj	@r�|j
dkr�|j
d8_
t|j|j
j�d|_d|_d|_d}nB|tj
@r�t|j�d|_
t|j|j
j�d|_d|_d|_d}�n|tjk�rf|jdk�r|jd8_d}nT|jtj|d�}|�r�|j|j
j|j}|j�r�|j|jj}|�r�t|�d|_�n�|tjk�rN|j|j
j|j}|j}|j
}|j}	|j}
|j}|jdk�r�|jd8_d|_d}n@|jtj|�}|�r
|j|j
j|j}|j�r
t|j�d|_|j|j
j|j}|�r.|�r.t|j�dk�sZt|j��r.|j|jjj��r.d}|j
dk�r�t|t��r�|j|j
djd}
|
j|jk�r�d}|j|k�s�|�r�|jtj|�}nn|jd}
xR|
dk�r|j|
j�st|j|
j��s|j|
jj��r|
d8}
nP�q�W|
dk�r.|
|_|�s�||_
|	|_|
|_||_n�|tjk�r�|tj	@�r�|j
dk�r�|j
d8_
d|_d|_d|_d}nB|tj
@�r�t|j�dk�r�t|j�d|_
d|_d|_d|_d}ntd|��|�r|tjk�r|jtj�|_|S)aiMoves this context's locus of interest to the first char
        of the previous type.

        Arguments:
        - flatReviewType: one of ZONE, CHAR, WORD, LINE
        - wrap: if True, will cross boundaries, including top and
                bottom; if False, will stop on boundaries.

        Returns True if the locus of interest actually changed.
        z!goPrevious(): no lines in contextFrrTzInvalid type: %dr0)rvrr��
LEVEL_FINErqr�rxryrz�	WRAP_LINErwrrf�WRAP_TOP_BOTTOMr��
goPrevious�WORDr9rr"r�isspacermrRr�r�r�r{)rr��wrap�omitWhitespacer�rrr"rwrxryrzZhasMoreTextZprevZonerrrr�)s�









zContext.goPreviouscCs�|jstjtjd�dSd}|tjkr�|jt|j|jj	�dkrb|jd7_d|_
d|_d}nj|tj@r�|jt|j�dkr�|jd7_d|_d|_
d|_d}n&|tj
@r�d|_d|_d|_
d|_d}�n�|tjk�rh|j|jj	|j}|j�rV|j|j
j}|�rF|jt|�dk�r4|jd7_d}n|jtj|d�}n|jtj|�}n|jtj|�}�n0|tjk�r|j|jj	|j}|j}|j}|j}	|j
}
|j}|j�r�|j
t|j�dk�r�|j
d7_
d|_d}n|jtj|�}n|jtj|�}|j|jj	|j}|�r�|�r�t|j�dk�sLt|j��r�|j|j
jj��r�|j|k�rh|jtj|�}nz|j
d}
xX|
t|j�k�r�|j|
j�s�t|j|
j��s�|j|
jj��r�|
d7}
nP�qtW|
t|j�k�r�|
|_
|�s�||_|	|_|
|_
||_n�|tjk�r�|tj@�r�|jt|j�dk�rV|jd7_d|_d|_
d|_d}n4|tj
@�r�|jdk�r�d|_d|_d|_
d|_d}ntd|��|�r�|tjk�r�|jtj�|_|S)a Moves this context's locus of interest to first char of
        the next type.

        Arguments:
        - flatReviewType: one of ZONE, CHAR, WORD, LINE
        - wrap: if True, will cross boundaries, including top and
                bottom; if False, will stop on boundaries.
        zgoNext(): no lines in contextFrrTzInvalid type: %d)rvrr�r�rqr�rxrrwrfryrzr�r�r�r9r�goNextr�r"rr�r�r�r�r{)rr�r�r�r�rrr"rwrxryrzrrrr��s�






zContext.goNextcCs�d}|tjkr�|js"|jtj�|_|j}|\}}}}}	||d}
|jtj|�}|r�x<|jtj�\}}}}
}|||
kr|PqV|jtjtj�sVPqVW||_n"|tjkr�|j||�Std|��|S)a�Moves this context's locus of interest to first char
        of the type that's closest to and above the current locus of
        interest.

        Arguments:
        - flatReviewType: LINE
        - wrap: if True, will cross top/bottom boundaries; if False, will
                stop on top/bottom boundaries.

        Returns: [string, startOffset, endOffset, x, y, width, height]
        FrEzInvalid type: %d)	rqr�r{r�r�r�r��	WRAP_NONEr�)rr�r�r��targetrrrrr�
middleTargetX�bx�by�bwidth�bheightrrr�goAbove1s(


zContext.goAbovecCs�d}|tjkr�|js"|jtj�|_|j}|\}}}}}	||d}
|jtj|�}|r�x<|jtj�\}}}}
}|||
kr|PqV|jtjtj�sVPqVW||_n$|tjkr�|j||�}ntd|��|S)a�Moves this context's locus of interest to the first
        char of the type that's closest to and below the current
        locus of interest.

        Arguments:
        - flatReviewType: one of WORD, LINE
        - wrap: if True, will cross top/bottom boundaries; if False, will
                stop on top/bottom boundaries.

        Returns: [string, startOffset, endOffset, x, y, width, height]
        FrEzInvalid type: %d)rqr�r{r�r�r�r�r�)rr�r�r�r�rrrrrr�r�r�r�r�rrr�goBelow`s(


zContext.goBelowrrE)N)r)"rrrrr�r�r�r�r�r�r�r�ZWRAP_ALLrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrq�sF3W	/




	'0/rq)rZ__id__�__version__Z__date__Z
__copyright__Z__license__r&r;r\rrrrrrr�r	rr4rRr[rcrerqrrrr�<module>s,9z-a