[orca/570658] committing Wills patch, 134461



commit bbafee2d49cba5cf11cd803e2b938e2db688dd5c
Author: Mesar Hameed <mhameed src gnome org>
Date:   Tue May 12 11:13:12 2009 +0100

    committing Wills patch, 134461
---
 .gitignore                     |    2 +
 ChangeLog                      |    2 +-
 NEWS                           |    2 +-
 src/orca/Makefile.am           |    2 +-
 src/orca/altspeechgenerator.py | 1047 +++++++++++++++++-----------------------
 src/orca/braille.py            |  141 +++++-
 src/orca/chnames.py            |    8 +
 src/orca/default.py            |   84 ++++-
 src/orca/formatting.py         |  189 ++++++++
 src/orca/generator_settings.py |  298 ------------
 src/orca/script.py             |    6 +
 src/orca/speechgenerator.py    |    4 +-
 12 files changed, 846 insertions(+), 939 deletions(-)

diff --git a/.gitignore b/.gitignore
index 39bd73d..b5c22aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,5 @@ core
 run_pylint.sh
 bld
 *~
+patch.*
+[0-9][0-9][0-9][0-9][-]*
diff --git a/ChangeLog b/ChangeLog
index ccc64fe..a9161ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -154,7 +154,7 @@ commit 2ea4de15f8543f9a6ddc83707f7bf29b6d105a22
 2009-04-15  Willie Walker <william walker sun com>
 
         * src/orca/gnomespeechfactory.py:
-          Fix for bug #570952 - Orca should be able to run with AT-SPI/D-Bus
+          Fix for bug #579052 - Orca should be able to run with AT-SPI/D-Bus
 
 2009-04-12  Joanmarie Diggs <joanmarie diggs gmail com>
 
diff --git a/NEWS b/NEWS
index 766456b..b8e94a4 100644
--- a/NEWS
+++ b/NEWS
@@ -21,7 +21,7 @@ General:
 * Adjust debug utilities to print to console and debug log.
   (Willie Walker)
 
-* Fix for bgo#570952 - Orca should be able to run with AT-SPI/D-Bus.
+* Fix for bgo#579052 - Orca should be able to run with AT-SPI/D-Bus.
   (Willie Walker)
 
 * Fix for bgo#573535 - Orca should use the 16x16 pixels application
diff --git a/src/orca/Makefile.am b/src/orca/Makefile.am
index e16dc83..b4a026d 100644
--- a/src/orca/Makefile.am
+++ b/src/orca/Makefile.am
@@ -26,7 +26,7 @@ orca_python_PYTHON = \
 	find.py \
 	flat_review.py \
 	focus_tracking_presenter.py \
-	generator_settings.py \
+	formatting.py \
 	gnomespeechfactory.py \
 	httpserver.py \
 	input_event.py \
diff --git a/src/orca/altspeechgenerator.py b/src/orca/altspeechgenerator.py
old mode 100755
new mode 100644
index 51128a7..8cf2d60
--- a/src/orca/altspeechgenerator.py
+++ b/src/orca/altspeechgenerator.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -24,28 +24,20 @@ class."""
 __id__        = "$Id:$"
 __version__   = "$Revision:$"
 __date__      = "$Date:$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
-import pdb
 import sys
 import re
-#import time
 import traceback
 
 import pyatspi
-#import debug
-#import orca_state
 import rolenames
 import settings
-#import focus_tracking_presenter_settings
-import generator_settings
 
 from orca_i18n import _         # for gettext support
 from orca_i18n import ngettext  # for ngettext support
 from orca_i18n import C_        # to provide qualified translatable strings
-from IPython.Shell import IPShellEmbed
-ipshell = IPShellEmbed() 
 
 def formatExceptionInfo(maxTBlevel=5):
     cla, exc, trbk = sys.exc_info()
@@ -55,12 +47,6 @@ def formatExceptionInfo(maxTBlevel=5):
     except KeyError:
         excArgs = "<no args>"
     excTb = traceback.format_tb(trbk, maxTBlevel)
-    #print "-*** exception ***-"
-    #print excName
-    #print excArgs
-    #for i in excTb:
-    #    print i
-    #print "-*** ***-"
     return (excName, excArgs, excTb)
 
 class AltSpeechGenerator:
@@ -70,242 +56,116 @@ class AltSpeechGenerator:
     speechGenerators instance field as they see fit."""
 
     def __init__(self, script):
-
-        # The script that created us.  This allows us to ask the
-        # script for information if we need it.
-        #
         self._script = script
+        self._methodsDict = {}
+        for method in \
+            filter(lambda z: callable(z),
+                   map(lambda y: getattr(self, y).__get__(self, self.__class__),
+                       filter(lambda x: x.startswith("_get"), dir(self)))):
+            name = method.__name__[4:]
+            name = name[0].lower() + name[1:]
+            self._methodsDict[name] = method
+
+        for roleKey in self._script.formatting["speech"]:
+            for speechKey in ["focused", "unfocused"]:
+                try:
+                    evalString = \
+                        self._script.formatting["speech"][roleKey][speechKey]
+                except:
+                    continue
+                else:
+                    if not evalString:
+                        # It's legal to have an empty string for speech.
+                        #
+                        continue
+                    generatedResultsDict = {}
+                    while True:
+                        try:
+                            eval(evalString, generatedResultsDict)
+                            break
+                        except NameError:
+                            info = formatExceptionInfo()
+                            arg = info[1][0]
+                            arg = arg.replace("name '", "")
+                            arg = arg.replace("' is not defined", "")
+                            if not self._methodsDict.has_key(arg):
+                                print roleKey, speechKey, evalString, \
+                                      "    no function for '%s'\n" % arg
+                            generatedResultsDict[arg] = ""
+                        except:
+                            print roleKey, speechKey, evalString, \
+                                  formatExceptionInfo()
+                            break
 
-        self._argExp = re.compile('[ ]*\+?[ ]*([a-zA-Z0-9]+)[ ]*(.*)')
-
-        self._myswitch = {
-        'accelerator' : self._getAccelerator,
-        'embedded': self._getEmbedded,
-        'availability' : self._getAvailability,
-        'checkState': self._getCheckState,
-        'isCheckbox': self._isCheckbox,
-        'checkRole': self._getCheckRole,
-        'currentLineText': self._getCurrentLineText,
-        'displayedText': self._getDisplayedText,
-        'realActiveDescendantDisplayedText': \
-          self._getRealActiveDescendantDisplayedText,
-        'tableCell2ChildLabel': self._getTableCell2ChildLabel,
-        'tableCell2ChildToggle': self._getTableCell2ChildToggle,
-        'tableCellRow': self._getTableCellRow,
-        'expandableState': self._getExpandableState,
-        'hasNoChildren': self._getHasNoChildren,
-        'imageDescription': self._getImageDescription,
-        'isCheckedState': self._getIsCheckedState,
-        'isReadOnly': self._getIsReadOnly,
-        'label' : self._getLabel,
-        'labelOrName': self._getLabelOrName,
-        'labelOrName2': self._getLabelOrName2,
-        'mnemonic' : self._getMnemonic,
-        'name' : self._getName,
-        'percentage': self._getPercentage,
-        'radioState': self._getRadioState,
-        'required' : self._getRequiredObject,
-        'roleName' : self._getRoleName,
-        'terminal': self._getTerminal,
-        'textRole': self._getTextRole,
-        'textSelection' : self._getAllTextSelection,
-        'toggleState': self._getToggleState,
-        'unrelatedLabels' : self._getUnrelatedLabels,
-        'value': self._getValue,
-        'hashNoShowingChildren': self._getHasNoShowingChildren,
-        'noOfChildren': self._getNoOfChildren,
-        'unfocusedDialogueCount': self._getUnfocusedDialogueCount,
-        'image': self._getImage
-        }
-
-    def _getImage(self, obj, **args):
-        result = []
-        try:
-            image = obj.queryImage()
-        except:
-            image = None
-        else:
-            print "args is:"
-            print args
-            #pdb.set_trace()
-            #oldFmtstr = args.get('fmtstr', None)
-            role = pyatspi.ROLE_IMAGE
-            result.extend(self.getSpeech(obj, role=role))
-            #args['fmtstr'] = oldFmtstr
-        return result
-
-    def _getNoOfChildren(self, obj, **args):
-        result = []
-        childNodes = self._script.getChildNodes(obj)
-        children = len(childNodes)
-
-        if not children:
-            # Translators: this is the number of items in a layered
-            # pane or table.
-            #
-            itemString = ngettext("%d item", "%d items", children) % children
-            result.append(itemString)
-        return result
+    #####################################################################
+    #                                                                   #
+    # Name, role, and label information                                 #
+    #                                                                   #
+    #####################################################################
 
-    def _isCheckbox(self, obj, **args):
-        # pylint: disable-msg=W0142
+    def _getName(self, obj, **args):
         result = []
-        try:
-            action = obj.queryAction()
-        except NotImplementedError:
-            action = None
-        if action:
-            for i in range(0, action.nActions):
-                # Translators: this is the action name for
-                # the 'toggle' action. It must be the same
-                # string used in the *.po file for gail.
-                #
-                if action.getName(i) in ["toggle", _("toggle")]:
-                    #pdb.set_trace()
-                    #ipshell()
-
-                    oldFmtstr = args.get('fmtstr', None)
-
-                    args['fmtstr'] = self._getFmtstr( \
-                      forceRole=pyatspi.ROLE_CHECK_BOX, **args) 
-                    #print "args is:"
-                    #print args
-                    #pdb.set_trace()
-                    result.extend( \
-                      self.getSpeech(obj, **args))
-                    args['fmtstr'] = oldFmtstr
-                    break
+        name = self._script.getDisplayedText(obj)
+        if name:
+            result.append(name)
+        elif obj.description:
+            result.append(obj.description)
         return result
 
