Hyphenate Braille using pyphen#19916
Draft
LeonarddeR wants to merge 18 commits intonvaccess:masterfrom
Draft
Conversation
…tation Agent-Logs-Url: https://github.com/LeonarddeR/nvda/sessions/3c0c92ab-c024-44d3-bd6a-c7d6c3a92364 Co-authored-by: LeonarddeR <3049216+LeonarddeR@users.noreply.github.com>
Contributor
|
Once the Chinese word segmentation PR is merged, will it be possible to use its rules to handle Chinese line breaks within this new text wrap framework |
Collaborator
Author
|
I have no idea honestly. That is something we'd need to find out after that is merged. |
Replace BrailleTextWrap IntEnum with BrailleTextWrapFlag feature flag stored via featureFlag config spec, mirroring reviewRoutingMovesSystemCaret. Rename members to NONE, MARK_WORD_CUTS, AT_WORD_BOUNDARIES, AT_WORD_OR_SYLLABLE_BOUNDARIES for clarity (braille uses word division, not print hyphenation). Unify continuation-marker semantics under rule A: the marker now fires on any mid-word row end regardless of mode, including the no-whitespace fallback in AT_WORD_BOUNDARIES/AT_WORD_OR_SYLLABLE_BOUNDARIES. Handle unknown languages gracefully in getHyphenPositions by returning an empty tuple and logging once per locale. Update profile upgrade, deprecation bridge for wordWrap, settings dialog (FeatureFlagCombo), and user guide.
… region language, and hyphenation Update test_calculateWindowRowBufferOffsets for the renamed BrailleTextWrapFlag feature flag and add tests #1-nvaccess#8 covering NONE, MARK_WORD_CUTS, AT_WORD_BOUNDARIES (including the rule-A marker fix for the no-whitespace fallback), and AT_WORD_OR_SYLLABLE_BOUNDARIES (success, empty positions, past-edge position, unknown language). Add test_windowBrailleCells for CONTINUATION_SHAPE rendering (nvaccess#9-nvaccess#10). Add test_regionLanguageIndexes for Region._languageIndexes defaults, _addFieldText switch/restore entries, _addTextWithFields formatChange language handling, and TextInfoRegion.update reset (nvaccess#11-nvaccess#14). Add test_hyphenation for getHyphenPositions with known and unknown locales (nvaccess#15-nvaccess#16).
Collaborator
Author
|
I guess that when the chinese work is merged, we can fallback to that in the hyphenation module. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Link to issue number:
Closes #17010
Summary of the issue:
Word wrap is sometimes pretty aggressive, especially on shorter braille displays.
Description of user facing changes:
The boolean "word wrap" option in the braille settings has been replaced with a four-valued Text wrap option, giving finer-grained control over how words are broken when they don't fit on the display. The four choices are:
pyphenlibrary) so less of the word spills onto the next row. NVDA marks the split with braille dots 7-8, not a printed hyphen, because braille conventions use word division rather than print-style hyphenation.Whenever a word is cut mid-way across rows — regardless of which mode is selected — the cut is now marked with the continuation symbol. This makes it easy to tell at a glance whether a row ends cleanly at a space or carries over into the next row.
Existing user profiles with the old
wordWrap = True/wordWrap = Falsesetting are automatically upgraded:Truebecomes "At word boundaries" andFalsebecomes "Off".Description of developer facing changes:
The deprecated
braille.wordWrapboolean is bridged to the newbraille.textWrapfeature flag in both directions via_linkDeprecatedValues, so add-ons that still read or write the old key keep working (with a deprecation warning).Description of development approach:
BrailleTextWrapFlagwith membersDEFAULT,NONE,MARK_WORD_CUTS,AT_WORD_BOUNDARIES,AT_WORD_OR_SYLLABLE_BOUNDARIES. The default behaviour isAT_WORD_OR_SYLLABLE_BOUNDARIES.textUtils.hyphenationmodule wraps thepyphenlibrary.getHyphenPositions(text, locale)returns an empty tuple for locales without a pyphen dictionary (logging once at debug level per locale), so the wrap logic falls back cleanly to word-boundary behaviour without raising.Region._languageIndexesrecords language changes within a braille region so hyphenation can be performed in the correct language when regions contain multilingual content._hook_pypheninsource/setup.py) bundles pyphen's*.dicfiles intodist/pyphenDictionaries/and rewrites pyphen's dictionary lookup path at freeze time. Only the.dicfiles are included — README files are skipped.upgradeConfigFrom_22_to_23maps the oldwordWrapboolean to the newtextWrapstring enum.Testing strategy:
Automated unit tests cover:
_calculateWindowRowBufferOffsets, including the case where no whitespace fits on the row, the syllable-boundary success path, the fallback when no syllable boundary fits before the display edge, and the unknown-language case._get_windowBrailleCells._addFieldTextinserting switch/restore entries when a field is in a different language,_addTextWithFieldshandling aformatChangecommand with alanguageattribute, andTextInfoRegion.updateresetting the language index across updates.textUtils.hyphenation.getHyphenPositionsfor both a known language (en_US) and an unknown one (returns()without raising).Manual testing: loaded a pre-upgrade profile with
wordWrap = True/Falseand confirmed the profile upgrade writes the expectedtextWrapvalue and that the braille settings panel shows the matching label; confirmedscons.bat distproducesdist/pyphenDictionaries/containing onlyhyph_*.dicfiles.Known issues with pull request:.
Unit tests were written by AI and are a bit difficult to parse, though the behavior has been manually tested too and the unit tests ensure that the behavior stays stable.
Code Review Checklist: