[orca] Fix for some keyboard-event-refactor issues in Orca's support for gnome-terminal
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix for some keyboard-event-refactor issues in Orca's support for gnome-terminal
- Date: Mon, 16 Jan 2012 11:24:24 +0000 (UTC)
commit 1f5895652a7df98e0345f7d8c93e7c8dbb6e3171
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Mon Jan 16 12:23:25 2012 +0100
Fix for some keyboard-event-refactor issues in Orca's support for gnome-terminal
src/orca/scripts/apps/gnome-terminal/script.py | 110 ------------------------
src/orca/scripts/default.py | 7 ++
2 files changed, 7 insertions(+), 110 deletions(-)
---
diff --git a/src/orca/scripts/apps/gnome-terminal/script.py b/src/orca/scripts/apps/gnome-terminal/script.py
index b530caa..d48cc96 100644
--- a/src/orca/scripts/apps/gnome-terminal/script.py
+++ b/src/orca/scripts/apps/gnome-terminal/script.py
@@ -30,7 +30,6 @@ __license__ = "LGPL"
import pyatspi
import orca.scripts.default as default
-import orca.input_event as input_event
import orca.orca as orca
import orca.orca_state as orca_state
import orca.settings as settings
@@ -143,115 +142,6 @@ class Script(default.Script):
else:
speech.speak(character, voice, False)
- def onTextInserted(self, event):
- """Called whenever text is inserted into an object.
-
- Arguments:
- - event: the Event
- """
-
- # We only do special things for terminals.
- #
- if event.source.getRole() != pyatspi.ROLE_TERMINAL:
- default.Script.onTextInserted(self, event)
- return
-
- # Ignore text insertions from non-focused objects, unless the
- # currently focused object is the parent of the object from which
- # text was inserted.
- #
- if (event.source != orca_state.locusOfFocus) \
- and (event.source.parent != orca_state.locusOfFocus):
- return
-
- self.updateBraille(event.source)
-
- text = event.any_data
-
- # When one does a delete in a terminal, the remainder of the
- # line is "inserted" instead of being shifted left. We will
- # detect this by seeing if the keystring was a delete action.
- # If we run into this case, we don't really want to speak the
- # rest of the line.
- #
- # We'll let our super class handle "Delete". We'll handle Ctrl+D.
- #
-
- if not orca_state.lastInputEvent:
- return
-
- matchFound = False
- speakThis = False
- if isinstance(orca_state.lastInputEvent, input_event.KeyboardEvent):
- keyString, mods = self.utilities.lastKeyAndModifiers()
- controlPressed = mods & settings.CTRL_MODIFIER_MASK
- if keyString in ["Delete", "BackSpace"]:
- return
- elif (keyString == "D") and controlPressed:
- text = text.decode("UTF-8")[0].decode("UTF-8")
-
- # If the last input event was a keyboard event, check to see if
- # the text for this event matches what the user typed. If it does,
- # then echo it (based on the user's key echo preferences).
- #
- # Note that the text widgets sometimes compress their events,
- # thus we might get a longer string from a single text inserted
- # event, while we also get individual keyboard events for the
- # characters used to type the string. This is ugly. We attempt
- # to handle it here by only echoing text if we think it was the
- # result of a command (e.g., a paste operation).
- #
- # Note that we have to special case the space character as it
- # comes across as "space" in the keyboard event and " " in the
- # text event.
- #
- # For terminal, Return usually ends up in more text from the
- # system, which we want to hear. Tab is also often used for
- # command line completion, so we want to hear that, too.
- #
- # Finally, if we missed some command and the system is giving
- # us a string typically longer than what the length of a
- # compressed string is (we choose 5 here), then output that.
- #
- wasCommand = controlPressed or keyString in ["Return", "Tab"]
- if (text == " " and keyString == "space") or text == keyString:
- matchFound = True
- elif wasCommand or (len(text) > 5):
- speakThis = True
-
- elif isinstance(orca_state.lastInputEvent, \
- input_event.MouseButtonEvent) and \
- orca_state.lastInputEvent.button == "2":
- speakThis = True
-
- if matchFound:
- echoed = orca_state.lastInputEvent.present()
- else:
- echoed = False
-
- if not echoed:
- # We might need to echo this if it is a single character.
- #
- speakThis = speakThis \
- or ((_settingsManager.getSetting('enableEchoByCharacter') \
- or (_settingsManager.getSetting('enableKeyEcho') \
- and _settingsManager.getSetting('enablePrintableKeys'))) \
- and text \
- and event.source.getRole() \
- != pyatspi.ROLE_PASSWORD_TEXT \
- and len(text.decode("UTF-8")) == 1)
-
- if speakThis:
- if text.decode("UTF-8").isupper():
- speech.speak(text, self.voices[settings.UPPERCASE_VOICE])
- else:
- speech.speak(text)
-
- if _settingsManager.getSetting('enableEchoByWord') \
- and self.utilities.isWordDelimiter(text.decode("UTF-8")[-1:]):
- if matchFound:
- self.echoPreviousWord(event.source)
-
def getTextLineAtCaret(self, acc, offset=None):
"""Gets the line of text where the caret is.
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 5d6c309..34b40ea 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3560,11 +3560,15 @@ class Script(script.Script):
#
string = event.any_data
speakThis = False
+ wasCommand = False
if isinstance(orca_state.lastInputEvent, input_event.MouseButtonEvent):
speakThis = orca_state.lastInputEvent.button == "2"
else:
keyString, mods = self.utilities.lastKeyAndModifiers()
wasCommand = mods & settings.COMMAND_MODIFIER_MASK
+ if not wasCommand and keyString in ["Return", "Tab"] \
+ and event.source.getRole() == pyatspi.ROLE_TERMINAL:
+ wasCommand = True
wasAutoComplete = (event.source.getRole() == pyatspi.ROLE_TEXT \
and event.source.queryText().getNSelections())
@@ -3600,6 +3604,9 @@ class Script(script.Script):
else:
speech.speak(string)
+ if wasCommand:
+ return
+
try:
text = event.source.queryText()
except NotImplementedError:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]