-    def _getTerminal(self, obj, **args):
-        """Get the speech for a terminal
-
-        Arguments:
-        - obj: the terminal
-        
-        Returns a list of utterances to be spoken for the object.
-        """
-        result = []
-
-        title = None
-        frame = self._script.getFrame(obj)
-        if frame:
-            title = frame.name
-        if not title:
-            title = self._script.getDisplayedLabel(obj)
-
-        result.append(title)
-        return result
-        
     def _getTextRole(self, obj, **args):
-        """Get the speech for a text component.
-
-        Arguments:
-        - obj: the text component
-        
-        Returns a list of utterances to be spoken for the object.
-        """
         result = []
         # pylint: disable-msg=W0142
         if obj.getRole() != pyatspi.ROLE_PARAGRAPH:
             result.extend(self._getRoleName(obj, **args))
         return result
 
-    def _getCurrentLineText(self, obj, **args ):
-        """Get the speech for a text component.
-
-        Arguments:
-        - obj: the text component
-
-        Returns a list of utterances to be spoken for the object.
-        """
+    def _getRoleName(self, obj, forceRole=None, **args):
         result = []
+        if forceRole:
+            role = forceRole
+        else:
+            role = args.get('role', None)
+        if (obj.getRole() != pyatspi.ROLE_UNKNOWN):
+            result.append(rolenames.getSpeechForRoleName(obj, role))
+        return result
 
-        [text, caretOffset, startOffset] = self._script.getTextLineAtCaret(obj)
-        return [text]
-
-    def _getIsReadOnly(self, obj, **args):
-        """Get the speech for a text component.
-
-        Arguments:
-        - obj: the text component
-
-        Returns a list of utterances to be spoken for the object.
-        """
+    def _getLabel(self, obj, **args):
         result = []
-
-        if settings.presentReadOnlyText \
-           and self._script.isReadOnlyTextArea(obj):
-            result.append(settings.speechReadOnlyString)
+        label = self._script.getDisplayedLabel(obj)
+        if label:
+            result = [label]
         return result
 
-    def _getLabelOrName2(self, obj, **args ):
-        """Get the speech for a text component.
-
-        Arguments:
-        - obj: the text component
-
-        Returns a list of utterances to be spoken for the object.
-        """
+    def _getLabelAndName(self, obj, **args):
+        """Gets the label and the name if the name is different from the label."""
+        # pylint: disable-msg=W0142
+        result = []
+        label = self._getLabel(obj, **args)
+        name = self._getName(obj, **args)
+        result.extend(label)
+        if not len(label):
+            result.extend(name)
+        elif len(name) and name[0] != label[0]:
+            result.extend(name)
+        return result
 
+    def _getLabelOrName(self, obj, **args):
+        """Gets the label or the name if the label is not preset."""
         result = []
         # pylint: disable-msg=W0142
         result.extend(self._getLabel(obj, **args))
-        if len(result) == 0:
+        if not result:
             if obj.name and (len(obj.name)):
                 result.append(obj.name)
         return result
 
-    def _getHasNoShowingChildren(self, obj, **args):
-        """Get the speech for a layered pane
-
-        Arguments:
-        - obj: the table
-
-        Returns a list of utterances to be spoken for the object.
-        """
-        result = []
-
-        # If this has no children, then let the user know.
-        #
-        hasItems = False
-        for child in obj:
-            state = child.getState()
-            if state.contains(pyatspi.STATE_SHOWING):
-                hasItems = True
-                break
-        if not hasItems:
-            # Translators: this is the number of items in a layered pane
-            # or table.
-            #
-            result.append(_("0 items"))
-
-        return result
-
-    def _getImageDescription(self, obj, **args ):
-        """Get the speech for an icon.
-
-        Arguments:
-        - obj: the icon
-
-        Returns a list of utterances to be spoken for the object.
-        """
-
-        # [[[TODO: WDW - HACK to remove availability output because nautilus
-        # doesn't include this information for desktop icons.  If, at some
-        # point, it is determined that availability should be added back in,
-        # then a custom script for nautilus needs to be written to remove the
-        # availability.]]]
-        #        
+    def _getUnrelatedLabels(self, obj, **args):
+        """Finds all labels not in a label for or labelled by relation."""
+        labels = self._script.findUnrelatedLabels(obj)
         result = []
-        try:
-            image = obj.queryImage()
-        except NotImplementedError:
-            pass
-        else:
-            description = image.imageDescription
-            if description and len(description):
-                result.append(description)
+        for label in labels:
+            name = self._getName(label, **args)
+            result.extend(name)
         return result
 
     def _getEmbedded(self, obj, **args):
@@ -318,338 +178,174 @@ class AltSpeechGenerator:
                 pass
         return result
 
-    def _getDisplayedText(self, obj, **args ):
-        return [self._script.getDisplayedText(obj)]
+    #####################################################################
+    #                                                                   #
+    # State information                                                 #
+    #                                                                   #
+    #####################################################################
 
-    def _getRealActiveDescendantDisplayedText(self, obj, **args ):
-        text = self._script.getDisplayedText(\
-          self._script.getRealActiveDescendant(obj))
-        if text:
-            return [text]
-        else:
-            return []
-
-    def _getHasNoChildren(self, obj, **args ):
-        result = []
-        if not obj.childCount:
-            # Translators: this is the number of items in a layered pane
-            # or table.
-            #
-            result.append(_("0 items"))
-        return result
-
-    def _getPercentage(self, obj, **args ):
-        value = obj.queryValue()
-        percentValue = (value.currentValue / \
-            (value.maximumValue - value.minimumValue)) * 100.0
-
-        # Translators: this is the percentage value of a progress bar.
-        #
-        percentage = _("%d percent.") % percentValue + " "
-        return [percentage]
-
-    def _getIsCheckedState(self, obj, **args ):
+    def _getCheckedState(self, obj, **args):
         result = []
         state = obj.getState()
-        if state.contains(pyatspi.STATE_CHECKED):
-            # Translators: this represents the state of a checked menu item.
+        if state.contains(pyatspi.STATE_INDETERMINATE):
+            # Translators: this represents the state of a checkbox.
+            #
+            result.append(_("partially checked"))
+        elif state.contains(pyatspi.STATE_CHECKED):
+            # Translators: this represents the state of a checkbox.
             #
             result.append(_("checked"))
-        return result
-
-    def _getUnfocusedDialogueCount(self, obj,  **args):
-        result = []
-        # If this application has more than one unfocused alert or
-        # dialog window, then speak '<m> unfocused dialogs'
-        # to let the user know.
-        #
-        alertAndDialogCount = \
-                    self._script.getUnfocusedAlertAndDialogCount(obj)
-        if alertAndDialogCount > 0:
-            # Translators: this tells the user how many unfocused
-            # alert and dialog windows that this application has.
+        else:
+            # Translators: this represents the state of a checkbox.
             #
-            result.append(ngettext("%d unfocused dialog",
-                            "%d unfocused dialogs",
-                            alertAndDialogCount) % alertAndDialogCount)
+            result.append(_("not checked"))
         return result
 
-    def _getExpandableState(self, obj, **args):
+    def _getCellCheckedState(self, obj, **args):
+        # pylint: disable-msg=W0142
         result = []
-        # If already in focus then the tree probably collapsed or expanded
-        state = obj.getState()
-        if state.contains(pyatspi.STATE_EXPANDABLE):
-            if state.contains(pyatspi.STATE_EXPANDED):
-                # Translators: this represents the state of a node in a tree.
-                # 'expanded' means the children are showing.
-                # 'collapsed' means the children are not showing.
-                #
-                result.append(_("expanded"))
-            else:
-                # Translators: this represents the state of a node in a tree.
-                # 'expanded' means the children are showing.
-                # 'collapsed' means the children are not showing.
+        try:
+            action = obj.queryAction()
+        except NotImplementedError:
+            action = None
+        if action:
+            for i in range(0, action.nActions):
+                # Translators: this is the action name for
+                # the 'toggle' action. It must be the same
+                # string used in the *.po file for gail.
                 #
-                result.append( _("collapsed"))
-        return result
-
-    def _getValue(self, obj, **args):
-        return [self._script.getTextForValue(obj)]
-
-    def _getAccelerator(self, obj, **args):
-        """returns an utterance that describes the keyboard accelerator for the
-        given object.
-
-        Arguments:
-        - obj: the Accessible object
-
-        Returns a list of utterances to be spoken.
-        """
-        # replaces _addSpeechForObjectAccelerator
-
-        result = []
-        [mnemonic, shortcut, accelerator] = self._script.getKeyBinding(obj)
-        if accelerator:
-            # Add punctuation for better prosody.
-            #
-            #if utterances:
-            #    utterances[-1] += "."
-            result.append(accelerator)
+                if action.getName(i) in ["toggle", _("toggle")]:
+                    oldFormat = args.get('format', None)
+                    args['format'] = self._script.formatting.getFormat(
+                        forceRole=pyatspi.ROLE_CHECK_BOX, **args)
+                    result.extend(
+                        self.getSpeech(obj, **args))
+                    args['format'] = oldFormat
+                    break
         return result
 
     def _getRadioState(self, obj, **args):
+        result = []
         state = obj.getState()
         if state.contains(pyatspi.STATE_CHECKED):
             # Translators: this is in reference to a radio button being
             # selected or not.
             #
-            selectionState = C_("radiobutton", "selected")
+            result.append(C_("radiobutton", "selected"))
         else:
             # Translators: this is in reference to a radio button being
             # selected or not.
             #
-            selectionState = C_("radiobutton", "not selected")
-        return [selectionState]
-
-    def _getCheckState(self, obj, **args):
-        # replaces _getSpeechForCheckBox
-        state = obj.getState()
-        if state.contains(pyatspi.STATE_INDETERMINATE):
-            # Translators: this represents the state of a checkbox.
-            #
-            checkedState = _("partially checked")
-        elif state.contains(pyatspi.STATE_CHECKED):
-            # Translators: this represents the state of a checkbox.
-            #
-            checkedState = _("checked")
-        else:
-            # Translators: this represents the state of a checkbox.
-            #
-            checkedState = _("not checked")
-        return [checkedState]
+            result.append(C_("radiobutton", "not selected"))
+        return result
 
     def _getToggleState(self, obj, **args):
