Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
- Add type annotations to decide_handleRawKey extension point parameters
- Rename speechPaused to post_speechPaused to follow coding standards for post-event naming
- Add PR reference (#17428) to changelog entry
- Format extension point names in changelog with backticks
  • Loading branch information
ctoth committed Nov 26, 2024
1 parent af49d20 commit f43c0cc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion projectDocs/dev/developerGuide/developerGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ For examples of how to define and use new extension points, please see the code
|`Action` |`speechCanceled` |Triggered when speech is canceled.|
|`Action` |`pre_speechCanceled` |Triggered before speech is canceled.|
|`Action` |`pre_speech` |Triggered before NVDA handles prepared speech.|
|`Action` |`speechPaused` |Triggered when speech is paused or resumed.|
|`Action` |`post_speechPaused` |Triggered when speech is paused or resumed.|
|`Filter` |`filter_speechSequence` |Allows components or add-ons to filter speech sequence before it passes to the synth driver.|

### synthDriverHandler {#synthDriverHandlerExtPts}
Expand Down
5 changes: 5 additions & 0 deletions source/inputCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,15 @@ def __eq__(self, other: Any) -> bool:
Notifies when a raw keyboard event is received, before any NVDA processing.
Handlers can decide whether the key should be processed by NVDA and/or passed to the OS.
@param vkCode: The virtual key code
@type vkCode: int
@param scanCode: The scan code
@type scanCode: int
@param extended: Whether this is an extended key
@type extended: bool
@param pressed: Whether this is a key press or release
@type pressed: bool
@return: True to allow normal processing, False to block the key
@rtype: bool
"""

decide_executeGesture = extensionPoints.Decider()
Expand Down
4 changes: 2 additions & 2 deletions source/speech/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
spellTextInfo,
splitTextIndentation,
)
from .extensions import speechCanceled, speechPaused
from .extensions import speechCanceled, post_speechPaused
from .priorities import Spri

from .types import (
Expand Down Expand Up @@ -142,7 +142,7 @@
"spellTextInfo",
"splitTextIndentation",
"speechCanceled",
"speechPaused",
"post_speechPaused",
]

import synthDriverHandler
Expand Down
2 changes: 1 addition & 1 deletion source/speech/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Handlers are called without arguments.
"""

speechPaused = Action()
post_speechPaused = Action()
"""
Notifies when speech is paused.
Expand Down
4 changes: 2 additions & 2 deletions source/speech/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from textUtils import unicodeNormalize
from textUtils.uniscribe import splitAtCharacterBoundaries
from . import manager
from .extensions import speechCanceled, speechPaused, pre_speechCanceled, pre_speech
from .extensions import speechCanceled, post_speechPaused, pre_speechCanceled, pre_speech
from .extensions import filter_speechSequence
from .commands import (
# Commands that are used in this file.
Expand Down Expand Up @@ -211,7 +211,7 @@ def cancelSpeech():

def pauseSpeech(switch):
getSynth().pause(switch)
speechPaused.notify(switch=switch)
post_speechPaused.notify(switch=switch)
_speechState.isPaused = switch
_speechState.beenCanceled = False

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
cancelSpeech,
pauseSpeech,
speechCanceled,
speechPaused,
post_speechPaused,
)
from speech.commands import (
BeepCommand,
Expand Down Expand Up @@ -594,9 +594,9 @@ def test_speechCanceledExtensionPoint(self):
):
cancelSpeech()

def test_speechPausedExtensionPoint(self):
with actionTester(self, speechPaused, switch=True):
def test_post_speechPausedExtensionPoint(self):
with actionTester(self, post_speechPaused, switch=True):
pauseSpeech(True)

with actionTester(self, speechPaused, switch=False):
with actionTester(self, post_speechPaused, switch=False):
pauseSpeech(False)
6 changes: 3 additions & 3 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ Add-ons will need to be re-tested and have their manifest updated.
* Removed the requirement to indent function parameter lists by two tabs from NVDA's Coding Standards, to be compatible with modern automatic linting. (#17126, @XLTechie)
* Added the [VS Code workspace configuration for NVDA](https://nvaccess.org/nvaccess/vscode-nvda) as a git submodule. (#17003)
* In the `brailleTables` module, a `getDefaultTableForCurrentLang` function has been added (#17222, @nvdaes)
* Added the following extension points:
* inputCore.decide_handleRawKey: called on each keypress
* speech.extensions.speechPaused: Called when speech is paused or unpaused
* Added the following extension points (#17428):
* `inputCore.decide_handleRawKey`: called on each keypress
* `speech.extensions.post_speechPaused`: Called when speech is paused or unpaused


#### API Breaking Changes
Expand Down

0 comments on commit f43c0cc

Please sign in to comment.