[orca] Present terminal paste events like we do paste events from other applications
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Present terminal paste events like we do paste events from other applications
- Date: Tue, 23 Aug 2016 20:11:44 +0000 (UTC)
commit 37cda738848267890742d049e727f00b2e0501d5
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Tue Aug 23 16:10:08 2016 -0400
Present terminal paste events like we do paste events from other applications
src/orca/script_utilities.py | 23 +++++++++-----
src/orca/scripts/terminal/script_utilities.py | 40 ++++++++++++++++++++++++-
test/keystrokes/gnome-terminal/pasting.py | 29 ++++++++++++++++++
3 files changed, 83 insertions(+), 9 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 752b53d..f69c18d 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4219,6 +4219,19 @@ class Utilities:
return False
+ def isEditableTextArea(self, obj):
+ if not self.isTextArea(obj):
+ return False
+
+ try:
+ state = obj.getState()
+ except:
+ msg = "ERROR: Exception getting state of %s" % obj
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return False
+
+ return state.contains(pyatspi.STATE_EDITABLE)
+
def isClipboardTextChangedEvent(self, event):
if not event.type.startswith("object:text-changed"):
return False
@@ -4232,14 +4245,8 @@ class Utilities:
if "delete" in event.type and self.lastInputEventWasPaste():
return False
- try:
- state = event.source.getState()
- except:
- msg = "ERROR: Exception getting state of %s" % event.source
- debug.println(debug.LEVEL_INFO, msg, True)
- else:
- if not state.contains(pyatspi.STATE_EDITABLE):
- return False
+ if not self.isEditableTextArea(event.source):
+ return False
contents = self.getClipboardContents()
if not contents:
diff --git a/src/orca/scripts/terminal/script_utilities.py b/src/orca/scripts/terminal/script_utilities.py
index 9b2a954..1bdcf73 100644
--- a/src/orca/scripts/terminal/script_utilities.py
+++ b/src/orca/scripts/terminal/script_utilities.py
@@ -49,6 +49,9 @@ class Utilities(script_utilities.Utilities):
if self.isAutoTextEvent(event):
return event.any_data
+ if self.isClipboardTextChangedEvent(event):
+ return event.any_data
+
try:
text = event.source.queryText()
except:
@@ -69,8 +72,17 @@ class Utilities(script_utilities.Utilities):
return text.getText(start, end)
+ def isEditableTextArea(self, obj):
+ if obj and obj.getRole() == pyatspi.ROLE_TERMINAL:
+ return True
+
+ return super().isEditableTextArea(obj)
+
def isTextArea(self, obj):
- return True
+ if obj and obj.getRole() == pyatspi.ROLE_TERMINAL:
+ return True
+
+ return super().isTextArea(obj)
def isAutoTextEvent(self, event):
if not event.type.startswith("object:text-changed:insert"):
@@ -87,8 +99,34 @@ class Utilities(script_utilities.Utilities):
return False
+ def lastInputEventWasCopy(self):
+ keycode, mods = self._lastKeyCodeAndModifiers()
+ keynames = self._allNamesForKeyCode(keycode)
+ if 'c' not in keynames:
+ return False
+
+ if mods & keybindings.CTRL_MODIFIER_MASK:
+ return mods & keybindings.SHIFT_MODIFIER_MASK
+
+ return False
+
+ def lastInputEventWasPaste(self):
+ keycode, mods = self._lastKeyCodeAndModifiers()
+ keynames = self._allNamesForKeyCode(keycode)
+ if 'v' not in keynames:
+ return False
+
+ if mods & keybindings.CTRL_MODIFIER_MASK:
+ return mods & keybindings.SHIFT_MODIFIER_MASK
+
+ return False
+
def treatEventAsCommand(self, event):
if event.type.startswith("object:text-changed:insert") and event.any_data.strip():
+ # To let default script handle presentation.
+ if self.lastInputEventWasPaste():
+ return False
+
keyString, mods = self.lastKeyAndModifiers()
if keyString in ["Return", "Tab", "space", " "]:
return True
diff --git a/test/keystrokes/gnome-terminal/pasting.py b/test/keystrokes/gnome-terminal/pasting.py
new file mode 100644
index 0000000..7a20377
--- /dev/null
+++ b/test/keystrokes/gnome-terminal/pasting.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+import gi
+gi.require_version("Gdk", "3.0")
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gdk
+from gi.repository import Gtk
+from macaroon.playback import *
+import utils
+
+clipboard = Gtk.Clipboard.get(Gdk.Atom.intern("CLIPBOARD", False))
+clipboard.set_text("Hello world", -1)
+
+sequence = MacroSequence()
+sequence.append(KeyComboAction("Return"))
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("<Control><Shift>v"))
+sequence.append(utils.AssertPresentationAction(
+ "1. Paste",
+ ["BRAILLE LINE: '$ Hello world'",
+ " VISIBLE: '$ Hello world', cursor=14",
+ "BRAILLE LINE: 'Pasted contents from clipboard.'",
+ " VISIBLE: 'Pasted contents from clipboard.', cursor=0",
+ "BRAILLE LINE: '$ Hello world'",
+ " VISIBLE: '$ Hello world', cursor=14",
+ "SPEECH OUTPUT: 'Pasted contents from clipboard.' voice=system"]))
+
+sequence.append(utils.AssertionSummaryAction())
+sequence.start()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]