+        result = []
         state = obj.getState()
         if state.contains(pyatspi.STATE_CHECKED) \
            or state.contains(pyatspi.STATE_PRESSED):
             # Translators: the state of a toggle button.
             #
-            checkedState = _("pressed")
+            result.append(_("pressed"))
         else:
             # Translators: the state of a toggle button.
             #
-            checkedState = _("not pressed")
-        return [checkedState]
-
-    def _getCheckRole(self, obj, **args):
-        # replaces _getSpeechForCheckBox
-        # pylint: disable-msg=W0142
-        if obj.getRole() == pyatspi.ROLE_TABLE_CELL:
-            result = \
-              self._getRoleName(obj, forceRole=pyatspi.ROLE_CHECK_BOX, **args)
-        else:
-            result = self._getRoleName(obj, **args)
+            result.append(_("not pressed"))
         return result
 
-    def _getMnemonic(self, obj, **args):
-        """returns an utterance that describes the mnemonic for the given object
-
-        Arguments:
-        - obj: the Accessible object
-        """
-        # replaces _addSpeechForObjectMnemonic
+    def _getExpandableState(self, obj, **args):
+        result = []
+        state = obj.getState()
+        if state.contains(pyatspi.STATE_EXPANDABLE):
+            if state.contains(pyatspi.STATE_EXPANDED):
+                # Translators: this represents the state of a node in a tree.
+                # 'expanded' means the children are showing.
+                # 'collapsed' means the children are not showing.
+                #
+                result.append(_("expanded"))
+            else:
+                # Translators: this represents the state of a node in a tree.
+                # 'expanded' means the children are showing.
+                # 'collapsed' means the children are not showing.
+                #
+                result.append(_("collapsed"))
+        return result
 
+    def _getMenuItemCheckedState(self, obj, **args):
         result = []
-        #if obj != orca_state.locusOfFocus:
-        #    return []
-        [mnemonic, shortcut, accelerator] = self._script.getKeyBinding(obj)
-        if mnemonic:
-            mnemonic = mnemonic[-1] # we just want a single character
-        if not mnemonic and shortcut:
-            mnemonic = shortcut
-        if mnemonic:
-            # Add punctuation for better prosody.
+        if state.contains(pyatspi.STATE_CHECKED):
+            # Translators: this represents the state of a checked menu item.
             #
-            #if utterances:
-            #    utterances[-1] += "."
-            result = [mnemonic]
+            result.append(_("checked"))
         return result
 
     def _getAvailability(self, obj, **args):
-        """Returns a list of utterances that describes the availability
-        of the given object.
-
-        Arguments:
-        - obj: the Accessible object
-
-        Returns a list of utterances to be spoken.
-        """
-        # replaces _getSpeechForObjectAvailability
-
+        result = []
         state = obj.getState()
         if not state.contains(pyatspi.STATE_SENSITIVE):
             # Translators: this represents an item on the screen that has
             # been set insensitive (or grayed out).
             #
-            return [_("grayed")]
-        else:
-            return []
-
-    def _getLabelOrName(self, obj, **args):
-        # pylint: disable-msg=W0142
-        result = []
-        label = self._getLabel(obj, **args)
-        name = self._getName(obj, **args)
-        result.extend(label)
-        if not len(label):
-            result.extend(name)
-        elif len(name) and name[0] != label[0]:
-            result.extend(name)
+            result.append(_("grayed"))
         return result
 
-    def _getLabel(self, obj, **args):
-        # replaces _getSpeechForObjectLabel
-
+    def _getRequired(self, obj, **args):
         result = []
-        label = self._script.getDisplayedLabel(obj)
-        if label:
-            result =  [label]
+        state = obj.getState()
+        if state.contains(pyatspi.STATE_REQUIRED):
+            result = [settings.speechRequiredStateString]
         return result
 
-    def _getUnrelatedLabels(self, obj, **args):
-        # _getSpeechForAlert
-        labels = self._script.findUnrelatedLabels(obj)
+    def _getReadOnly(self, obj, **args):
         result = []
-        for label in labels:
-            name = self._getName(label, False)
-            result.extend(name)
+        if settings.presentReadOnlyText \
+           and self._script.isReadOnlyTextArea(obj):
+            result.append(settings.speechReadOnlyString)
         return result
 
-    def _getName(self, obj, **args):
-        # replaces _getSpeechForObjectName
-        name = self._script.getDisplayedText(obj)
-        if name:
-            return [name]
-        elif obj.description:
-            return [obj.description]
-        else:
-            return []
-
-    def _getRoleName(self, obj, forceRole=None, **args):
-        # replaces getSpeechForObjectRole
-        role =  args.get('role', None)
-
-        if forceRole:
-            role = forceRole
-
-        if (obj.getRole() != pyatspi.ROLE_UNKNOWN):
-            result = [rolenames.getSpeechForRoleName(obj, role)]
-            return  result
-        else:
-            return []
-
-    def _getRequiredObject(self, obj, **args):
-        """Returns the list of utterances that describe the required state
-        of the given object.
-
-        Arguments:
-        - obj: the Accessible object
+    #####################################################################
+    #                                                                   #
+    # Image information                                                 #
+    #                                                                   #
+    #####################################################################
 
-        Returns a list of utterances to be spoken.
-        """
-        # replaces _getSpeechForRequiredObject
-        state = obj.getState()
-        if state.contains(pyatspi.STATE_REQUIRED):
-            return [settings.speechRequiredStateString]
+    def _getImageDescription(self, obj, **args ):
+        result = []
+        try:
+            image = obj.queryImage()
+        except NotImplementedError:
+            pass
         else:
-            return []
-
-    def _getAllTextSelection(self, obj, **args):
-        """Check if this object has text associated with it and it's 
-        completely selected.
-
-        Arguments:
-        - obj: the object being presented
-        """
-        # replaces _getSpeechForAllTextSelection
+            description = image.imageDescription
+            if description and len(description):
+                result.append(description)
+        return result
 
+    def _getImage(self, obj, **args):
         result = []
         try:
-            textObj = obj.queryText()
+            image = obj.queryImage()
         except:
             pass
         else:
-            noOfSelections = textObj.getNSelections()
-            if noOfSelections == 1:
-                [string, startOffset, endOffset] = \
-                   textObj.getTextAtOffset(0, pyatspi.TEXT_BOUNDARY_LINE_START)
-                if startOffset == 0 and endOffset == len(string):
-                    # Translators: when the user selects (highlights) text in
-                    # a document, Orca lets them know this.
-                    #
-                    result = [C_("text", "selected")]
-
+            role = pyatspi.ROLE_IMAGE
+            result.extend(self.getSpeech(obj, role=role))
         return result
 
-
-    def _getFmtstr(self, forceRole=None, **args):
-        already_focused = args.get('already_focused', False)
-        role = args.get('role', None)
-
-        if forceRole:
-            role = forceRole
-
-        fmtstr = ''
-        # Finding the formatting string to be used.
-        #
-        # Checking if we have the role defined.
-        #
-        if generator_settings.formattingDict.has_key(role):
-            roleDict =     generator_settings.formattingDict[role]
-        else:
-            roleDict =     generator_settings.formattingDict['default']
-
-        if already_focused and 'focusedSpeech' in roleDict:
-            fmtstr = roleDict['focusedSpeech']
-        else:
-            fmtstr = roleDict['unfocusedSpeech']
-        return fmtstr
-
+    #####################################################################
+    #                                                                   #
+    # Table interface information                                       #
+    #                                                                   #
+    #####################################################################
 
     def _getTableCell2ChildLabel(self, obj, **args):
-        """Get the speech utterances for a single table cell
-
-        Arguments:
-        - obj: the table
-        
-        Returns a list of utterances to be spoken for the object.
-        """
-
+        """Get the speech utterances for the label of single table cell that
+        has a special 2 child pattern that we run into."""
         # pylint: disable-msg=W0142
         result = []
 
-        # If this table cell has 2 children and one of them has a 
-        # 'toggle' action and the other does not, then present this 
+        # If this table cell has 2 children and one of them has a
+        # 'toggle' action and the other does not, then present this
         # as a checkbox where:
         # 1) we get the checked state from the cell with the 'toggle' action
         # 2) we get the label from the other cell.
@@ -657,7 +353,7 @@ class AltSpeechGenerator:
         #
         if obj.childCount == 2:
             cellOrder = []
-            hasToggle = [ False, False ]
+            hasToggle = [False, False]
             for i, child in enumerate(obj):
                 try:
                     action = child.queryAction()
@@ -672,35 +368,26 @@ class AltSpeechGenerator:
                         if action.getName(j) in ["toggle", _("toggle")]:
                             hasToggle[i] = True
                             break
-
             if hasToggle[0] and not hasToggle[1]:
-                cellOrder = [ 1, 0 ] 
+                cellOrder = [ 1, 0 ]
             elif not hasToggle[0] and hasToggle[1]:
                 cellOrder = [ 0, 1 ]
             if cellOrder:
