Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cursor movement with braille display routing keys in PowerPoint #17004

Merged
merged 8 commits into from
Aug 15, 2024
30 changes: 30 additions & 0 deletions source/appModules/powerpnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,36 @@ def _getFormatFieldAndOffsets(self, offset, formatConfig, calculateOffsets=True)
formatField["link"] = True
return formatField, (startOffset, endOffset)

def _setCaretOffset(self, offset: int):
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
if not (0 <= offset <= (maxLength := self._getStoryLength())):
log.debugWarning(
f"Got out of range {offset=} (min 0, max {maxLength}. Clamping.",
stack_info=True,
)
offset = max(0, min(offset, maxLength))
# Use the TextRange.select method to move the text caret to a 0-length TextRange.
# The TextRange.characters method is 1-indexed.
self.obj.ppObject.textRange.characters(offset + 1, 0).select()

def _setSelectionOffsets(self, start: int, end: int):
if not start < end:
log.debug(f"start must be less than end. Got {start=}, {end=}.", stack_info=True)
return
maxLength = self._getStoryLength()
# Having start = maxLength does not make sense, as there will be no selection if this is the case.
if not (0 <= start < maxLength):
log.debugWarning(
f"Got out of range {start=} (min 0, max {maxLength - 1}. Clamping.",
stack_info=True,
)
start = max(0, min(start, maxLength - 1))
# Having end = 0 does not make sense, as there will be no selection if this is the case.
if not (0 < end <= maxLength):
log.debugWarning(f"Got out of range {end=} (min 1, max {maxLength}. Clamping.", stack_info=True)
end = max(1, min(end, maxLength))
# The TextRange.characters method is 1-indexed.
self.obj.ppObject.textRange.characters(start + 1, end - start).select()


class Table(Shape):
"""Represents the table shape in Powerpoint. Provides row and column counts."""
Expand Down
3 changes: 3 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ The available options are:
* NVDA no longer throws an error when panning the braille display forward in some empty edit controls. (#16927)
* NVDA no longer occasionally fails to open browsable messages (such as pressing `NVDA+f` twice). (#16806, @LeonarddeR)
* NVDA is no longer unstable after restarting NVDA during an automatic Braille Bluetooth scan. (#16933)
* Improvements in Microsoft PowerPoint: (#17004)
* It is now possible to use braille display routing keys to move the text cursor. (#9101)
* It is now possible to use the review cursor selection commands to select text.

### Changes for Developers

Expand Down