Index: default.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/default.py,v
retrieving revision 1.198
diff -u -r1.198 default.py
--- default.py	18 Sep 2006 18:31:28 -0000	1.198
+++ default.py	20 Sep 2006 17:18:19 -0000
@@ -806,6 +806,57 @@
 
         return script.Script.processKeyboardEvent(self, keyboardEvent)
 
+    def adjustForRepeats(self, line):
+        """Adjust line to include repeat character counts.
+        As some people will want this and others might not,
+        there is a setting in settings.py that determines
+        whether this functionality is enabled.
+
+        repeatCharacterLimit = <n>
+
+        If <n> is 0, then there would be no repeat characters.
+        Otherwise <n> would be the number of same characters (or more)
+        in a row that cause the repeat character count output.
+        If the value is set to 1, 2 or 3 then it's treated as if it was
+        zero. In other words, no repeat character count is given.
+
+        Arguments:
+        - line: the string to adjust for repeat character counts.
+
+        Returns: a new line adjusted for repeat character counts (if enabled).
+        """
+
+        if (len(line) < 4) or (settings.repeatCharacterLimit < 4):
+            return line
+
+        newLine = ''
+        segment = lastChar = line[0]
+        count = 1
+
+        for i in range(1, len(line)):
+            if line[i] == lastChar:
+                count += 1
+                segment += line[i]
+            else:
+                if count >= settings.repeatCharacterLimit \
+                   and not segment[0] in string.whitespace:
+                    newLine += str(count) + ' ' + segment[0] + " characters "
+                else:
+                    newLine += segment
+
+                segment = line[i]
+                count = 1
+
+            lastChar = line[i]
+
+        if count >= settings.repeatCharacterLimit \
+           and not segment[0] in string.whitespace:
+            newLine += str(count) + ' ' + segment[0] + " characters "
+        else:
+            newLine += segment
+
+        return newLine
+
     def __sayAllProgressCallback(self, context, type):
         # [[[TODO: WDW - this needs work.  Need to be able to manage
         # the monitoring of progress and couple that with both updating
@@ -865,6 +916,7 @@
             else:
                 voice = self.voices[settings.DEFAULT_VOICE]
 
+            phrase = self.adjustForRepeats(phrase)
             speech.speak(phrase, voice)
             util.speakTextSelectionState(obj, startOffset, endOffset)
 
@@ -889,6 +941,7 @@
 
             if settings.enableSpeechIndentation:
                 self.speakTextIndentation(obj, line)
+            line = self.adjustForRepeats(line)
             speech.speak(line, voice)
             util.speakTextSelectionState(obj, startOffset, endOffset)
 
@@ -914,6 +967,7 @@
         else:
             voice = self.voices[settings.DEFAULT_VOICE]
 
+        word = self.adjustForRepeats(word)
         speech.speak(word, voice)
         util.speakTextSelectionState(obj, startOffset, endOffset)
 
@@ -1027,6 +1081,7 @@
         else:
             voice = self.voices[settings.DEFAULT_VOICE]
 
+        word = self.adjustForRepeats(word)
         speech.speak(word, voice)
 
     def sayCharacter(self, obj):
@@ -2687,6 +2742,7 @@
             elif clickCount == 3:
                 self.phoneticSpellCurrentItem(string)
             else:
+                string = self.adjustForRepeats(string)
                 speech.speak(string)
 
         self.updateBrailleReview()
@@ -2844,6 +2900,7 @@
                 elif clickCount == 3:
                     self.phoneticSpellCurrentItem(string)
                 else:
+                    string = self.adjustForRepeats(string)
                     speech.speak(string)
 
         self.updateBrailleReview(targetCursorCell)
Index: settings.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/settings.py,v
retrieving revision 1.73
diff -u -r1.73 settings.py
--- settings.py	19 Sep 2006 21:30:55 -0000	1.73
+++ settings.py	20 Sep 2006 17:18:19 -0000
@@ -302,6 +302,15 @@
 #
 readTableCellRow    = True
 
+# The limit to enable a repeat character count to be spoken.
+# If set to 0, then there will be no repeat character count.
+# Each character will be spoken singularly (i.e. "dash dash
+# dash dash dash" instead of "five dash characters").
+# If the value is set to 1, 2 or 3 then it's treated as if it was
+# zero. In other words, no repeat character count is given.
+#
+repeatCharacterLimit = 0
+
 # Script developer feature.  If False, just the default script
 # will be used.  Helps determine difference between custom
 # scripts and the default script behavior.