-                args['fmtstr'] = self._getFmtstr( \
+                args['format'] = self._script.formatting.getFormat( \
                   forceRole=pyatspi.ROLE_TABLE_CELL, **args)
                 for i in cellOrder:
                     if not hasToggle[i]:
-                        result.extend( \
-                            self.getSpeech(obj[i],
-                                                        **args))
+                        result.extend(self.getSpeech(obj[i], **args))
         return result
 
     def _getTableCell2ChildToggle(self, obj, **args):
-        """Get the speech utterances for a single table cell
-
-        Arguments:
-        - obj: the table
-
-        Returns a list of utterances to be spoken for the object.
-        """
-
+        """Get the speech utterances for the label of single table cell that
+        has a special 2 child pattern that we run into."""
         # pylint: disable-msg=W0142
         result = []
 
-        # If this table cell has 2 children and one of them has a 
-        # 'toggle' action and the other does not, then present this 
+        # If this table cell has 2 children and one of them has a
+        # 'toggle' action and the other does not, then present this
         # as a checkbox where:
         # 1) we get the checked state from the cell with the 'toggle' action
         # 2) we get the label from the other cell.
@@ -708,7 +395,7 @@ class AltSpeechGenerator:
         #
         if obj.childCount == 2:
             cellOrder = []
-            hasToggle = [ False, False ]
+            hasToggle = [False, False]
             for i, child in enumerate(obj):
                 try:
                     action = child.queryAction()
@@ -725,43 +412,32 @@ class AltSpeechGenerator:
                             break
 
             if hasToggle[0] and not hasToggle[1]:
-                cellOrder = [ 1, 0 ] 
+                cellOrder = [ 1, 0 ]
             elif not hasToggle[0] and hasToggle[1]:
                 cellOrder = [ 0, 1 ]
             if cellOrder:
-                args['role'] = pyatspi.ROLE_CHECK_BOX 
+                args['role'] = pyatspi.ROLE_CHECK_BOX
                 for i in cellOrder:
                     if hasToggle[i]:
-                        result.extend( \
-                            self.getSpeech(obj[i],
-                                                        **args))
+                        result.extend(self.getSpeech(obj[i], **args))
         return result
 
     def _getTableCellRow(self, obj, **args):
         """Get the speech for a table cell row or a single table cell
-        if settings.readTableCellRow is False.
-
-        Arguments:
-        - obj: the table
-        - already_focused: False if object just received focus
-
-        Returns a list of utterances to be spoken for the object.
-        """
-
+        if settings.readTableCellRow is False."""
         # pylint: disable-msg=W0142
-        utterances = []
-        #pdb.set_trace()
+        result = []
 
         try:
-            parent_table = obj.parent.queryTable()
+            parentTable = obj.parent.queryTable()
         except NotImplementedError:
-            parent_table = None
-        if settings.readTableCellRow and parent_table \
-            and (not self._script.isLayoutOnly(obj.parent)):
+            parentTable = None
+        if settings.readTableCellRow and parentTable \
+           and (not self._script.isLayoutOnly(obj.parent)):
             parent = obj.parent
             index = self._script.getCellIndex(obj)
-            row = parent_table.getRowAtIndex(index)
-            column = parent_table.getColumnAtIndex(index)
+            row = parentTable.getRowAtIndex(index)
+            column = parentTable.getColumnAtIndex(index)
 
             # This is an indication of whether we should speak all the
             # table cells (the user has moved focus up or down a row),
@@ -770,28 +446,21 @@ class AltSpeechGenerator:
             #
             speakAll = True
             if "lastRow" in self._script.pointOfReference and \
-                "lastColumn" in self._script.pointOfReference:
+               "lastColumn" in self._script.pointOfReference:
                 pointOfReference = self._script.pointOfReference
                 speakAll = (pointOfReference["lastRow"] != row) or \
-                    ((row == 0 or row == parent_table.nRows-1) and \
+                    ((row == 0 or row == parentTable.nRows-1) and \
                        pointOfReference["lastColumn"] == column)
-
             if speakAll:
-                print("this table has %s columns" %parent_table.nColumns)
-                for i in range(0, parent_table.nColumns):
-                    #print("trying to deal with child %s" %i)
-                    cell = parent_table.getAccessibleAt(row, i)
+                for i in range(0, parentTable.nColumns):
+                    cell = parentTable.getAccessibleAt(row, i)
                     if not cell:
-                        #debug.println(debug.LEVEL_WARNING,
-                        #     "ERROR: speechgenerator." \
-                        #     + "_getSpeechForTableCellRow" \
-                        #     + " no accessible at (%d, %d)" % (row, i))
                         continue
                     state = cell.getState()
                     showing = state.contains(pyatspi.STATE_SHOWING)
                     if showing:
                         # If this table cell has a "toggle" action, and
-                        # doesn't have any label associated with it then 
+                        # doesn't have any label associated with it then
                         # also speak the table column header.
                         # See Orca bug #455230 for more details.
                         #
@@ -810,97 +479,257 @@ class AltSpeechGenerator:
                                 if action.getName(j) in ["toggle", \
                                                          _("toggle")]:
                                     accHeader = \
-                                        parent_table.getColumnHeader(i)
-                                    utterances.append(accHeader.name)
-                        fmtstr = self._getFmtstr( \
-                          forceRole='REAL_ROLE_TABLE_CELL', **args)
-                        utterances.extend( \
-                          self.getSpeech(cell, fmtstr=fmtstr, **args))
-                    #print ("finished with child")
+                                        parentTable.getColumnHeader(i)
+                                    result.append(accHeader.name)
+                        format = self._script.formatting.getFormat( \
+                            forceRole='REAL_ROLE_TABLE_CELL', **args)
+                        result.extend( \
+                            self.getSpeech(cell,
+                                           format=format,
+                                           **args))
             else:
-                fmtstr = self._getFmtstr( \
-                  forceRole='REAL_ROLE_TABLE_CELL', **args)
-                utterances.extend( \
-                  self.getSpeech(obj, fmtstr=fmtstr, **args))
+                format = self._script.formatting.getFormat( \
+                    forceRole='REAL_ROLE_TABLE_CELL', **args)
+                result.extend( \
+                    self.getSpeech(obj, format=format, **args))
         else:
-            fmtstr = self._getFmtstr(forceRole='REAL_ROLE_TABLE_CELL', **args)
-            utterances = self.getSpeech(obj, \
-              fmtstr=fmtstr, **args)
-        return utterances
+            format = self._script.formatting.getFormat(
+                forceRole='REAL_ROLE_TABLE_CELL',
+                **args)
+            result = self.getSpeech(obj, format=format, **args)
+        return result
+
+    #####################################################################
+    #                                                                   #
+    # Terminal information                                              #
+    #                                                                   #
+    #####################################################################
+
+    def _getTerminal(self, obj, **args):
+        result = []
+        title = None
+        frame = self._script.getFrame(obj)
+        if frame:
+            title = frame.name
+        if not title:
+            title = self._script.getDisplayedLabel(obj)
+        result.append(title)
+        return result
+
+    #####################################################################
+    #                                                                   #
+    # Text interface information                                        #
+    #                                                                   #
+    #####################################################################
+
+    def _getCurrentLineText(self, obj, **args ):
+        [text, caretOffset, startOffset] = self._script.getTextLineAtCaret(obj)
+        return [text]
+
+    def _getDisplayedText(self, obj, **args ):
+        """Returns the text being displayed for an object or the object's
+        name if no text is being displayed."""
+        return [self._script.getDisplayedText(obj)]
+
+    def _getAllTextSelection(self, obj, **args):
+        """Check if this object has text associated with it and it's
+        completely selected."""
+        result = []
+        try:
+            textObj = obj.queryText()
+        except:
+            pass
+        else:
+            noOfSelections = textObj.getNSelections()
+            if noOfSelections == 1:
+                [string, startOffset, endOffset] = \
+                   textObj.getTextAtOffset(0, pyatspi.TEXT_BOUNDARY_LINE_START)
+                if startOffset == 0 and endOffset == len(string):
+                    # Translators: when the user selects (highlights) text in
+                    # a document, Orca lets them know this.
+                    #
+                    result = [C_("text", "selected")]
+        return result
+
+    #####################################################################
+    #                                                                   #
+    # Value interface information                                       #
+    #                                                                   #
+    #####################################################################
+
+    def _getValue(self, obj, **args):
+        return [self._script.getTextForValue(obj)]
+
+    def _getPercentage(self, obj, **args ):
+        result = []
+        try:
+            value = obj.queryValue()
+        except NotImplementedError:
+            pass
+        else:
+            percentValue = \
+                (value.currentValue \
+                 / (value.maximumValue - value.minimumValue)) \
+                * 100.0
+            # Translators: this is the percentage value of a progress bar.
+            #
+            percentage = _("%d percent.") % percentValue + " "
+            result.append(percentage)
+        return result
+
+    #####################################################################
+    #                                                                   #
+    # Hierarchy and related dialog information                          #
+    #                                                                   #
+    #####################################################################
+
+    def _getRealActiveDescendantDisplayedText(self, obj, **args ):
+        text = self._script.getDisplayedText(\
+          self._script.getRealActiveDescendant(obj))
+        if text:
+            return [text]
+        else:
+            return []
+
+    def _getNumberOfChildren(self, obj, **args):
+        result = []
+        childNodes = self._script.getChildNodes(obj)
+        children = len(childNodes)
+        if children:
+            # Translators: this is the number of items in a layered
+            # pane or table.
+            #
+            itemString = ngettext("%d item", "%d items", children) % children
+            result.append(itemString)
+        return result
+
+    def _getNoShowingChildren(self, obj, **args):
+        result = []
+        hasItems = False
+        for child in obj:
+            state = child.getState()
+            if state.contains(pyatspi.STATE_SHOWING):
+                hasItems = True
+                break
+        if not hasItems:
+            # Translators: this is the number of items in a layered pane
+            # or table.
+            #
+            result.append(_("0 items"))
+        return result
+
+    def _getNoChildren(self, obj, **args ):
+        result = []
+        if not obj.childCount:
+            # Translators: this is the number of items in a layered pane
+            # or table.
+            #
+            result.append(_("0 items"))
+        return result
+
+    def _getUnfocusedDialogCount(self, obj,  **args):
+        result = []
+        # If this application has more than one unfocused alert or
+        # dialog window, then speak '<m> unfocused dialogs'
+        # to let the user know.
+        #
+        alertAndDialogCount = \
+                    self._script.getUnfocusedAlertAndDialogCount(obj)
+        if alertAndDialogCount > 0:
+            # Translators: this tells the user how many unfocused
+            # alert and dialog windows that this application has.
+            #
+            result.append(ngettext("%d unfocused dialog",
+                            "%d unfocused dialogs",
+                            alertAndDialogCount) % alertAndDialogCount)
+        return result
+
+    #####################################################################
+    #                                                                   #
+    # Keyboard shortcut information                                     #
+    #                                                                   #
+    #####################################################################
+
+    def _getAccelerator(self, obj, **args):
+        result = []
+        [mnemonic, shortcut, accelerator] = self._script.getKeyBinding(obj)
+        if accelerator:
+            # Add punctuation for better prosody.
+            #
+            #if utterances:
+            #    utterances[-1] += "."
+            result.append(accelerator)
+        return result
+
+    def _getMnemonic(self, obj, **args):
+        result = []
+        [mnemonic, shortcut, accelerator] = self._script.getKeyBinding(obj)
+        if mnemonic:
+            mnemonic = mnemonic[-1] # we just want a single character
+        if not mnemonic and shortcut:
+            mnemonic = shortcut
+        if mnemonic:
+            # Add punctuation for better prosody.
+            #
+            #if utterances:
+            #    utterances[-1] += "."
+            result = [mnemonic]
+        return result
+
+    #####################################################################
+    #                                                                   #
+    # Tie it all together                                               #
+    #                                                                   #
+    #####################################################################
 
     def getSpeech(self, obj, already_focused=False, **args):
-        """ Test """
         # pylint: disable-msg=W0142
-        res = {}
-        #pdb.set_trace()
+        result = []
+        generatedResultsDict = {}
         try:
             role = args.get('role', obj.getRole())
             forceRole = args.get('forceRole', role)
             role = forceRole
 
-            # Used for debugging a particular role.
-            #
-            if role in []: # pyatspi.ROLE_DIALOG as example
-                pdb.set_trace()
-            #pdb.set_trace()
             roleName = self._getRoleName(obj, forceRole=role, **args)
+
             # If someone has already given us the format string to be used
             # then we dont need to look it up.
-            fmtstr = args.get('fmtstr', '')
-
-            #print "looking up fmtstr\n"
-            #sys.stdout.flush()
-            if not fmtstr:
+            #
+            format = args.get('format', '')
+            if not format:
                 args['already_focused'] = already_focused
-                fmtstr = self._getFmtstr(forceRole=role, **args)
-            fmtstrKey = args.get('fmtstrKey', None)
-            if fmtstrKey:
-                fmtstr = self._getFmtstr(forceRole=fmtstrKey, **args)
-
-            assert(fmtstr != '')
-            evalstr = fmtstr
-            utterances = []
-            myswitch = self._myswitch
-            #print("fmtstr = '%s'\n" %fmtstr)
-            sys.stdout.flush()
-            # Looping through the arguments of the formatting string.
+                format = self._script.formatting.getFormat('speech',
+                                                           forceRole=role,
+                                                           **args)
+
+            assert(format)
+            evalString = format
+
+            # We loop through the format string, catching each error
+            # as we go.  Each error should always be a NameError, where
+            # the name is the name of one of our generator functions.
+            # When we encounter this, we call the function and get its
+            # results, placing them in the generatedResultDict,
+            # which serves as the globals for the call to eval.
             #
-            e = []
-            finished = None
-            while not e and not finished:
-
-                # Checking if we evaluate to tru
-                # and therefore can escape from the loop
-                # and return.
-                #
+            while True:
                 try:
-                    e = eval(evalstr, res)
-                    finished = True
+                    result = eval(evalString, generatedResultsDict)
+                    break
                 except NameError:
-                    e = []
+                    result = []
                     info = formatExceptionInfo()
-                    #print "--here is the info:\n"
-                    #print info[1]
-                    #print "\n---end of info"
-                    #pdb.set_trace()
                     arg = info[1][0]
                     arg = arg.replace("name '", "")
                     arg = arg.replace("' is not defined", "")
-
-                    if not myswitch.has_key(arg):
-                        print("unable to find function for '%s'\n" %arg)
-                        sys.stdout.flush()
+                    if not self._methodsDict.has_key(arg):
+                        print("unable to find function for '%s'\n" % arg)
                         break
-            
-                    #print("calling func for %s" %arg)
-                    sys.stdout.flush()
-                    res[arg] = myswitch[arg](obj, **args)
-                    #print("returns '%s'" %res[arg])
-                    sys.stdout.flush()
-
-
+                    generatedResultsDict[arg] = \
+                        self._methodsDict[arg](obj, **args)
         except:
             print formatExceptionInfo()
+            result = []
 
-        result = e
         return result
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 5109ac8..193622e 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -28,7 +28,7 @@ moving the text caret.
 __id__        = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
 import logging
@@ -149,6 +149,24 @@ command_name[brlapi.KEY_CMD_SIXDOTS]  = _("Six Dots")
 #
 command_name[brlapi.KEY_CMD_ROUTE]    = _("Cursor Routing")
 
+# Translators: this is a command for a button on a refreshable braille
+# display (an external hardware device used by people who are blind).
+# This command represents the start of a selection operation.  It is
+# called "Cut Begin" to map to what BrlTTY users are used to:  in
+# character cell mode operation on virtual consoles, the act of copying
+# text is erroneously called a "cut" operation.
+#
+command_name[brlapi.KEY_CMD_CUTBEGIN] = _("Cut Begin")
+
+# Translators: this is a command for a button on a refreshable braille
+# display (an external hardware device used by people who are blind).
+# This command represents marking the endpoint of a selection.  It is
+# called "Cut Line" to map to what BrlTTY users are used to:  in
+# character cell mode operation on virtual consoles, the act of copying
+# text is erroneously called a "cut" operation.
+#
+command_name[brlapi.KEY_CMD_CUTLINE] = _("Cut Line")
+
 # The size of the physical display (width, height).  The coordinate system of
 # the display is set such that the upper left is (0,0), x values increase from
 # left to right, and y values increase from top to bottom.
@@ -224,9 +242,9 @@ class Region:
         # If louis is None, then we don't go into contracted mode.
         self.contracted = settings.enableContractedBraille and \
                           louis is not None
-        
+
         self.expandOnCursor = expandOnCursor
-        
+
         # The uncontracted string for the line.
         #
         self.rawLine = string.decode("UTF-8").strip("\n")
@@ -241,7 +259,7 @@ class Region:
         else:
             self.string = self.rawLine
             self.cursorOffset = cursorOffset
-            
+
     def processRoutingKey(self, offset):
         """Processes a cursor routing key press on this Component.  The offset
         is 0-based, where 0 represents the leftmost character of string
@@ -269,7 +287,7 @@ class Region:
         #
         mask = ['\x00'] * maskSize
         return "".join(mask)
-    
+
     def repositionCursor(self):
         """Reposition the cursor offset for contracted mode.
         """
@@ -293,7 +311,7 @@ class Region:
             cursorOnSpace = line[cursorOffset] == ' '
         except IndexError:
             cursorOnSpace = False
-            
+
         if not expandOnCursor or cursorOnSpace:
             contracted, inPos, outPos, cursorPos = \
                              louis.translate([self.contractionTable],
@@ -307,7 +325,7 @@ class Region:
                                              mode=louis.MODE.compbrlAtCursor)
 
         return contracted, inPos, outPos, cursorPos
-    
+
     def displayToBufferOffset(self, display_offset):
         try:
             offset = self.inPos[display_offset]
@@ -336,7 +354,7 @@ class Region:
                                        self.cursorOffset,
                                        self.expandOnCursor)
         self.contracted = True
