diff --git a/src/orca/Gecko.py b/src/orca/Gecko.py
index 958d993..434160c 100644
--- a/src/orca/Gecko.py
+++ b/src/orca/Gecko.py
@@ -4653,10 +4653,7 @@ class Script(default.Script):
                 if not len(string):
                     continue
 
-                regions = [braille.Region(
-                    string,
-                    focusedCharacterOffset - startOffset,
-                    expandOnCursor=True)]
+                regions = [braille.Text(obj)]
                 if obj.getRole() == pyatspi.ROLE_LINK:
                     link = obj
                 else:
@@ -8229,6 +8226,10 @@ class Script(default.Script):
     #                                                                  #
     ####################################################################
 
+    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.
diff --git a/src/orca/braille.py b/src/orca/braille.py
index bacc86f..528c299 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -467,20 +467,6 @@ class Text(Region):
             [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)
-
         cursorOffset = min(self.caretOffset - self.lineOffset, len(string))
 
         self._maxCaretOffset = self.lineOffset + len(string.decode("UTF-8"))
@@ -540,7 +526,8 @@ class Text(Region):
             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
@@ -555,83 +542,45 @@ class Text(Region):
         # Start with an empty mask.
         #
         stringLength = len(self.string) - len(self.eol)
-        attrMask = ['\x00']*stringLength
+        lineEndOffset = self.lineOffset + stringLength
+        regionMask = [settings.TEXT_ATTR_BRAILLE_NONE]*stringLength
 
         attrIndicator = settings.textAttributesBrailleIndicator
         selIndicator = settings.brailleSelectorIndicator
-        indicateAttr = (attrIndicator != settings.TEXT_ATTR_BRAILLE_NONE)
-        indicateSel = (selIndicator != settings.BRAILLE_SEL_NONE)
-
-        if indicateAttr and settings.enabledBrailledTextAttributes:
-            # Identify what attributes the user cares about.  Also get the
-            # default attributes for the text object because those attributes
-            # may not be included as attributes for the character.
-            #
-            script = orca_state.activeScript
-            enabledAttributes = settings.enabledBrailledTextAttributes
-            [userAttrList, userAttrDict] = \
-                script.textAttrsToDictionary(enabledAttributes)
-            defaultAttributes = text.getDefaultAttributes()
-            [defaultAttrList, defaultAttrDict] = \
-                script.textAttrsToDictionary(defaultAttributes)
-
-            # [[[TODO - HACK - JD: The end offset returned by SO/OOo is the
-            # offset of the first character that doesn't have the attribute
-            # in question; all other apps return the offset of the last
-            # character that has that attribute]]]
-            #
-            adjustment = 0
-            appName = orca_state.locusOfFocus.getApplication().name
-            if appName.startswith("soffice"):
-                adjustment += 1
-
-            i = self.lineOffset
-            endOffset = self.lineOffset + stringLength
-            while i < endOffset - 1:
-                for attribute in userAttrList:
-                    defaultValue = None
-                    if attribute in defaultAttrList:
-                        defaultValue = defaultAttrDict[attribute]
-                    [value, start, end, defined] = \
-                            text.getAttributeValue(i, attribute)
-
-                    notOfInterest = userAttrDict[attribute]
-                    if defined:
-                        weCare = (value != notOfInterest)
-                    elif defaultValue and len(notOfInterest):
-                        weCare = (defaultValue != notOfInterest)
-                    else:
-                        weCare = False
-
-                    if weCare and start >= 0:
-                        maskStart = start - self.lineOffset
-                        maskEnd = end - self.lineOffset - adjustment
-                        maskLength = maskEnd - maskStart
-                        attrMask[maskStart:maskEnd] = \
-                                                  [attrIndicator] * maskLength
-                if (end <= i):
+        script = orca_state.activeScript
+
+        if attrIndicator:
+            enabledAttributes = script.attribsToDictionary(
+                settings.enabledBrailledTextAttributes)
+
+            offset = self.lineOffset
+            while offset < lineEndOffset:
+                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:
+                    if enabledAttributes.get(attrib, '') != '':
+                        if enabledAttributes[attrib] != attributes[attrib]:
+                            mask = attrIndicator
+                            break
+                if mask != settings.TEXT_ATTR_BRAILLE_NONE:
+                    maskStart = max(startOffset - self.lineOffset, 0)
+                    maskEnd = min(endOffset - self.lineOffset, stringLength)
+                    for i in xrange(maskStart, maskEnd):
+                        regionMask[i] |= attrIndicator
+
+        if selIndicator:
+            selections = script.getTextSelections(self.accessible)
+            for startOffset, endOffset in selections:
+                maskStart = max(startOffset - self.lineOffset, 0)
+                maskEnd = min(endOffset - self.lineOffset, stringLength)
+                for i in xrange(maskStart, maskEnd):
+                    regionMask[i] |= selIndicator
 
