[orca] More work on the new terminal script
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] More work on the new terminal script
- Date: Thu, 25 Aug 2016 03:28:33 +0000 (UTC)
commit 53caa48f785597d0e8eb17f38383e54e221b9c09
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Aug 24 23:18:31 2016 -0400
More work on the new terminal script
* Fix instance where braille was not being refreshed
* Check deletion event is not the result of BackSpace prior to skipping it
* Don't adjust inserted text for presentation if it's contained in one line
* Update some cached information
* Remove overridden callbacks that don't override anything
src/orca/scripts/terminal/script.py | 26 +++--
src/orca/scripts/terminal/script_utilities.py | 22 ++++-
.../keystrokes/gnome-terminal/command_not_found.py | 7 +-
test/keystrokes/gnome-terminal/exit_shell.py | 2 +
test/keystrokes/gnome-terminal/ls_flat_review.py | 6 +-
.../gnome-terminal/man_page_flat_review.py | 4 +
test/keystrokes/gnome-terminal/pasting.py | 1 +
test/keystrokes/gnome-terminal/reverse_i_search.py | 113 ++++++++++++++++++++
test/keystrokes/gnome-terminal/tab_completion.py | 4 +-
9 files changed, 163 insertions(+), 22 deletions(-)
---
diff --git a/src/orca/scripts/terminal/script.py b/src/orca/scripts/terminal/script.py
index eb00ca5..3eebb33 100644
--- a/src/orca/scripts/terminal/script.py
+++ b/src/orca/scripts/terminal/script.py
@@ -62,16 +62,6 @@ class Script(default.Script):
return Utilities(self)
- def locusOfFocusChanged(self, event, oldFocus, newFocus):
- """Handles changes of focus of interest to the script."""
-
- super().locusOfFocusChanged(event, oldFocus, newFocus)
-
- def onCaretMoved(self, event):
- """Callback for object:text-caret-moved accessibility events."""
-
- super().onCaretMoved(event)
-
def onFocus(self, event):
"""Callback for focus: accessibility events."""
@@ -98,6 +88,8 @@ class Script(default.Script):
msg = "TERMINAL: Insertion is believed to be due to terminal command"
debug.println(debug.LEVEL_INFO, msg, True)
+ self.updateBraille(event.source)
+
newString = self.utilities.insertedText(event)
if len(newString) == 1:
self.speakCharacter(newString)
@@ -105,6 +97,17 @@ class Script(default.Script):
voice = self.speechGenerator.voice(string=newString)
speech.speak(newString, voice)
+ if self.flatReviewContext:
+ return
+
+ try:
+ text = event.source.queryText()
+ except:
+ pass
+ else:
+ self._saveLastCursorPosition(event.source, text.caretOffset)
+ self.utilities.updateCachedTextSelection(event.source)
+
def presentKeyboardEvent(self, event):
if orca_state.learnModeEnabled or not event.isPrintableKey():
return super().presentKeyboardEvent(event)
@@ -141,6 +144,9 @@ class Script(default.Script):
def skipObjectEvent(self, event):
newEvent, newTime = None, 0
if event.type == "object:text-changed:delete":
+ if self.utilities.isBackSpaceCommandTextDeletionEvent(event):
+ return False
+
newEvent, newTime = self.eventCache.get("object:text-changed:insert")
if newEvent is None or newEvent.source != event.source:
diff --git a/src/orca/scripts/terminal/script_utilities.py b/src/orca/scripts/terminal/script_utilities.py
index 7bda988..0c0448a 100644
--- a/src/orca/scripts/terminal/script_utilities.py
+++ b/src/orca/scripts/terminal/script_utilities.py
@@ -66,14 +66,30 @@ class Utilities(script_utilities.Utilities):
firstLine = text.getTextAtOffset(start, boundary)
msg = "TERMINAL: First line of insertion: '%s' (%i, %i)" % firstLine
debug.println(debug.LEVEL_INFO, msg, True)
- if firstLine != ("", 0, 0):
- start = firstLine[1]
lastLine = text.getTextAtOffset(end - 1, boundary)
msg = "TERMINAL: Last line of insertion: '%s' (%i, %i)" % lastLine
debug.println(debug.LEVEL_INFO, msg, True)
+
+ if firstLine == lastLine:
+ msg = "TERMINAL: Not adjusting single-line insertion."
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return event.any_data
+
+ currentLine = text.getTextAtOffset(text.caretOffset, boundary)
+ msg = "TERMINAL: Current line: '%s' (%i, %i)" % currentLine
+ debug.println(debug.LEVEL_INFO, msg, True)
+
+ if firstLine != ("", 0, 0):
+ start = firstLine[1]
+
+ if currentLine not in (("", 0, 0), firstLine, lastLine):
+ lastLine = currentLine
+
if lastLine != ("", 0, 0):
- end = min(lastLine[2], text.caretOffset)
+ end = lastLine[2]
+ if lastLine[0].endswith("\n"):
+ end -= 1
adjusted = text.getText(start, end)
if adjusted:
diff --git a/test/keystrokes/gnome-terminal/command_not_found.py
b/test/keystrokes/gnome-terminal/command_not_found.py
index 219ee4a..1788f02 100644
--- a/test/keystrokes/gnome-terminal/command_not_found.py
+++ b/test/keystrokes/gnome-terminal/command_not_found.py
@@ -13,10 +13,9 @@ sequence.append(utils.AssertPresentationAction(
"1. Return after typing 'foo'",
["BRAILLE LINE: ''",
" VISIBLE: '', cursor=1",
- "BRAILLE LINE: ''",
- " VISIBLE: '', cursor=3",
- "SPEECH OUTPUT: 'bash: foo: command not found...",
- "'",
+ "BRAILLE LINE: '$ '",
+ " VISIBLE: '$ ', cursor=3",
+ "SPEECH OUTPUT: 'bash: foo: command not found...'",
"SPEECH OUTPUT: '$ '"]))
sequence.append(utils.AssertionSummaryAction())
diff --git a/test/keystrokes/gnome-terminal/exit_shell.py b/test/keystrokes/gnome-terminal/exit_shell.py
index b91d44e..dd31769 100644
--- a/test/keystrokes/gnome-terminal/exit_shell.py
+++ b/test/keystrokes/gnome-terminal/exit_shell.py
@@ -7,6 +7,8 @@ utils.setClipboardText('PS1="prompt> "')
sequence = MacroSequence()
+sequence.append(PauseAction(3000))
+
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Return"))
sequence.append(utils.AssertPresentationAction(
diff --git a/test/keystrokes/gnome-terminal/ls_flat_review.py
b/test/keystrokes/gnome-terminal/ls_flat_review.py
index 5b5c7c6..e9e2d63 100644
--- a/test/keystrokes/gnome-terminal/ls_flat_review.py
+++ b/test/keystrokes/gnome-terminal/ls_flat_review.py
@@ -91,9 +91,9 @@ sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_9"))
sequence.append(utils.AssertPresentationAction(
"9. Review next line",
- ["BRAILLE LINE: 'vertical scroll bar 0% $l'",
- " VISIBLE: 'vertical scroll bar 0% $l', cursor=1",
- "SPEECH OUTPUT: 'vertical scroll bar 0 percent.'"]))
+ ["BRAILLE LINE: ' $l'",
+ " VISIBLE: ' $l', cursor=1",
+ "SPEECH OUTPUT: 'blank'"]))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("KP_9"))
diff --git a/test/keystrokes/gnome-terminal/man_page_flat_review.py
b/test/keystrokes/gnome-terminal/man_page_flat_review.py
index eb262be..1dadbe3 100644
--- a/test/keystrokes/gnome-terminal/man_page_flat_review.py
+++ b/test/keystrokes/gnome-terminal/man_page_flat_review.py
@@ -109,6 +109,8 @@ sequence.append(utils.AssertPresentationAction(
" VISIBLE: '(press h for help or q to quit)', cursor=32",
"BRAILLE LINE: ' Manual page orca(1) line 24 (press h for help or q to quit)'",
" VISIBLE: '(press h for help or q to quit)', cursor=32",
+ "BRAILLE LINE: ' Manual page orca(1) line 24 (press h for help or q to quit)'",
+ " VISIBLE: '(press h for help or q to quit)', cursor=32",
"SPEECH OUTPUT: ' When starting orca, use dirname as an alternate directory for",
" the user preferences.",
"",
@@ -203,6 +205,8 @@ sequence.append(utils.AssertPresentationAction(
" VISIBLE: '(press h for help or q to quit)', cursor=32",
"BRAILLE LINE: ' Manual page orca(1) line 1 (press h for help or q to quit)'",
" VISIBLE: '(press h for help or q to quit)', cursor=32",
+ "BRAILLE LINE: ' Manual page orca(1) line 1 (press h for help or q to quit)'",
+ " VISIBLE: '(press h for help or q to quit)', cursor=32",
"SPEECH OUTPUT: 'orca(1) General Commands Manual orca(1)",
"",
"NAME",
diff --git a/test/keystrokes/gnome-terminal/pasting.py b/test/keystrokes/gnome-terminal/pasting.py
index 8257e06..5057773 100644
--- a/test/keystrokes/gnome-terminal/pasting.py
+++ b/test/keystrokes/gnome-terminal/pasting.py
@@ -6,6 +6,7 @@ import utils
utils.setClipboardText("Hello world")
sequence = MacroSequence()
+sequence.append(PauseAction(3000))
sequence.append(KeyComboAction("Return"))
sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("<Control><Shift>v"))
diff --git a/test/keystrokes/gnome-terminal/reverse_i_search.py
b/test/keystrokes/gnome-terminal/reverse_i_search.py
new file mode 100644
index 0000000..a6d093a
--- /dev/null
+++ b/test/keystrokes/gnome-terminal/reverse_i_search.py
@@ -0,0 +1,113 @@
+#!/usr/bin/python
+
+from macaroon.playback import *
+import utils
+
+sequence = MacroSequence()
+sequence.append(PauseAction(3000))
+sequence.append(TypeAction("echo hello world"))
+sequence.append(KeyComboAction("Return"))
+sequence.append(TypeAction("echo hey guys"))
+sequence.append(KeyComboAction("Return"))
+sequence.append(TypeAction("echo goodbye world"))
+sequence.append(KeyComboAction("Return"))
+sequence.append(TypeAction("cat foo"))
+sequence.append(KeyComboAction("Return"))
+sequence.append(PauseAction(3000))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("<Control>r"))
+sequence.append(utils.AssertPresentationAction(
+ "1. Ctrl+R",
+ ["BRAILLE LINE: '(reverse-i-search)`': '",
+ " VISIBLE: '(reverse-i-search)`': ', cursor=23",
+ "SPEECH OUTPUT: '(reverse-i-search)`':'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(TypeAction("c"))
+sequence.append(utils.AssertPresentationAction(
+ "2. Type 'c'",
+ ["BRAILLE LINE: '(reverse-i-search)`c': cat foo'",
+ " VISIBLE: '(reverse-i-search)`c': cat foo', cursor=24",
+ "SPEECH OUTPUT: 'c': cat foo'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(TypeAction("a"))
+sequence.append(utils.AssertPresentationAction(
+ "3. Type 'a'",
+ ["BRAILLE LINE: '(reverse-i-search)`ca': cat foo'",
+ " VISIBLE: '(reverse-i-search)`ca': cat foo', cursor=25",
+ "BRAILLE LINE: '(reverse-i-search)`ca': cat foo'",
+ " VISIBLE: '(reverse-i-search)`ca': cat foo', cursor=25"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("BackSpace"))
+sequence.append(utils.AssertPresentationAction(
+ "4. BackSpace",
+ ["BRAILLE LINE: '(reverse-i-search)`c': cat foo'",
+ " VISIBLE: '(reverse-i-search)`c': cat foo', cursor=24",
+ "BRAILLE LINE: '(reverse-i-search)`c': cat foo'",
+ " VISIBLE: '(reverse-i-search)`c': cat foo', cursor=24",
+ "SPEECH OUTPUT: 'a'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("BackSpace"))
+sequence.append(utils.AssertPresentationAction(
+ "5. BackSpace",
+ ["BRAILLE LINE: '(reverse-i-search)`': cat foo'",
+ " VISIBLE: '(reverse-i-search)`': cat foo', cursor=23",
+ "BRAILLE LINE: '(reverse-i-search)`': cat foo'",
+ " VISIBLE: '(reverse-i-search)`': cat foo', cursor=23",
+ "SPEECH OUTPUT: 'c'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(TypeAction("e"))
+sequence.append(utils.AssertPresentationAction(
+ "6. Type 'e'",
+ ["BRAILLE LINE: '(reverse-i-search)`e': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`e': echo goodbye', cursor=32",
+ "SPEECH OUTPUT: 'e': echo goodbye world'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(TypeAction("cho "))
+sequence.append(utils.AssertPresentationAction(
+ "7. Type 'cho '",
+ ["BRAILLE LINE: '(reverse-i-search)`ec': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`ec': echo goodby', cursor=22",
+ "BRAILLE LINE: '(reverse-i-search)`ec': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`ec': echo goodby', cursor=22",
+ "BRAILLE LINE: '(reverse-i-search)`ech': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`ech': echo goodb', cursor=23",
+ "BRAILLE LINE: '(reverse-i-search)`ech': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`ech': echo goodb', cursor=23",
+ "BRAILLE LINE: '(reverse-i-search)`echo': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`echo': echo good', cursor=24",
+ "BRAILLE LINE: '(reverse-i-search)`echo': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`echo': echo good', cursor=24",
+ "BRAILLE LINE: '(reverse-i-search)`echo ': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`echo ': echo goo', cursor=25",
+ "BRAILLE LINE: '(reverse-i-search)`echo ': echo goodbye world'",
+ " VISIBLE: 'verse-i-search)`echo ': echo goo', cursor=25"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(TypeAction("he"))
+sequence.append(utils.AssertPresentationAction(
+ "8. Type 'he'",
+ ["BRAILLE LINE: '(reverse-i-search)`echo h': echo hey guys'",
+ " VISIBLE: 'verse-i-search)`echo h': echo he', cursor=26",
+ "BRAILLE LINE: '(reverse-i-search)`echo he': echo hey guys'",
+ " VISIBLE: 'verse-i-search)`echo he': echo h', cursor=27",
+ "BRAILLE LINE: '(reverse-i-search)`echo he': echo hey guys'",
+ " VISIBLE: 'verse-i-search)`echo he': echo h', cursor=27",
+ "SPEECH OUTPUT: 'h': echo hey guys'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(TypeAction("l"))
+sequence.append(utils.AssertPresentationAction(
+ "9. Type 'l'",
+ ["BRAILLE LINE: '(reverse-i-search)`echo hel': echo hello world'",
+ " VISIBLE: 'verse-i-search)`echo hel': echo ', cursor=28",
+ "SPEECH OUTPUT: 'l': echo hello world'"]))
+
+sequence.append(utils.AssertionSummaryAction())
+sequence.start()
diff --git a/test/keystrokes/gnome-terminal/tab_completion.py
b/test/keystrokes/gnome-terminal/tab_completion.py
index f671d41..856467e 100644
--- a/test/keystrokes/gnome-terminal/tab_completion.py
+++ b/test/keystrokes/gnome-terminal/tab_completion.py
@@ -18,8 +18,8 @@ sequence.append(utils.StartRecordingAction())
sequence.append(KeyComboAction("Tab"))
sequence.append(utils.AssertPresentationAction(
"1. Tab to complete 'cd /ho'",
- ["BRAILLE LINE: '$ cd /ho'",
- " VISIBLE: '$ cd /ho', cursor=12",
+ ["BRAILLE LINE: '$ cd /home/'",
+ " VISIBLE: '$ cd /home/', cursor=12",
"SPEECH OUTPUT: 'me/'"]))
sequence.append(utils.AssertionSummaryAction())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]