[orca] Implmeneted reviewing of current character unicode information (for now just value)
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [orca] Implmeneted reviewing of current character unicode information (for now just value)
- Date: Wed, 20 Jan 2010 14:17:02 +0000 (UTC)
commit 39326b893956fe4dd9a0fed1dc576145abb3463d
Author: Rui Batista <ruiandrebatista gmail com>
Date: Tue Jan 19 19:53:32 2010 +0000
Implmeneted reviewing of current character unicode information (for now just value)
This is a partial solution for the issues addressed on the comments for Bug 431531 - Add support for user-configurable character naming
src/orca/default.py | 76 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/default.py b/src/orca/default.py
index 992016e..4909140 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -601,6 +601,24 @@ class Script(script.Script):
#
_("Phonetically speaks the current flat review character."))
+ self.inputEventHandlers["reviewUnicodeInformationCurrentCharacterHandler"] = \
+ input_event.InputEventHandler(
+ Script.reviewUnicodeInformationCurrentCharacter,
+ # Translators: the 'flat review' feature of Orca
+ # allows the blind user to explore the text in a
+ # window in a 2D fashion. That is, Orca treats all
+ # the text from all objects in a window (e.g.,
+ # buttons, labels, etc.) as a sequence of words in a
+ # sequence of lines. The flat review feature allows
+ # the user to explore this text by the {previous,next}
+ # {line,word,character}. Previous will go backwards
+ # in the window until you reach the top (i.e., it will
+ # wrap across lines if necessary). This command will
+ # cause Orca to speak information about the current character
+ # Like its unicode value and other relevant information
+ _("Speaks some extra information about the current flat review character."))
+
+
self.inputEventHandlers["reviewNextCharacterHandler"] = \
input_event.InputEventHandler(
Script.reviewNextCharacter,
@@ -1445,6 +1463,15 @@ class Script(script.Script):
keyBindings.add(
keybindings.KeyBinding(
+ "KP_2",
+ settings.defaultModifierMask,
+ settings.NO_MODIFIER_MASK,
+ self.inputEventHandlers["reviewUnicodeInformationCurrentCharacterHandler"],
+ 3))
+
+
+ keyBindings.add(
+ keybindings.KeyBinding(
"KP_Down",
settings.defaultModifierMask,
settings.NO_MODIFIER_MASK,
@@ -1461,6 +1488,14 @@ class Script(script.Script):
keyBindings.add(
keybindings.KeyBinding(
+ "KP_Down",
+ settings.defaultModifierMask,
+ settings.NO_MODIFIER_MASK,
+ self.inputEventHandlers["reviewUnicodeInformationCurrentCharacterHandler"],
+ 3))
+
+ keyBindings.add(
+ keybindings.KeyBinding(
"KP_3",
settings.defaultModifierMask,
settings.NO_MODIFIER_MASK,
@@ -5589,12 +5624,22 @@ class Script(script.Script):
return True
+ def reviewUnicodeInformationCurrentCharacter(self, inputEvent):
+ """Brailles and speaks unicode information about the current flat review
+ character.
+ """
+
+ self._reviewCurrentCharacter(inputEvent, 3)
+ self.lastReviewCurrentEvent = inputEvent
+
+ return True
+
def _reviewCurrentCharacter(self, inputEvent, speechType=1):
"""Presents the current flat review character via braille and speech.
Arguments:
- inputEvent - the current input event.
- - speechType - the desired presentation: speak (1) or phonetic (2)
+ - speechType - the desired presentation: speak (1), phonetic (2) or unicode value information (3)
"""
context = self.getFlatReviewContext()
@@ -5615,11 +5660,13 @@ class Script(script.Script):
else:
[lineString, x, y, width, height] = \
context.getCurrent(flat_review.Context.LINE)
- if lineString == "\n":
+ if lineString == "\n" and speechType != 3:
# Translators: "blank" is a short word to mean the
# user has navigated to an empty line.
#
speech.speak(_("blank"))
+ elif speechType == 3:
+ self.speakUnicodeCharacterInformation(charString)
elif speechType == 2:
self.phoneticSpellCurrentItem(charString)
elif charString.decode("UTF-8").isupper():
@@ -5632,6 +5679,31 @@ class Script(script.Script):
return True
+ def speakUnicodeCharacterInformation(self, character):
+ """ Speaks some information about an unicode character.
+ At the Momment it just anounces the character unicode number but this information may be
+ changed in the future
+
+ Arguments:
+ - character: the character to speak information of
+ """
+ vars = {"value" : self.getUnicodeValueRepresentation(character)}
+ # Translators: this is information about an unicode character reported to the user.
+ # value is the unicode number value of this character in hex.
+ speech.speak(_("Character %(value)s" % vars))
+
+ def getUnicodeValueRepresentation(self, character):
+ """ Returns a four hex dijit representaiton of the given character
+
+ Arguments:
+ - The character to return representation
+
+ returns a string representaition of the given character unicode vlue
+ """
+ if not isinstance(character, unicode):
+ character = character.decode('UTF-8')
+ return "%04x" % ord(character)
+
def reviewPreviousCharacter(self, inputEvent):
"""Moves the flat review context to the previous character. Places
the flat review cursor at character."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]