-                i = end
-
-        if indicateSel:
-            nSelections = text.getNSelections()
-            if nSelections:
-                for i in range(0, nSelections):
-                    [start, end] = text.getSelection(i)
-                    maskStart = max(self.lineOffset, start) - self.lineOffset
-                    maskEnd = min(end - self.lineOffset, stringLength)
-                    # Combine the selection indicator with the attribute
-                    # indicator.
-                    #
-                    for j in range(maskStart, maskEnd):
-                        if attrMask[j] != '\x00' \
-                           and attrMask[j] != selIndicator:
-                            attrMask[j] = '\xc0'
-                        else:
-                            attrMask[j] = selIndicator
-
-        mask = "".join(attrMask)
 
         if self.contracted:
             contractedMask = [0] * len(self.rawLine)
@@ -640,24 +589,23 @@ class Text(Region):
                 # Transform the offsets.
                 outPos = \
                        [offset - len(self.label) - 1 for offset in outPos]
-            for i, m in enumerate(mask):
+            for i, m in enumerate(regionMask):
                 try:
-                    contractedMask[outPos[i]] |= ord(m)
+                    contractedMask[outPos[i]] |= m
                 except IndexError:
                     continue
-            mask = ''.join(map(chr, contractedMask))
+            regionMask = contractedMask
 
         # Add empty mask characters for the EOL character as well as for
         # any label that might be present.
         #
-        for i in range (0, len(self.eol)):
-            mask += '\x00'
+        regionMask += [0]*len(self.eol)
+
 
         if self.label:
-            for i in range (0, len(self.label) + 1):
-                mask = '\x00' + mask
+            regionMask = [0]*len(self.label) + mask
 
-        return mask
+        return ''.join(map(chr, regionMask))
 
     def contractLine(self, line, cursorOffset=0, expandOnCursor=True):
         contracted, inPos, outPos, cursorPos = Region.contractLine(
@@ -723,7 +671,7 @@ class ReviewText(Region):
 
         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
diff --git a/src/orca/default.py b/src/orca/default.py
index bc10c8e..a82c83f 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -6712,6 +6712,58 @@ class Script(script.Script):
         """
         print "\a"
 
+    def setCaretOffset(self, obj, offset):
+        try:
+            texti = obj.queryText()
+        except:
+           return None
+
+        texti.setCaretOffset(offset)
+
+    def attribsToDictionary(self, dict_string):
+        try:
+            return dict(
+                map(lambda pair: pair.strip().split(':'),
+                    dict_string.strip(';').split(';')))
+        except ValueError:
+            return {}
+
+    def getTextSelections(self, acc):
+        rv = []
+        try:
+            texti = acc.queryText()
+        except:
+            return rv
+       
+        for i in xrange(texti.getNSelections()):
+            rv.append(texti.getSelection(i))
+            
+        return rv
+
+    def getTextAttributes(self, acc, offset, get_defaults):
+        rv = {}
+        try:
+            texti = acc.queryText()
+        except:
+            return rv, 0, 0
+
+        if get_defaults:
+            rv.update(self.attribsToDictionary(texti.getDefaultAttributes()))
+
+        attrib_str, start, end = texti.getAttributes(offset)
+
+        rv.update(self.attribsToDictionary(attrib_str))
+
+        return rv, start, end
+
+    def setCaretOffset(self, acc, offset):
+        try:
+            texti = acc.queryText()
+        except:
+            pass
+        else:
+            texti.setCaretOffset(offset)
+        
 # Dictionary that defines the state changes we care about for various
 # objects.  The key represents the role and the value represents a list
 # of states that we care about.
diff --git a/src/orca/scripts/StarOffice.py b/src/orca/scripts/StarOffice.py
index 76a59f0..61137f9 100644
--- a/src/orca/scripts/StarOffice.py
+++ b/src/orca/scripts/StarOffice.py
@@ -2762,3 +2762,8 @@ class Script(default.Script):
                 speech.speak(text)
         else:
             default.Script.onTextInserted(self, event)
+
+    def getTextAttributes(self, acc, offset, get_defaults):
+        rv, start, end = \
+            default.Script.getTextAttributes(self, acc, offset, get_defaults)
+        return rv, start, end - 1
diff --git a/src/orca/scripts/gnome-terminal.py b/src/orca/scripts/gnome-terminal.py
index 3f256c4..9fe76e1 100644
--- a/src/orca/scripts/gnome-terminal.py
+++ b/src/orca/scripts/gnome-terminal.py
@@ -266,3 +266,23 @@ class Script(default.Script):
            and self.isWordDelimiter(text.decode("UTF-8")[-1:]):
             if matchFound:
                 self.echoPreviousWord(event.source)
+
+    def getTextLineAtCaret(self, acc):
+        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)
+
+
diff --git a/src/orca/settings.py b/src/orca/settings.py
index cfbe7fb..dfe267f 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -221,10 +221,10 @@ brailleRolenameStyle    = BRAILLE_ROLENAME_STYLE_LONG
 # The values represent the character to be used in the attrOr
 # field of brlAPI's writeStruct.
 #
-BRAILLE_SEL_NONE = '\x00' # 00000000
-BRAILLE_SEL_7    = '\x40' # 01000000
-BRAILLE_SEL_8    = '\x80' # 10000000
-BRAILLE_SEL_BOTH = '\xc0' # 11000000
+BRAILLE_SEL_NONE = 0x00 # 00000000
+BRAILLE_SEL_7    = 0x40 # 01000000
+BRAILLE_SEL_8    = 0x80 # 10000000
+BRAILLE_SEL_BOTH = 0xc0 # 11000000
 brailleSelectorIndicator = BRAILLE_SEL_BOTH
 
 # Speech punctuation levels (see verbalizePunctuationStyle).
@@ -593,10 +593,10 @@ enabledBrailledTextAttributes = \
 # The values represent the character to be used in the attrOr
 # field of brlAPI's writeStruct.
 #
-TEXT_ATTR_BRAILLE_NONE = '\x00' # 00000000
-TEXT_ATTR_BRAILLE_7    = '\x40' # 01000000
-TEXT_ATTR_BRAILLE_8    = '\x80' # 10000000
-TEXT_ATTR_BRAILLE_BOTH = '\xc0' # 11000000
+TEXT_ATTR_BRAILLE_NONE = 0x00 # 00000000
+TEXT_ATTR_BRAILLE_7    = 0x40 # 01000000
+TEXT_ATTR_BRAILLE_8    = 0x80 # 10000000
+TEXT_ATTR_BRAILLE_BOTH = 0xc0 # 11000000
 textAttributesBrailleIndicator = TEXT_ATTR_BRAILLE_NONE
 
 # The limit to enable a repeat character count to be spoken.
