Skip to content

Commit

Permalink
Merge branch 'master' into tables
Browse files Browse the repository at this point in the history
  • Loading branch information
AAClause committed Apr 1, 2023
2 parents 26166c8 + b60d100 commit 1e28323
Show file tree
Hide file tree
Showing 21 changed files with 699 additions and 693 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 <[email protected]>
# Copyright (C) 2016-2023 André-Abush Clause <[email protected]>
#
# Additional third party copyrighted code is included:
# - *Attribra*: Copyright (C) 2017 Alberto Zanella <[email protected]>
Expand Down Expand Up @@ -168,8 +169,6 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
noKC = None
backupInputTable = brailleInput.handler.table
backupMessageTimeout = None
backupTether = utils.getTether()
switchedMode = False

def __init__(self):
startTime = time.time()
Expand Down Expand Up @@ -217,32 +216,13 @@ 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"]["tables"].copy().keys(): self.onReload(None, 1)
if self.hourDatePlayed: self.script_hourDate(None)
if self.autoTestPlayed: self.script_autoTest(None)
if braille.handler is not None and addoncfg.curBD != braille.handler.display.name:
addoncfg.curBD = braille.handler.display.name
self.onReload(None, 1)


nextHandler()
return

def event_foreground(self, obj, nextHandler):
if braille.handler._auto_scroll:
Expand Down Expand Up @@ -318,27 +298,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 @@ -1297,23 +1256,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"] = "toggleAttribra"

def terminate(self):
if braille.handler.getTether() == "speech":
Expand Down
1 change: 1 addition & 0 deletions addon/globalPlugins/brailleExtender/addoncfg.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# addoncfg.py
# Part of BrailleExtender addon for NVDA
# Copyright 2016-2022 André-Abush CLAUSE, released under GPL.
Expand Down
1 change: 1 addition & 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
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
18 changes: 18 additions & 0 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-2022 André-Abush CLAUSE, released under GPL.
# This file modify some functions from core.
# coding: utf-8

import os
import struct
Expand All @@ -13,6 +15,7 @@
import braille
import brailleInput
import config
import controlTypes
import core
import globalCommands
import inputCore
Expand Down Expand Up @@ -559,6 +562,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.Region.update = update
Expand Down Expand Up @@ -588,3 +605,4 @@ def _displayWithCursor(self):
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
1 change: 1 addition & 0 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
3 changes: 2 additions & 1 deletion 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 @@ -185,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
2 changes: 2 additions & 0 deletions 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-2022 André-Abush CLAUSE, released under GPL.

import re

import addonHandler
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 1e28323

Please sign in to comment.