Skip to content

Commit

Permalink
Merge branch 'master' into formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AAClause committed Apr 1, 2023
2 parents d344923 + ae564b3 commit 4bd8705
Show file tree
Hide file tree
Showing 27 changed files with 8,064 additions and 2,155 deletions.
54 changes: 4 additions & 50 deletions addon/globalPlugins/brailleExtender/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# coding: utf-8
# BrailleExtender Addon for NVDA
# This file is covered by the GNU General Public License.
# See the file LICENSE for more details.
# Copyright (C) 2016-2020 André-Abush Clause <dev@andreabc.net>
# Copyright (C) 2016-2023 André-Abush Clause <dev@andreabc.net>

import subprocess
import time
Expand Down Expand Up @@ -109,8 +110,6 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
if not addoncfg.noUnicodeTable:
backupInputTable = brailleInput.handler.table
backupMessageTimeout = None
backupTether = utils.getTether()
switchedMode = False

def __init__(self):
startTime = time.time()
Expand Down Expand Up @@ -159,22 +158,6 @@ def event_gainFocus(self, obj, nextHandler):
rotorItem = 0
self.bindRotorGES()

if config.conf["brailleExtender"]["reviewModeTerminal"]:
if not self.switchedMode and obj.role == utils.get_control_type("ROLE_TERMINAL") and obj.hasFocus:
if not hasattr(braille.handler, "TETHER_AUTO"):
self.backupTether = utils.getTether()
braille.handler.tether = braille.handler.TETHER_REVIEW
else:
if config.conf["braille"]["autoTether"]:
self.backupTether = braille.handler.TETHER_AUTO
config.conf["braille"]["autoTether"] = False
else:
self.backupTether = utils.getTether()
braille.handler.setTether(braille.handler.TETHER_REVIEW, auto=False)
braille.handler.handleReviewMove(shouldAutoTether=False)
self.switchedMode = True
elif self.switchedMode and obj.role != utils.get_control_type("ROLE_TERMINAL"): self.restorReviewCursorTethering()

if "tabSize_%s" % addoncfg.curBD not in config.conf["brailleExtender"].copy().keys(): self.onReload(None, 1)
if self.hourDatePlayed: self.script_hourDate(None)
if self.autoTestPlayed: self.script_autoTest(None)
Expand All @@ -183,9 +166,7 @@ def event_gainFocus(self, obj, nextHandler):
self.onReload(None, 1)

if self.backup__brailleTableDict != config.conf["braille"]["translationTable"]: self.reloadBrailleTables()

nextHandler()
return

def event_foreground(self, obj, nextHandler):
if braille.handler._auto_scroll:
Expand Down Expand Up @@ -284,27 +265,6 @@ def onTableDictionary(evt):
def onTemporaryDictionary(evt):
gui.mainFrame._popupSettingsDialog(tabledictionaries.DictionaryDlg, _("Temporary dictionary"), "tmp")

def restorReviewCursorTethering(self):
if not self.switchedMode: return
if not hasattr(braille.handler, "TETHER_AUTO"):
braille.handler.tether = self.backupTether
else:
if self.backupTether == braille.handler.TETHER_AUTO:
config.conf["braille"]["autoTether"] = True
config.conf["braille"]["tetherTo"] = braille.handler.TETHER_FOCUS
else:
config.conf["braille"]["autoTether"] = False
braille.handler.setTether(self.backupTether, auto=False)
if self.backupTether == braille.handler.TETHER_REVIEW:
braille.handler.handleReviewMove(shouldAutoTether=False)
else:
focus = api.getFocusObject()
if focus.treeInterceptor and not focus.treeInterceptor.passThrough:
braille.handler.handleGainFocus(focus.treeInterceptor,shouldAutoTether=False)
else:
braille.handler.handleGainFocus(focus,shouldAutoTether=False)
self.switchedMode = False

def getGestureWithBrailleIdentifier(self, gesture = ''):
return ("br(%s):" % addoncfg.curBD if ':' not in gesture else '') + gesture