-        
+
     def expandRegion(self):
         if not self.contracted:
             return
@@ -346,7 +364,7 @@ class Region:
         except IndexError:
             self.cursorOffset = len(self.string)
         self.contracted = False
-        
+
 class Component(Region):
     """A subclass of Region backed by an accessible.  This Region will react
     to any cursor routing key events and perform the default action on the
@@ -373,6 +391,15 @@ class Component(Region):
 
         self.accessible = accessible
 
+    def getCaretOffset(self, offset):
+        """Returns the caret position of the given offset if the object
+        has text with a caret.  Otherwise, returns -1.
+
+        Arguments:
+        - offset: 0-based offset of the cell on the physical display
+        """
+        return -1
+
     def processRoutingKey(self, offset):
         """Processes a cursor routing key press on this Component.  The offset
         is 0-based, where 0 represents the leftmost character of string
@@ -429,7 +456,7 @@ class Text(Region):
     [[[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=None, endOffset=None):
         """Creates a new Text region.
 
@@ -499,7 +526,7 @@ class Text(Region):
         string = string.decode("UTF-8")
 
         cursorOffset = min(caretOffset - lineOffset, len(string))
-        
+
         if lineOffset != self.lineOffset:
             return False
 
@@ -516,20 +543,33 @@ class Text(Region):
 
         return True
 
+    def getCaretOffset(self, offset):
+        """Returns the caret position of the given offset if the object
+        has text with a caret.  Otherwise, returns -1.
+
+        Arguments:
+        - offset: 0-based offset of the cell on the physical display
+        """
+        offset = self.displayToBufferOffset(offset)
+
+        if offset < 0:
+            return -1
+
+        return min(self.lineOffset + offset, self._maxCaretOffset)
+
     def processRoutingKey(self, offset):
         """Processes a cursor routing key press on this Component.  The offset
         is 0-based, where 0 represents the leftmost character of text
         associated with this region.  Note that the zeroeth character may have
-        been scrolled off the display."""
-        
-        offset = self.displayToBufferOffset(offset)
+        been scrolled off the display.
+        """
 
-        if offset < 0:
+        caretOffset = self.getCaretOffset(offset)
+
+        if caretOffset < 0:
             return
 
-        newCaretOffset = min(self.lineOffset + offset, self._maxCaretOffset)
-        orca_state.activeScript.setCaretOffset(
-            self.accessible, newCaretOffset)
+        orca_state.activeScript.setCaretOffset(self.accessible, caretOffset)
 
     def getAttributeMask(self, getLinkMask=True):
         """Creates a string which can be used as the attrOr field of brltty's
@@ -636,7 +676,7 @@ class Text(Region):
     def contractLine(self, line, cursorOffset=0, expandOnCursor=True):
         contracted, inPos, outPos, cursorPos = Region.contractLine(
             self, line, cursorOffset, expandOnCursor)
-        
+
         return contracted + self.eol, inPos, outPos, cursorPos
 
     def displayToBufferOffset(self, display_offset):
@@ -688,15 +728,28 @@ class ReviewText(Region):
         self.lineOffset = lineOffset
         self.zone = zone
 
+    def getCaretOffset(self, offset):
+        """Returns the caret position of the given offset if the object
+        has text with a caret.  Otherwise, returns -1.
+
+        Arguments:
+        - offset: 0-based offset of the cell on the physical display
+        """
+        offset = self.displayToBufferOffset(offset)
+
+        if offset < 0:
+            return -1
+
+        return self.lineOffset + offset
+
     def processRoutingKey(self, offset):
         """Processes a cursor routing key press on this Component.  The offset
         is 0-based, where 0 represents the leftmost character of text
         associated with this region.  Note that the zeroeth character may have
         been scrolled off the display."""
 
-        offset = self.displayToBufferOffset(offset)
-        newCaretOffset = self.lineOffset + offset
-        orca_state.activeScript.setCaretOffset(self.accessible, newCaretOffset)
+        caretOffset = self.getCaretOffset(offset)
+        orca_state.activeScript.setCaretOffset(self.accessible, caretOffset)
 
 class Line:
     """A horizontal line on the display.  Each Line is composed of a sequential
@@ -794,7 +847,8 @@ def getRegionAtCell(cell):
     associated with that cell in the form of [region, offsetinregion]
     where 'region' is the region associated with the cell and
     'offsetinregion' is the 0-based offset of where the cell is
-    in the region, where 0 represents the beginning of the region, """
+    in the region, where 0 represents the beginning of the region.
+    """
 
     if len(_lines) > 0:
         offset = (cell - 1) + viewport[0]
@@ -803,6 +857,27 @@ def getRegionAtCell(cell):
     else:
         return [None, -1]
 
+def getCaretContext(event):
+    """Gets the accesible and caret offset associated with the given
+    event.  The event should have a BrlAPI event that contains an
+    argument value that corresponds to a cell on the display.
+
+    Arguments:
+    - event: an instance of input_event.BrailleEvent.  event.event is
+    the dictionary form of the expanded BrlAPI event.
+    """
+
+    offset = event.event["argument"]
+    [region, regionOffset] = getRegionAtCell(offset + 1)
+    if region and (isinstance(region, Text) or isinstance(region, ReviewText)):
+        accessible = region.accessible
+        caretOffset = region.getCaretOffset(regionOffset)
+    else:
+        accessible = None
+        caretOffset = -1
+
+    return [accessible, caretOffset]
+
 def clear():
     """Clears the logical structure, but keeps the Braille display as is
     (until a refresh operation).
@@ -1139,6 +1214,13 @@ def returnToRegionWithFocus(inputEvent=None):
     return True
 
 def setContractedBraille(event):
+    """Turns contracted braille on or off based upon the event.
+
+    Arguments:
+    - event: an instance of input_event.BrailleEvent.  event.event is
+    the dictionary form of the expanded BrlAPI event.
+    """
+
     settings.enableContractedBraille = \
         (event.event["flags"] & brlapi.KEY_FLG_TOGGLE_ON) != 0
     for line in _lines:
@@ -1146,11 +1228,20 @@ def setContractedBraille(event):
     refresh()
 
 def processRoutingKey(event):
+    """Processes a cursor routing key event.
+
+    Arguments:
+    - event: an instance of input_event.BrailleEvent.  event.event is
+    the dictionary form of the expanded BrlAPI event.
+    """
+
     cell = event.event["argument"]
+
     if len(_lines) > 0:
         cursor = cell + viewport[0]
         lineNum = viewport[1]
         _lines[lineNum].processRoutingKey(cursor)
+
     return True
 
 def _processBrailleEvent(event):
@@ -1215,7 +1306,7 @@ def setupKeyRanges(keys):
     #
     for key in keys:
         keySet.append(brlapi.KEY_TYPE_CMD | key)
-            
+
     _brlAPI.acceptKeys(brlapi.rangeType_command, keySet)
 
 def init(callback=None, tty=7):
diff --git a/src/orca/chnames.py b/src/orca/chnames.py
index bdcb57f..f2f0783 100644
--- a/src/orca/chnames.py
+++ b/src/orca/chnames.py
@@ -632,6 +632,14 @@ chnames[u'\u20ac'] = _("euro")
 #
 chnames[u'\u2122'] = _("trademark")
 
+# Translators: this is the spoken word for the character 'â??' (U+2190)
+#
+chnames[u'\u2190'] = _("left arrow")
+
+# Translators: this is the spoken word for the character 'â??' (U+2192)
+#
+chnames[u'\u2192'] = _("right arrow")
+
 # Translators: this is the spoken word for the character 'â??' (U+2248)
 #
 chnames[u'\u2248'] = _("almost equal to")
diff --git a/src/orca/default.py b/src/orca/default.py
index bf597af..60a5195 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2004-2008 Sun Microsystems Inc.
+# Copyright 2004-2009 Sun Microsystems Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -25,7 +25,7 @@ for GTK."""
 __id__        = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
 import locale
@@ -693,6 +693,22 @@ class Script(script.Script):
                 #
                 _("Processes a cursor routing key."))
 
+        self.inputEventHandlers["processBrailleCutBeginHandler"] = \
+            input_event.InputEventHandler(
+                Script.processBrailleCutBegin,
+                # Translators: this is used to indicate the start point
+                # of a text selection.
+                #
+                _("Marks the beginning of a text selection."))
+
+        self.inputEventHandlers["processBrailleCutLineHandler"] = \
+            input_event.InputEventHandler(
+                Script.processBrailleCutLine,
+                # Translators: this is used to indicate the end point
+                # of a text selection.
+                #
+                _("Marks the end of a text selection."))
+
         self.inputEventHandlers["enterLearnModeHandler"] = \
             input_event.InputEventHandler(
                 Script.enterLearnMode,
@@ -1961,6 +1977,10 @@ class Script(script.Script):
             self.inputEventHandlers["contractedBrailleHandler"]
         brailleBindings[braille.brlapi.KEY_CMD_ROUTE]   = \
             self.inputEventHandlers["processRoutingKeyHandler"]
+        brailleBindings[braille.brlapi.KEY_CMD_CUTBEGIN] = \
+            self.inputEventHandlers["processBrailleCutBeginHandler"]
+        brailleBindings[braille.brlapi.KEY_CMD_CUTLINE] = \
+            self.inputEventHandlers["processBrailleCutLineHandler"]
 
         return brailleBindings
 
@@ -4968,6 +4988,7 @@ class Script(script.Script):
 
     def setContractedBraille(self, inputEvent=None):
         """Toggles contracted braille."""
+
         braille.setContractedBraille(inputEvent)
         return True
 
@@ -4977,6 +4998,35 @@ class Script(script.Script):
         braille.processRoutingKey(inputEvent)
         return True
 
+    def processBrailleCutBegin(self, inputEvent=None):
+        """Clears the selection and moves the caret offset in the currently
+        active text area.
+        """
+
+        obj, caretOffset = braille.getCaretContext(inputEvent)
+
+        if caretOffset >= 0:
+            self.clearTextSelection(obj)
+            self.setCaretOffset(obj, caretOffset)
+
+        return True
+
+    def processBrailleCutLine(self, inputEvent=None):
+        """Extends the text selection in the currently active text
+        area and also copies the selected text to the system clipboard."""
+
+        obj, caretOffset = braille.getCaretContext(inputEvent)
+
+        if caretOffset >= 0:
+            self.adjustTextSelection(obj, caretOffset)
+            texti = obj.queryText()
+            startOffset, endOffset = texti.getSelection(0)
+            import gtk
+            clipboard = gtk.clipboard_get()
+            clipboard.set_text(texti.getText(startOffset, endOffset))
+
+        return True
+
     def leftClickReviewItem(self, inputEvent=None):
         """Performs a left mouse button click on the current item."""
 
@@ -7596,6 +7646,36 @@ class Script(script.Script):
         """
         print "\a"
 
+    def clearTextSelection(self, obj):
+        """Clears the text selection if the object supports it."""
+        try:
+            texti = obj.queryText()
+        except:
+            return
+
+        for i in range(0, texti.getNSelections()):
+            texti.removeSelection(0)
+
+    def adjustTextSelection(self, obj, offset):
+        """Adjusts the end point of a text selection"""
+        try:
+            texti = obj.queryText()
+        except:
+            return
+
+        if not texti.getNSelections():
+            caretOffset = texti.caretOffset
+            startOffset = min(offset, caretOffset)
+            endOffset = max(offset, caretOffset)
+            texti.addSelection(startOffset, endOffset)
+        else:
+            startOffset, endOffset = texti.getSelection(0)
+            if offset < startOffset:
+                startOffset = offset
+            else:
+                endOffset = offset
+            texti.setSelection(0, startOffset, endOffset)
+
     def setCaretOffset(self, obj, offset):
         """Set the caret offset on a given accessible. Similar to
         Accessible.setCaretOffset()
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
new file mode 100644
index 0000000..8b7bfd6
--- /dev/null
+++ b/src/orca/formatting.py
@@ -0,0 +1,189 @@
+# Orca
+#
+# Copyright 2004-2009 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+"""Manages the formatting settings for Orca."""
+
+__id__        = "$Id:$"
+__version__   = "$Revision:$"
+__date__      = "$Date:$"
+__copyright__ = "Copyright (c) 2004-2009 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+import pyatspi
+
+defaultFormatting = {
+    'speech': {
+        'default': {
+            'focused': '',
+            'unfocused': 'labelAndName + allTextSelection + roleName + availability'
+            },
+        pyatspi.ROLE_ALERT: {
+            'unfocused': 'labelAndName + unrelatedLabels'
+            }, 
+        pyatspi.ROLE_ANIMATION: {
+            'unfocused': 'labelAndName'
+            }, 
+        pyatspi.ROLE_CHECK_BOX: {
+            'focused': 'checkedState', 
+            'unfocused': 'labelAndName + roleName + checkedState + required + availability'
+            }, 
+        pyatspi.ROLE_CHECK_MENU_ITEM: {
+            'focused': 'checkedState', 
+            'unfocused': 'labelAndName + roleName + checkedState + required + availability + accelerator'
+            }, 
+        pyatspi.ROLE_DIALOG: {
+            'unfocused': 'labelAndName + unrelatedLabels'
+            }, 
+        pyatspi.ROLE_FRAME: {
+            'focused': '', 
+            'unfocused': 'labelAndName + allTextSelection + roleName + unfocusedDialogCount + availability'
+            }, 
+        pyatspi.ROLE_ICON: {
+            'focused': 'labelAndName + imageDescription + roleName', 
+            'unfocused': 'labelAndName + imageDescription + roleName'
+            }, 
+        pyatspi.ROLE_LAYERED_PANE: {
+            'focused': 'labelAndName + allTextSelection + roleName + availability + noShowingChildren',
+            'unfocused': 'labelAndName + allTextSelection + roleName + availability + noShowingChildren'
+            },
+        pyatspi.ROLE_LIST_ITEM: {
+            'focused': 'expandableState + availability',
+            'unfocused': 'labelAndName + allTextSelection + expandableState + availability'
+            },
+        pyatspi.ROLE_MENU: {
+            'focused': '',
+            'unfocused': 'labelAndName + allTextSelection + roleName + availability'
+            },
+        pyatspi.ROLE_MENU_ITEM: {
+            'focused': '',
+            'unfocused': 'labelAndName + menuItemCheckedState + availability + accelerator'
+            },
+        pyatspi.ROLE_PASSWORD_TEXT: {
+            'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
+            'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection'
+            },
+        pyatspi.ROLE_PROGRESS_BAR: {
+            'focused': 'percentage',
+            'unfocused': 'labelAndName + percentage'
+            },
+        pyatspi.ROLE_PUSH_BUTTON: {
+            'unfocused': 'labelAndName + roleName'
+            },
+        pyatspi.ROLE_RADIO_BUTTON: {
+            'focused': 'radioState',
+            'unfocused': 'labelAndName + radioState + roleName + availability'
+            },
+        pyatspi.ROLE_RADIO_MENU_ITEM: {
+            # OpenOffice check menu items currently have a role of "menu item"
+            # rather then "check menu item", so we need to test if one of the
+            # states is CHECKED. If it is, then add that in to the list of
+            # speech utterances. Note that we can't tell if this is a "check
+            # menu item" that is currently unchecked and speak that state.
+            # See Orca bug #433398 for more details.
+            # 
+            'focused': 'labelAndName + radioState + roleName + availability',
+            'unfocused': 'labelAndName + radioState + roleName + availability + accelerator'
+            },
+        pyatspi.ROLE_SLIDER: {
+            # Ignore the text on the slider.  See bug 340559
+            # (http://bugzilla.gnome.org/show_bug.cgi?id=340559): the
+            # implementors of the slider support decided to put in a
+            # Unicode left-to-right character as part of the text,
+            # even though that is not painted on the screen.
+            #
+            # In Java, however, there are sliders without a label. In
+            # this case, we'll add to presentation the slider name if
+            # it exists and we haven't found anything yet.
+            #
+            'focused': 'value',
+            'unfocused': 'labelAndName + roleName + value + required + availability'
+            },
+        pyatspi.ROLE_SPIN_BUTTON: {
+            'focused': 'name',
+            'unfocused': 'labelAndName + allTextSelection + roleName + availability + required'
+            },
+        pyatspi.ROLE_SPLIT_PANE: {
+            'focused': 'value',
+            'unfocused': 'labelAndName + roleName + value + availability'
+            },
+        pyatspi.ROLE_TABLE: {
+            'focused': 'labelAndName + allTextSelection + roleName + availability + noChildren',
+            'unfocused': 'labelAndName + allTextSelection + roleName + availability + noChildren'
+            },
+        pyatspi.ROLE_TABLE_CELL: {
+            'focused': '(tableCell2ChildLabel + tableCell2ChildToggle) or cellCheckedState + (realActiveDescendantDisplayedText or imageDescription) + (expandableState and (expandableState + numberOfChildren)) + required',
+            'unfocused': 'tableCellRow'
+            },
+        'REAL_ROLE_TABLE_CELL': {
+            # the real cell information
+            # note that pyatspi.ROLE_TABLE_CELL is used to work out if we need to
+            # read a whole row. It calls REAL_ROLE_TABLE_CELL internally.
+            # maybe it can be done in a cleaner way?
+            #
+            'focused': '(tableCell2ChildLabel + tableCell2ChildToggle) or cellCheckedState + (realActiveDescendantDisplayedText or imageDescription + image) + (expandableState and (expandableState + numberOfChildren)) + required',
+            'unfocused': '(tableCell2ChildLabel + tableCell2ChildToggle) or cellCheckedState + (realActiveDescendantDisplayedText or imageDescription + image) + (expandableState and (expandableState + numberOfChildren)) + required'
+            },
+        pyatspi.ROLE_TEAROFF_MENU_ITEM: {
+            'focused': '',
+            'unfocused': 'labelAndName + allTextSelection + roleName + availability'
+            },
+        pyatspi.ROLE_TERMINAL: {
+            'focused': 'terminal',
+            'unfocused': 'terminal'
+            },
+        pyatspi.ROLE_TEXT: {
+            'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
+            'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection'
+            },
+        pyatspi.ROLE_TOGGLE_BUTTON: {
+            'focused': 'toggleState',
+            'unfocused': 'labelAndName + roleName + toggleState + availability'
+            },
+        pyatspi.ROLE_PARAGRAPH: {
+            'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
+            'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection'
+            },
+        pyatspi.ROLE_EMBEDDED: {
+            'focused': 'embedded',
+            'unfocused': 'embedded'
+            },
+    }
+}
+
+class Formatting(dict):
+
+    def __init__(self, script):
+        self._script = script
+        self.update(defaultFormatting)
+
+    def getFormat(self, type, forceRole=None, **args):
+        already_focused = args.get('already_focused', False)
+        if forceRole:
+            role = forceRole
+        else:
+            role = args.get('role', None)
+        if self[type].has_key(role):
+            roleDict = self[type][role]
+        else:
+            roleDict = self[type]['default']
+        if already_focused and 'focused' in roleDict:
+            format = roleDict['focused']
+        else:
+            format = roleDict['unfocused']
+        return format
diff --git a/src/orca/generator_settings.py b/src/orca/generator_settings.py
deleted file mode 100755
index 1cbe098..0000000
--- a/src/orca/generator_settings.py
+++ /dev/null
@@ -1,298 +0,0 @@
-# Orca
-#
-# Copyright 2004-2008 Sun Microsystems Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
-# Boston MA  02110-1301 USA.
-
-"""Manages the formatting settings for Orca."""
-
-__id__        = "$Id:$"
-__version__   = "$Revision:$"
-__date__      = "$Date:$"
-__copyright__ = "Copyright (c) 2004-2008 Sun Microsystems Inc."
-__license__   = "LGPL"
-
-# importing so that we can use the role constants.
-#
-import pyatspi
-
-
-formattingDict = {}
-
-#### default role settings ####
-__roleDict = {}
-
-# the formatting string for the attributes to speak
-# when the object has just received focus. (already_focused: False)
-#
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + textSelection + roleName + availability'
-
-# the formatting string for the attributes to speak
-# when the object has already the focus. (already_focused: True)
-#
-#__roleDict['focusedSpeech'] = ''
-
-# The acss to be used for speaking the text.
-#
-#__roleDict['acss'] = 
-
-# The unfocused braille formatting string
-#
-#__roleDict['unfocusedBraille'] = '%labelOrName'
-
-# The focused braille formatting string
-# This is usually, but not necessarily the same as the above.
-# if it is not defined, then we use the unfocused version.
-#
-#__roleDict['focusedBraille'] = '%labelOrName'
-
-# braille attributes to send along for this role
-#
-#__roleDict['brailleAttributes'] = None
-formattingDict['default'] = __roleDict
-
-
-#### pyatspi.ROLE_PUSH_BUTTON ####
-__roleDict = {}
-
-__roleDict['unfocusedSpeech'] = 'labelOrName + roleName'
-formattingDict[pyatspi.ROLE_PUSH_BUTTON] = __roleDict
-
-#### pyatspi.ROLE_ALERT ####
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = 'labelOrName + unrelatedLabels'
-formattingDict[pyatspi.ROLE_ALERT] = __roleDict
-
-
-#### pyatspi.ROLE_CHECK_BOX ####
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + checkRole + checkState + required + availability'
-__roleDict['focusedSpeech'] = 'checkState'
-formattingDict[pyatspi.ROLE_CHECK_BOX] = __roleDict
-
-#### pyatspi.ROLE_RADIO_BUTTON ####
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + radioState + roleName + availability'
-__roleDict['focusedSpeech'] = 'radioState'
-formattingDict[pyatspi.ROLE_RADIO_BUTTON] = __roleDict
-
-
-### pyatspi.ROLE_RADIO_MENU_ITEM ###
-__roleDict = {}
-__roleDict['focusedSpeech'] = \
-__roleDict['unfocusedSpeech'] = \
-formattingDict[pyatspi.ROLE_RADIO_BUTTON]['unfocusedSpeech']
-__roleDict['unfocusedSpeech'] += ' + accelerator'
-formattingDict[pyatspi.ROLE_RADIO_MENU_ITEM] = __roleDict
-
-#### pyatspi.ROLE_ANIMATION####
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = 'labelOrName'
-formattingDict[pyatspi.ROLE_ANIMATION] = __roleDict
-
-
-#### pyatspi.ROLE_ARROW ####
-# [[[TODO: determine orientation of arrow.  Logged as bugzilla bug 319744.]]]
-# text = arrow direction (left, right, up, down)
-#
-        
-### pyatspi.ROLE_CHECK_MENU_ITEM ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + checkRole + checkState + required + availability + accelerator'
-__roleDict['focusedSpeech'] = 'checkState'
-formattingDict[pyatspi.ROLE_CHECK_MENU_ITEM] = __roleDict
-
-#### pyatspi.ROLE_DIAL ####
-# [[[TODO: WDW - might need to include the value here?  Logged as
-# bugzilla bug 319746.]]]
-#
-
-### pyatspi.ROLE_DIALOG ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = 'labelOrName + unrelatedLabels'
-formattingDict[pyatspi.ROLE_DIALOG] = __roleDict
-
-### pyatspi.ROLE_LIST ###
-# [[[TODO: WDW - include how many items in the list?
-# Logged as bugzilla bug 319749.]]]
-#
-
-### pyatspi.ROLE_TOGGLE_BUTTON ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + roleName + toggleState + availability'
-__roleDict['focusedSpeech'] = 'toggleState'
-formattingDict[pyatspi.ROLE_TOGGLE_BUTTON] = __roleDict
-
-### pyatspi.ROLE_SLIDER ###
-# Ignore the text on the slider.  See bug 340559
-# (http://bugzilla.gnome.org/show_bug.cgi?id=340559): the
-# implementors of the slider support decided to put in a
-# Unicode left-to-right character as part of the text,
-# even though that is not painted on the screen.
-#
-# In Java, however, there are sliders without a label. In
-# this case, we'll add to presentation the slider name if
-# it exists and we haven't found anything yet.
-#
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + roleName + value + required + availability'
-__roleDict['focusedSpeech'] = 'value'
-formattingDict[pyatspi.ROLE_SLIDER] = __roleDict
-
-### pyatspi.ROLE_SPIN_BUTTON ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  formattingDict['default']['unfocusedSpeech'] + ' + required'
-__roleDict['focusedSpeech'] = 'name'
-formattingDict[pyatspi.ROLE_SPIN_BUTTON] = __roleDict
-
-### pyatspi.ROLE_FRAME ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName +textSelection +roleName +unfocusedDialogueCount +availability'
-__roleDict['focusedSpeech'] = ''
-formattingDict[pyatspi.ROLE_FRAME] = __roleDict
-
-
-### pyatspi.ROLE_LIST_ITEM ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + textSelection + expandableState + availability'
-__roleDict['focusedSpeech'] = 'expandableState + availability'
-formattingDict[pyatspi.ROLE_LIST_ITEM] = __roleDict
-
-
-### pyatspi.ROLE_MENU ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + textSelection + roleName + availability'
-__roleDict['focusedSpeech'] = ''
-formattingDict[pyatspi.ROLE_MENU] = __roleDict
-
-
-### pyatspi.ROLE_MENU_ITEM ###
-# OpenOffice check menu items currently have a role of "menu item"
-# rather then "check menu item", so we need to test if one of the
-# states is CHECKED. If it is, then add that in to the list of
-# speech utterances. Note that we can't tell if this is a "check
-# menu item" that is currently unchecked and speak that state. 
-# See Orca bug #433398 for more details.
-#
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-  'labelOrName + isCheckedState + availability + accelerator'
-__roleDict['focusedSpeech'] = ''
-formattingDict[pyatspi.ROLE_MENU_ITEM] = __roleDict
-
-
-### pyatspi.ROLE_PROGRESS_BAR ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = 'labelOrName + percentage'
-__roleDict['focusedSpeech'] = 'percentage'
-formattingDict[pyatspi.ROLE_PROGRESS_BAR] = __roleDict
-
-
-### pyatspi.ROLE_SCROLL_BAR ###
-# [[[TODO: WDW - want to get orientation and maybe the
-# percentage scrolled so far. Logged as bugzilla bug
-# 319744.]]]
-#
-
-### pyatspi.ROLE_SPLIT_PANE ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = ' labelOrName + roleName + value + availability'
-__roleDict['focusedSpeech'] = 'value'
-formattingDict[pyatspi.ROLE_SPLIT_PANE] = __roleDict
-
-### pyatspi.ROLE_TABLE ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-__roleDict['focusedSpeech'] = \
-formattingDict['default']['unfocusedSpeech'] + ' + hasNoChildren'
-formattingDict[pyatspi.ROLE_TABLE] = __roleDict
-
-### REAL_ROLE_TABLE_CELL ### 
-# the real cell information
-# note that pyatspi.ROLE_TABLE_CELL is used to work out if we need to
-# read a whole row. It calls REAL_ROLE_TABLE_CELL internally.
-# maybe it can be done in a cleaner way?
-
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-__roleDict['focusedSpeech'] = \
-  '(tableCell2ChildLabel +tableCell2ChildToggle ) or isCheckbox ' + \
-  ' + (realActiveDescendantDisplayedText or imageDescription +image) ' + \
-  ' + (expandableState and (expandableState +noOfChildren ) ) +required '
-formattingDict['REAL_ROLE_TABLE_CELL']  = __roleDict
-
-######## mesar ####
-
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = 'tableCellRow'
-__roleDict['focusedSpeech'] = \
-  '( tableCell2ChildLabel + tableCell2ChildToggle ) or ' + \
-  ' isCheckbox + ( realActiveDescendantDisplayedText or imageDescription ) + ' \
-  '( expandableState and ( expandableState + noOfChildren ) ) + required '
-formattingDict[pyatspi.ROLE_TABLE_CELL] = __roleDict
-
-### pyatspi.ROLE_EMBEDDED ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-__roleDict['focusedSpeech'] = 'embedded'
-formattingDict[pyatspi.ROLE_EMBEDDED] = __roleDict
-
-
-### pyatspi.ROLE_ICON ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-__roleDict['focusedSpeech'] = 'labelOrName + imageDescription + roleName'
-formattingDict[pyatspi.ROLE_ICON] = __roleDict
-
-### pyatspi.ROLE_LAYERED_PANE ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-__roleDict['focusedSpeech'] = \
-formattingDict['default']['unfocusedSpeech'] + ' + hasNoShowingChildren '
-formattingDict[pyatspi.ROLE_LAYERED_PANE] = __roleDict
-
-### pyatspi.ROLE_PARAGRAPH, pyatspi.ROLE_PASSWORD_TEXT, pyatspi.ROLE_TEXT ###
-# [[[TODO: WDW - HACK to remove availability because some text
-# areas, such as those in yelp, come up as insensitive though
-# they really are ineditable.]]]
-#
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-__roleDict['focusedSpeech'] = \
-  'labelOrName2 + isReadOnly + textRole + currentLineText + textSelection'
-formattingDict[pyatspi.ROLE_PARAGRAPH] = \
-formattingDict[pyatspi.ROLE_PASSWORD_TEXT] = \
-formattingDict[pyatspi.ROLE_TEXT] = __roleDict
-
-### pyatspi.ROLE_TERMINAL ###
-__roleDict = {}
-__roleDict['unfocusedSpeech'] = \
-__roleDict['focusedSpeech'] = 'terminal'
-formattingDict[pyatspi.ROLE_TERMINAL] = __roleDict
-
-### pyatspi.ROLE_TEAROFF_MENU_ITEM ###
-formattingDict[pyatspi.ROLE_TEAROFF_MENU_ITEM] = \
-formattingDict[pyatspi.ROLE_MENU]
diff --git a/src/orca/script.py b/src/orca/script.py
index 563e09d..859f83a 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -42,6 +42,7 @@ __license__   = "LGPL"
 import braillegenerator
 import debug
 import flat_review
+import formatting
 import keybindings
 import orca_state
 import settings
@@ -86,6 +87,7 @@ class Script:
         self.brailleBindings = self.getBrailleBindings()
         self.app_pronunciation_dict = self.getPronunciations()
 
+        self.formatting = self.getFormatting()
         self.brailleGenerator = self.getBrailleGenerator()
         self.speechGenerator = self.getSpeechGenerator()
         self.whereAmI = self.getWhereAmI()
@@ -178,6 +180,10 @@ class Script:
                 for command, handler in self.brailleBindings.iteritems()
                 if inputEventHandler == handler]
 
+    def getFormatting(self):
+        """Returns the formatting strings for this script."""
+        return formatting.Formatting(self)
+
     def getBrailleGenerator(self):
         """Returns the braille generator for this script.
         """
diff --git a/src/orca/speechgenerator.py b/src/orca/speechgenerator.py
old mode 100755
new mode 100644
index bb6f12f..eb64d32
--- a/src/orca/speechgenerator.py
+++ b/src/orca/speechgenerator.py
@@ -1879,12 +1879,12 @@ class SpeechGenerator:
         print("processing obj of role %s\n" % obj.getRoleName())
         result1 =  [" ".join(generator(obj, already_focused))]
         print("r%d='%s'\n" %(len(result1[0]), result1))
-        
+
         result2 = self.alt.getSpeech(obj, already_focused=already_focused)
         # making the returned values from alt.getSpeech into a string.
         speak =  [" ".join(result2)]
         print("s%d='%s'\n" %(len(speak[0]), speak))
-        print("r==s=%s\n" %cmp(result1[0], speak[0])) 
+        print("r==s=%s\n" %cmp(result1[0], speak[0]))
         return speak
 
     def getSpeechContext(self, obj, stopAncestor=None):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]