Esempio n. 1
0
    def script_forward_review_currentCharacter(self, gesture):
        #When speech review mode is enabled, the first character description is spoken on first script call.
        #When Braille review mode is set to "On" or "Auto", character descriptions are displayed on the first script call.
        CJK["direction"] = 1
        info = api.getReviewPosition().copy()
        info.expand(textInfos.UNIT_CHARACTER)
        count = getLastScriptRepeatCount()

        try:
            c = ord(info.text)
        except:
            c = 0

        if count == 1 or (CJK["speechReview"] == "On"
                          or CJK["brailleReview"] != "Off"):
            CJK["isReviewCharacter"] = True
            if count == 1 or CJK["speechReview"] == "On":
                speech.speakSpelling(info.text, useCharacterDescriptions=True)
            else:
                speech.speakTextInfo(info,
                                     unit=textInfos.UNIT_CHARACTER,
                                     reason=controlTypes.OutputReason.CARET)
            if CJK["brailleReview"] == "On" or CJK["brailleReview"] == "Auto":
                try:
                    char = info.text.lower()
                    charDesc = characterProcessing.getCharacterDescription(
                        CJK["locale"], char)
                    BrailleHandler.message(handler,
                                           char + " " + " ".join(charDesc))
                except TypeError:
                    pass
        elif count == 0:
            speech.speakTextInfo(info,
                                 unit=textInfos.UNIT_CHARACTER,
                                 reason=controlTypes.OutputReason.CARET)
        else:
            try:
                speech.speakMessage("%d," % c)
                speech.speakSpelling(hex(c))
            except:
                speech.speakTextInfo(info,
                                     unit=textInfos.UNIT_CHARACTER,
                                     reason=controlTypes.OutputReason.CARET)
        #Reset parameters to prepare for the next call.
        CJK["direction"] = 0
        CJK["isReviewCharacter"] = False
Esempio n. 2
0
 def script_modified_review_nextCharacter(self, gesture):
     #Add character description Braille output to the review character when Braille review mode is turned on.
     lineInfo = api.getReviewPosition().copy()
     lineInfo.expand(textInfos.UNIT_LINE)
     charInfo = api.getReviewPosition().copy()
     charInfo.expand(textInfos.UNIT_CHARACTER)
     charInfo.collapse()
     res = charInfo.move(textInfos.UNIT_CHARACTER, 1)
     if res == 0 or charInfo.compareEndPoints(lineInfo, "endToEnd") >= 0:
         ui.reviewMessage(_("Right"))
         reviewInfo = api.getReviewPosition().copy()
         reviewInfo.expand(textInfos.UNIT_CHARACTER)
         speech.speakTextInfo(reviewInfo,
                              unit=textInfos.UNIT_CHARACTER,
                              reason=controlTypes.OutputReason.CARET)
         char = reviewInfo.text.lower()
         if not isAlphanumeric(char) and CJK["brailleReview"] == "Auto":
             try:
                 charDesc = characterProcessing.getCharacterDescription(
                     CJK["locale"], char)
                 BrailleHandler.message(handler,
                                        char + " " + " ".join(charDesc))
             except TypeError:
                 pass
     else:
         api.setReviewPosition(charInfo)
         charInfo.expand(textInfos.UNIT_CHARACTER)
         speech.speakTextInfo(charInfo,
                              unit=textInfos.UNIT_CHARACTER,
                              reason=controlTypes.OutputReason.CARET)
         char = charInfo.text.lower()
         if not isAlphanumeric(char) and CJK["brailleReview"] == "Auto":
             try:
                 charDesc = characterProcessing.getCharacterDescription(
                     CJK["locale"], char)
                 BrailleHandler.message(handler,
                                        char + " " + " ".join(charDesc))
             except TypeError:
                 pass
Esempio n. 3
0
def custom_doCursorMove(self, region):
    """
    This is derived from BrailleHandler._doCursorMove to handle the Braille review behavior.
    When the cursor is moved to a new raw text region, the region is displayed in Braille.
    Once the cursor is moved with left and right arrow, the character descriptions  are displayed for each character at the cursor position.
    @param self: the instance of BrailleHandler currently initialized
    @type self: braille.BrailleHandler
    @param region: the region of Braille displayed
    @type region: braille.Region
    """
    self.mainBuffer.saveWindow()
    region.update()
    self.mainBuffer.update()
    self.mainBuffer.restoreWindow()
    if region.brailleCursorPos is not None:
        self.mainBuffer.scrollTo(region, region.brailleCursorPos)
    if self.buffer is self.mainBuffer:
        self.update()
    elif self.buffer is self.messageBuffer and keyboardHandler.keyCounter > self._keyCountForLastMessage:
        self._dismissMessage()

    if CJK["brailleReview"] == "Auto" and CJK[
            "previousRawText"] == region.rawText and CJK[
                "previousCursorPos"] != region.cursorPos:
        #The cursor is inside the raw text of the previous region and its position as moved, so display the character descriptions.
        try:
            i = region.cursorPos
            char = region.rawText[int(_(i or 0))]
            charDesc = characterProcessing.getCharacterDescription(
                CJK["locale"], char.lower())
            BrailleHandler.message(handler, char + " " + " ".join(charDesc))
        except TypeError:
            BrailleHandler.message(handler, char)
    else:
        #This region has a new raw text, so store the raw text for subsequent comparison.
        CJK["previousRawText"] = region.rawText
    CJK["previousCursorPos"] = region.cursorPos