Commit 364d84db authored by Joanmarie Diggs's avatar Joanmarie Diggs

Mouse review: Don't spew giant text blobs at the user

Some authors write content with very textful divs whose functional
paragraphs are created by the insertion of br elements. This is why
we cannot have nice things. For the time being, just present the line
under the mouse rather than speak this entire text blob at once.
parent a2db770f
......@@ -535,6 +535,8 @@ class MouseReviewer:
boundary = pyatspi.TEXT_BOUNDARY_LINE_START
elif obj and obj.getState().contains(pyatspi.STATE_SELECTABLE):
boundary = pyatspi.TEXT_BOUNDARY_LINE_START
elif script.utilities.isMultiParagraphObject(obj):
boundary = pyatspi.TEXT_BOUNDARY_LINE_START
new = _ItemContext(pX, pY, obj, boundary, window, script)
if new.present(self._currentMouseOver):
......
......@@ -4207,6 +4207,18 @@ class Utilities:
def _adjustPointForObj(self, obj, x, y, coordType):
return x, y
def isMultiParagraphObject(self, obj):
if not obj:
return False
if "Text" not in pyatspi.listInterfaces(obj):
return False
text = obj.queryText()
string = text.getText(0, -1)
chunks = list(filter(lambda x: x.strip(), string.split("\n\n")))
return len(chunks) > 1
def textAtPoint(self, obj, x, y, coordType=None, boundary=None):
text = self.queryNonEmptyText(obj)
if not text:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment