Skip to content

Commit

Permalink
Report the code of combined characters (#16098)
Browse files Browse the repository at this point in the history
Closes #5011.

Summary of the issue:
Some characters are built with two or more Unicode characters: the first is a normal character and the following ones are combining characters. For example the character "é". It is built from the character "e" and the character "combining acute accent".

Pressing numpad2 twice, the description of the two characters are reported. However pressing numpad2 3 times, no character code is reported and the compound character is just reported as at first press; thus, triple press brings no useful information in this case.

Description of user facing changes
When pressing three times numpad2:

if the character under the review cursor is a single character, its decimal and hexadecimal codes will be reported as in pevious NVDA versions
if the character under the review cursor is compound of two or more characters, the codes for each character building it will be reported:
In braille, both decimal and hexadecimal codes will be reported for each character
With speech, only the decimal code is reported to avoid cluttering the speech output with too much numeric information that may be hard to parse.
  • Loading branch information
CyrilleB79 authored Jan 29, 2024
1 parent 61d99da commit 3c2add5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1922,13 +1922,17 @@ def script_review_currentCharacter(self, gesture: inputCore.InputGesture):
speech.spellTextInfo(info,useCharacterDescriptions=True)
else:
try:
c = ord(info.text)
cList = [ord(c) for c in info.text]
except TypeError:
c = None
if c is not None:
speech.speakMessage("%d," % c)
speech.speakSpelling(hex(c))
braille.handler.message(f"{c}, {hex(c)}")
if cList:

for c in cList:
speech.speakMessage("%d," % c)
# Report hex along with decimal only when there is one character; else, it's confusing.
if len(cList) == 1:
speech.speakSpelling(hex(c))
braille.handler.message("; ".join(f"{c}, {hex(c)}" for c in cList))
else:
log.debugWarning("Couldn't calculate ordinal for character %r" % info.text)
speech.speakTextInfo(info, unit=textInfos.UNIT_CHARACTER, reason=controlTypes.OutputReason.CARET)
Expand Down

0 comments on commit 3c2add5

Please sign in to comment.