Expand Down Expand Up @@ -1238,23 +1198,18 @@ def script_toggleSpeechHistoryMode(self, gesture):
__gestures["kb:shift+NVDA+p"] = "currentBrailleTable"
__gestures["kb:shift+NVDA+i"] = "switchInputBrailleTable"
__gestures["kb:shift+NVDA+u"] = "switchOutputBrailleTable"
__gestures["kb:shift+NVDA+y"] = "autoScroll"
__gestures["kb:nvda+k"] = "reload_brailledisplay1"
__gestures["kb:nvda+shift+k"] = "reload_brailledisplay2"
__gestures["kb:nvda+alt+h"] = "toggleDots78"
__gestures["kb:nvda+j"] = "reload_brailledisplay1"
__gestures["kb:nvda+shift+j"] = "reload_brailledisplay2"
__gestures["kb:nvda+alt+f"] = "toggleBRFMode"
__gestures["kb:nvda+windows+i"] = "advancedInput"
__gestures["kb:nvda+windows+u"] = "undefinedCharsDesc"
__gestures["kb:nvda+windows+h"] = "toggleOneHandMode"
__gestures["kb:nvda+windows+k"] = "reloadAddon"
__gestures["kb:volumeMute"] = "toggleVolume"
__gestures["kb:volumeUp"] = "volumePlus"
__gestures["kb:volumeDown"] = "volumeMinus"
__gestures["kb:nvda+alt+u"] = "translateInBRU"
__gestures["kb:nvda+alt+i"] = "charsToCellDescriptions"
__gestures["kb:nvda+alt+o"] = "cellDescriptionsToChars"
__gestures["kb:nvda+alt+y"] = "addDictionaryEntry"
__gestures["kb:nvda+shift+j"] = "toggleTextAttributes"

def terminate(self):
if braille.handler.getTether() == "speech":
Expand All @@ -1264,7 +1219,6 @@ def terminate(self):
braille.TextInfoRegion.update = self.backup__update
braille.TextInfoRegion._getTypeformFromFormatField = self.backup__getTypeformFromFormatField
self.removeMenu()
self.restorReviewCursorTethering()
rolelabels.discardRoleLabels()
if addoncfg.noUnicodeTable:
brailleInput.handler.table = self.backupInputTable
Expand Down
11 changes: 6 additions & 5 deletions addon/globalPlugins/brailleExtender/addoncfg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf-8
# addoncfg.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2020 André-Abush CLAUSE, released under GPL.
# Copyright 2016-2022 André-Abush CLAUSE, released under GPL.

import os

Expand All @@ -27,7 +28,6 @@
Validator = configobj.validate.Validator

CHANNEL_stable = "stable"
CHANNEL_testing = "testing"
CHANNEL_dev = "dev"

CHOICE_braille = "braille"
Expand Down Expand Up @@ -98,7 +98,7 @@ def getConfspec():
return {
"autoCheckUpdate": "boolean(default=True)",
"lastNVDAVersion": 'string(default="unknown")',
"updateChannel": f"option({CHANNEL_dev}, {CHANNEL_stable}, {CHANNEL_testing}, default={addonUpdateChannel})",
"updateChannel": f"option({CHANNEL_dev}, {CHANNEL_stable}, default={addonUpdateChannel})",
"lastCheckUpdate": "float(min=0, default=0)",
"profile_%s" % curBD: 'string(default="default")',
"keyboardLayout_%s" % curBD: "string(default=\"?\")",
Expand Down Expand Up @@ -153,7 +153,7 @@ def getConfspec():
"tabSpace": "boolean(default=False)",
f"tabSize_{curBD}": "integer(min=1, default=2, max=42)",
"undefinedCharsRepr": {
"method": f"integer(min=0, default=0)",
"method": f"integer(min=0, default=8)",
"hardSignPatternValue": "string(default=??)",
"hardDotPatternValue": "string(default=6-12345678)",
"desc": "boolean(default=True)",
Expand All @@ -163,7 +163,8 @@ def getConfspec():
"start": "string(default=[)",
"end": "string(default=])",
"lang": "string(default=Windows)",
"table": "string(default=current)"
"table": "string(default=current)",
"characterLimit": "integer(min=0, default=2048)",
},
"postTable": 'string(default="None")',
"viewSaved": "string(default=%s)" % NOVIEWSAVED,
Expand Down
3 changes: 3 additions & 0 deletions addon/globalPlugins/brailleExtender/addondoc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# addondoc.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2021 André-Abush CLAUSE, released under GPL.
Expand Down Expand Up @@ -310,6 +311,8 @@ def __init__(self, instanceGP):
_("Persian"): "Mohammadreza Rashad <mohammadreza5712@gmail.com>",
_("Polish"): "Zvonimir Stanečić <zvonimirek222@yandex.com>, Dorota Krać",
_("Russian"): "Zvonimir Stanečić <zvonimirek222@yandex.com>, Pavel Kaplan <pavel46@gmail.com>, Artem Plaksin <admin@maniyax.ru>",
_("Turkish"): "Umut Korkmaz <umutkork@gmail.com>",
_("Ukrainian"): "VovaMobile",
}
doc += (
"<h2>" + _("Copyrights and acknowledgements") + "</h2>"
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/advancedinput.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# advancedinput.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2021 André-Abush CLAUSE, released under GPL.
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/autoscroll.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# autoscroll.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2020 André-Abush CLAUSE, released under GPL.
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# common.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2020 André-Abush CLAUSE, released under GPL.
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/huc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# coding: utf-8
import re

HUC6_patterns = {
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/onehand.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# onehand.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2020 André-Abush CLAUSE, released under GPL.
Expand Down
27 changes: 25 additions & 2 deletions addon/globalPlugins/brailleExtender/patches.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# coding: utf-8
# patches.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2021 André-Abush CLAUSE, released under GPL.
# Copyright 2016-2022 André-Abush CLAUSE, released under GPL.
# This file modify some functions from core.
# coding: utf-8

import os
import struct
Expand All @@ -14,6 +16,7 @@
import brailleInput
import colors
import config
import controlTypes
import core
import globalCommands
import inputCore
Expand Down Expand Up @@ -174,7 +177,10 @@ def update_region(self):
mode=mode,
cursorPos=self.cursorPos
)
if self.parseUndefinedChars and config.conf["brailleExtender"]["undefinedCharsRepr"]["method"] != undefinedchars.CHOICE_tableBehaviour:
if (self.parseUndefinedChars
and config.conf["brailleExtender"]["undefinedCharsRepr"]["method"] != undefinedchars.CHOICE_tableBehaviour
and len(self.rawText) <= config.conf["brailleExtender"]["undefinedCharsRepr"]["characterLimit"]
):
undefinedchars.undefinedCharProcess(self)
if selectedElementEnabled():
d = {
Expand Down Expand Up @@ -1203,6 +1209,20 @@ def _displayWithCursor(self):
cells[self._cursorPos] |= config.conf["braille"]["cursorShapeReview"]
self._writeCells(cells)

origGetTether = braille.BrailleHandler.getTether

def getTetherWithRoleTerminal(self):
role = None
obj = api.getNavigatorObject()
if obj:
role = api.getNavigatorObject().role
if (
config.conf["brailleExtender"]["reviewModeTerminal"]
and role == controlTypes.ROLE_TERMINAL
):
return braille.handler.TETHER_REVIEW
return origGetTether(self)


# applying patches
braille.getControlFieldBraille = getControlFieldBraille
Expand Down Expand Up @@ -1240,3 +1260,6 @@ def _displayWithCursor(self):
braille.BrailleHandler.report_auto_scroll_delay = autoscroll.report_auto_scroll_delay
braille.BrailleHandler.toggle_auto_scroll = autoscroll.toggle_auto_scroll
braille.BrailleHandler._displayWithCursor = _displayWithCursor

REASON_CARET = get_output_reason("CARET")
braille.BrailleHandler.getTether = getTetherWithRoleTerminal
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/regionhelper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# regionhelper.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2020 André-Abush CLAUSE, released under GPL.
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/rolelabels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# rolelabels.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2021 André-Abush CLAUSE, released under GPL.
Expand Down
13 changes: 10 additions & 3 deletions addon/globalPlugins/brailleExtender/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# settings.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2020 André-Abush CLAUSE, released under GPL.
Expand Down Expand Up @@ -63,7 +64,7 @@ def makeSettings(self, settingsSizer):
if config.conf["brailleExtender"]["updateChannel"] in addoncfg.updateChannels.keys():
itemToSelect = list(addoncfg.updateChannels.keys()).index(config.conf["brailleExtender"]["updateChannel"])
else:
itemToSelect = list(config.conf["brailleExtender"]["updateChannel"]).index(addoncfg.CHANNEL_stable)
itemToSelect = list(addoncfg.updateChannels.keys()).index(addoncfg.CHANNEL_stable)
if not config.conf["brailleExtender"]["autoCheckUpdate"]: itemToSelect += len(addoncfg.updateChannels.keys())
self.updateCheck.SetSelection(itemToSelect)

Expand Down Expand Up @@ -138,9 +139,15 @@ def makeSettings(self, settingsSizer):
self.reverseScrollBtns.SetValue(config.conf["brailleExtender"]["reverseScrollBtns"])

self.brailleDisplay1 = sHelper.addLabeledControl(_("Preferred &primary braille display:"), wx.Choice, choices=self.bds_v)
self.brailleDisplay1.SetSelection(self.bds_k.index(config.conf["brailleExtender"]["brailleDisplay1"]))
driver_name = "last"
if config.conf["brailleExtender"]["brailleDisplay1"] in self.bds_k:
driver_name = config.conf["brailleExtender"]["brailleDisplay1"]
self.brailleDisplay1.SetSelection(self.bds_k.index(driver_name))
self.brailleDisplay2 = sHelper.addLabeledControl(_("Preferred &secondary braille display:"), wx.Choice, choices=self.bds_v)
self.brailleDisplay2.SetSelection(self.bds_k.index(config.conf["brailleExtender"]["brailleDisplay2"]))
driver_name = "last"
if config.conf["brailleExtender"]["brailleDisplay2"] in self.bds_k:
driver_name = config.conf["brailleExtender"]["brailleDisplay2"]
self.brailleDisplay2.SetSelection(self.bds_k.index(driver_name))

def postInit(self): self.autoCheckUpdate.SetFocus()

Expand Down
13 changes: 8 additions & 5 deletions addon/globalPlugins/brailleExtender/speechhistorymode.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# speechhistorymode.py
# Part of BrailleExtender addon for NVDA
# Copyright 2021 Emil Hesmyr, André-Abush Clause, released under GPL.
Expand Down Expand Up @@ -112,12 +113,12 @@ def showSpeech(index, allowReadEntry=False):

def speak(
speechSequence,
symbolLevel=None,
priority=speech.Spri.NORMAL,
saveString=True,
allowReadEntry=False
allowReadEntry=False,
*args,
**kwargs
):
orig_speak(speechSequence, symbolLevel, priority)
orig_speak(speechSequence, *args, **kwargs)
if not saveString: return
string = ""
for i in speechSequence:
Expand All @@ -135,6 +136,8 @@ def speak(
speech.speak = speak
else:
speech.speech.speak = speak
if hasattr(speech, "speak"):
speech.speak = speak
oldScrollBack = braille.BrailleBuffer.scrollBack


Expand Down Expand Up @@ -183,7 +186,7 @@ def showSpeechFromRoutingIndex(routingNumber):
elif routingNumber == braille.handler.displaySize - 1:
ui.browseableMessage(speechList[index])
else:
direction = routingNumber > braille.handler.displaySize / 2
direction = routingNumber + 1 > braille.handler.displaySize / 2
if direction:
index = index - (braille.handler.displaySize - routingNumber) + 1
else:
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/tabledictionaries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# tabledictionaries.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2020 André-Abush CLAUSE, released under GPL.
Expand Down
16 changes: 15 additions & 1 deletion addon/globalPlugins/brailleExtender/undefinedchars.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding: utf-8
# undefinedchars.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2021 André-Abush CLAUSE, released under GPL.
# Copyright 2016-2022 André-Abush CLAUSE, released under GPL.

import re

import addonHandler
Expand Down Expand Up @@ -325,6 +327,17 @@ def makeSettings(self, settingsSizer):
_("Braille &table:"), wx.Choice, choices=values
)
self.undefinedCharTable.SetSelection(undefinedCharTableID)

# Translators: label of a dialog.
label = _("Character limit at which descriptions are disabled (to avoid freezes, >):")
self.characterLimit = sHelper.addLabeledControl(
label,
gui.nvdaControls.SelectOnFocusSpinCtrl,
min=0,
max=1000000,
initial=config.conf["brailleExtender"]["undefinedCharsRepr"]["characterLimit"]
)

self.onExtendedDesc()
self.onUndefinedCharDesc()
self.onUndefinedCharReprList()
Expand Down Expand Up @@ -421,6 +434,7 @@ def onSave(self):
config.conf["brailleExtender"]["undefinedCharsRepr"]["table"] = keys[
undefinedCharTable
]
config.conf["brailleExtender"]["undefinedCharsRepr"]["characterLimit"] = self.characterLimit.Value


def getExtendedSymbols(locale):
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/updatecheck.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# updatecheck.py
# Part of BrailleExtender addon for NVDA
# Copyright 2021 André-Abush Clause, released under GPL.
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# utils.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2021 André-Abush CLAUSE, released under GPL.
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/volumehelper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# volumehelper.py
# Borrowed from Tim Roberts => See https://mail.python.org/pipermail/python-win32/2014-March/013080.html
from ctypes import POINTER
Expand Down
Loading

0 comments on commit 4bd8705

Please sign in to comment.