Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions addon/globalPlugins/brailleExtender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def onDefaultDictionary(evt):

@staticmethod
def onTableDictionary(evt):
outTable = addoncfg.tablesTR[addoncfg.tablesFN.index(config.conf["braille"]["translationTable"])]
outTable = addoncfg.tablesTR[addoncfg.tablesFN.index(utils.getTranslationTable())]
gui.mainFrame._popupSettingsDialog(tabledictionaries.DictionaryDlg, _("Table dictionary ({})").format(outTable), "table")

@staticmethod
Expand Down Expand Up @@ -573,8 +573,8 @@ def script_reportExtraInfos(self, gesture):

def script_getTableOverview(self, gesture):
inTable = brailleInput.handler.table.displayName
ouTable = addoncfg.tablesTR[addoncfg.tablesFN.index(config.conf["braille"]["translationTable"])]
t = (_(" Input table")+": %s\n"+_("Output table")+": %s\n\n") % (inTable+' (%s)' % (brailleInput.handler.table.fileName), ouTable+' (%s)' % (config.conf["braille"]["translationTable"]))
ouTable = addoncfg.tablesTR[addoncfg.tablesFN.index(utils.getTranslationTable())]
t = (_(" Input table")+": %s\n"+_("Output table")+": %s\n\n") % (inTable+' (%s)' % (brailleInput.handler.table.fileName), ouTable+' (%s)' % (utils.getTranslationTable()))
t += utils.getTableOverview()
ui.browseableMessage("<pre>%s</pre>" % t, _("Table overview (%s)") % brailleInput.handler.table.displayName, True)
script_getTableOverview.__doc__ = _("Shows an overview of current input braille table in a browseable message")
Expand Down Expand Up @@ -755,10 +755,11 @@ def script_switchInputBrailleTable(self, gesture):
addoncfg.inputTables.append(config.conf["braille"]["inputTable"])
tid = addoncfg.inputTables.index(config.conf["braille"]["inputTable"])
nID = tid + 1 if tid + 1 < len(addoncfg.inputTables) else 0
brailleInput.handler.table = brailleTables.listTables(
)[addoncfg.tablesFN.index(addoncfg.inputTables[nID])]
try:
brailleInput.handler.table = brailleTables.getTable(addoncfg.inputTables[nID])
except ValueError:
brailleInput.handler.table = brailleTables.getTable(brailleTables.getDefaultTableForCurLang(brailleTables.TableType.INPUT))
ui.message(_("Input: %s") % brailleInput.handler.table.displayName)
return
script_switchInputBrailleTable.__doc__ = _("Switches between configured braille input tables")

def script_switchOutputBrailleTable(self, gesture):
Expand All @@ -768,19 +769,18 @@ def script_switchOutputBrailleTable(self, gesture):
return ui.message(_("You must choose at least two tables for this feature. Please fill in the settings"))
if not config.conf["braille"]["translationTable"] in addoncfg.outputTables:
addoncfg.outputTables.append(config.conf["braille"]["translationTable"])
tid = addoncfg.outputTables.index(
config.conf["braille"]["translationTable"])
tid = addoncfg.outputTables.index(utils.getTranslationTable())
nID = tid + 1 if tid + 1 < len(addoncfg.outputTables) else 0
config.conf["braille"]["translationTable"] = addoncfg.outputTables[nID]
utils.refreshBD()
tabledictionaries.setDictTables()
ui.message(_("Output: %s") % addoncfg.tablesTR[addoncfg.tablesFN.index(config.conf["braille"]["translationTable"])])
ui.message(_("Output: %s") % addoncfg.tablesTR[addoncfg.tablesFN.index(utils.getTranslationTable())])
return
script_switchOutputBrailleTable.__doc__ = _("Switches between configured braille output tables")

def script_currentBrailleTable(self, gesture):
inTable = brailleInput.handler.table.displayName
ouTable = addoncfg.tablesTR[addoncfg.tablesFN.index(config.conf["braille"]["translationTable"])]
ouTable = addoncfg.tablesTR[addoncfg.tablesFN.index(utils.getTranslationTable())]
if ouTable == inTable:
braille.handler.message(_("I⣿O:{I}").format(I=inTable, O=ouTable))
speech.speakMessage(_("Input and output: {I}.").format(I=inTable, O=ouTable))
Expand Down
1 change: 0 additions & 1 deletion addon/globalPlugins/brailleExtender/addoncfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import globalVars
import inputCore
from logHandler import log

