orca r4160 - in trunk: . src/orca
- From: wwalker svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r4160 - in trunk: . src/orca
- Date: Sat, 6 Sep 2008 18:16:59 +0000 (UTC)
Author: wwalker
Date: Sat Sep 6 18:16:59 2008
New Revision: 4160
URL: http://svn.gnome.org/viewvc/orca?rev=4160&view=rev
Log:
Fix for bug #551077 and partial fix for bug #527022 -- this addresses a
few unicode vs. UTF-8 issues in the code.
Modified:
trunk/ChangeLog
trunk/src/orca/braille.py
trunk/src/orca/default.py
Modified: trunk/src/orca/braille.py
==============================================================================
--- trunk/src/orca/braille.py (original)
+++ trunk/src/orca/braille.py Sat Sep 6 18:16:59 2008
@@ -288,9 +288,9 @@
self.expandOnCursor = expandOnCursor
- string = string.decode("UTF-8")
- string = string.strip('\n')
- self.rawLine = string.encode("UTF-8")
+ # The uncontracted string for the line.
+ #
+ self.rawLine = string.decode("UTF-8").strip("\n")
if self.contracted:
self.contractionTable = settings.brailleContractionTable or \
@@ -354,12 +354,12 @@
if not expandOnCursor or cursorOnSpace:
contracted, inPos, outPos, cursorPos = \
louis.translate([self.contractionTable],
- line.decode(),
+ line,
cursorPos=cursorOffset)
else:
contracted, inPos, outPos, cursorPos = \
louis.translate([self.contractionTable],
- line.decode(),
+ line,
cursorPos=cursorOffset,
mode=louis.MODE.compbrlAtCursor)
@@ -476,6 +476,10 @@
string = ""
string = string.decode("UTF-8")
+ if label:
+ label = label.decode("UTF-8")
+ if eol:
+ eol = eol.decode("UTF-8")
try:
endOffset = endOffset - self.lineOffset
@@ -493,7 +497,7 @@
cursorOffset = min(self.caretOffset - self.lineOffset, len(string))
- self._maxCaretOffset = self.lineOffset + len(string.decode("UTF-8"))
+ self._maxCaretOffset = self.lineOffset + len(string)
self.eol = eol
@@ -520,6 +524,8 @@
[string, caretOffset, lineOffset] = \
orca_state.activeScript.getTextLineAtCaret(self.accessible)
+ string = string.decode("UTF-8")
+
cursorOffset = min(caretOffset - lineOffset, len(string))
if lineOffset != self.lineOffset:
@@ -757,13 +763,13 @@
attributeMask = ""
for region in self.regions:
if region == _regionWithFocus:
- focusOffset = len(string.decode("UTF-8"))
+ focusOffset = len(string)
if region.string:
- # [[[TODO: WDW - HACK: Replace UTF-8 ellipses with "..."
+ # [[[TODO: WDW - HACK: Replace ellipses with "..."
# The ultimate solution is to get i18n support into
# BrlTTY.]]]
#
- string += region.string.replace("\342\200\246", "...")
+ string += region.string.replace(u'\u2026', "...")
mask = region.getAttributeMask(getLinkMask)
attributeMask += mask
@@ -787,12 +793,12 @@
for region in self.regions:
foundRegion = region
string = string + region.string
- if len(string.decode("UTF-8")) > offset:
+ if len(string) > offset:
break
else:
- pos = len(string.decode("UTF-8"))
+ pos = len(string)
- if offset >= len(string.decode("UTF-8")):
+ if offset >= len(string):
return [None, -1]
else:
return [foundRegion, offset - pos]
@@ -972,7 +978,7 @@
# right of the display if we need to pan right.
#
if panToCursor and (cursorOffset >= 0):
- if len(string.decode("UTF-8")) <= _displaySize[0]:
+ if len(string) <= _displaySize[0]:
viewport[0] = 0
elif targetCursorCell:
viewport[0] = max(0, cursorOffset - targetCursorCell + 1)
@@ -1001,13 +1007,12 @@
debug.println(debug.LEVEL_INFO, logLine)
log.info(logLine)
- string = string.decode("UTF-8")
- substring = string[startPos:endPos].encode("UTF-8")
+ substring = string[startPos:endPos]
if useBrlAPIBindings:
if brlAPIRunning:
writeStruct = brlapi.WriteStruct()
writeStruct.regionBegin = 1
- writeStruct.regionSize = len(substring.decode("UTF-8"))
+ writeStruct.regionSize = len(substring)
while writeStruct.regionSize < _displaySize[0]:
substring += " "
if attributeMask:
@@ -1015,7 +1020,6 @@
writeStruct.regionSize += 1
writeStruct.text = substring
writeStruct.cursor = cursorCell
- writeStruct.charset = "UTF-8"
# [[[WDW - if you want to muck around with the dots on the
# display to do things such as add underlines, you can use
@@ -1133,7 +1137,7 @@
lineNum = viewport[1]
newX = viewport[0] + panAmount
[string, focusOffset, attributeMask] = _lines[lineNum].getLineInfo()
- if newX < len(string.decode("UTF-8")):
+ if newX < len(string):
viewport[0] = newX
return oldX != viewport[0]
Modified: trunk/src/orca/default.py
==============================================================================
--- trunk/src/orca/default.py (original)
+++ trunk/src/orca/default.py Sat Sep 6 18:16:59 2008
@@ -6311,6 +6311,8 @@
Returns: a new line adjusted for repeat character counts (if enabled).
"""
+ line = line.decode("UTF-8")
+
try:
hyperText = obj.queryHypertext()
nLinks = hyperText.getNLinks()
@@ -6338,7 +6340,7 @@
n -= 1
- return line
+ return line.encode("UTF-8")
def adjustForRepeats(self, line):
"""Adjust line to include repeat character counts.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]