Skip to content

Commit 31d5394

Browse files
authored
Merge 917e403 into 318e55c
2 parents 318e55c + 917e403 commit 31d5394

8 files changed

Lines changed: 54 additions & 123 deletions

File tree

source/NVDAObjects/UIA/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import textInfos
2727
from logHandler import log
2828
from UIAUtils import *
29-
from UIAUtils import shouldUseUIAConsole
3029
from NVDAObjects.window import Window
3130
from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject
3231
from NVDAObjects.behaviors import (
@@ -930,7 +929,7 @@ def findOverlayClasses(self,clsList):
930929
# Support Windows Console's UIA interface
931930
if (
932931
self.windowClassName == "ConsoleWindowClass"
933-
and shouldUseUIAConsole()
932+
and config.conf['UIA']['winConsoleImplementation'] == "UIA"
934933
):
935934
from . import winConsoleUIA
936935
winConsoleUIA.findExtraOverlayClasses(self, clsList)

source/NVDAObjects/UIA/winConsoleUIA.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from comtypes import COMError
1414
from UIAUtils import isTextRangeOffscreen
15+
from winVersion import isWin10
1516
from . import UIATextInfo
1617
from ..behaviors import KeyboardHandlerBasedTypedCharSupport
1718
from ..window import Window
@@ -48,13 +49,15 @@ def __init__(self, obj, position, _rangeObj=None):
4849
_rangeObj = first._rangeObj
4950
super(consoleUIATextInfo, self).__init__(obj, position, _rangeObj)
5051

51-
def collapse(self, end=False):
52-
"""Works around a UIA bug on Windows 10 1803 and later."""
52+
def collapse(self,end=False):
53+
"""Works around a UIA bug on Windows 10 1903 and later."""
54+
if not isWin10(1903):
55+
return super(consoleUIATextInfo, self).collapse(end=end)
5356
# When collapsing, consoles seem to incorrectly push the start of the
5457
# textRange back one character.
5558
# Correct this by bringing the start back up to where the end is.
56-
oldInfo = self.copy()
57-
super(consoleUIATextInfo, self).collapse(end=end)
59+
oldInfo=self.copy()
60+
super(consoleUIATextInfo,self).collapse(end=end)
5861
if not end:
5962
self._rangeObj.MoveEndpointByRange(
6063
UIAHandler.TextPatternRangeEndpoint_Start,
@@ -258,9 +261,9 @@ def _getWordOffsetsInThisLine(self, offset, lineInfo):
258261
min(end.value, max(1, lineTextLen - 2))
259262
)
260263

261-
def __ne__(self, other):
264+
def __ne__(self,other):
262265
"""Support more accurate caret move detection."""
263-
return not self == other
266+
return not self==other
264267

265268
def _get_text(self):
266269
# #10036: return a space if the text range is empty.

source/NVDAObjects/behaviors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def event_typedCharacter(self, ch):
436436
config.conf['keyboard']['speakTypedCharacters']
437437
or config.conf['keyboard']['speakTypedWords']
438438
)
439-
and not config.conf['terminals']['speakPasswords']
439+
and not config.conf['UIA']['winConsoleSpeakPasswords']
440440
and self._supportsTextChange
441441
):
442442
self._queuedChars.append(ch)

source/UIAUtils.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2015-2019 NV Access Limited, Bill Dengler
3-
# This file is covered by the GNU General Public License.
4-
# See the file COPYING for more details.
1+
#A part of NonVisual Desktop Access (NVDA)
2+
#Copyright (C) 2015-2016 NV Access Limited
3+
#This file is covered by the GNU General Public License.
4+
#See the file COPYING for more details.
55

66
import operator
77
from comtypes import COMError
8-
import config
98
import ctypes
109
import UIAHandler
11-
from winVersion import isWin10
1210

