Skip to content
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

Improves document formatting & object presentation #64

Closed
wants to merge 101 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
d02eab8
Starts code refactoring
AAClause Jun 1, 2020
2c3be54
settings: adds accelerators on options, allows to select "tags" choice
AAClause Jun 1, 2020
8355639
Settings: hides other options when feature is disabled
AAClause Jun 1, 2020
c635df0
Small fixes
AAClause Jun 1, 2020
606c319
Prepares 'customizes tags' dialog
AAClause Jun 6, 2020
7828b84
Object Presentation and text alignement: first implementation
AAClause Jun 7, 2020
ef43587
justify <-> justified + improves right alignement
AAClause Jun 8, 2020
0637569
Various improvements: grammar errors can be reported, improves settin…
AAClause Jun 8, 2020
0872bf3
Justify alignment with 3 spaces
AAClause Jun 10, 2020
111bcf5
Adds the possibility to reorder object properties
AAClause Jun 13, 2020
08be845
report text-alignment even if 'report font attributes' option is disa…
AAClause Jun 15, 2020
6f0c3ce
settings: possibility to enable/disable alignment report
AAClause Jun 15, 2020
6dc6019
Adds a script to enable/disable alignment report 'on the fly'
AAClause Jun 15, 2020
585da47
default profile: define a gesture on FreedomScientific/Baum/Braillian…
AAClause Jun 15, 2020
7a8c865
Adds the possibility to report the indentation and the level of items…
AAClause Jun 19, 2020
22b2288
alignment: cheks if NVDAObject has 'IA2Attributes' attribute / fixes …
AAClause Jun 23, 2020
a1e4277
Disables sel/nsel state label when a element is selected/unselected i…
AAClause Jun 27, 2020
399a377
Merge branch 'master' into formatting
AAClause Jul 5, 2020
d15d786
Restores 'sel' role label when dots 7 and/or 8 are not possible to sh…
AAClause Jul 5, 2020
f2f399b
first implementation of tags for attributes, dot(s) 7/8 methods is te…
AAClause Jul 10, 2020
503a1ad
Reverses the order of closing tags
AAClause Jul 11, 2020
508e68f
Adds the possibility to manage the report of line numbers
AAClause Jul 11, 2020
c03c1ac
Disables tags when attributes are disabled / representation is set on…
AAClause Jul 12, 2020
59f2ba7
Adds the possibility to show the text alignment via tags
AAClause Jul 13, 2020
ee2bd36
small fix: alignment tags not appear in some case
AAClause Jul 14, 2020
fc87545
Merge branch 'master' into formatting
AAClause Jul 14, 2020
2637e14
Fix: some link report was broken
AAClause Jul 15, 2020
0df6130
Restores 'attributes via dot(s) 7 and/or 8
AAClause Jul 15, 2020
5d19d87
Fixup for link report
AAClause Jul 16, 2020
c1d0f40
patch: update_TextInfoRegion() -> fixes 2 variable references
AAClause Jul 16, 2020
339b889
Merge branch 'master' into formatting
AAClause Jul 16, 2020
c4304e2
Merge branch 'master' into formatting
AAClause Jul 16, 2020
f3eeba5
Optimizes 'import's
AAClause Jul 17, 2020
aafbef0
Shortens some messages
AAClause Jul 17, 2020
5b5aa22
Adds a missing import
AAClause Jul 17, 2020
3a8e451
Merge branch 'master' into formatting
AAClause Jul 17, 2020
e441cdc
Merge branch 'master' into formatting
AAClause Jul 18, 2020
8ea3988
Merge branch 'master' into formatting
AAClause Jul 20, 2020
81cc70c
Attempt to fix issue with marking attribute with dot(s) 7/8 in some …
AAClause Jul 20, 2020
b1c7cd2
Fixes another variable reference (error occurs when a contracted tabl…
AAClause Jul 23, 2020
4e6399a
Merge branch 'master' into formatting
AAClause Jul 25, 2020
0490add
Adds new formatting reports: color, style, font name, font size and p…
AAClause Jul 26, 2020
60993ec
Format code
AAClause Jul 31, 2020
d0be175
Merge branch 'master' into formatting
AAClause Aug 1, 2020
b729d3c
Merge branch 'master' into formatting
AAClause Aug 12, 2020
4285c63
Merge branch 'master' into formatting
AAClause Aug 14, 2020
94aedb6
Add the possibility to hide/display cell coordinates in braille only
AAClause Aug 15, 2020
4b7d823
Default Order Properties: display cell coordinates before value
AAClause Aug 15, 2020
3726378
Excel: display formula in braille when we are in read only
AAClause Aug 15, 2020
97ba18b
Various improvements, code refactoring
AAClause Aug 15, 2020
5171b44
Settings: don't forget to save 'Cell formula' checkbox state
AAClause Aug 16, 2020
503ec45
Settings: add some accelerators
AAClause Aug 16, 2020
64d4737
Bug fix
AAClause Aug 16, 2020
be5af51
More auto-translatable string + — toggle report — supports "like speech"
AAClause Aug 16, 2020
b75793c
Report alignment fix + linting
AAClause Aug 16, 2020
2155025
Merge branch 'master' into formatting
AAClause Aug 17, 2020
583c96f
settings: Move — role labels — category in — Object Presentation — ca…
AAClause Aug 18, 2020
1b2b5bc
Indicate the number of items in a list, the number of row and column …
AAClause Aug 19, 2020
3dfa34f
Merge branch 'master' into formatting
AAClause Aug 19, 2020
43126f7
Small bug fix
AAClause Aug 22, 2020
6770bc4
Another bug fix introduced in 1b2b5bc -> fixes #84
AAClause Aug 22, 2020
a8427d8
patches: uniformize TEXT_SEPARATOR -> braille.TEXT_SEPARATOR
AAClause Aug 23, 2020
93ef9ed
Support for revisions and comments
AAClause Aug 29, 2020
f811124
New feature: plain text mode (i.e. all text formatting are disabled),…
AAClause Aug 29, 2020
b422104
Report colors: bug fix
AAClause Aug 30, 2020
f66051f
Merge branch 'master' into formatting
AAClause Sep 9, 2020
188f46b
* refreshed outdated languages catalogs, i will hand over these to th…
zstanecic Sep 9, 2020
cbbaef1
Update french translation (#89)
CoBC Sep 13, 2020
f4402ad
Add Oreonan as contributors
AAClause Sep 13, 2020
cbf321a
Support for paragraph indentations
AAClause Sep 20, 2020
bcee1eb
Merge branch 'master' into formatting
AAClause Sep 20, 2020
3cf4c7f
Merge branch 'master' into formatting
AAClause Oct 25, 2020
906f0b5
Fix a bug when another braille table is used for undefined chars desc…
AAClause Oct 25, 2020
0e48a28
Merge branch 'master' into formatting
AAClause Oct 25, 2020
5ff9003
Merge branch 'master' into formatting
AAClause Nov 1, 2020
d824193
tables: display column/row headers and coordinates in more cases
AAClause Nov 3, 2020
927f0bf
Reformat code
AAClause Nov 3, 2020
0b8a967
NVDA 2021.1 fix: Remove deprecated REASON_* constants from controlTypes
AAClause Jan 29, 2021
08a8548
Merge branch 'master' into formatting
AAClause Jan 29, 2021
19f4421
NVDA 2021.1 fix: Remove deprecated REASON_* constants from controlTypes
AAClause Jan 29, 2021
818064f
NVDA 2020.1: superscript and subscript fix
AAClause Feb 7, 2021
95ff2c2
NVDA 2021.1 change: Fix misleading log message for aria-current="true"
AAClause Feb 3, 2021
17b6e57
Merge branch 'master' into formatting
AAClause Aug 21, 2021
7ceeb9b
Merge branch 'master' into formatting
AAClause Sep 23, 2021
9d70991
NVDA 2022.1: fix deprecations/issues
AAClause Oct 21, 2021
393f6ce
Merge branch 'deprecations2022.1' into formatting
AAClause Oct 21, 2021
839e6d6
Compatibility with NVDA 2022.1
AAClause Oct 21, 2021
32d3e1d
Merge branch 'deprecations2022.1' into formatting
AAClause Oct 25, 2021
2f17a3a
Let's try to keep compatibility with NVDA 2021.1 and earlier
AAClause Oct 26, 2021
ae7b8a3
isCurrentLabels fix
AAClause Oct 26, 2021
6282c92
Merge branch 'master' into formatting
AAClause Oct 26, 2021
0bddae9
Fix typo
AAClause Oct 28, 2021
06f49b3
Merge branch 'master' into formatting
AAClause Nov 8, 2021
aa89758
Merge branch 'roleLabels' into formatting
AAClause Nov 11, 2021
1832218
Merge branch 'roleLabels' into formatting
AAClause Nov 11, 2021
c042fbc
Merge branch 'master' into formatting
AAClause Nov 15, 2021
4efd6ec
Merge branch 'master' into formatting
AAClause Apr 30, 2022
2efc023
New features: "Progress bar output using braille messages" + "Report …
Apr 30, 2022
f91fb89
Fix "AttributeError: module 'mathPres' has no attribute 'ensureInit'"
AAClause May 18, 2022
d344923
reportBorderStyle and reportBorderColor have been removed and are rep…
AAClause Apr 1, 2023
4bd8705
Merge branch 'master' into formatting
AAClause Apr 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
volumeMinus = b10+b1+b2+b6
toggleVolume = b10+b2+b5+b7
toggleSpeech = b10+b1+b3+b4, d6+d5+d2
toggleAttribra = b10+b1+b7+b8
toggleTextAttributes = b10+b1+b7+b8
toggleSpeechScrollFocusMode = b10+b2+b3+b4+b7
toggleLockBrailleKeyboard = b10+b1+b3+b7, b9+b1+b3+b7
toggleLockModifiers = b10+b1+b3+b4+b7
Expand All @@ -65,6 +65,7 @@
undefinedCharsDesc = b1+b3+b6+b7+b10
toggleRoutingCursorsEditFields = b10+b1+b5+b7
toggleSpeechHistoryMode = b10+b1+b2+b5+b7
toggleReportAlignments = b1+b2+b3+b7+b8+b10

[keyboardLayouts]
[[l1]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
volumeMinus = space+dot1+dot2+dot6
toggleVolume = space+dot2+dot5+dot7
toggleSpeech = space+dot1+dot3+dot4, c6+c5+c2
toggleAttribra = space+dot1+dot7+dot8
toggleTextAttributes = space+dot1+dot7+dot8
toggleSpeechScrollFocusMode = space+dot2+dot3+dot4+dot7
toggleLockBrailleKeyboard = space+dot1+dot3+dot7
toggleLockModifiers = space+dot1+dot3+dot4+dot7
Expand All @@ -57,6 +57,7 @@
undefinedCharsDesc = space+dot1+dot3+dot6+dot7
toggleRoutingCursorsEditFields = space+dot1+dot5+dot7
toggleSpeechHistoryMode = space+dot1+dot2+dot5+dot7
toggleReportAlignments = space+dot1+dot2+dot3+dot7+dot8

[rotor]
nextEltRotor = right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
volumeMinus = space+dot1+dot2+dot6
toggleVolume = space+dot2+dot5+dot7
toggleSpeech = space+dot1+dot3+dot4
toggleAttribra = space+dot1+dot7+dot8
toggleTextAttributes = space+dot1+dot7+dot8
toggleSpeechScrollFocusMode = space+dot2+dot3+dot4+dot7
toggleLockBrailleKeyboard = space+dot1+dot3+dot7
toggleLockModifiers = space+dot1+dot3+dot4+dot7
Expand All @@ -57,6 +57,7 @@
undefinedCharsDesc = space+dot1+dot3+dot6+dot7
toggleRoutingCursorsEditFields = space+dot1+dot5+dot7
toggleSpeechHistoryMode = space+dot1+dot2+dot5+dot7
toggleReportAlignments = space+dot1+dot2+dot3+dot7+dot8

[rotor]
nextEltRotor = joystick2Right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
volumeMinus = braillespacebar+dot1+dot2+dot6
toggleVolume = braillespacebar+dot2+dot5+dot7
toggleSpeech = braillespacebar+dot1+dot3+dot4
toggleAttribra = braillespacebar+dot1+dot7+dot8
toggleTextAttributes = braillespacebar+dot1+dot7+dot8
toggleSpeechScrollFocusMode = braillespacebar+dot2+dot3+dot4+dot7
toggleLockBrailleKeyboard = braillespacebar+dot1+dot3+dot7
toggleLockModifiers = braillespacebar+dot1+dot3+dot4+dot7
Expand All @@ -57,6 +57,7 @@
undefinedCharsDesc = braillespacebar+dot1+dot3+dot6+dot7
toggleRoutingCursorsEditFields = braillespacebar+dot1+dot5+dot7
toggleSpeechHistoryMode = braillespacebar+dot1+dot2+dot5+dot7
toggleReportAlignments = braillespacebar+dot1+dot2+dot3+dot7+dot8

[rotor]
nextEltRotor = leftwizwheeldown
Expand Down
128 changes: 55 additions & 73 deletions addon/globalPlugins/brailleExtender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
# This file is covered by the GNU General Public License.
# See the file LICENSE for more details.
# Copyright (C) 2016-2023 André-Abush Clause <dev@andreabc.net>
#
# Additional third party copyrighted code is included:
# - *Attribra*: Copyright (C) 2017 Alberto Zanella <lapostadialberto@gmail.com>
# -> https://github.com/albzan/attribra/

import os
import subprocess
import time
from collections import OrderedDict
Expand Down Expand Up @@ -38,6 +33,8 @@
config.conf.spec["brailleExtender"] = addoncfg.getConfspec()
from . import advancedinput
from . import huc
from . import documentformatting
from . import objectpresentation
from . import patches
from . import rolelabels
from . import settings
Expand All @@ -52,8 +49,7 @@
addonHandler.initTranslation()

instanceGP = None
ATTRS = config.conf["brailleExtender"]["attributes"].copy().keys()
logTextInfo = False

rotorItems = [
("default", _("Default")),
("moveInText", _("Moving in the text")),
Expand Down Expand Up @@ -96,60 +92,6 @@
lastRotorItemInVDSaved = True
HLP_browseModeInfo = ". %s" % _("If pressed twice, presents the information in browse mode")

# ***** Attribra code *****
def attribraEnabled():
if instanceGP and instanceGP.BRFMode: return False
return config.conf["brailleExtender"]["features"]["attributes"]

def decorator(fn, s):
def _getTypeformFromFormatField(self, field, formatConfig=None):
for attr in ATTRS:
v = attr.split(':')
k = v[0]
v = True if len(v) == 1 else v[1]
if k in field and (field[k] == v or field[k] == '1'):
if config.conf["brailleExtender"]["attributes"][attr] == addoncfg.CHOICE_dot7: return 7
if config.conf["brailleExtender"]["attributes"][attr] == addoncfg.CHOICE_dot8: return 8
if config.conf["brailleExtender"]["attributes"][attr] == addoncfg.CHOICE_dots78: return 78
# if COMPLCOLORS != None:
# col = field.get("color",False)
# if col and (col != COMPLCOLORS):
# return 4
return 0

def addTextWithFields_edit(self, info, formatConfig, isSelection=False):
conf = formatConfig.copy()
if attribraEnabled():
conf["reportFontAttributes"] = True
conf["reportColor"] = True
conf["reportSpellingErrors"] = True
if logTextInfo: log.info(info.getTextWithFields(conf))
fn(self, info, conf, isSelection)

def update(self):
fn(self)
if not attribraEnabled(): return
DOT7 = 64
DOT8 = 128
size = len(self.rawTextTypeforms)
for i, j in enumerate(self.rawTextTypeforms):
try:
start = self.rawToBraillePos[i]
end = self.rawToBraillePos[i+1 if i+1 < size else (i if i<size else size-1)]
except IndexError as e:
log.debug(e)
return
k = start
for k in range(start, end):
if j == 78: self.brailleCells[k] |= DOT7 | DOT8
if j == 7: self.brailleCells[k] |= DOT7
if j == 8: self.brailleCells[k] |= DOT8

if s == "addTextWithFields": return addTextWithFields_edit
if s == "update": return update
if s == "_getTypeformFromFormatField": return _getTypeformFromFormatField
# *************************


class GlobalPlugin(globalPluginHandler.GlobalPlugin):
scriptCategory = addonName
Expand Down Expand Up @@ -191,14 +133,16 @@ def __init__(self):
self.backup__update = braille.TextInfoRegion.update
self.backup__getTypeformFromFormatField = braille.TextInfoRegion._getTypeformFromFormatField
self.backup__brailleTableDict = config.conf["braille"]["translationTable"]
braille.TextInfoRegion._addTextWithFields = decorator(braille.TextInfoRegion._addTextWithFields, "addTextWithFields")
braille.TextInfoRegion.update = decorator(braille.TextInfoRegion.update, "update")
braille.TextInfoRegion._getTypeformFromFormatField = decorator(braille.TextInfoRegion._getTypeformFromFormatField, "_getTypeformFromFormatField")
braille.TextInfoRegion._addTextWithFields = documentformatting.decorator(braille.TextInfoRegion._addTextWithFields, "addTextWithFields")
braille.TextInfoRegion.update = documentformatting.decorator(braille.TextInfoRegion.update, "update")
braille.TextInfoRegion._getTypeformFromFormatField = documentformatting.decorator(braille.TextInfoRegion._getTypeformFromFormatField, "_getTypeformFromFormatField")
if config.conf["brailleExtender"]["reverseScrollBtns"]: self.reverseScrollBtns()
self.createMenu()
advancedinput.initialize()
if config.conf["brailleExtender"]["features"]["roleLabels"]:
rolelabels.loadRoleLabels()
objectpresentation.loadOrderProperties()
documentformatting.load_tags()
log.info(f"{addonName} {addonVersion} loaded ({round(time.time()-startTime, 2)}s)")

def event_gainFocus(self, obj, nextHandler):
Expand Down Expand Up @@ -229,6 +173,29 @@ def event_foreground(self, obj, nextHandler):
braille.handler.toggle_auto_scroll()
nextHandler()

_oldObj = None
_oldVal = None
def event_valueChange(self, obj, nextHandler):
if not config.conf["brailleExtender"]["objectPresentation"]["progressBarUpdate"]:
return nextHandler()
List = objectpresentation.validProgressBar(obj)
if not List or False in List:
return nextHandler()
try:
if self._oldObj == obj and self._oldVal == obj.value:
return nextHandler()
value = obj.value
self._oldObj = obj
self._oldVal = value
if config.conf["brailleExtender"]["objectPresentation"]["progressBarUpdate"] == 1:#show value
braille.handler.message(value)
else:
string = objectpresentation.generateProgressBarString(value, braille.handler.displaySize) or value
braille.handler.message(string)
except BaseException as e:
log.error(e)
nextHandler()

def createMenu(self):
self.submenu = wx.Menu()
item = self.submenu.Append(wx.ID_ANY, _("Docu&mentation"), _("Opens the addon's documentation."))
Expand Down Expand Up @@ -537,14 +504,30 @@ def script_toggleLockModifiers(self, gesture):
ui.message(_("Modifier keys unlocked"))
script_toggleLockModifiers.__doc__ = _("Toggle locking modifier keys when using braille input")

def script_toggleAttribra(self, gesture):
config.conf["brailleExtender"]["features"]["attributes"] = not attribraEnabled()
def script_toggleTextAttributes(self, gesture):
key = "fontAttributes"
documentformatting.toggle_report(key)
documentformatting.report_formatting(key)
utils.refreshBD()
if config.conf["brailleExtender"]["features"]["attributes"]:
speech.speakMessage("Attribra enabled")
script_toggleTextAttributes.__doc__ = _("Toggle font attributes report")

def script_toggleReportAlignments(self, gesture):
key = "alignment"
documentformatting.toggle_report(key)
documentformatting.report_formatting(key)
utils.refreshBD()
script_toggleReportAlignments.__doc__ = _("Toggle alignments report")

def script_toggle_plain_text(self, gesture):
cur = config.conf["brailleExtender"]["documentFormatting"]["plainText"]
config.conf["brailleExtender"]["documentFormatting"]["plainText"] = not cur
cur = config.conf["brailleExtender"]["documentFormatting"]["plainText"]
if cur:
ui.message(_("Plain text mode enabled"))
else:
speech.speakMessage("Attribra disabled")
script_toggleAttribra.__doc__ = _("Toggle font attributes report")
ui.message(_("Plain text mode disabled"))
utils.refreshBD()
script_toggle_plain_text.__doc__ = _("Toggle plain text mode")

def script_toggleSpeechScrollFocusMode(self, gesture):
choices = addoncfg.focusOrReviewChoices
Expand Down Expand Up @@ -1042,10 +1025,9 @@ def reverseScrollBtns(self, gesture=None, cancel=False):
return

def script_logFieldsAtCursor(self, gesture):
global logTextInfo
logTextInfo = not logTextInfo
documentformatting.logTextInfo = not documentformatting.logTextInfo
msg = ["stop", "start"]
ui.message("debug textInfo " + msg[logTextInfo])
ui.message(f"debug textInfo {msg[documentformatting.logTextInfo]}")

def script_saveCurrentBrailleView(self, gesture):
if scriptHandler.getLastScriptRepeatCount() == 0:
Expand Down
Loading