orca r3802 - in trunk: . src/orca src/orca/scripts
- From: eitani svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r3802 - in trunk: . src/orca src/orca/scripts
- Date: Thu, 3 Apr 2008 23:17:44 +0100 (BST)
Author: eitani
Date: Thu Apr 3 23:17:44 2008
New Revision: 3802
URL: http://svn.gnome.org/viewvc/orca?rev=3802&view=rev
Log:
* src/orca/Gecko.py:
src/orca/default.py:
src/orca/flat_review.py:
src/orca/scripts/gnome-terminal.py:
src/orca/braille.py:
Added cursor key routing support to Gecko (bug #520612).
Modified:
trunk/ChangeLog
trunk/src/orca/Gecko.py
trunk/src/orca/braille.py
trunk/src/orca/default.py
trunk/src/orca/flat_review.py
trunk/src/orca/scripts/gnome-terminal.py
Modified: trunk/src/orca/Gecko.py
==============================================================================
--- trunk/src/orca/Gecko.py (original)
+++ trunk/src/orca/Gecko.py Thu Apr 3 23:17:44 2008
@@ -4641,23 +4641,30 @@
focusedRegion = regions[0]
elif text and (obj.getRole() != pyatspi.ROLE_MENU_ITEM):
string = text.getText(startOffset, endOffset)
- if string.endswith(" "):
- endOffset -= 1
- string = text.getText(startOffset, endOffset)
-
- regions = [braille.Region(
- string,
- focusedCharacterOffset - startOffset,
- expandOnCursor=True)]
+ string = string.strip(" ")
+ endOffset = startOffset + len(string)
+ if endOffset == startOffset:
+ continue
+
if obj.getRole() == pyatspi.ROLE_LINK:
link = obj
else:
link = self.getAncestor(obj,
[pyatspi.ROLE_LINK],
[pyatspi.ROLE_DOCUMENT_FRAME])
+
+ if not link:
+ regions = [braille.Text(obj,
+ startOffset=startOffset,
+ endOffset=endOffset)]
+
if link:
- regions.append(braille.Region(
- " " + rolenames.getBrailleForRoleName(link)))
+ regions = [braille.Component(
+ link,
+ string + " " + \
+ rolenames.getBrailleForRoleName(link),
+ focusedCharacterOffset - startOffset,
+ expandOnCursor=True)]
elif obj.getRole() == pyatspi.ROLE_CAPTION:
regions.append(braille.Region(
" " + rolenames.getBrailleForRoleName(obj)))
@@ -8242,6 +8249,10 @@
# #
####################################################################
+ def setCaretOffset(self, obj, characterOffset):
+ self.setCaretPosition(obj, characterOffset)
+ self.updateBraille(obj)
+
def setCaretPosition(self, obj, characterOffset):
"""Sets the caret position to the given character offset in the
given object.
Modified: trunk/src/orca/braille.py
==============================================================================
--- trunk/src/orca/braille.py (original)
+++ trunk/src/orca/braille.py Thu Apr 3 23:17:44 2008
@@ -454,7 +454,8 @@
[[[TODO: WDW - need to add in text selection capabilities. Logged
as bugzilla bug 319754.]]]"""
- def __init__(self, accessible, label="", eol=""):
+ def __init__(self, accessible, label="", eol="",
+ startOffset=0, endOffset=-1):
"""Creates a new Text region.
Arguments:
@@ -467,20 +468,17 @@
[string, self.caretOffset, self.lineOffset] = \
orca_state.activeScript.getTextLineAtCaret(self.accessible)
- # Sometimes, gnome-terminal will give us very odd values when
- # the user is editing using 'vi' and has positioned the caret
- # at the first character of the first line. In this case, we
- # end up getting a very large negative number for the line offset.
- # So, we just assume the user is at the first character.
- #
- if self.lineOffset < 0:
- self.caretOffset = 0
- self.lineOffset = 0
- [string, startOffset, endOffset] = \
- self.accessible.queryText().getTextAtOffset(
- 0,
- pyatspi.TEXT_BOUNDARY_LINE_START)
+ if endOffset == -1:
+ self.endOffset = len(string)
+ else:
+ self.endOffset = endOffset - self.lineOffset
+
+ self.startOffset = startOffset - self.lineOffset
+
+ string = string.decode("UTF-8")[self.startOffset:self.endOffset]
+
+ self.caretOffset -= self.startOffset
cursorOffset = min(self.caretOffset - self.lineOffset, len(string))
self._maxCaretOffset = self.lineOffset + len(string.decode("UTF-8"))
@@ -540,7 +538,8 @@
return
newCaretOffset = min(self.lineOffset + offset, self._maxCaretOffset)
- self.accessible.queryText().setCaretOffset(newCaretOffset)
+ orca_state.activeScript.setCaretOffset(
+ self.accessible, newCaretOffset)
def getAttributeMask(self):
"""Creates a string which can be used as the attrOr field of brltty's
@@ -571,6 +570,8 @@
attributes, startOffset, endOffset = \
script.getTextAttributes(self.accessible,
offset, True)
+ if endOffset <= offset:
+ break
mask = settings.TEXT_ATTR_BRAILLE_NONE
offset = endOffset
for attrib in attributes:
@@ -610,6 +611,7 @@
# any label that might be present.
#
regionMask += [0]*len(self.eol)
+
if self.label:
regionMask = [0]*len(self.label) + regionMask
@@ -623,6 +625,7 @@
def displayToBufferOffset(self, display_offset):
offset = Region.displayToBufferOffset(self, display_offset)
+ offset += self.startOffset
offset -= len(self.label)
return offset
@@ -644,7 +647,6 @@
for this Region if it gets focus.
- zone: the flat review Zone associated with this component
"""
-
Component.__init__(self, accessible, string,
cursorOffset, expandOnCursor=True)
self.zone = zone
@@ -665,7 +667,6 @@
- lineOffset: the character offset into where the text line starts
- zone: the flat review Zone associated with this component
"""
-
Region.__init__(self, string, expandOnCursor=True)
self.accessible = accessible
self.lineOffset = lineOffset
@@ -679,7 +680,7 @@
offset = self.displayToBufferOffset(offset)
newCaretOffset = self.lineOffset + offset
- self.accessible.queryText().setCaretOffset(newCaretOffset)
+ orca_state.activeScript.setCaretOffset(self.accessible, newCaretOffset)
class Line:
"""A horizontal line on the display. Each Line is composed of a sequential
Modified: trunk/src/orca/default.py
==============================================================================
--- trunk/src/orca/default.py (original)
+++ trunk/src/orca/default.py Thu Apr 3 23:17:44 2008
@@ -6822,6 +6822,21 @@
"""
print "\a"
+ def setCaretOffset(self, obj, offset):
+ """Set the caret offset on a given accessible. Similar to
+ Accessible.setCaretOffset()
+
+ Arguments:
+ - obj: Given accessible object.
+ - offset: Offset to hich to set the caret.
+ """
+ try:
+ texti = obj.queryText()
+ except:
+ return None
+
+ texti.setCaretOffset(offset)
+
def attribsToDictionary(self, dict_string):
"""Creates a Python dict from a typical attributes list returned from
different AT-SPI methods.
@@ -6986,7 +7001,7 @@
ti = acc.queryText()
except NotImplementedError:
return '', 0, 0
-
+
text_contents = ti.getText(0, -1)
line_offsets = []
start_offset = 0
Modified: trunk/src/orca/flat_review.py
==============================================================================
--- trunk/src/orca/flat_review.py (original)
+++ trunk/src/orca/flat_review.py Thu Apr 3 23:17:44 2008
@@ -531,10 +531,19 @@
# The 'isinstance(zone, TextZone)' test is a sanity check
# to handle problems with Java text. See Bug 435553.
if isinstance(zone, TextZone) and \
- ((zone.accessible.getRole() == pyatspi.ROLE_TEXT) \
- or (zone.accessible.getRole() == \
- pyatspi.ROLE_PASSWORD_TEXT) \
- or (zone.accessible.getRole() == pyatspi.ROLE_TERMINAL)):
+ ((zone.accessible.getRole() in \
+ (pyatspi.ROLE_TEXT,
+ pyatspi.ROLE_PASSWORD_TEXT,
+ pyatspi.ROLE_TERMINAL)) or \
+ # [[[TODO: Eitan - HACK:
+ # This is just to get FF3 cursor key routing support.
+ # We really should not be determining all this stuff here,
+ # it should be in the scripts.
+ # Same applies to roles above.]]]
+ (zone.accessible.getRole() in \
+ (pyatspi.ROLE_PARAGRAPH,
+ pyatspi.ROLE_HEADING,
+ pyatspi.ROLE_LINK))):
region = braille.ReviewText(zone.accessible,
zone.string,
zone.startOffset,
Modified: trunk/src/orca/scripts/gnome-terminal.py
==============================================================================
--- trunk/src/orca/scripts/gnome-terminal.py (original)
+++ trunk/src/orca/scripts/gnome-terminal.py Thu Apr 3 23:17:44 2008
@@ -266,3 +266,33 @@
and self.isWordDelimiter(text.decode("UTF-8")[-1:]):
if matchFound:
self.echoPreviousWord(event.source)
+
+ def getTextLineAtCaret(self, acc):
+ """Gets the line of text where the caret is.
+
+ Argument:
+ - obj: an Accessible object that implements the AccessibleText
+ interface
+
+ Returns the [string, caretOffset, startOffset] for the line of text
+ where the caret is.
+ """
+ string, caretOffset, lineOffset = \
+ default.Script.getTextLineAtCaret(self, acc)
+
+ # Sometimes, gnome-terminal will give us very odd values when
+ # the user is editing using 'vi' and has positioned the caret
+ # at the first character of the first line. In this case, we
+ # end up getting a very large negative number for the line offset.
+ # So, we just assume the user is at the first character.
+ #
+ if lineOffset < 0:
+ caretOffset = 0
+ lineOffset = 0
+ texti = acc.queryText()
+ string, startOffset, endOffset = \
+ texti.getTextAtOffset(0,
+ pyatspi.TEXT_BOUNDARY_LINE_START)
+
+ return string, caretOffset, lineOffset
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]