1311
def createUIAMultiPropertyCondition(*dicts):
1412
"""
@@ -226,22 +224,3 @@ def getValue(self,ID,ignoreMixedValues=False):
226224
if not ignoreMixedValues and val==UIAHandler.handler.ReservedMixedAttributeValue:
227225
raise UIAMixedAttributeError
228226
return val
229-
230-
231-
def shouldUseUIAConsole(setting=None):
232-
"""Determines whether to use UIA in the Windows Console.
233-
@param setting: the config value to base this check on (if not provided,
234-
it is retrieved from config).
235-
"""
236-
if not setting:
237-
setting = config.conf['UIA']['winConsoleImplementation']
238-
if setting == "legacy":
239-
return False
240-
elif setting == "UIA":
241-
return True
242-
# #7497: Windows 10 Fall Creators Update has an incomplete UIA
243-
# implementation for console windows, therefore for now we should
244-
# ignore it.
245-
# It does not implement caret/selection, and probably has no
246-
# new text events.
247-
return isWin10(1809)

source/_UIAHandler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,9 @@ def IUIAutomationNotificationEventHandler_HandleNotificationEvent(
500500

501501
def _isBadUIAWindowClassName(self, windowClass):
502502
"Given a windowClassName, returns True if this is a known problematic UIA implementation."
503-
if (
504-
windowClass == "ConsoleWindowClass"
505-
and not UIAUtils.shouldUseUIAConsole()
506-
):
503+
# #7497: Windows 10 Fall Creators Update has an incomplete UIA implementation for console windows, therefore for now we should ignore it.
504+
# It does not implement caret/selection, and probably has no new text events.
505+
if windowClass == "ConsoleWindowClass" and config.conf['UIA']['winConsoleImplementation'] != "UIA":
507506
return True
508507
return windowClass in badUIAWindowClassNames
509508

source/config/profileUpgradeSteps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ def upgradeConfigFrom_2_to_3(profile):
6060
if "terminals" not in profile:
6161
profile["terminals"] = {}
6262
profile["terminals"]["speakPasswords"] = speakPasswords
63+

source/gui/settingsDialogs.py

Lines changed: 29 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# -*- coding: UTF-8 -*-
2-
# settingsDialogs.py
3-
# A part of NonVisual Desktop Access (NVDA)
4-
# Copyright (C) 2006-2019 NV Access Limited, Peter Vágner, Aleksey Sadovoy,
5-
# Rui Batista, Joseph Lee, Heiko Folkerts, Zahari Yurukov, Leonard de Ruijter,
6-
# Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Bill Dengler
7-
# This file is covered by the GNU General Public License.
8-
# See the file COPYING for more details.
2+
#settingsDialogs.py
3+
#A part of NonVisual Desktop Access (NVDA)
4+
#Copyright (C) 2006-2019 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee, Heiko Folkerts, Zahari Yurukov, Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger
5+
#This file is covered by the GNU General Public License.
6+
#See the file COPYING for more details.
97

108
import logging
119
from abc import abstractmethod, ABCMeta
@@ -51,7 +49,6 @@
5149
from autoSettingsUtils.utils import UnsupportedConfigParameterError
5250
from autoSettingsUtils.autoSettings import AutoSettings
5351
from autoSettingsUtils.driverSetting import BooleanDriverSetting, NumericDriverSetting, DriverSetting
54-
from UIAUtils import shouldUseUIAConsole
5552
import touchHandler
5653
import winVersion
5754
import weakref
@@ -2271,43 +2268,20 @@ def __init__(self, parent):
22712268
self.UIAInMSWordCheckBox.SetValue(config.conf["UIA"]["useInMSWordWhenAvailable"])
22722269
self.UIAInMSWordCheckBox.defaultValue = self._getDefaultValue(["UIA", "useInMSWordWhenAvailable"])
22732270

2274-
# Translators: This is the label for a combo box for selecting the
2275-
# active console implementation in the advanced settings panel.
2276-
# Choices are automatic, prefer UIA, and legacy.
2277-
consoleComboText = _("Windows C&onsole support:")
2278-
consoleChoices = [
2279-
# Translators: A choice in a combo box in the advanced settings
2280-
# panel to have NVDA determine its Windows Console implementation
2281-
# automatically.
2282-
_("Automatic"),
2283-
# Translators: A choice in a combo box in the advanced settings
2284-
# panel to have NVDA use UIA in the Windows Console when available.
2285-
_("Prefer UIA"),
2286-
# Translators: A choice in a combo box in the advanced settings
2287-
# panel to have NVDA use its legacy Windoes Console support
2288-
# in all cases.
2289-
_("Legacy")
2290-
]
2291-
#: The possible console config values, in the order they appear
2292-
#: in the combo box.
2293-
self.consoleVals = (
2294-
"auto",
2295-
"UIA",
2296-
"legacy"
2297-
)
2298-
self.consoleCombo = UIAGroup.addLabeledControl(consoleComboText, wx.Choice, choices=consoleChoices)
2299-
self.consoleCombo.Bind(
2300-
wx.EVT_CHOICE,
2301-
self.enableConsolePasswordsCheckBox,
2302-
self.consoleCombo
2303-
)
2304-
curChoice = self.consoleVals.index(
2305-
config.conf['UIA']['winConsoleImplementation']
2306-
)
2307-
self.consoleCombo.SetSelection(curChoice)
2308-
self.consoleCombo.defaultValue = self.consoleVals.index(
2309-
self._getDefaultValue(["UIA", "winConsoleImplementation"])
2310-
)
2271+
# Translators: This is the label for a checkbox in the
2272+
# Advanced settings panel.
2273+
label = _("Use UI Automation to access the Windows Console when available")
2274+
consoleUIADevMap = True if config.conf['UIA']['winConsoleImplementation'] == 'UIA' else False
2275+
self.ConsoleUIACheckBox=UIAGroup.addItem(wx.CheckBox(self, label=label))
2276+
self.ConsoleUIACheckBox.SetValue(consoleUIADevMap)
2277+
self.ConsoleUIACheckBox.defaultValue = self._getDefaultValue(["UIA", "winConsoleImplementation"])
2278+
2279+
# Translators: This is the label for a checkbox in the
2280+
# Advanced settings panel.
2281+
label = _("Speak &passwords in UIA consoles (may improve performance)")
2282+
self.winConsoleSpeakPasswordsCheckBox=UIAGroup.addItem(wx.CheckBox(self, label=label))
2283+
self.winConsoleSpeakPasswordsCheckBox.SetValue(config.conf["terminals"]["speakPasswords"])
2284+
self.winConsoleSpeakPasswordsCheckBox.defaultValue = self._getDefaultValue(["terminals", "speakPasswords"])
23112285

23122286
# Translators: This is the label for a group of advanced options in the
23132287
# Advanced settings panel
@@ -2319,14 +2293,7 @@ def __init__(self, parent):
23192293
sHelper.addItem(terminalsGroup)
23202294
# Translators: This is the label for a checkbox in the
23212295
# Advanced settings panel.
2322-
label = _("Speak &passwords in Windows Console (may improve performance)")
2323-
self.speakPasswordsCheckBox = terminalsGroup.addItem(wx.CheckBox(self, label=label))
2324-
self.speakPasswordsCheckBox.SetValue(config.conf["terminals"]["speakPasswords"])
2325-
self.speakPasswordsCheckBox.defaultValue = self._getDefaultValue(["terminals", "speakPasswords"])
2326-
self.enableConsolePasswordsCheckBox()
2327-
# Translators: This is the label for a checkbox in the
2328-
# Advanced settings panel.
2329-
label = _("Use the new t&yped character support in legacy Windows consoles when available")
2296+
label = _("Use the new t&yped character support in Windows Console when available")
23302297
self.keyboardSupportInLegacyCheckBox=terminalsGroup.addItem(wx.CheckBox(self, label=label))
23312298
self.keyboardSupportInLegacyCheckBox.SetValue(config.conf["terminals"]["keyboardSupportInLegacy"])
23322299
self.keyboardSupportInLegacyCheckBox.defaultValue = self._getDefaultValue(["terminals", "keyboardSupportInLegacy"])
@@ -2407,13 +2374,6 @@ def __init__(self, parent):
24072374
]
24082375
self.Layout()
24092376

2410-
def enableConsolePasswordsCheckBox(self, evt=None):
2411-
return self.speakPasswordsCheckBox.Enable(
2412-
shouldUseUIAConsole(self.consoleVals[
2413-
self.consoleCombo.GetSelection()
2414-
])
2415-
)
2416-
24172377
def onOpenScratchpadDir(self,evt):
24182378
path=config.getScratchpadDir(ensureExists=True)
24192379
os.startfile(path)
@@ -2426,8 +2386,8 @@ def haveConfigDefaultsBeenRestored(self):
24262386
self._defaultsRestored and
24272387
self.scratchpadCheckBox.IsChecked() == self.scratchpadCheckBox.defaultValue and
24282388
self.UIAInMSWordCheckBox.IsChecked() == self.UIAInMSWordCheckBox.defaultValue and
2429-
self.consoleCombo.GetSelection() == self.consoleCombo.defaultValue and
2430-
self.speakPasswordsCheckBox.IsChecked() == self.speakPasswordsCheckBox.defaultValue and
2389+
self.ConsoleUIACheckBox.IsChecked() == (self.ConsoleUIACheckBox.defaultValue=='UIA') and
2390+
self.winConsoleSpeakPasswordsCheckBox.IsChecked() == self.winConsoleSpeakPasswordsCheckBox.defaultValue and
24312391
self.keyboardSupportInLegacyCheckBox.IsChecked() == self.keyboardSupportInLegacyCheckBox.defaultValue and
24322392
self.autoFocusFocusableElementsCheckBox.IsChecked() == self.autoFocusFocusableElementsCheckBox.defaultValue and
24332393
self.caretMoveTimeoutSpinControl.GetValue() == self.caretMoveTimeoutSpinControl.defaultValue and
@@ -2438,8 +2398,8 @@ def haveConfigDefaultsBeenRestored(self):
24382398
def restoreToDefaults(self):
24392399
self.scratchpadCheckBox.SetValue(self.scratchpadCheckBox.defaultValue)
24402400
self.UIAInMSWordCheckBox.SetValue(self.UIAInMSWordCheckBox.defaultValue)
2441-
self.consoleCombo.SetSelection(self.consoleCombo.defaultValue == 'UIA')
2442-
self.speakPasswordsCheckBox.SetValue(self.speakPasswordsCheckBox.defaultValue)
2401+
self.ConsoleUIACheckBox.SetValue(self.ConsoleUIACheckBox.defaultValue=='UIA')
2402+
self.winConsoleSpeakPasswordsCheckBox.SetValue(self.winConsoleSpeakPasswordsCheckBox.defaultValue)
24432403
self.keyboardSupportInLegacyCheckBox.SetValue(self.keyboardSupportInLegacyCheckBox.defaultValue)
24442404
self.autoFocusFocusableElementsCheckBox.SetValue(self.autoFocusFocusableElementsCheckBox.defaultValue)
24452405
self.caretMoveTimeoutSpinControl.SetValue(self.caretMoveTimeoutSpinControl.defaultValue)
@@ -2450,11 +2410,11 @@ def onSave(self):
24502410
log.debug("Saving advanced config")
24512411
config.conf["development"]["enableScratchpadDir"]=self.scratchpadCheckBox.IsChecked()
24522412
config.conf["UIA"]["useInMSWordWhenAvailable"]=self.UIAInMSWordCheckBox.IsChecked()
2453-
consoleChoice = self.consoleCombo.GetSelection()
2454-
config.conf['UIA']['winConsoleImplementation'] = (
2455-
self.consoleVals[consoleChoice]
2456-
)
2457-
config.conf["terminals"]["speakPasswords"] = self.speakPasswordsCheckBox.IsChecked()
2413+
if self.ConsoleUIACheckBox.IsChecked():
2414+
config.conf['UIA']['winConsoleImplementation'] = "UIA"
2415+
else:
2416+
config.conf['UIA']['winConsoleImplementation'] = "auto"
2417+
config.conf["terminals"]["speakPasswords"]=self.winConsoleSpeakPasswordsCheckBox.IsChecked()
24582418
config.conf["terminals"]["keyboardSupportInLegacy"]=self.keyboardSupportInLegacyCheckBox.IsChecked()
24592419
config.conf["virtualBuffers"]["autoFocusFocusableElements"] = self.autoFocusFocusableElementsCheckBox.IsChecked()
24602420
config.conf["editableText"]["caretMoveTimeoutMs"]=self.caretMoveTimeoutSpinControl.GetValue()

user_docs/en/userGuide.t2t

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,24 +1779,14 @@ This includes Microsoft Word itself, and also the Microsoft Outlook message view
17791779
However, There may be some information which is either not exposed, or exposed incorrectly in some versions of Microsoft Office, which means this UI automation support cannot always be relied upon.
17801780
We still do not recommend that the majority of users turn this on by default, though we do welcome users of Office 2016/365 to test this feature and provide feedback.
17811781

1782-
==== Windows Console support ====[AdvancedSettingsConsoleUIA]
1783-
This option selects how NVDA interacts with the Windows Console used by command prompt, PowerShell, and the Windows Subsystem for Linux.
1784-
It does not affect the modern Windows Terminal.
1785-
In Windows 10 version 1709, Microsoft [added support for its UI Automation API to the console https://devblogs.microsoft.com/commandline/whats-new-in-windows-console-in-windows-10-fall-creators-update/], bringing vastly improved performance and stability for screen readers that support it.
1786-
In situations where UI Automation is unavailable or known to result in an inferior user experience, NVDA's legacy console support is available as a fallback.
1787-
The Windows Console support combo box has three options:
1788-
- Automatic: Uses UI Automation in consoles on Windows 10 version 1809 and later. This option is recommended and set by default.
1789-
- Prefer UIA: Uses UI Automation in consoles if available, even on Windows versions with incomplete or buggy implementations. While this limited functionality may be useful (and even sufficient for your usage), use of this option is entirely at your own risk and no support for it will be provided.
1790-
- Legacy: UI Automation in the Windows Console will be completely disabled, so the legacy fallback will always be used.
1791-
-
1782+
==== Use UI Automation to access the Windows Console when available ====[AdvancedSettingsConsoleUIA]
1783+
When this option is enabled, NVDA will use a new, work in progress version of its support for Windows Console which takes advantage of [accessibility improvements made by Microsoft https://devblogs.microsoft.com/commandline/whats-new-in-windows-console-in-windows-10-fall-creators-update/]. This feature is highly experimental and is still incomplete, so its use is not yet recommended. However, once completed, it is anticipated that this new support will become the default, improving NVDA's performance and stability in Windows command consoles.
17921784

1793-
==== Speak passwords in Windows Console ====[AdvancedSettingsWinConsoleSpeakPasswords]
1794-
This setting controls whether characters are spoken by [speak typed characters #KeyboardSettingsSpeakTypedCharacters] or [speak typed words #KeyboardSettingsSpeakTypedWords] in situations where the screen does not update (such as password entry) in some terminal programs, such as the Windows Console with UI automation support enabled and Mintty.
1795-
For security purposes, this setting should be left disabled.
1796-
However, you may wish to enable it if you experience performance issues or instability with typed character and/or word reporting in consoles, or work in trusted environments and prefer password announcement.
1785+
==== Speak passwords in UIA consoles ====[AdvancedSettingsWinConsoleSpeakPasswords]
1786+
This setting controls whether characters are spoken by [speak typed characters #KeyboardSettingsSpeakTypedCharacters] or [speak typed words #KeyboardSettingsSpeakTypedWords] in situations where the screen does not update (such as password entry) in the Windows Console with UI automation support enabled. For security purposes, this setting should be left disabled. However, you may wish to enable it if you experience performance issues or instability with typed character and/or word reporting while using NVDA's new experimental console support.
17971787

1798-
==== Use the new typed character support in legacy Windows consoles when available ====[AdvancedSettingsKeyboardSupportInLegacy]
1799-
This option enables an alternative method for detecting typed characters in legacy Windows consoles.
1788+
==== Use the new typed character support in Windows Console when available ====[AdvancedSettingsKeyboardSupportInLegacy]
1789+
This option enables an alternative method for detecting typed characters in Windows command consoles.
18001790
While it improves performance and prevents some console output from being spelled out, it may be incompatible with some terminal programs.
18011791
This feature is available and enabled by default on Windows 10 versions 1607, 1703, 1709 and 1803 as well as on newer Windows 10 releases when UI Automation is unavailable or disabled.
18021792
Warning: with this option enabled, typed characters that do not appear onscreen, such as passwords, will not be suppressed.

0 commit comments

Comments
 (0)