from .common import (
addonUpdateChannel, configDir, profilesDir,
MIN_AUTO_SCROLL_DELAY, DEFAULT_AUTO_SCROLL_DELAY, MAX_AUTO_SCROLL_DELAY, MIN_STEP_DELAY_CHANGE, DEFAULT_STEP_DELAY_CHANGE, MAX_STEP_DELAY_CHANGE,
Expand Down
2 changes: 2 additions & 0 deletions addon/globalPlugins/brailleExtender/documentformatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def normalize_report_key(key):
key_ = "report" + key[0].upper() + key[1:]
if key_ in config.conf["documentFormatting"]:
return key_
if key_ == "reportFontAttributes":
return "fontAttributeReporting"


def get_report(key, simple=True):
Expand Down
9 changes: 7 additions & 2 deletions addon/globalPlugins/brailleExtender/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,14 +682,19 @@ def getFormatFieldBraille(field, fieldCache, isAtStart, formatConfig):
end_tag_list = []

tags = []
if formatConfig["reportFontAttributes"]:
fontAttributeReporting = formatConfig.get("fontAttributeReporting")
if fontAttributeReporting is None:
fontAttributeReporting = formatConfig.get("reportFontAttributes")
else:
fontAttributeReporting = fontAttributeReporting == 1
if fontAttributeReporting:
tags += [tag for tag in [
"bold",
"italic",
"underline",
"strikethrough"] if get_method(tag) == CHOICE_tags
]
if (normalize_report_key("superscriptsAndSubscripts") and formatConfig["reportSuperscriptsAndSubscripts"]) or formatConfig["reportFontAttributes"]:
if normalize_report_key("superscriptsAndSubscripts") and formatConfig["reportSuperscriptsAndSubscripts"]:
tags += [tag for tag in [
"text-position:sub",
"text-position:super"] if get_method(tag) == CHOICE_tags
Expand Down
7 changes: 4 additions & 3 deletions addon/globalPlugins/brailleExtender/tabledictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from . import addoncfg
from .common import configDir
from .utils import getTranslationTable
from . import huc

TableDictEntry = namedtuple("TableDictEntry", ("opcode", "textPattern", "braillePattern", "direction", "comment"))
Expand Down Expand Up @@ -63,7 +64,7 @@ def getValidPathsDict():
return [path for path in paths if valid(path)]

def getPathDict(type_):
if type_ == "table": path = os.path.join(configDir, "brailleDicts", config.conf["braille"]["translationTable"])
if type_ == "table": path = os.path.join(configDir, "brailleDicts", getTranslationTable())
elif type_ == "tmp": path = os.path.join(configDir, "brailleDicts", "tmp")
else: path = os.path.join(configDir, "brailleDicts", "default")
return "%s.cti" % path
Expand Down Expand Up @@ -293,7 +294,7 @@ def __init__(self, parent=None, title=_("Edit Dictionary Entry"), textPattern=''
if specifyDict:
# Translators: This is a label for an edit field in add dictionary entry dialog.
dictText = _("Dictionary")
outTable = addoncfg.tablesTR[addoncfg.tablesFN.index(config.conf["braille"]["translationTable"])]
outTable = addoncfg.tablesTR[addoncfg.tablesFN.index(getTranslationTable())]
dictChoices = [_("Global"), _("Table ({})").format(outTable), _("Temporary")]
self.dictRadioBox = sHelper.addItem(wx.RadioBox(self, label=dictText, choices=dictChoices))
self.dictRadioBox.SetSelection(1)
Expand Down Expand Up @@ -339,7 +340,7 @@ def __init__(self, parent=None, title=_("Edit Dictionary Entry"), textPattern=''


def onSeeEntriesClick(self, evt):
outTable = addoncfg.tablesTR[addoncfg.tablesFN.index(config.conf["braille"]["translationTable"])]
outTable = addoncfg.tablesTR[addoncfg.tablesFN.index(getTranslationTable())]
label = [_("Global dictionary"), _("Table dictionary ({})").format(outTable), _("Temporary dictionary")][self.dictRadioBox.GetSelection()]
type_ = self.getType_()
self.Destroy()
Expand Down
18 changes: 14 additions & 4 deletions addon/globalPlugins/brailleExtender/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@
addonHandler.initTranslation()
import treeInterceptorHandler
import unicodedata
from .addoncfg import CHOICE_braille, CHOICE_speech, CHOICE_speechAndBraille
from .common import INSERT_AFTER, INSERT_BEFORE, REPLACE_TEXT, baseDir
from . import huc
from . import tabledictionaries
from . import volumehelper

get_mute = volumehelper.get_mute
get_volume_level = volumehelper.get_volume_level


def report_volume_level():
from .addoncfg import CHOICE_braille, CHOICE_speech, CHOICE_speechAndBraille
if get_mute() and config.conf["brailleExtender"]["volumeChangeFeedback"] in [CHOICE_braille, CHOICE_speechAndBraille]:
return braille.handler.message(_("Muted sound"))
volume_level = get_volume_level()
Expand Down Expand Up @@ -307,7 +306,16 @@ def getCharFromValue(s):
n = int(n, b)
return chr(n)


def getTranslationTable():
translationTable = config.conf["braille"]["translationTable"]
if translationTable == "auto":
return brailleTables.getDefaultTableForCurLang(brailleTables.TableType.OUTPUT)
return translationTable


def getCurrentBrailleTables(input_=False, brf=False):
from . import tabledictionaries
if brf:
tables = [
os.path.join(baseDir, "res", "brf.ctb").encode("UTF-8"),
Expand All @@ -317,8 +325,10 @@ def getCurrentBrailleTables(input_=False, brf=False):
tables = []
app = appModuleHandler.getAppModuleForNVDAObject(api.getNavigatorObject())
if app and app.appName != "nvda": tables += tabledictionaries.dictTables
if input_: mainTable = os.path.join(brailleTables.TABLES_DIR, brailleInput.handler._table.fileName)
else: mainTable = os.path.join(brailleTables.TABLES_DIR, config.conf["braille"]["translationTable"])
if input_:
mainTable = os.path.join(brailleTables.TABLES_DIR, brailleInput.handler._table.fileName)
else:
mainTable = os.path.join(brailleTables.TABLES_DIR, getTranslationTable())
tables += [
mainTable,
os.path.join(brailleTables.TABLES_DIR, "braille-patterns.cti")
Expand Down
Loading