Fix input gesture identifier normalization.#6962
Conversation
Previously, arbitrarily ordered items (e.g. multiple keys) were reordered using Python set order. However, different input ordering could incorrectly cause different output in some cases due to hash bucket conflicts. For example, dot4+space and space+dot4 incorrectly produced different output. In addition, these items were reordered *before* conversion to lower case instead of after, which could also incorrectly result in different output. Now, the entire identifier is converted to lower case and arbitrarily ordered items are then sorted by character. The InputGesture.identifiers property has been changed so that it is no longer normalized. Instead, there is now an InputGesture.normalizedIdentifiers property which returns normalized identifiers. This was done to make normalization changes easier to apply and to eliminate the potential for normalization errors in InputGesture subclasses. The InputGesture.logIdentifier property is now deprecated. InputGesture.identifiers[0] should be used instead. Finally, various InputGesture implementations have been changed to remove normalization code. In some cases, this may result in nicer reporting in input help mode.
feerrenrut
left a comment
There was a problem hiding this comment.
I'm a little worried that there may be issues caused by localisation. Other than that a few little things I noticed and a few questions.
| Then, any items separated by a + sign after the source prefix are considered to be of indeterminate order | ||
| and are sorted by character. | ||
| """ | ||
| identifier = identifier.lower() |
There was a problem hiding this comment.
is this locale dependant? Will it use the system locale or the invariant locale by default?
There was a problem hiding this comment.
If the string has any non-ASCII characters in it, it should be unicode, in which case .lower() will operate using the Unicode database:
>>> ua = u'\u0391'
>>> unicodedata.name(ua)
'GREEK CAPITAL LETTER ALPHA'
>>> la = ua.lower(); la
u'\u03b1'
>>> unicodedata.name(la)
'GREEK SMALL LETTER ALPHA'
| for modVk, modExt in self.generalizedModifiers: | ||
| if isNVDAModifierKey(modVk, modExt): | ||
| modTexts.add("NVDA") | ||
| modTexts.append("NVDA") |
There was a problem hiding this comment.
Does this need to be uppercase for some reason? It will get converted to lowercase right? Or is it for the log output?
There was a problem hiding this comment.
It gets converted to lower case when normalised. However, we want it to be displayed in upper case in log output, since that's how we write it in documentation.
| ID+="%s_"%self.counterNames[min(self.tracker.actionCount,4)-1] | ||
| ID+=self.tracker.action | ||
| IDs.append("TS(%s):%s"%(self.mode,ID)) | ||
| IDs.append("ts(%s):%s"%(self.mode,ID)) |
There was a problem hiding this comment.
what does ts mean? could you add a comment to explain please.
…rs; we got rid of that in #6962. Make it possible to get the display text from a braille keyboard gesture identifier (as used in the Input Gestures dialog).
Previously, arbitrarily ordered items (e.g. multiple keys) were reordered using Python set order. However, different input ordering could incorrectly cause different output in some cases due to hash bucket conflicts. For example, dot4+space and space+dot4 incorrectly produced different output.
In addition, these items were reordered before conversion to lower case instead of after, which could also incorrectly result in different output.
Now, the entire identifier is converted to lower case and arbitrarily ordered items are then sorted by character.
The InputGesture.identifiers property has been changed so that it is no longer normalized. Instead, there is now an InputGesture.normalizedIdentifiers property which returns normalized identifiers.
This was done to make normalization changes easier to apply and to eliminate the potential for normalization errors in InputGesture subclasses.
The InputGesture.logIdentifier property is now deprecated. InputGesture.identifiers[0] should be used instead.
Finally, various InputGesture implementations have been changed to remove normalization code. In some cases, this may result in nicer reporting in input help mode.
Fixes #6945. Re #3157.