-
-
Notifications
You must be signed in to change notification settings - Fork 783
Support for uncontracted and contracted braille input. #6449
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
Merged
Merged
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
75b163b
Support for uncontracted and contracted braille input.
jcsteh eb7babf
Address code review comments.
jcsteh 0b643d6
brailleInput: Fix exceptions when typing a single cell, pressing spac…
jcsteh 11912ca
User Guide: Add note about translation only reflecting the braille wo…
jcsteh f4859a5
Pressing dot7+dot8 translates immediately but without adding a space …
jcsteh 5ff07e5
Mask braille input in protected fields.
jcsteh 2f3f4fc
Merge branch 'master' into i2439ContractedBrailleInput
jcsteh e78f955
Update to a temporary NV Access branch of liblouis which incorporates…
jcsteh 414504d
Add the Unicode braille input table.
jcsteh 7efa322
Use new liblouis modes to improve back-translation:
jcsteh a224cab
liblouis sconscript: Add additional source file added in liblouis 3.1.0.
jcsteh 84bbd53
Merge branch 'master' into i2439ContractedBrailleInput
jcsteh f240afc
Merge branch 'i6935Liblouis3.1' into i2439ContractedBrailleInput
jcsteh 61d7c16
Update to liblouis 3.1.0, though we're still using a temporary NV Acc…
jcsteh 5d202d4
Merge branch 'master' into i2439ContractedBrailleInput
jcsteh 7aef11d
Upgrade to liblouis 3.2.0.
jcsteh 99b1fbf
Don't need liblouis.def any more.
jcsteh 1d6035b
Place indicators at the start and end of braille input so users under…
jcsteh 36dac59
Clear braille input state if the caret gets moved (other than by text…
jcsteh 243d39f
Fix keyboardHandler's treatment of Unicode characters sent by SendInp…
jcsteh 840e516
braille: Remove RENAMED_TABLES, as this got moved to brailleTables.
jcsteh 9f0d714
brailleInput: Handle renamed tables like we do for braille output, wh…
jcsteh 77abb34
Switch to a fork of liblouis 3.2.0 which contains some additional bac…
jcsteh 9a4537c
readme: Update liblouis version.
jcsteh ff6f627
brailleTables: Update for rename of Greek table in liblouis 3.2.0. Al…
jcsteh e2f8609
Switch liblouis to official liblouis master, since all fixes from us …
jcsteh c0004f0
Review actions.
jcsteh 84e6565
BrailleInputGesture: Don't use Python set order for gesture identifie…
jcsteh c2c7162
inputCore: Update code doc.
jcsteh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| # -*- coding: UTF-8 -*- | ||
| #braille.py | ||
| #A part of NonVisual Desktop Access (NVDA) | ||
| #This file is covered by the GNU General Public License. | ||
|
|
@@ -25,18 +26,6 @@ | |
| import inputCore | ||
| import brailleTables | ||
|
|
||
| #: Maps old table names to new table names for tables renamed in newer versions of liblouis. | ||
| RENAMED_TABLES = { | ||
| "da-dk-g16.utb":"da-dk-g16.ctb", | ||
| "da-dk-g18.utb":"da-dk-g18.ctb", | ||
| "nl-BE-g1.ctb":"nl-BE-g0.utb", | ||
| "nl-NL-g1.ctb":"nl-NL-g0.utb", | ||
| "no-no.ctb":"no-no-comp8.ctb", | ||
| "sk-sk-g1.utb":"sk-g1.ctb", | ||
| "UEBC-g1.ctb":"en-ueb-g1.ctb", | ||
| "UEBC-g2.ctb":"en-ueb-g2.ctb", | ||
| } | ||
|
|
||
| roleLabels = { | ||
| # Translators: Displayed in braille for an object which is an | ||
| # editable text field. | ||
|
|
@@ -138,6 +127,11 @@ | |
| ) | ||
| SELECTION_SHAPE = 0xC0 #: Dots 7 and 8 | ||
|
|
||
| #: Unicode braille indicator at the start of untranslated braille input. | ||
| INPUT_START_IND = u"⣏" | ||
| #: Unicode braille indicator at the end of untranslated braille input. | ||
| INPUT_END_IND = u" ⣹" | ||
|
|
||
| # used to separate chunks of text when programmatically joined | ||
| TEXT_SEPARATOR = " " | ||
|
|
||
|
|
@@ -732,12 +726,12 @@ def update(self): | |
| import brailleInput | ||
| text = brailleInput.handler.untranslatedBraille | ||
| if text: | ||
| rawInputStart = len(self.rawText) | ||
| rawInputIndStart = len(self.rawText) | ||
| # _addFieldText adds text to self.rawText and updates other state accordingly. | ||
| self._addFieldText(text, None, separate=False) | ||
| rawInputEnd = len(self.rawText) | ||
| self._addFieldText(INPUT_START_IND + text + INPUT_END_IND, None, separate=False) | ||
| rawInputIndEnd = len(self.rawText) | ||
| else: | ||
| rawInputStart = None | ||
| rawInputIndStart = None | ||
| # Now, the selection itself. | ||
| self._addTextWithFields(sel, formatConfig, isSelection=True) | ||
| # Finally, get the chunk from the end of the selection to the end of the reading unit. | ||
|
|
@@ -772,17 +766,28 @@ def update(self): | |
| self.focusToHardLeft = self._isMultiline() | ||
| super(TextInfoRegion, self).update() | ||
|
|
||
| if rawInputStart is not None: | ||
| assert rawInputEnd is not None, "rawInputStart set but rawInputEnd isn't" | ||
| self._brailleInputStart = self.rawToBraillePos[rawInputStart] | ||
| self._brailleInputEnd = self.rawToBraillePos[rawInputEnd] | ||
| if rawInputIndStart is not None: | ||
| assert rawInputIndEnd is not None, "rawInputIndStart set but rawInputIndEnd isn't" | ||
| # These are the start and end of the untranslated input area, | ||
| # including the start and end indicators. | ||
| self._brailleInputIndStart = self.rawToBraillePos[rawInputIndStart] | ||
| self._brailleInputIndEnd = self.rawToBraillePos[rawInputIndEnd] | ||
| # These are the start and end of the actual untranslated input, excluding indicators. | ||
| self._brailleInputStart = self._brailleInputIndStart + len(INPUT_START_IND) | ||
| self._brailleInputEnd = self._brailleInputIndEnd - len(INPUT_END_IND) | ||
| self.brailleCursorPos = self._brailleInputStart + brailleInput.handler.untranslatedCursorPos | ||
| else: | ||
| self._brailleInputStart = None | ||
| self._brailleInputIndStart = None | ||
|
|
||
| def routeTo(self, braillePos): | ||
| if self._brailleInputStart is not None and self._brailleInputStart <= braillePos <= self._brailleInputEnd: | ||
| if self._brailleInputIndStart is not None and self._brailleInputIndStart <= braillePos < self._brailleInputIndEnd: | ||
| # The user is moving within untranslated braille input. | ||
| if braillePos < self._brailleInputStart: | ||
| # The user routed to the start indicator. Route to the start of the input. | ||
| braillePos = self._brailleInputStart | ||
| elif braillePos > self._brailleInputEnd: | ||
| # The user routed to the end indicator. Route to the end of the input. | ||
| braillePos = self._brailleInputEnd | ||
| # Import late to avoid circular import. | ||
| import brailleInput | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here, not at the top of the file? |
||
| brailleInput.handler.untranslatedCursorPos = braillePos - self._brailleInputStart | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,21 +17,28 @@ | |
| #: * 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")) | ||
| BrailleTable = collections.namedtuple("BrailleTable", ("fileName", "displayName", "contracted", "output", "input")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This docstring should also have |
||
|
|
||
| #: Maps file names to L{BrailleTable} objects. | ||
| _tables = {} | ||
|
|
||
| def addTable(fileName, displayName, contracted=False): | ||
| def addTable(fileName, displayName, contracted=False, output=True, input=True): | ||
| """Register a braille translation table. | ||
| At least one of C{input} or C{output} must be C{True}. | ||
| @param fileName: The file name of the table. | ||
| @type fileName: basestring | ||
| @param displayname: The name of the table as displayed to the user. This should be translatable. | ||
| @type displayName: unicode | ||
| @param contracted: C{True} if the table is contracted, C{False} if uncontracted. | ||
| @type cContracted: bool | ||
| @param output: C{True} if this table can be used for output, C{False} if not. | ||
| @type output: bool | ||
| @param input: C{True} if this table can be used for input, C{False} if not. | ||
| @type input: bool | ||
| """ | ||
| table = BrailleTable(fileName, displayName, contracted) | ||
| if not output and not input: | ||
| raise ValueError("input and output cannot both be False") | ||
| table = BrailleTable(fileName, displayName, contracted, output, input) | ||
| _tables[fileName] = table | ||
|
|
||
| def getTable(fileName): | ||
|
|
@@ -55,6 +62,7 @@ def listTables(): | |
| RENAMED_TABLES = { | ||
| "da-dk-g16.utb":"da-dk-g16.ctb", | ||
| "da-dk-g18.utb":"da-dk-g18.ctb", | ||
| "gr-gr-g1.utb":"el.ctb", | ||
| "nl-BE-g1.ctb":"nl-BE-g0.utb", | ||
| "nl-NL-g1.ctb":"nl-NL-g0.utb", | ||
| "no-no.ctb":"no-no-comp8.ctb", | ||
|
|
@@ -114,6 +122,9 @@ def listTables(): | |
| addTable("de-de-g2.ctb", _("German grade 2"), contracted=True) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
| addTable("el.ctb", _("Greek (Greece)")) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
| addTable("en-gb-comp8.ctb", _("English (U.K.) 8 dot computer braille")) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
|
|
@@ -186,9 +197,6 @@ def listTables(): | |
| addTable("gr-bb.ctb", _("Koine Greek")) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
| addTable("gr-gr-g1.utb", _("Greek (Greece) grade 1")) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
| addTable("he.ctb", _("Hebrew 8 dot computer braille")) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
|
|
@@ -321,6 +329,9 @@ def listTables(): | |
| addTable("tr.ctb", _("Turkish grade 1")) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
| addTable("unicode-braille.utb", _("Unicode braille"), output=False) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
| addTable("zh-hk.ctb", _("Chinese (Hong Kong, Cantonese)")) | ||
| # Translators: The name of a braille table displayed in the | ||
| # braille settings dialog. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this import local and not at the top of the file? Perhaps add a comment