Support for uncontracted and contracted braille input.#6449
Conversation
Beyond the main code in brailleInput to support uncontracted/contracted input, this includes the following changes: * The list of braille tables has been moved out of the braille module into a separate brailleTables module. Braille tables are now added with a function rather than directly adding them to the data structure. Aside from being necessary in order to specify and check whether a table is contracted, this also makes the data about tables more extensible in future. * As the data structure for braille tables has now changed and is no longer ordered, this was a good opportunity to sort the list of tables alphabetically when displaying them to the user. * brailleInput is now notified when reverting config or changing config profiles. This is necessary because brailleInput now maintains some state when the input table is changed. * brailleInput is now initialised before braille at startup. This is because braille depends on brailleInput to get the currently untranslated input. * Dot7 and dot8 are now universally bound to braille input specific scripts for erase and enter. Any braille display drivers that had bindings for backspace/enter for braille input have been adjusted accordingly.
|
@feerrenrut, would you mind reviewing this please? Note that I've tried to explain some of the more obscure changes in the description of this pull request. |
| chunk.setEndPoint(sel, "endToStart") | ||
| self._addTextWithFields(chunk, formatConfig) | ||
| # If the user is entering braille, place any untranslated braille before the selection. | ||
| import brailleInput |
There was a problem hiding this comment.
Why is this import local and not at the top of the file? Perhaps add a comment
| def routeTo(self, braillePos): | ||
| if self._brailleInputStart is not None and self._brailleInputStart <= braillePos <= self._brailleInputEnd: | ||
| # The user is moving within untranslated braille input. | ||
| import brailleInput |
There was a problem hiding this comment.
Same question here, not at the top of the file?
| if text: | ||
| rawInputStart = len(self.rawText) | ||
| self._addFieldText(text, None, separate=False) | ||
| rawInputEnd = len(self.rawText) |
There was a problem hiding this comment.
Is this correct? rawImputStart and rawInputEnd are both being initialised to the same thing:len(self.rawText). If so I think the intent is clearer if it is written rawInputEnd=rawInputStart
| self.focusToHardLeft = self._isMultiline() | ||
| super(TextInfoRegion, self).update() | ||
|
|
||
| if rawInputStart is not None: |
There was a problem hiding this comment.
It might be a good idea to also check that rawInputEnd is not None
| "kb:control+home": ("br(braillenote):space+d1+d2+d3",), | ||
| "kb:control+end": ("br(braillenote):space+d4+d5+d6",), | ||
| "kb:enter": ("br(braillenote):space+d8",), | ||
| "braille_enter": ("br(braillenote):space+d8",), |
There was a problem hiding this comment.
I'm assuming this change is a new line conversion?
There was a problem hiding this comment.
Weird. This doesn't even show up in diffs from command line git. I reckon this is a GitHub bogus thingy. :(
|
|
||
| def script_braille_enter(self, gesture): | ||
| brailleInput.handler.enter() | ||
| script_braille_enter.__doc__= _("Translates any braille input and presses the enter key") |
There was a problem hiding this comment.
missing translators comment
| label = wx.StaticText(self, wx.ID_ANY, label=_("&Input table:")) | ||
| self.inputTableNames = [table[0] for table in braille.INPUT_TABLES] | ||
| self.inputTableList = wx.Choice(self, wx.ID_ANY, choices=[table[1] for table in braille.INPUT_TABLES]) | ||
| self.inputTableList = wx.Choice(self, wx.ID_ANY, choices=tableChoices) |
There was a problem hiding this comment.
wx.ID_ANY is unnecessary, I think this might conflict with next
| @type number: int | ||
| """ | ||
| global _suppressSpeakTypedCharactersData | ||
| _suppressSpeakTypedCharactersData = (number, time.time()) |
There was a problem hiding this comment.
Can this be called twice before number has had a chance to decrement to 0?
| timeOk = time.time() - supTime <= 0.1 | ||
| suppress = number > 0 and timeOk | ||
| number -= 1 | ||
| if number > 0 and timeOk: |
There was a problem hiding this comment.
I think this logic could be cleaned up so the condition does not need to be repeated. It would have the implication that _suppressSpeakTypedCharactersData exists for longer, and number is allowed to reach zero.
eg:
if _suppressSpeakTypedCharactersData:
...
timeOk = time.time() - supTime <= 0.1
suppress = number > 0 and timeOk
if suppress:
_suppressSpeakTypedCharactersData = (--number, supTime)
else:
_suppressSpeakTypedCharactersData = None
else:
suppress = False
if not suppress and config.conf["keyboard"]["speakTypedCharacters"] and ord(ch)>=32:
speakSpelling(realChar)
| _suppressSpeakTypedCharactersData = None | ||
| else: | ||
| suppress = False | ||
| if not suppress and config.conf["keyboard"]["speakTypedCharacters"] and ord(ch)>=32: |
There was a problem hiding this comment.
I'm guessing 32 is a limit for non-printable characters? A named constant would make this more readable.
There was a problem hiding this comment.
Quite true. However, as that's very much unrelated code that existed previously (I just added an extra condition), I'd prefer to address this somewhere else.
…e, typing two cells then pressing backspace. This occurred because cellsWithText was being updated even for the space at the end of a word. At this point, we're starting a new word, so cellsWithText needs to be empty.
…rd you are typing.
…or pressing enter.
|
@feerrenrut, I'm done with this batch of changes. I addressed your code review comments plus some other stuff noted below. Would you mind taking a look again? @derekriemer reported a bug to me via IRC. STR:
This causes an exception. I've fixed this in 0b643d6. I've also addressed a couple of other issues @derekriemer reported in recent comments on #2439. |
Actually, I just pushed one more commit to mask characters in protected fields (e.g. password fields). Thanks @derekriemer for catching! |
… several pending upstream changes related to braille input.
This necessitated the ability to have tables specific to either output or input, rather than assuming all tables can handle both.
* Always set noUndefinedDots so undefined dots (such as indicators that mean nothing by themselves) don't get translated to, for example, "\456/" for dots 4 5 6. * Set partialTrans when reporting contracted cells, thus avoiding the "zz" hack which was breaking French where z is actually a contraction.
|
Holding this back from the 2016.4 release, as there are some major outstanding issues:
|
…ess branch for now due to some changes that aren't yet in 3.1.0.
…so, remove "grade 1" from the description, since there's no other grade.
|
@feerrenrut, this is finally ready for another round of review. There have been a lot of changes and quite a long time since you last reviewed it, so you may want to just review from scratch. In case it's helpful, though, the changes since your last review are 5ff07e5b..ff6f627a. |
| #: * fileName: The file name of the table. | ||
| #: * displayname: The name of the table as displayed to the user. This should be translatable. | ||
| #: * contracted: C{True} if the table is contracted, C{False} if uncontracted. | ||
| BrailleTable = collections.namedtuple("BrailleTable", ("fileName", "displayName", "contracted", "output", "input")) |
There was a problem hiding this comment.
This docstring should also have output and input
| _suppressSpeakTypedCharactersTime = None | ||
| else: | ||
| suppress = False | ||
| if not suppress and config.conf["keyboard"]["speakTypedCharacters"] and ord(ch)>=32: |
There was a problem hiding this comment.
Could you replace the value 32 with a name please? I'm not really sure what this is testing for
| #A part of NonVisual Desktop Access (NVDA) | ||
| #This file is covered by the GNU General Public License. | ||
| #See the file COPYING for more details. | ||
| #Copyright (C) 2008-2016 NV Access Limited, Joseph Lee |
There was a problem hiding this comment.
update copyright year
…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).
|
@feerrenrut, can you please review the latest commit? Sorry. :( |
| return self._makeDisplayText(self.dots, self.space) | ||
|
|
||
| @classmethod | ||
| def getDisplayTextForIdentifier(cls, identifier): |
There was a problem hiding this comment.
Perhaps a docstring on this to explain what its for? Also, it would be nice to see a couple of examples of what identifier might be.
|
fixes #6956 |
|
I'm amazed at how many tickets this autoclosed. What a huge chunk of work. |
Beyond the main code in brailleInput to support uncontracted/contracted input, this includes the following changes:
Fixes #2439. Fixes #6054. Fixes #6113. Fixes #6935.
What's New entries:
In New Features:
In Changes: