Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into threshold
Browse files Browse the repository at this point in the history
Resolved Conflicts:
	source/speech/__init__.py
	user_docs/en/changes.t2t
  • Loading branch information
feerrenrut committed Jul 5, 2019
2 parents 52ba6ac + 9dfbd2e commit f905f7b
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 55 deletions.
10 changes: 7 additions & 3 deletions developerGuide.t2t
Expand Up @@ -764,14 +764,18 @@ See [Snapshot Variables #PythonConsoleSnapshotVariables] for more details.
-

The console is similar to the standard interactive Python interpreter.
Input is accepted one line at a time.
The current line is processed when enter is pressed.
Input is accepted one line at a time and processed when enter is pressed.
Multiple lines can be pasted at once from the clipboard and will be processed one by one.
You can navigate through the history of previously entered lines using the up and down arrow keys.

Output (responses from the interpreter) will be spoken when enter is pressed.
The f6 key toggles between the input and output controls.

Closing the console window simply hides it.
The result of the last executed command is stored in the "_" global variable.
This shadows the gettext function which is stored as a built-in with the same name.
It can be unshadowed by executing "del _" and avoided altogether by executing "_ = _".

Closing the console window (with escape or alt+F4) simply hides it.
This allows the user to return to the session as it was left when it was closed, including history and variables.

++ Namespace ++[PythonConsoleNamespace]
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -91,7 +91,7 @@ For reference, the following dependencies are included in Git submodules:
### Other Dependencies
These dependencies are not included in Git submodules, but aren't needed by most people.

* To generate developer documentation for nvdaHelper: [Doxygen Windows installer](http://www.stack.nl/~dimitri/doxygen/download.html), version 1.7.3:
* To generate developer documentation for nvdaHelper: [Doxygen version 1.7.3 Windows installer](https://sourceforge.net/projects/doxygen/files/rel-1.7.3/doxygen-1.7.3-setup.exe)

## Preparing the Source Tree
Before you can run the NVDA source code, you must prepare the source tree.
Expand Down
10 changes: 10 additions & 0 deletions source/appModules/code.py
@@ -0,0 +1,10 @@
#appModules/code.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2019 NV Access Limited, Babbage B.V.
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.

import appModuleHandler

class AppModule(appModuleHandler.AppModule):
disableBrowseModeByDefault = True
1 change: 1 addition & 0 deletions source/appModules/dllhost.py
Expand Up @@ -10,6 +10,7 @@
"""

import appModuleHandler
import controlTypes
from .explorer import ReadOnlyEditBox

class AppModule(appModuleHandler.AppModule):
Expand Down
3 changes: 1 addition & 2 deletions source/appModules/kindle.py
Expand Up @@ -137,8 +137,7 @@ def script_showSelectionOptions(self, gesture):
# so retrieve and report the selection from Kindle.
# we can't just use self.makeTextInfo, as that will use our fake selection.
realSel = self.rootNVDAObject.makeTextInfo(textInfos.POSITION_SELECTION)
# Translators: Announces selected text. %s is replaced with the text.
speech.speakSelectionMessage(_("selected %s"), realSel.text)
speech.speakSelectedText(realSel.text)
# Remove our virtual selection and move the caret to the active end.
fakeSel.innerTextInfo = realSel
fakeSel.collapse(end=not self._lastSelectionMovedStart)
Expand Down
2 changes: 1 addition & 1 deletion source/appModules/powerpnt.py
Expand Up @@ -1081,7 +1081,7 @@ def event_treeInterceptor_gainFocus(self):
else:
info = self.selection
if not info.isCollapsed:
speech.speakSelectionMessage(_("selected %s"), info.text)
speech.speakSelectedText(info.text)
else:
info.expand(textInfos.UNIT_LINE)
speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE)
Expand Down
2 changes: 1 addition & 1 deletion source/browseMode.py
Expand Up @@ -1221,7 +1221,7 @@ def event_treeInterceptor_gainFocus(self):
speech.speakObject(self.rootNVDAObject, reason=controlTypes.REASON_FOCUS)
info = self.selection
if not info.isCollapsed:
speech.speakSelectionMessage(_("selected %s"), info.text)
speech.speakSelectedText(info.text)
else:
info.expand(textInfos.UNIT_LINE)
speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE)
Expand Down
2 changes: 1 addition & 1 deletion source/compoundDocuments.py
Expand Up @@ -446,7 +446,7 @@ def event_treeInterceptor_gainFocus(self):
info.expand(textInfos.UNIT_LINE)
speech.speakTextInfo(info, unit=textInfos.UNIT_LINE, reason=controlTypes.REASON_CARET)
else:
speech.speakSelectionMessage(_("selected %s"), info.text)
speech.speakSelectedText(info.text)
braille.handler.handleGainFocus(self)
self.initAutoSelectDetection()

Expand Down
2 changes: 1 addition & 1 deletion source/globalCommands.py
Expand Up @@ -210,7 +210,7 @@ def script_reportCurrentSelection(self,gesture):
if not info or info.isCollapsed:
speech.speakMessage(_("No selection"))
else:
speech.speakMessage(_("Selected %s")%info.text)
speech.speakSelectedText(info.text)
# Translators: Input help mode message for report current selection command.
script_reportCurrentSelection.__doc__=_("Announces the current selection in edit controls and documents. If there is no selection it says so.")
script_reportCurrentSelection.category=SCRCAT_SYSTEMCARET
Expand Down
9 changes: 9 additions & 0 deletions source/gui/settingsDialogs.py
Expand Up @@ -48,6 +48,7 @@
import time
import keyLabels
from dpiScalingHelper import DpiScalingHelperMixin
import warnings

class SettingsDialog(with_metaclass(guiHelper.SIPABCMeta, wx.Dialog, DpiScalingHelperMixin)):
"""A settings dialog.
Expand Down Expand Up @@ -3361,3 +3362,11 @@ def onOk(self, evt):
_("Error"), wx.OK | wx.ICON_ERROR)

super(InputGesturesDialog, self).onOk(evt)

class VoiceSettingsSlider(nvdaControls.EnhancedInputSlider):
"""@Deprecated: use L{gui.NVDAControls.EnhancedInputSlider} instead."""

def __init__(self,*args, **kwargs):
warnings.warn("gui.settingsDialogs.VoiceSettingsSlider is deprecated. Use gui.NVDAControls.EnhancedInputSlider instead",
DeprecationWarning, stacklevel=2)
super(VoiceSettingsSlider,self).__init__(*args,**kwargs)
106 changes: 91 additions & 15 deletions source/pythonConsole.py
Expand Up @@ -13,6 +13,7 @@
import __builtin__
import os
import code
import codeop
import sys
import pydoc
import re
Expand Down Expand Up @@ -64,6 +65,26 @@ def _callable_postfix(self, val, word):
# Just because something is callable doesn't always mean we want to call it.
return word

class CommandCompiler(codeop.CommandCompiler):
"""
A L{codeop.CommandCompiler} exposing the status of the last compilation.
"""

def __init__(self):
# Old-style class
codeop.CommandCompiler.__init__(self)
#: Whether the last compilation was on error.
#: @type: bool
self.error = False

def __call__(self, *args, **kwargs):
self.error = False
try:
return codeop.CommandCompiler.__call__(self, *args, **kwargs)
except:
self.error = True
raise

class PythonConsole(code.InteractiveConsole, AutoPropertyObject):
"""An interactive Python console for NVDA which directs output to supplied functions.
This is necessary for a Python console with input/output other than stdin/stdout/stderr.
Expand All @@ -76,32 +97,22 @@ class PythonConsole(code.InteractiveConsole, AutoPropertyObject):
def __init__(self, outputFunc, setPromptFunc, exitFunc, echoFunc=None, **kwargs):
self._output = outputFunc
self._echo = echoFunc
self._exit = exitFunc
self._setPrompt = setPromptFunc

#: The namespace available to the console. This can be updated externally.
#: @type: dict
# Populate with useful modules.
exitCmd = ExitConsoleCommand(exitFunc)
self.namespace = {
"help": HelpCommand(),
"exit": exitCmd,
"quit": exitCmd,
"sys": sys,
"os": os,
"wx": wx,
"log": log,
"api": api,
"queueHandler": queueHandler,
"speech": speech,
"braille": braille,
}
self.namespace = {}
self.initNamespace()
#: The variables last added to the namespace containing a snapshot of NVDA's state.
#: @type: dict
self._namespaceSnapshotVars = None

# Can't use super here because stupid code.InteractiveConsole doesn't sub-class object. Grrr!
code.InteractiveConsole.__init__(self, locals=self.namespace, **kwargs)
self.compile = CommandCompiler()
self.prompt = ">>>"
self.lastResult = None

def _set_prompt(self, prompt):
self._prompt = prompt
Expand All @@ -121,12 +132,47 @@ def push(self, line):
sys.stdout = sys.stderr = self
# Prevent this from messing with the gettext "_" builtin.
saved_ = __builtin__._
self.lastResult = None
more = code.InteractiveConsole.push(self, line)
sys.stdout, sys.stderr = stdout, stderr
if __builtin__._ is not saved_:
self.lastResult = __builtin__._
# Preserve the namespace if gettext has explicitly been pushed there
if "_" not in self.namespace or self.namespace["_"] is not saved_:
self.namespace["_"] = __builtin__._
__builtin__._ = saved_
self.prompt = "..." if more else ">>>"
return more

def initNamespace(self):
"""(Re-)Initialize the console namespace with useful globals.
"""
exitCmd = ExitConsoleCommand(self._exit)
import appModules
import config
import controlTypes
import globalPlugins
import textInfos
self.namespace.clear()
self.namespace.update({
"help": HelpCommand(),
"exit": exitCmd,
"quit": exitCmd,
"os": os,
"sys": sys,
"wx": wx,
"api": api,
"appModules": appModules,
"braille": braille,
"config": config,
"controlTypes": controlTypes,
"globalPlugins": globalPlugins,
"log": log,
"queueHandler": queueHandler,
"speech": speech,
"textInfos": textInfos,
})

def updateNamespaceSnapshotVars(self):
"""Update the console namespace with a snapshot of NVDA's current state.
This creates/updates variables for the current focus, navigator object, etc.
Expand Down Expand Up @@ -175,6 +221,7 @@ def __init__(self, parent):
inputSizer.Add(self.promptLabel, flag=wx.EXPAND)
self.inputCtrl = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_DONTWRAP | wx.TE_PROCESS_TAB)
self.inputCtrl.Bind(wx.EVT_CHAR, self.onInputChar)
self.inputCtrl.Bind(wx.EVT_TEXT_PASTE, self.onInputPaste)
inputSizer.Add(self.inputCtrl, proportion=1, flag=wx.EXPAND)
mainSizer.Add(inputSizer, proportion=1, flag=wx.EXPAND)
self.SetSizer(mainSizer)
Expand Down Expand Up @@ -335,6 +382,35 @@ def onInputChar(self, evt):
self.Close()
return
evt.Skip()

def onInputPaste(self, evt):
cpText = api.getClipData()
if not cpText.strip():
evt.Skip()
return
cpLines = cpText.splitlines()
inputLine = self.inputCtrl.GetValue()
from_, to_ = self.inputCtrl.GetSelection()
prefix = inputLine[:from_]
suffix = inputLine[to_:]
for index, line in enumerate(cpLines):
if index == 0:
# First pasted line: Prepend the input text before the cursor
line = prefix + line
if index == len(cpLines) - 1:
# Last pasted line: Append the input text after the cursor
self.inputCtrl.ChangeValue(line + suffix)
self.inputCtrl.SetInsertionPoint(len(line))
return
self.inputCtrl.ChangeValue(line)
self.execute()
if self.console.compile.error:
# A compilation error occurred: Unlike in the standard Python
# Console, restore the original input text after the cursor and
# stop here to avoid execution of the remaining lines and ease
# reading of output errors.
self.inputCtrl.ChangeValue(suffix)
break

def onOutputKeyDown(self, evt):
key = evt.GetKeyCode()
Expand Down
16 changes: 10 additions & 6 deletions source/speech/__init__.py
Expand Up @@ -390,8 +390,7 @@ def speakObject(obj, reason=controlTypes.REASON_QUERY, _prefixSpeechCommand=None
info=obj.makeTextInfo(textInfos.POSITION_SELECTION)
if not info.isCollapsed:
# if there is selected text, then there is a value and we do not report placeholder
# Translators: This is spoken to indicate what has been selected. for example 'selected hello world'
speakSelectionMessage(_("selected %s"),info.text)
speakSelectedText(info.text)
else:
info.expand(textInfos.UNIT_LINE)
_speakPlaceholderIfEmpty(info, obj, reason,priority=priority)
Expand Down Expand Up @@ -558,6 +557,13 @@ def speak(speechSequence, symbolLevel=None, priority=None):
speechSequence[index]+=CHUNK_SEPARATOR
_manager.speak(speechSequence, priority)

def speakSelectedText(text):
""" Helper method to speak the provided text with the word "selected" appended.
Implemented using L{speakSelectionMessage}, which allows for speaking text with an arbitrary attached message.
"""
# Translators: This is spoken to indicate what has been selected. for example 'hello world selected'
speakSelectionMessage(_("%s selected"),text)

def speakSelectionMessage(message,text,priority=None):
if len(text) < 512:
speakMessage(message % text,priority=priority)
Expand Down Expand Up @@ -617,14 +623,12 @@ def speakSelectionChange(oldInfo,newInfo,speakSelected=True,speakUnselected=True
for text in selectedTextList:
if len(text)==1:
text=characterProcessing.processSpeechSymbol(locale,text)
# Translators: This is spoken while the user is in the process of selecting something, For example: "hello selected"
speakSelectionMessage(_("%s selected"),text,priority=priority)
speakSelectedText(text)
elif len(selectedTextList)>0:
text=newInfo.text
if len(text)==1:
text=characterProcessing.processSpeechSymbol(locale,text)
# Translators: This is spoken to indicate what has been selected. for example 'selected hello world'
speakSelectionMessage(_("selected %s"),text,priority=priority)
speakSelectedText(text)
if speakUnselected:
if not generalize:
for text in unselectedTextList:
Expand Down
37 changes: 14 additions & 23 deletions user_docs/en/changes.t2t
Expand Up @@ -22,28 +22,7 @@ What's New in NVDA
- SynthDriver classes must support the speech.PitchCommand in their speak method, as changes in pitch for speak spelling now depends on this functionality.


= 2019.3 =

== New Features ==
- Added a command to show the replacement for the symbol under the review cursor. (#9286)
- Added an experimental option to the Advanced Settings panel that allows you to try out a new, work-in-progress rewrite of NVDA's Windows Console support using the Microsoft UI Automation API. (#9614)


== changes ==
- Updated eSpeak-NG to commit 86e67a.
- Updated liblouis braille translator to version 3.10.0. (#9678)


== Bug Fixes ==
- In Mozilla Firefox, updates to a live region are no longer reported if the live region is in a background tab. (#1318)
- NVDA's browse mode Find dialog no longer fails to function if NVDA's About dialog is currently open in the background. (#8566)


== Changes for Developers ==
- Added a new isWin10 function to the winVersion module which returns whether or not this copy of NVDA is running on (at least) the supplied release version of Windows 10 (such as 1903). (#9761)


= 2019.2 =
= 2019.2 =
Highlights of this release include auto detection of Freedom Scientific braille displays, an experimental setting in the Advanced panel to stop browse mode from automatically moving focus (which may provide performance improvements), a rate boost option for the Windows OneCore synthesizer to achieve very fast rates, and many other bug fixes.

== New Features ==
Expand All @@ -66,15 +45,21 @@ Highlights of this release include auto detection of Freedom Scientific braille
- Browse mode keystrokes are slow to respond.
- For braille display drivers that support it, driver settings can now be changed from the braille settings category in NVDA's settings dialog. (#7452)
- Freedom Scientific braille displays are now supported by braille display auto detection. (#7727)
- Added a command to show the replacement for the symbol under the review cursor. (#9286)
- Added an experimental option to the Advanced Settings panel that allows you to try out a new, work-in-progress rewrite of NVDA's Windows Console support using the Microsoft UI Automation API. (#9614)
- In the Python Console, the input field now supports pasting multiple lines from the clipboard. (#9776)


== Changes ==
- Synthesizer volume is now increased and decreased by 5 instead of 10 when using the settings ring. (#6754)
- Clarified the text in the add-on manager when NVDA is launched with the --disable-addons flag. (#9473)
- Updated Unicode Common Locale Data Repository emoji annotations to version 35.0. (#9445)
- Updated liblouis braille translator to version 3.9.0. (#9439)
- The hotkey for the filter field in the elements list in browse mode has changed to alt+y. (#8728)
- When an auto detected braille display is connected via Bluetooth, NVDA will keep searching for USB displays supported by the same driver and switch to a USB connection if it becomes available. (#8853)
- Updated eSpeak-NG to commit 67324cc.
- Updated liblouis braille translator to version 3.10.0. (#9439, #9678)
- NVDA will now report the word 'selected' after saying what is selected. (#9028)
- In Microsoft Visual Studio Code, browse mode is now off by default. (#9828)


== Bug Fixes ==
Expand All @@ -98,6 +83,8 @@ Highlights of this release include auto detection of Freedom Scientific braille
- The bumper keys now work correctly on Freedom Scientific braille displays. (#8849)
- When reading the first character of a document in Notepad++ 7.7 X64, NVDA no longer freezes for up to ten seconds. (#9609)
- HTCom can now be used with a Handy Tech Braille display in combination with NVDA. (#9691)
- In Mozilla Firefox, updates to a live region are no longer reported if the live region is in a background tab. (#1318)
- NVDA's browse mode Find dialog no longer fails to function if NVDA's About dialog is currently open in the background. (#8566)


== Changes for Developers ==
Expand All @@ -106,6 +93,10 @@ Highlights of this release include auto detection of Freedom Scientific braille
- Updated comtypes package to 1.1.7. (#9440, #8522)
- When using the report module info command, the order of information has changed to present the module first. (#7338)
- Added an example to demonstrate using nvdaControllerClient.dll from C#. (#9600)
- Added a new isWin10 function to the winVersion module which returns whether or not this copy of NVDA is running on (at least) the supplied release version of Windows 10 (such as 1903). (#9761)
- The NVDA Python console now contains more useful modules in its namespace (such as appModules, globalPlugins, config and textInfos). (#9789)
- The result of the last executed command in the NVDA Python console is now accessible from the _ (line) variable. (#9782)
- Note that this shadows the gettext translation function also called "_". To access the translation function: del _


= 2019.1.1 =
Expand Down

0 comments on commit f905f7b

Please sign in to comment.